dolibarr 21.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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31
41// Load translation files required by the page
42$langs->loadLangs(array('orders', 'companies'));
43
44$action = GETPOST('action', 'alpha');
45$cancel = GETPOST('cancel', 'alpha');
46
47$id = GETPOSTINT('id');
48$_socid = GETPOSTINT("id");
49// Security check
50if ($user->socid > 0) {
51 $_socid = $user->socid;
52}
53
54// Security check
55$socid = GETPOSTINT("socid");
56if ($user->socid > 0) {
57 $action = '';
58 $id = $user->socid;
59}
60$hookmanager->initHooks(array('thirdpartyprice', 'globalcard'));
61$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
62
63
64/*
65 * Actions
66 */
67
68if ($action == 'setpricelevel' && $user->hasRight('societe', 'creer')) {
69 $soc = new Societe($db);
70 $soc->fetch($id);
71 $soc->setPriceLevel(GETPOST("price_level"), $user);
72
73 header("Location: multiprix.php?id=".$id);
74 exit;
75}
76
77
78/*
79 * View
80 */
81
82llxHeader();
83
84$userstatic = new User($db);
85
86if ($_socid > 0) {
87 // We load data of thirdparty
88 $objsoc = new Societe($db);
89 $objsoc->id = $_socid;
90 $objsoc->fetch($_socid);
91
92
93 $head = societe_prepare_head($objsoc);
94
95 $tabchoice = '';
96 if ($objsoc->client == 1) {
97 $tabchoice = 'customer';
98 }
99 if ($objsoc->client == 2) {
100 $tabchoice = 'prospect';
101 }
102
103 print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
104 print '<input type="hidden" name="token" value="'.newToken().'">';
105 print '<input type="hidden" name="action" value="setpricelevel">';
106
107 print dol_get_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
108
109 print '<table class="border centpercent tableforfield">';
110
111 print '<tr><td class="titlefieldcreate">';
112 print $langs->trans("PriceLevel").'</td><td>'.$objsoc->price_level."</td></tr>";
113
114 print '<tr><td>';
115 print $langs->trans("NewValue").'</td><td>';
116 print '<select name="price_level" class="flat">';
117 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
118 print '<option value="'.$i.'"';
119 if ($i == $objsoc->price_level) {
120 print 'selected';
121 }
122 print '>'.$i;
123 $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
124 if (getDolGlobalString($keyforlabel)) {
125 print ' - '.$langs->trans(getDolGlobalString($keyforlabel));
126 }
127 print '</option>';
128 }
129 print '</select>';
130 print '</td></tr>';
131
132 print "</table>";
133
134 print dol_get_fiche_end();
135
136 print $form->buttonsSaveCancel("Save", '');
137
138 print "</form>";
139
140
141 print '<br><br>';
142
143
144 /*
145 * List historic of multiprices
146 */
147 $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
148 $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
149 $sql .= " WHERE rc.fk_soc = ".((int) $objsoc->id);
150 $sql .= " AND u.rowid = rc.fk_user_author";
151 $sql .= " ORDER BY rc.datec DESC";
152
153 $resql = $db->query($sql);
154 if ($resql) {
155 print '<table class="noborder centpercent">';
156 print '<tr class="liste_titre">';
157 print '<td>'.$langs->trans("Date").'</td>';
158 print '<td>'.$langs->trans("PriceLevel").'</td>';
159 print '<td class="right">'.$langs->trans("User").'</td>';
160 print '</tr>';
161 $i = 0;
162 $num = $db->num_rows($resql);
163
164 while ($i < $num) {
165 $obj = $db->fetch_object($resql);
166
167 print '<tr class="oddeven">';
168 print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';
169 print '<td>'.$obj->price_level.' </td>';
170 $userstatic->id = $obj->uid;
171 $userstatic->lastname = $obj->login;
172 print '<td class="right">'.$userstatic->getNomUrl(1).'</td>';
173 print '</tr>';
174 $i++;
175 }
176 $db->free($resql);
177 print "</table>";
178 } else {
179 dol_print_error($db);
180 }
181}
182
183// End of page
184llxFooter();
185$db->close();
$id
Definition account.php:48
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
llxFooter()
Footer empty.
Definition document.php:107
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.