dolibarr 21.0.0-alpha
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
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
29require_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 = GETPOSTINT('id');
38$_socid = GETPOSTINT("id");
39// Security check
40if ($user->socid > 0) {
41 $_socid = $user->socid;
42}
43
44// Security check
45$socid = GETPOSTINT("socid");
46if ($user->socid > 0) {
47 $action = '';
48 $id = $user->socid;
49}
50$hookmanager->initHooks(array('thirdpartyprice', 'globalcard'));
51$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
52
53
54/*
55 * Actions
56 */
57
58if ($action == 'setpricelevel' && $user->hasRight('societe', 'creer')) {
59 $soc = new Societe($db);
60 $soc->fetch($id);
61 $soc->setPriceLevel(GETPOST("price_level"), $user);
62
63 header("Location: multiprix.php?id=".$id);
64 exit;
65}
66
67
68/*
69 * View
70 */
71
72llxHeader();
73
74$userstatic = new User($db);
75
76if ($_socid > 0) {
77 // We load data of thirdparty
78 $objsoc = new Societe($db);
79 $objsoc->id = $_socid;
80 $objsoc->fetch($_socid);
81
82
83 $head = societe_prepare_head($objsoc);
84
85 $tabchoice = '';
86 if ($objsoc->client == 1) {
87 $tabchoice = 'customer';
88 }
89 if ($objsoc->client == 2) {
90 $tabchoice = 'prospect';
91 }
92
93 print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
94 print '<input type="hidden" name="token" value="'.newToken().'">';
95 print '<input type="hidden" name="action" value="setpricelevel">';
96
97 print dol_get_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
98
99 print '<table class="border centpercent tableforfield">';
100
101 print '<tr><td class="titlefieldcreate">';
102 print $langs->trans("PriceLevel").'</td><td>'.$objsoc->price_level."</td></tr>";
103
104 print '<tr><td>';
105 print $langs->trans("NewValue").'</td><td>';
106 print '<select name="price_level" class="flat">';
107 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
108 print '<option value="'.$i.'"';
109 if ($i == $objsoc->price_level) {
110 print 'selected';
111 }
112 print '>'.$i;
113 $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
114 if (getDolGlobalString($keyforlabel)) {
115 print ' - '.$langs->trans(getDolGlobalString($keyforlabel));
116 }
117 print '</option>';
118 }
119 print '</select>';
120 print '</td></tr>';
121
122 print "</table>";
123
124 print dol_get_fiche_end();
125
126 print $form->buttonsSaveCancel("Save", '');
127
128 print "</form>";
129
130
131 print '<br><br>';
132
133
134 /*
135 * List historic of multiprices
136 */
137 $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
138 $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
139 $sql .= " WHERE rc.fk_soc = ".((int) $objsoc->id);
140 $sql .= " AND u.rowid = rc.fk_user_author";
141 $sql .= " ORDER BY rc.datec DESC";
142
143 $resql = $db->query($sql);
144 if ($resql) {
145 print '<table class="noborder centpercent">';
146 print '<tr class="liste_titre">';
147 print '<td>'.$langs->trans("Date").'</td>';
148 print '<td>'.$langs->trans("PriceLevel").'</td>';
149 print '<td class="right">'.$langs->trans("User").'</td>';
150 print '</tr>';
151 $i = 0;
152 $num = $db->num_rows($resql);
153
154 while ($i < $num) {
155 $obj = $db->fetch_object($resql);
156
157 print '<tr class="oddeven">';
158 print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';
159 print '<td>'.$obj->price_level.' </td>';
160 $userstatic->id = $obj->uid;
161 $userstatic->lastname = $obj->login;
162 print '<td class="right">'.$userstatic->getNomUrl(1).'</td>';
163 print '</tr>';
164 $i++;
165 }
166 $db->free($resql);
167 print "</table>";
168 } else {
169 dol_print_error($db);
170 }
171}
172
173// End of page
174llxFooter();
175$db->close();
$id
Definition account.php:39
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:70
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.
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.