dolibarr 24.0.3
price.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
7 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
8 * Copyright (C) 2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
9 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2024 Mélina Joum <melina.joum@altairis.fr>
11 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
34// Load Dolibarr environment
35require '../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
49require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
50
51$prodcustprice = null;
52if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
53 $prodcustprice = new ProductCustomerPrice($db);
54}
55
56
57// Load translation files required by the page
58$langs->loadLangs(array("products", "companies", "bills"));
59
60
61// Get parameters
62$action = GETPOST('action', 'aZ09');
63$search_prod = GETPOST('search_prod', 'alpha');
64$cancel = GETPOST('cancel', 'alpha');
65$search_label = GETPOST('search_label', 'alpha');
66$search_price = GETPOST('search_price');
67$search_price_ttc = GETPOST('search_price_ttc');
68
69// Security check
70$socid = GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id');
71if ($user->socid) {
72 $socid = $user->socid;
73}
74
75// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
76$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard'));
77
78$result = restrictedArea($user, 'societe', $socid, '&societe');
79
80// Initialize objects
81$object = new Societe($db);
82
83$error = 0;
84
85
86/*
87 * Actions
88 */
89
90$parameters = array('id' => $socid);
91$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
92if ($reshook < 0) {
93 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
94}
95
96if (empty($reshook)) {
97 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
98 $search_prod = $search_label = $search_price = $search_price_ttc = '';
99 }
100
101 if ($action == 'add_customer_price_confirm' && $prodcustprice !== null && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
102 if (!(GETPOSTINT('prodid') > 0)) {
103 $error++;
104 setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors');
105 $action = 'add_customer_price';
106 }
107
108 if (!$error) {
109 $update_child_soc = GETPOSTINT('updatechildprice');
110
111 // add price by customer
112 $prodcustprice->fk_soc = $socid;
113 $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha');
114 $prodcustprice->fk_product = GETPOSTINT('prodid');
115 $prodcustprice->price = price2num(GETPOST("price"), 'MU');
116 $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
117 $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
118 $prodcustprice->discount_percent = price2num(GETPOST("discount_percent"));
119 $prodcustprice->date_begin = dol_mktime(0, 0, 0, GETPOSTINT('date_beginmonth'), GETPOSTINT('date_beginday'), GETPOSTINT('date_beginyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
120 $prodcustprice->date_end = dol_mktime(0, 0, 0, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
121
122 $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
123
124 // We must define tva_tx, npr and local taxes
125 $vatratecode = '';
126 $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
127 $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
128 $localtax1 = 0;
129 $localtax2 = 0;
130 $localtax1_type = '0';
131 $localtax2_type = '0';
132 // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes
133 if (preg_match('/\‍((.*)\‍)/', $tva_tx_txt, $reg)) {
134 // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
135 $vatratecode = $reg[1];
136 // Get record from code
137 $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
138 $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
139 $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'";
140 $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
141 $sql .= " AND t.code = '".$db->escape($vatratecode)."'";
142 $sql .= " AND t.entity IN (".getEntity('c_tva').")";
143 $resql = $db->query($sql);
144 if ($resql) {
145 $obj = $db->fetch_object($resql);
146 $npr = $obj->recuperableonly;
147 $localtax1 = $obj->localtax1;
148 $localtax2 = $obj->localtax2;
149 $localtax1_type = $obj->localtax1_type;
150 $localtax2_type = $obj->localtax2_type;
151 }
152 }
153
154 $prodcustprice->default_vat_code = $vatratecode;
155 $prodcustprice->tva_tx = $tva_tx;
156 $prodcustprice->recuperableonly = $npr;
157 $prodcustprice->localtax1_tx = $localtax1;
158 $prodcustprice->localtax2_tx = $localtax2;
159 $prodcustprice->localtax1_type = $localtax1_type;
160 $prodcustprice->localtax2_type = $localtax2_type;
161
162 $result = $prodcustprice->create($user, 0, $update_child_soc);
163 if ($result > 0) {
164 $extrafields->fetch_name_optionals_label("product_customer_price");
165 $extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
166 $extrafield_values = $extrafields->getOptionalsFromPost("product_customer_price");
167 if (!empty($extralabels) && is_array($extralabels)) {
168 $productcustomerprice = new ProductCustomerPrice($db);
169 $res = $productcustomerprice->fetch($prodcustprice->id);
170 if ($res > 0) {
171 foreach ($extrafield_values as $key => $value) {
172 $productcustomerprice->array_options[$key] = $value;
173 }
174 $result2 = $productcustomerprice->insertExtraFields();
175 if ($result2 < 0) {
176 $prodcustprice->error = $productcustomerprice->error;
177 $prodcustprice->errors = $productcustomerprice->errors;
178 $error++;
179 }
180 }
181 }
182 }
183
184 if ($result < 0) {
185 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
186 $action = 'add_customer_price';
187 } else {
188 setEventMessages($langs->trans("Save"), null, 'mesgs');
189 $action = '';
190 }
191 }
192 }
193
194 if ($action == 'delete_customer_price' && $prodcustprice !== null && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
195 // Delete price by customer
196 $prodcustprice->id = GETPOSTINT('lineid');
197 $result = $prodcustprice->delete($user);
198
199 if ($result < 0) {
200 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
201 } else {
202 setEventMessages($langs->trans('RecordDeleted'), null, 'errors');
203 }
204 $action = '';
205 }
206
207 if ($action == 'update_customer_price_confirm' && $prodcustprice !== null && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
208 $prodcustprice->fetch(GETPOSTINT('lineid'));
209
210 $update_child_soc = GETPOSTINT('updatechildprice');
211
212 // update price by customer
213 $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha');
214 $prodcustprice->price = price2num(GETPOST("price"), 'MU');
215 $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
216 $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
217 $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
218
219 // We must define tva_tx, npr and local taxes, as when adding a price
220 $vatratecode = '';
221 $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
222 $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
223 $localtax1 = 0;
224 $localtax2 = 0;
225 $localtax1_type = '0';
226 $localtax2_type = '0';
227 // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes, else we use the line with no code
228 if (preg_match('/\‍((.*)\‍)/', $tva_tx_txt, $reg)) {
229 $vatratecode = $reg[1];
230 }
231 if ($tva_tx !== '') {
232 $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
233 $sql .= " FROM ".$db->prefix()."c_tva as t, ".$db->prefix()."c_country as c";
234 $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'";
235 $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
236 $sql .= " AND t.code = '".$db->escape($vatratecode)."'";
237 if ($vatratecode === '') {
238 $sql .= " AND t.recuperableonly = ".((int) $npr);
239 }
240 $sql .= " AND t.entity IN (".getEntity('c_tva').")";
241 $resql = $db->query($sql);
242 if ($resql) {
243 $obj = $db->fetch_object($resql);
244 if ($obj) {
245 $npr = $obj->recuperableonly;
246 $localtax1 = $obj->localtax1;
247 $localtax2 = $obj->localtax2;
248 $localtax1_type = $obj->localtax1_type;
249 $localtax2_type = $obj->localtax2_type;
250 }
251 }
252 }
253
254 $prodcustprice->default_vat_code = $vatratecode;
255 $prodcustprice->tva_tx = $tva_tx;
256 $prodcustprice->recuperableonly = $npr;
257 $prodcustprice->localtax1_tx = $localtax1;
258 $prodcustprice->localtax2_tx = $localtax2;
259 $prodcustprice->localtax1_type = $localtax1_type;
260 $prodcustprice->localtax2_type = $localtax2_type;
261 $prodcustprice->discount_percent = price2num(GETPOST("discount_percent"));
262 $prodcustprice->date_begin = dol_mktime(0, 0, 0, GETPOSTINT('date_beginmonth'), GETPOSTINT('date_beginday'), GETPOSTINT('date_beginyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
263 $prodcustprice->date_end = dol_mktime(0, 0, 0, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
264
265 $result = $prodcustprice->update($user, 0, $update_child_soc);
266 if ($result > 0) {
267 $extrafields->fetch_name_optionals_label("product_customer_price");
268 $extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
269 $extrafield_values = $extrafields->getOptionalsFromPost("product_customer_price");
270 if (!empty($extralabels) && is_array($extralabels)) {
271 $productcustomerprice = new ProductCustomerPrice($db);
272 $res = $productcustomerprice->fetch($prodcustprice->id);
273 if ($res > 0) {
274 foreach ($extrafield_values as $key => $value) {
275 $productcustomerprice->array_options[$key] = $value;
276 }
277 $result2 = $productcustomerprice->insertExtraFields();
278 if ($result2 < 0) {
279 $prodcustprice->error = $productcustomerprice->error;
280 $prodcustprice->errors = $productcustomerprice->errors;
281 $error++;
282 }
283 }
284 }
285 }
286 if ($result < 0) {
287 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
288 $action = 'edit_customer_price';
289 } else {
290 setEventMessages($langs->trans("Save"), null, 'mesgs');
291 $action = '';
292 }
293 }
294}
295
296
297/*
298 * View
299 */
300
301$form = new Form($db);
302
303$object = new Societe($db);
304
305$result = $object->fetch($socid);
306llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
307
308$head = societe_prepare_head($object);
309
310print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
311
312$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
313
314dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
315
316print '<div class="fichecenter">';
317
318print '<div class="underbanner clearboth"></div>';
319print '<table class="border centpercent tableforfield">';
320
321// Type Prospect/Customer/Supplier
322print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
323print $object->getTypeUrl(1);
324print '</td></tr>';
325
326if ($object->client) {
327 print '<tr><td class="titlefield">';
328 print $langs->trans('CustomerCode').'</td><td colspan="3">';
329 print $object->code_client;
330 $tmpcheck = $object->check_codeclient();
331 if ($tmpcheck != 0 && $tmpcheck != -5) {
332 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
333 }
334 print '</td></tr>';
335}
336
337if ($object->fournisseur) {
338 print '<tr><td class="titlefield">';
339 print $langs->trans('SupplierCode').'</td><td colspan="3">';
340 print $object->code_fournisseur;
341 $tmpcheck = $object->check_codefournisseur();
342 if ($tmpcheck != 0 && $tmpcheck != -5) {
343 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
344 }
345 print '</td></tr>';
346}
347
348print '</table>';
349
350print '</div>';
351
352print dol_get_fiche_end();
353
354
355
356if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
357 $prodcustprice = new ProductCustomerPrice($db);
358
359 $sortfield = GETPOST('sortfield', 'aZ09comma');
360 $sortorder = GETPOST('sortorder', 'aZ09comma');
361 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
362 $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
363 if (empty($page) || $page == -1) {
364 $page = 0;
365 } // If $page is not defined, or '' or -1
366 $offset = $limit * $page;
367 $pageprev = $page - 1;
368 $pagenext = $page + 1;
369 if (!$sortorder) {
370 $sortorder = "ASC,ASC";
371 }
372 if (!$sortfield) {
373 $sortfield = "soc.nom,t.date_begin";
374 }
375
376 // Build filter to display only related lines
377 $filter = array(
378 't.fk_soc' => (string) $object->id
379 );
380
381 if (!empty($search_prod)) {
382 $filter ['prod.ref'] = (string) $search_prod;
383 }
384
385 if (!empty($search_label)) {
386 $filter ['prod.label'] = (string) $search_label;
387 }
388
389 if (!empty($search_price)) {
390 $filter ['t.price'] = (string) $search_price;
391 }
392
393 if (!empty($search_price_ttc)) {
394 $filter ['t.price_ttc'] = (string) $search_price_ttc;
395 }
396
397 if ($action == 'add_customer_price') {
398 // Create mode
399
400 print '<br>';
401 print '<!-- Price by customer -->'."\n";
402
403 print load_fiche_titre($langs->trans('PriceByCustomer'));
404
405 print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
406 print '<input type="hidden" name="token" value="'.newToken().'">';
407 print '<input type="hidden" name="action" value="add_customer_price_confirm">';
408 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
409 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
410 print '<input type="hidden" name="socid" value="'.$object->id.'">';
411 print '<table class="border centpercent">';
412 print '<tr>';
413 print '<td>'.$langs->trans('Product').'</td>';
414 print '<td>';
415 $form->select_produits(GETPOSTINT('prodid'), 'prodid', '', 0);
416 print '</td>';
417 print '</tr>';
418
419 // Ref. Customer
420 print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
421 print '<td><input name="ref_customer" size="12"></td></tr>';
422
423 // Applied Prices From
424 $date_begin = dol_mktime(0, 0, 0, GETPOSTINT('date_beginmonth'), GETPOSTINT('date_beginday'), GETPOSTINT('date_beginyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
425 print '<tr><td>'.$langs->trans("AppliedPricesFrom").'</td><td>';
426 print $form->selectDate(!empty($date_begin) ? $date_begin : dol_now(), "date_begin", 0, 0, 1, "date_begin");
427 print '</td></tr>';
428
429 // Applied Prices To
430 $date_end = dol_mktime(0, 0, 0, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
431 print '<tr><td>'.$langs->trans("AppliedPricesTo").'</td><td>';
432 print $form->selectDate($date_end, "date_end", 0, 0, 1, "date_end");
433 print '</td></tr>';
434
435 // VAT
436 print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
437 print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, $object, 0, 0, '', false, 1, 1);
438 print '</td></tr>';
439
440 // Price base
441 print '<tr><td width="15%">';
442 print $langs->trans('PriceBase');
443 print '</td>';
444 print '<td>';
445 print $form->selectPriceBaseType(GETPOST("price_base_type", "aZ09"), "price_base_type");
446 print '</td>';
447 print '</tr>';
448
449 // Price
450 print '<tr><td width="20%">';
451 $text = $langs->trans('SellingPrice');
452 print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", getDolGlobalString('MAIN_MAX_DECIMALS_UNIT')), 1, 'help');
453 print '</td><td>';
454 print '<input name="price" size="10" value="'.GETPOSTINT('price').'">';
455 print '</td></tr>';
456
457 // Price minimum
458 print '<tr><td>';
459 $text = $langs->trans('MinPrice');
460 print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", getDolGlobalString('MAIN_MAX_DECIMALS_UNIT')), 1, 'help');
461 print '<td><input name="price_min" size="10" value="'.GETPOSTINT('price_min').'">';
462 print '</td></tr>';
463
464 // Discount
465 $discount_percent = price2num(GETPOST("discount_percent"));
466 print '<tr><td>'.$langs->trans("Discount").'</td><td>';
467 print '<input name="discount_percent" size="10" value="'.price($discount_percent).'">';
468 print '</td></tr>';
469
470 // Update all child soc
471 print '<tr><td width="15%">';
472 print $langs->trans('ForceUpdateChildPriceSoc');
473 print '</td>';
474 print '<td>';
475 print '<input type="checkbox" name="updatechildprice" value="1"/>';
476 print '</td>';
477 print '</tr>';
478
479 // Extrafields
480 $extrafields->fetch_name_optionals_label("product_customer_price");
481 $extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
482 $extrafield_values = $extrafields->getOptionalsFromPost("product_customer_price");
483 if (!empty($extralabels)) {
484 if (empty($prodcustprice->id)) {
485 foreach ($extralabels as $key => $value) {
486 if (!empty($extrafields->attributes["product_customer_price"]['list'][$key]) && ($extrafields->attributes["product_customer_price"]['list'][$key] == 1 || $extrafields->attributes["product_customer_price"]['list'][$key] == 3 || ($action == "add_customer_price" && $extrafields->attributes["product_customer_price"]['list'][$key] == 4))) {
487 if (!empty($extrafields->attributes["product_customer_price"]['langfile'][$key])) {
488 $langs->load($extrafields->attributes["product_customer_price"]['langfile'][$key]);
489 }
490
491 print '<tr><td'.($extrafields->attributes["product_customer_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
492 if (!empty($extrafields->attributes["product_customer_price"]['help'][$key])) {
493 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_customer_price"]['help'][$key]));
494 } else {
495 print $langs->trans($value);
496 }
497 print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_customer_price').'</td></tr>';
498 }
499 }
500 }
501 }
502
503 print '</table>';
504
505 print $form->buttonsSaveCancel();
506
507 print '</form>';
508 } elseif ($action == 'edit_customer_price') {
509 // Edit mode
510
511 print load_fiche_titre($langs->trans('PriceByCustomer'));
512
513 $result = $prodcustprice->fetch(GETPOSTINT('lineid'));
514
515 if ($result <= 0) {
516 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
517 } else {
518 print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
519 print '<input type="hidden" name="token" value="'.newToken().'">';
520 print '<input type="hidden" name="action" value="update_customer_price_confirm">';
521 print '<input type="hidden" name="lineid" value="'.$prodcustprice->id.'">';
522 print '<table class="border centpercent">';
523 print '<tr>';
524 print '<td>'.$langs->trans('Product').'</td>';
525 $staticprod = new Product($db);
526 $staticprod->fetch($prodcustprice->fk_product);
527 print "<td>".$staticprod->getNomUrl(1)."</td>";
528 print '</tr>';
529
530 // Ref. Customer
531 print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
532 print '<td><input name="ref_customer" size="12" value="'.dol_escape_htmltag($prodcustprice->ref_customer).'"></td></tr>';
533
534 // Applied Prices From
535 print '<tr><td>'.$langs->trans("AppliedPricesFrom").'</td><td>';
536 print $form->selectDate($prodcustprice->date_begin, "date_begin", 0, 0, 1, "date_begin");
537 print '</td></tr>';
538
539 // Applied Prices To
540 print '<tr><td>'.$langs->trans("AppliedPricesTo").'</td><td>';
541 print $form->selectDate($prodcustprice->date_end, "date_end", 0, 0, 1, "date_end");
542 print '</td></tr>';
543
544 // VAT
545 print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
546 print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, null, $staticprod->id, $prodcustprice->recuperableonly, '', false, 1, 1);
547 print '</td></tr>';
548
549 // Price base
550 print '<tr><td width="15%">';
551 print $langs->trans('PriceBase');
552 print '</td>';
553 print '<td>';
554 print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
555 print '</td>';
556 print '</tr>';
557
558 // Price
559 print '<tr><td>';
560 $text = $langs->trans('SellingPrice');
561 print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", getDolGlobalString('MAIN_MAX_DECIMALS_UNIT')), 1, 'help');
562 print '</td><td>';
563 if ($prodcustprice->price_base_type == 'TTC') {
564 print '<input name="price" size="10" value="'.price($prodcustprice->price_ttc).'">';
565 } else {
566 print '<input name="price" size="10" value="'.price($prodcustprice->price).'">';
567 }
568 print '</td></tr>';
569
570 // Price minimum
571 print '<tr><td>';
572 $text = $langs->trans('MinPrice');
573 print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", getDolGlobalString('MAIN_MAX_DECIMALS_UNIT')), 1, 'help');
574 print '</td><td>';
575 if ($prodcustprice->price_base_type == 'TTC') {
576 print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).'">';
577 } else {
578 print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min).'">';
579 }
580 print '</td></tr>';
581
582 // Discount
583 print '<tr><td>'.$langs->trans("Discount").'</td><td>';
584 print '<input name="discount_percent" size="10" value="'.price($prodcustprice->discount_percent).'">';
585 print '</td></tr>';
586
587 // Extrafields
588 $extrafields->fetch_name_optionals_label("product_customer_price");
589 $extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
590 $extrafield_values = $extrafields->getOptionalsFromPost("product_customer_price");
591 if (!empty($extralabels)) {
592 if (empty($object->id)) {
593 foreach ($extralabels as $key => $value) {
594 if (!empty($extrafields->attributes["product_customer_price"]['list'][$key]) && ($extrafields->attributes["product_customer_price"]['list'][$key] == 1 || $extrafields->attributes["product_customer_price"]['list'][$key] == 3 || ($action == "edit_customer_price" && $extrafields->attributes["product_customer_price"]['list'][$key] == 4))) {
595 if (!empty($extrafields->attributes["product_customer_price"]['langfile'][$key])) {
596 $langs->load($extrafields->attributes["product_customer_price"]['langfile'][$key]);
597 }
598
599 print '<tr><td'.($extrafields->attributes["product_customer_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
600 if (!empty($extrafields->attributes["product_customer_price"]['help'][$key])) {
601 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_customer_price"]['help'][$key]));
602 } else {
603 print $langs->trans($value);
604 }
605 print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_customer_price').'</td></tr>';
606 }
607 }
608 } else {
609 $sql = "SELECT";
610 $sql .= " fk_object";
611 foreach ($extralabels as $key => $value) {
612 $sql .= ", ".$db->sanitize($key);
613 }
614 $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_extrafields";
615 $sql .= " WHERE fk_object = ".((int) $prodcustprice->id);
616 $resql = $db->query($sql);
617 if ($resql) {
618 $obj = $db->fetch_object($resql);
619 foreach ($extralabels as $key => $value) {
620 if (!empty($extrafields->attributes["product_customer_price"]['list'][$key]) && ($extrafields->attributes["product_customer_price"]['list'][$key] == 1 || $extrafields->attributes["product_customer_price"]['list'][$key] == 3 || ($action == "edit_customer_price" && $extrafields->attributes["product_customer_price"]['list'][$key] == 4))) {
621 if (!empty($extrafields->attributes["product_customer_price"]['langfile'][$key])) {
622 $langs->load($extrafields->attributes["product_customer_price"]['langfile'][$key]);
623 }
624
625 print '<tr><td'.($extrafields->attributes["product_customer_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
626 if (!empty($extrafields->attributes["product_customer_price"]['help'][$key])) {
627 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_customer_price"]['help'][$key]));
628 } else {
629 print $langs->trans($value);
630 }
631 print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : $obj->{$key}, '', '', '', '', 0, 'product_customer_price');
632
633 print '</td></tr>';
634 }
635 }
636 $db->free($resql);
637 }
638 }
639 }
640
641 print '</table>';
642
643 // Update all child soc
644 print '<center>';
645 print '<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
646 print '<label for="updatechildprice">'.$langs->trans('ForceUpdateChildPriceSoc').'</label>';
647 print '</center>';
648
649 print $form->buttonsSaveCancel();
650
651 print '</form>';
652 }
653 } elseif ($action == 'showlog_customer_price') {
654 print '<br>';
655 print '<!-- showlog_customer_price -->'."\n";
656
657 $sortfield = 't.datec';
658 $filter = array(
659 't.fk_product' => (string) GETPOSTINT('prodid'),
660 't.fk_soc' => (string) $socid
661 );
662
663 // Count total nb of records
664 $nbtotalofrecords = '';
665 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
666 if ($result < 0) {
667 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
668 } else {
669 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
670 $nbtotalofrecords = $result;
671 }
672 }
673
674 $option = '&socid='.GETPOSTINT('socid').'&prodid='.GETPOSTINT('prodid');
675
676 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
677 print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
678
679 if (count($prodcustprice->lines) > 0) {
680 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
681 print '<input type="hidden" name="token" value="'.newToken().'">';
682 print '<input type="hidden" name="id" value="'.$object->id.'">';
683
684 print '<table class="noborder centpercent">';
685
686 print '<tr class="liste_titre">';
687 print '<td>'.$langs->trans("Product").'</td>';
688 print '<td>'.$langs->trans('RefCustomer').'</td>';
689 print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
690 print '<td>'.$langs->trans("AppliedPricesTo").'</td>';
691 print '<td class="center">'.$langs->trans("PriceBase").'</td>';
692 print '<td class="right">'.$langs->trans("VAT").'</td>';
693 print '<td class="right">'.$langs->trans("HT").'</td>';
694 print '<td class="right">'.$langs->trans("TTC").'</td>';
695 print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
696 print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
697 print '<td class="right">'.$langs->trans("Discount").'</td>';
698 print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
699 print '<td>'.$langs->trans("DateCreation").'</td>';
700 print '</tr>';
701
702 foreach ($prodcustprice->lines as $line) {
703 $staticprod = new Product($db);
704 $staticprod->fetch($line->fk_product);
705
706 $userstatic = new User($db);
707 $userstatic->fetch($line->fk_user);
708
709 print '<tr class="oddeven">';
710
711 print "<td>".$staticprod->getNomUrl(1)."</td>";
712 print '<td>'.$line->ref_customer.'</td>';
713 print "<td>".dol_print_date($line->date_begin, "day", 'tzuserrel')."</td>";
714 print "<td>".dol_print_date($line->date_end, "day", 'tzuserrel')."</td>";
715
716 print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
717 print '<td class="right">'.vatrate($line->tva_tx, true, $line->recuperableonly)."</td>";
718 print '<td class="right">'.price($line->price)."</td>";
719 print '<td class="right">'.price($line->price_ttc)."</td>";
720 print '<td class="right">'.price($line->price_min).'</td>';
721 print '<td class="right">'.price($line->price_min_ttc).'</td>';
722 print '<td class="right">'.price($line->discount_percent).'</td>';
723
724 // User
725 print '<td class="right">';
726 print $userstatic->getNomUrl(-1);
727 print '</td>';
728 print "<td>".dol_print_date($line->datec, "dayhour", 'tzuserrel')."</td>";
729 }
730 print "</table>";
731 } else {
732 print $langs->trans('None');
733 }
734
735 print "\n".'<div class="tabsAction">'."\n";
736 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>';
737 print "\n</div><br>\n";
738 } else {
739 // View mode
740
741 /*
742 * Action bar
743 */
744 print "\n".'<div class="tabsAction">'."\n";
745
746 if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) {
747 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=add_customer_price&token='.newToken().'&socid='.$object->id.'">'.$langs->trans("AddCustomerPrice").'</a></div>';
748 }
749 print "\n</div>\n";
750
751
752 $arrayfields = array();
753 foreach ($prodcustprice->fields as $key => $val) {
754 // If $val['visible']==0, then we never show the field
755 if (!empty($val['visible'])) {
756 $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1');
757 $arrayfields['t.'.$key] = array(
758 'label' => $val['label'],
759 'checked' => (($visible < 0) ? 0 : 1),
760 'enabled' => (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
761 'position' => $val['position'],
762 'help' => isset($val['help']) ? $val['help'] : ''
763 );
764 }
765 }
766 // fetch optionals attributes and labels
767 $extrafields->fetch_name_optionals_label("product_customer_price");
768 if ($extrafields->attributes["product_customer_price"] && array_key_exists('label', $extrafields->attributes["product_customer_price"])) {
769 $extralabels = $extrafields->attributes["product_customer_price"]['label'];
770
771 if (!empty($extralabels)) {
772 foreach ($extralabels as $key => $value) {
773 // Show field if not hidden
774 if (!empty($extrafields->attributes["product_customer_price"]['list'][$key]) && $extrafields->attributes["product_customer_price"]['list'][$key] != 3) {
775 $extratitle = $langs->trans($value);
776 if (!empty($val['visible'])) {
777 $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1');
778 $arrayfields['ef.' . $key] = array(
779 'label' => $extratitle,
780 'checked' => (($visible < 0) ? 0 : 1),
781 'position' => (int) $extrafields->attributes['product_customer_price']['pos'][$key],
782 'langfile' => $extrafields->attributes["product_customer_price"]['langfile'][$key],
783 'help' => $extrafields->attributes["product_customer_price"]['help'][$key]
784 );
785 }
786 }
787 }
788 }
789 }
790
791 $arrayfields = dol_sort_array($arrayfields, 'position');
792
793 // Count total nb of records
794 $nbtotalofrecords = '';
795 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
796 $nbtotalofrecords = $prodcustprice->fetchAll('', '', 0, 0, $filter);
797 }
798
799 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
800 if ($result < 0) {
801 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
802 }
803
804 $option = '&search_prod='.urlencode($search_prod).'&id='.$object->id.'&search_label='.urlencode($search_label).'&search_price='.urlencode($search_price).'&search_price_ttc='.urlencode($search_price_ttc);
805
806 print '<!-- view specific price for each product -->'."\n";
807
808 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
809 print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, 'product');
810
811 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
812 print '<input type="hidden" name="token" value="'.newToken().'">';
813 print '<input type="hidden" name="id" value="'.$object->id.'">';
814 if (!empty($sortfield)) {
815 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
816 }
817 if (!empty($sortorder)) {
818 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
819 }
820 print '<div class="div-table-responsive-no-min">';
821 print '<table class="noborder centpercent liste">';
822
823 $param = 'socid='.$object->id.'&';
824 if ($search_prod) {
825 $param .= '&search_prod='.urlencode($search_prod);
826 }
827 if ($search_label) {
828 $param .= '&search_label='.urlencode($search_label);
829 }
830 if ($search_price) {
831 $param .= '&search_price='.urlencode($search_price);
832 }
833 if ($search_price) {
834 $param .= '&search_price='.urlencode($search_price);
835 }
836 if ($search_price_ttc) {
837 $param .= '&search_price_ttc='.urlencode($search_price_ttc);
838 }
839
840 print '<tr class="liste_titre">';
841
842 $colspan = 0;
843
844 foreach ($prodcustprice->fields as $key => $val) {
845 if (!empty($arrayfields['t.'.$key]['checked'])) {
846 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, '', $sortfield, $sortorder)."\n";
847 $colspan++;
848 }
849 }
850 if (!empty($extralabels) && is_array($extralabels)) {
851 foreach ($extralabels as $key => $val) {
852 if (!empty($arrayfields['ef.'.$key]['checked'])) {
853 print getTitleFieldOfList($arrayfields['ef.'.$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, '', $sortfield, $sortorder)."\n";
854 $colspan++;
855 }
856 }
857 }
858 print '<td></td>';
859 $colspan++;
860
861 print '</tr>';
862
863 if (count($prodcustprice->lines) > 0 || $search_prod) {
864 print '<tr class="liste_titre">';
865 print '<td class="liste_titre"><input type="text" class="flat width75" name="search_prod" value="'.$search_prod.'"></td>';
866 print '<td class="liste_titre" ><input type="text" class="flat width75" name="search_label" value="'.$search_label.'"></td>';
867 print '<td class="liste_titre"></td>';
868 print '<td class="liste_titre"></td>';
869 print '<td class="liste_titre"></td>';
870 print '<td class="liste_titre"></td>';
871 print '<td class="liste_titre"></td>';
872 print '<td class="liste_titre left"><input type="text" class="flat width75" name="search_price" value="'.$search_price.'"></td>';
873 print '<td class="liste_titre left"><input type="text" class="flat width75" name="search_price_ttc" value="'.$search_price_ttc.'"></td>';
874 print '<td class="liste_titre"></td>';
875 print '<td class="liste_titre"></td>';
876 print '<td class="liste_titre"></td>';
877 print '<td class="liste_titre"></td>';
878 print '<td class="liste_titre"></td>';
879 if (!empty($extralabels)) {
880 foreach ($extralabels as $key) {
881 print '<td class="right"></td>';
882 }
883 }
884 // Print the search button
885 print '<td class="liste_titre maxwidthsearch">';
886 $searchpicto = $form->showFilterAndCheckAddButtons(0);
887 print $searchpicto;
888 print '</td>';
889 print '</tr>';
890 }
891
892 if (count($prodcustprice->lines) > 0) {
893 foreach ($prodcustprice->lines as $line) {
894 $staticprod = new Product($db);
895 $staticprod->fetch($line->fk_product);
896
897 $userstatic = new User($db);
898 $userstatic->fetch($line->fk_user);
899
900 print '<tr class="oddeven">';
901
902 print '<td class="left">'.$staticprod->getNomUrl(1)."</td>";
903 print '<td class="left">'.$staticprod->label."</td>";
904 print '<td class="left">'.$line->ref_customer.'</td>';
905 print '<td class="left">'.dol_print_date($line->date_begin, "day", 'tzuserrel')."</td>";
906 print '<td class="left">'.dol_print_date($line->date_end, "day", 'tzuserrel')."</td>";
907 print '<td class="left">'.$langs->trans($line->price_base_type)."</td>";
908 print '<td class="left">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
909 print '<td class="left">'.price($line->price)."</td>";
910 print '<td class="left">'.price($line->price_ttc)."</td>";
911 print '<td class="left">'.price($line->price_min).'</td>';
912 print '<td class="left">'.price($line->price_min_ttc).'</td>';
913 print '<td class="left">'.$line->price_label.'</td>';
914 print '<td class="left">'.price($line->discount_percent).'</td>';
915 // User
916 print '<td class="left">';
917 print $userstatic->getNomUrl(-1);
918 print '</td>';
919
920 // Extrafields
921 $extrafields->fetch_name_optionals_label("product_customer_price");
922 $extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
923 if (!empty($extralabels)) {
924 $sql = "SELECT";
925 $sql .= " fk_object";
926 foreach ($extralabels as $key => $value) {
927 $sql .= ", ".$db->sanitize($key);
928 }
929 $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_extrafields";
930 $sql .= " WHERE fk_object = ".((int) $line->id);
931 $resql = $db->query($sql);
932 if ($resql) {
933 if ($db->num_rows($resql) != 1) {
934 foreach ($extralabels as $key => $value) {
935 if (!empty($extrafields->attributes["product_customer_price"]['list'][$key]) && $extrafields->attributes["product_customer_price"]['list'][$key] != 3) {
936 print "<td></td>";
937 }
938 }
939 } else {
940 $obj = $db->fetch_object($resql);
941 foreach ($extralabels as $key => $value) {
942 if (!empty($extrafields->attributes["product_customer_price"]['list'][$key]) && $extrafields->attributes["product_customer_price"]['list'][$key] != 3) {
943 print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key}, '', 'product_customer_price')."</td>";
944 }
945 }
946 }
947 $db->free($resql);
948 }
949 }
950 // Action
951 if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) {
952 print '<td class="right nowraponall">';
953 print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&token='.newToken().'&socid='.$object->id.'&prodid='.$line->fk_product.'">';
954 print img_info();
955 print '</a>';
956 print ' ';
957 print '<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&token='.newToken().'&socid='.$object->id.'&lineid='.$line->id.'">';
958 print img_edit('default', 0, 'style="vertical-align: middle;"');
959 print '</a>';
960 print ' ';
961 print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&token='.newToken().'&socid='.$object->id.'&lineid='.$line->id.'">';
962 print img_delete('default', 'style="vertical-align: middle;"');
963 print '</a>';
964 print '</td>';
965 }
966
967 print "</tr>\n";
968 }
969 } else {
970 if ($user->hasRight('produit', 'supprimer') || $user->hasRight('service', 'supprimer')) {
971 $colspan += 1;
972 }
973 print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans('None').'</span></td></tr>';
974 }
975
976 print "</table>";
977 print '</div>';
978
979 print "</form>";
980 }
981}
982
983// End of page
984llxFooter();
985$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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 generation of HTML components Only common components must be here.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_info($titlealt='default')
Show info logo.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.