dolibarr  13.0.2
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 <https://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 // Load translation files required by the page
31 $langs->loadLangs(array('orders', 'companies'));
32 
33 $id = GETPOST('id', 'int');
34 $_socid = GETPOST("id", 'int');
35 // Security check
36 if ($user->socid > 0)
37 {
38  $_socid = $user->socid;
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  // We load data of thirdparty
68  $objsoc = new Societe($db);
69  $objsoc->id = $_socid;
70  $objsoc->fetch($_socid, $to);
71 
72 
73  $head = societe_prepare_head($objsoc);
74 
75  $tabchoice = '';
76  if ($objsoc->client == 1) $tabchoice = 'customer';
77  if ($objsoc->client == 2) $tabchoice = 'prospect';
78 
79  print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
80  print '<input type="hidden" name="token" value="'.newToken().'">';
81  print '<input type="hidden" name="action" value="setpricelevel">';
82 
83  print dol_get_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
84 
85  print '<table class="border centpercent tableforfield">';
86 
87  print '<tr><td class="titlefieldcreate">';
88  print $langs->trans("PriceLevel").'</td><td>'.$objsoc->price_level."</td></tr>";
89 
90  print '<tr><td>';
91  print $langs->trans("NewValue").'</td><td>';
92  print '<select name="price_level" class="flat">';
93  for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
94  {
95  print '<option value="'.$i.'"';
96  if ($i == $objsoc->price_level)
97  print 'selected';
98  print '>'.$i;
99  $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
100  if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
101  print '</option>';
102  }
103  print '</select>';
104  print '</td></tr>';
105 
106  print "</table>";
107 
108  print dol_get_fiche_end();
109 
110  print '<div align="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
111 
112  print "</form>";
113 
114 
115  print '<br><br>';
116 
117 
118  /*
119  * List historic of multiprices
120  */
121  $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
122  $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
123  $sql .= " WHERE rc.fk_soc =".$objsoc->id;
124  $sql .= " AND u.rowid = rc.fk_user_author";
125  $sql .= " ORDER BY rc.datec DESC";
126 
127  $resql = $db->query($sql);
128  if ($resql)
129  {
130  print '<table class="noborder centpercent">';
131  $tag = !$tag;
132  print '<tr class="liste_titre">';
133  print '<td>'.$langs->trans("Date").'</td>';
134  print '<td>'.$langs->trans("PriceLevel").'</td>';
135  print '<td class="right">'.$langs->trans("User").'</td>';
136  print '</tr>';
137  $i = 0;
138  $num = $db->num_rows($resql);
139 
140  while ($i < $num)
141  {
142  $obj = $db->fetch_object($resql);
143 
144  print '<tr class="oddeven">';
145  print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';
146  print '<td>'.$obj->price_level.' </td>';
147  $userstatic->id = $obj->uid;
148  $userstatic->lastname = $obj->login;
149  print '<td class="right">'.$userstatic->getNomUrl(1).'</td>';
150  print '</tr>';
151  $i++;
152  }
153  $db->free($resql);
154  print "</table>";
155  } else {
156  dol_print_error($db);
157  }
158 }
159 
160 // End of page
161 llxFooter();
162 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
Definition: user.class.php:44
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59