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