dolibarr  7.0.0-beta
multiprix.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
29 
30 $langs->load("orders");
31 $langs->load("companies");
32 
33 $id = GETPOST('id','int');
34 $_socid = GETPOST("id",'int');
35 // Security check
36 if ($user->societe_id > 0)
37 {
38  $_socid = $user->societe_id;
39 }
40 
41 
42 /*
43  * Actions
44  */
45 
46 if ($_POST["action"] == 'setpricelevel')
47 {
48  $soc = New Societe($db);
49  $soc->fetch($id);
50  $soc->set_price_level($_POST["price_level"],$user);
51 
52  header("Location: multiprix.php?id=".$id);
53  exit;
54 }
55 
56 
57 /*
58  * View
59  */
60 
61 llxHeader();
62 
63 $userstatic=new User($db);
64 
65 if ($_socid > 0)
66 {
67  // On recupere les donnees societes par l'objet
68  $objsoc = new Societe($db);
69  $objsoc->id=$_socid;
70  $objsoc->fetch($_socid,$to);
71 
72  if ($errmesg)
73  {
74  print '<div class="error">'.$errmesg.'</div><br>';
75  }
76 
77 
78  /*
79  * Affichage onglets
80  */
81 
82  $head = societe_prepare_head($objsoc);
83 
84  $tabchoice='';
85  if ($objsoc->client == 1) $tabchoice='customer';
86  if ($objsoc->client == 2) $tabchoice='prospect';
87 
88  print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
89  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
90  print '<input type="hidden" name="action" value="setpricelevel">';
91 
92  dol_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
93 
94  print '<table width="100%" border="0">';
95  print '<tr><td class="tdtop">';
96  print '<table class="border" width="100%">';
97 
98  print '<tr><td colspan="2" width="25%">';
99  print $langs->trans("PriceLevel").'</td><td colspan="2">'.$objsoc->price_level."</td></tr>";
100 
101  print '<tr><td colspan="2">';
102  print $langs->trans("NewValue").'</td><td colspan="2">';
103  print '<select name="price_level" class="flat">';
104  for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
105  {
106  print '<option value="'.$i.'"' ;
107  if($i == $objsoc->price_level)
108  print 'selected';
109  print '>'.$i;
110  $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i;
111  if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
112  print '</option>';
113  }
114  print '</select>';
115  print '</td></tr>';
116 
117  print "</table>";
118 
119  print "</td>\n";
120 
121 
122  print "</td></tr>";
123  print "</table>";
124 
125  dol_fiche_end();
126 
127  print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
128 
129  print "</form>";
130 
131 
132  print '<br><br>';
133 
134 
135  /*
136  * List historic of multiprices
137  */
138  $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
139  $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
140  $sql .= " WHERE rc.fk_soc =". $objsoc->id;
141  $sql .= " AND u.rowid = rc.fk_user_author";
142  $sql .= " ORDER BY rc.datec DESC";
143 
144  $resql=$db->query($sql);
145  if ($resql)
146  {
147  print '<table class="noborder" width="100%">';
148  $tag = !$tag;
149  print '<tr class="liste_titre">';
150  print '<td>'.$langs->trans("Date").'</td>';
151  print '<td>'.$langs->trans("PriceLevel").'</td>';
152  print '<td align="right">'.$langs->trans("User").'</td>';
153  print '</tr>';
154  $i = 0 ;
155  $num = $db->num_rows($resql);
156 
157  while ($i < $num )
158  {
159  $obj = $db->fetch_object($resql);
160  $tag = !$tag;
161  print '<tr '.$bc[$tag].'>';
162  print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
163  print '<td>'.$obj->price_level.' </td>';
164  $userstatic->id=$obj->uid;
165  $userstatic->lastname=$obj->login;
166  print '<td align="right">'.$userstatic->getNomUrl(1).'</td>';
167  print '</tr>';
168  $i++;
169  }
170  $db->free($resql);
171  print "</table>";
172  }
173  else
174  {
175  dol_print_error($db);
176  }
177 
178 }
179 
180 llxFooter();
181 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
Class to manage Dolibarr users.
Definition: user.class.php:39
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:46
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:40
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013