dolibarr  16.0.5
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 $action = GETPOST('action', 'alpha');
34 $cancel = GETPOST('cancel', 'alpha');
35 
36 $id = GETPOST('id', 'int');
37 $_socid = GETPOST("id", 'int');
38 // Security check
39 if ($user->socid > 0) {
40  $_socid = $user->socid;
41 }
42 
43 // Security check
44 $socid = GETPOST("socid", 'int');
45 if ($user->socid > 0) {
46  $action = '';
47  $id = $user->socid;
48 }
49 $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
50 
51 
52 /*
53  * Actions
54  */
55 
56 if ($action == 'setpricelevel' && $user->rights->societe->creer) {
57  $soc = new Societe($db);
58  $soc->fetch($id);
59  $soc->setPriceLevel(GETPOST("price_level"), $user);
60 
61  header("Location: multiprix.php?id=".$id);
62  exit;
63 }
64 
65 
66 /*
67  * View
68  */
69 
70 llxHeader();
71 
72 $userstatic = new User($db);
73 
74 if ($_socid > 0) {
75  // We load data of thirdparty
76  $objsoc = new Societe($db);
77  $objsoc->id = $_socid;
78  $objsoc->fetch($_socid);
79 
80 
81  $head = societe_prepare_head($objsoc);
82 
83  $tabchoice = '';
84  if ($objsoc->client == 1) {
85  $tabchoice = 'customer';
86  }
87  if ($objsoc->client == 2) {
88  $tabchoice = 'prospect';
89  }
90 
91  print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
92  print '<input type="hidden" name="token" value="'.newToken().'">';
93  print '<input type="hidden" name="action" value="setpricelevel">';
94 
95  print dol_get_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
96 
97  print '<table class="border centpercent tableforfield">';
98 
99  print '<tr><td class="titlefieldcreate">';
100  print $langs->trans("PriceLevel").'</td><td>'.$objsoc->price_level."</td></tr>";
101 
102  print '<tr><td>';
103  print $langs->trans("NewValue").'</td><td>';
104  print '<select name="price_level" class="flat">';
105  for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
106  print '<option value="'.$i.'"';
107  if ($i == $objsoc->price_level) {
108  print 'selected';
109  }
110  print '>'.$i;
111  $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
112  if (!empty($conf->global->$keyforlabel)) {
113  print ' - '.$langs->trans($conf->global->$keyforlabel);
114  }
115  print '</option>';
116  }
117  print '</select>';
118  print '</td></tr>';
119 
120  print "</table>";
121 
122  print dol_get_fiche_end();
123 
124  print $form->buttonsSaveCancel("Save", '');
125 
126  print "</form>";
127 
128 
129  print '<br><br>';
130 
131 
132  /*
133  * List historic of multiprices
134  */
135  $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
136  $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
137  $sql .= " WHERE rc.fk_soc = ".((int) $objsoc->id);
138  $sql .= " AND u.rowid = rc.fk_user_author";
139  $sql .= " ORDER BY rc.datec DESC";
140 
141  $resql = $db->query($sql);
142  if ($resql) {
143  print '<table class="noborder centpercent">';
144  print '<tr class="liste_titre">';
145  print '<td>'.$langs->trans("Date").'</td>';
146  print '<td>'.$langs->trans("PriceLevel").'</td>';
147  print '<td class="right">'.$langs->trans("User").'</td>';
148  print '</tr>';
149  $i = 0;
150  $num = $db->num_rows($resql);
151 
152  while ($i < $num) {
153  $obj = $db->fetch_object($resql);
154 
155  print '<tr class="oddeven">';
156  print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';
157  print '<td>'.$obj->price_level.' </td>';
158  $userstatic->id = $obj->uid;
159  $userstatic->lastname = $obj->login;
160  print '<td class="right">'.$userstatic->getNomUrl(1).'</td>';
161  print '</tr>';
162  $i++;
163  }
164  $db->free($resql);
165  print "</table>";
166  } else {
167  dol_print_error($db);
168  }
169 }
170 
171 // End of page
172 llxFooter();
173 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
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_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
User
Class to manage Dolibarr users.
Definition: user.class.php:44
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59