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