dolibarr 23.0.3
price_suppliers.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2021 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
8 * Copyright (C) 2014 Ion Agorria <ion@agorria.com>
9 * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
10 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
11 * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2019 Tim Otte <otte@meuser.it>
13 * Copyright (C) 2020-2025 Pierre Ardoin <developpeur@lesmetiersdubatiment.fr>
14 * Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
15 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 */
30
37// Load Dolibarr environment
38require '../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
50require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
51require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
52require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php';
53require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
54if (isModEnabled('barcode')) {
55 dol_include_once('/core/class/html.formbarcode.class.php');
56}
57
58// Load translation files required by the page
59$langs->loadLangs(array('products', 'suppliers', 'bills', 'margins', 'stocks'));
60
61$id = GETPOSTINT('id');
62$ref = GETPOST('ref', 'alpha');
63$rowid = GETPOSTINT('rowid');
64$action = GETPOST('action', 'aZ09');
65$cancel = GETPOST('cancel', 'alpha');
66$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'pricesuppliercard';
67
68$socid = GETPOSTINT('socid');
69$cost_price = GETPOSTFLOAT('cost_price');
70$pmp = GETPOSTFLOAT('pmp');
71
72$backtopage = GETPOST('backtopage', 'alpha');
73$error = 0;
74
75$extrafields = new ExtraFields($db);
76
77// If socid provided by ajax company selector
78if (GETPOSTINT('search_fourn_id')) {
79 $_GET['id_fourn'] = GETPOSTINT('search_fourn_id'); // Keep set to $_GET an $_POST. Used later.
80 $_POST['id_fourn'] = GETPOSTINT('search_fourn_id'); // Keep set to $_GET an $_POST. Used later.
81}
82
83// Security check
84$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
85$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
86if ($user->socid) {
87 $socid = $user->socid;
88}
89
90$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
91$sortfield = GETPOST('sortfield', 'aZ09comma');
92$sortorder = GETPOST('sortorder', 'aZ09comma');
93$page = GETPOSTINT("page") ? GETPOSTINT("page") : 0;
94if (empty($page) || $page == -1) {
95 $page = 0;
96} // If $page is not defined, or '' or -1
97$offset = $limit * $page;
98$pageprev = $page - 1;
99$pagenext = $page + 1;
100if (!$sortfield) {
101 $sortfield = "s.nom";
102}
103if (!$sortorder) {
104 $sortorder = "ASC";
105}
106
107// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
108$hookmanager->initHooks(array('pricesuppliercard', 'globalcard'));
109
110$object = new ProductFournisseur($db);
111$prod = new Product($db);
112if ($id > 0 || $ref) {
113 $object->fetch($id, $ref);
114 $prod->fetch($id, $ref);
115}
116
117if (!$user->hasRight('fournisseur', 'lire') && (!isModEnabled('margin') && !$user->hasRight("margin", "liretous"))) {
119}
120
121$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire')));
122$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer')));
123// Case of advanced permission to write supplier prices
124$usercancreate = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $usercancreate : $user->hasRight('product', 'product_advance', 'write_supplier_prices'));
125
126if ($object->id > 0) {
127 if ($object->type == $object::TYPE_PRODUCT) {
128 restrictedArea($user, 'produit', $object->id, 'product&product', '', '');
129 }
130 if ($object->type == $object::TYPE_SERVICE) {
131 restrictedArea($user, 'service', $object->id, 'product&product', '', '');
132 }
133} else {
134 restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
135}
136
137
138/*
139 * Actions
140 */
141
142if ($cancel) {
143 $action = '';
144}
145
146$parameters = array('socid' => $socid, 'id_prod' => $id);
147$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
148if ($reshook < 0) {
149 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
150}
151
152if (empty($reshook)) {
153 if ($action == 'setcost_price' && $usercancreate) {
154 if ($id) {
155 $result = $object->fetch($id);
156 //Need dol_clone methode 1 (same object class) because update product use hasbatch method on oldcopy
157 $object->oldcopy = dol_clone($object, 1); // @phan-suppress-current-line PhanTypeMismatchProperty
158 $object->cost_price = $cost_price;
159 $result = $object->update($object->id, $user);
160 if ($result > 0) {
161 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
162 $action = '';
163 } else {
164 $error++;
165 setEventMessages($object->error, $object->errors, 'errors');
166 }
167 }
168 }
169 if ($action == 'setpmp' && $usercancreate) {
170 if ($id) {
171 $result = $object->fetch($id);
172 $object->pmp = $pmp;
173 $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".((float) $object->pmp)." WHERE rowid = ".((int) $id);
174 $resql = $db->query($sql);
175 //$result = $object->update($object->id, $user);
176 if ($resql) {
177 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
178 $action = '';
179 } else {
180 $error++;
181 setEventMessages($object->error, $object->errors, 'errors');
182 }
183 }
184 }
185
186 if ($action == 'confirm_remove_pf' && $usercancreate) {
187 if ($rowid) { // id of product supplier price to remove
188 $action = '';
189 $result = $object->remove_product_fournisseur_price($rowid);
190 if ($result > 0) {
191 $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".((int) $rowid));
192 setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs');
193 } else {
194 $error++;
195 setEventMessages($object->error, $object->errors, 'errors');
196 }
197 }
198 }
199
200 if ($action == 'save_price' && $usercancreate) {
201 $ref_fourn_price_id = GETPOSTINT('ref_fourn_price_id');
202 $id_fourn = GETPOSTINT("id_fourn");
203 if (empty($id_fourn)) {
204 $id_fourn = GETPOSTINT("search_id_fourn");
205 }
206 $ref_fourn = GETPOST("ref_fourn");
207 if (empty($ref_fourn)) {
208 $ref_fourn = GETPOST("search_ref_fourn");
209 }
210 $ref_fourn_old = GETPOST("ref_fourn_old");
211 if (empty($ref_fourn_old)) {
212 $ref_fourn_old = $ref_fourn;
213 }
214 $quantity = price2num(GETPOST("qty", 'alphanohtml'), 'MS');
215 $remise_percent = price2num(GETPOST('remise_percent', 'alpha'));
216
217 $npr = preg_match('/\*/', GETPOST('tva_tx', 'alpha')) ? 1 : 0;
218 $tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha'));
219 if (!preg_match('/\‍((.*)\‍)/', $tva_tx)) {
220 $tva_tx = price2num($tva_tx);
221 }
222
223 $price_expression = GETPOSTINT('eid') ? GETPOSTINT('eid') : ''; // Discard expression if not in expression mode
224 $delivery_time_days = GETPOSTINT('delivery_time_days') ? GETPOSTINT('delivery_time_days') : '';
225 $supplier_reputation = GETPOST('supplier_reputation');
226 $supplier_description = GETPOST('supplier_description', 'restricthtml');
227 $barcode = GETPOST('barcode', 'alpha');
228 $fk_barcode_type = GETPOSTINT('fk_barcode_type');
229 $packaging = price2num(GETPOST("packaging", 'alphanohtml'), 'MS');
230
231 if ($tva_tx == '') {
232 $error++;
233 $langs->load("errors");
234 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("VATRateForSupplierProduct")), null, 'errors');
235 }
236 if (!is_numeric($tva_tx)) {
237 $error++;
238 $langs->load("errors");
239 setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("VATRateForSupplierProduct")), null, 'errors');
240 }
241 if (empty($quantity)) {
242 $error++;
243 $langs->load("errors");
244 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Qty")), null, 'errors');
245 }
246 if (empty($ref_fourn)) {
247 $error++;
248 $langs->load("errors");
249 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("RefSupplier")), null, 'errors');
250 }
251 if ($id_fourn <= 0) {
252 $error++;
253 $langs->load("errors");
254 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Supplier")), null, 'errors');
255 }
256 if (price2num(GETPOST("price")) < 0 || GETPOST("price") == '') {
257 if ($price_expression === '') { // Return error of missing price only if price_expression not set
258 $error++;
259 $langs->load("errors");
260 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")), null, 'errors');
261 } else {
262 $_POST["price"] = 0;
263 }
264 }
265 if (isModEnabled("multicurrency")) {
266 if (!GETPOST("multicurrency_code")) {
267 $error++;
268 $langs->load("errors");
269 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Currency")), null, 'errors');
270 }
271 if (price2num(GETPOST("multicurrency_tx")) <= 0 || GETPOST("multicurrency_tx") == '') {
272 $error++;
273 $langs->load("errors");
274 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CurrencyRate")), null, 'errors');
275 }
276 if (price2num(GETPOST("multicurrency_price")) < 0 || GETPOST("multicurrency_price") == '') {
277 $error++;
278 $langs->load("errors");
279 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PriceCurrency")), null, 'errors');
280 }
281 }
282
283 if (!$error) {
284 $db->begin();
285
286 if (empty($ref_fourn_price_id)) {
287 $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, (float) $quantity); // This inserts record with no value for price. Values are updated later with update_buyprice
288 if ($ret == -3) {
289 $error++;
290
291 $tmpobject = new Product($db);
292 $tmpobject->fetch($object->product_id_already_linked);
293 $productLink = $tmpobject->getNomUrl(1, 'supplier');
294
295 $texttoshow = $langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct", '{s1}');
296 $texttoshow = str_replace('{s1}', $productLink, $texttoshow);
297 setEventMessages($texttoshow, null, 'errors');
298 } elseif ($ret < 0) {
299 $error++;
300 setEventMessages($object->error, $object->errors, 'errors');
301 }
302 }
303
304 if (!$error) {
305 $supplier = new Fournisseur($db);
306 $result = $supplier->fetch($id_fourn);
307 if (GETPOSTISSET('ref_fourn_price_id')) {
308 $object->fetch_product_fournisseur_price($ref_fourn_price_id);
309 }
310 $extralabels = $extrafields->fetch_name_optionals_label("product_fournisseur_price");
311 $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price");
312
313 $newprice = GETPOSTFLOAT("price");
314
315 if (empty($packaging)) {
316 $packaging = 1;
317 }
318 /* We can have a purchase ref that need to buy 100 min for a given price and with a packaging of 50.
319 if ($packaging < $quantity) {
320 $packaging = $quantity;
321 }*/
322 $object->product_fourn_packaging = $packaging;
323
324 if (isModEnabled("multicurrency")) {
325 $multicurrency_tx = GETPOSTFLOAT("multicurrency_tx");
326 $multicurrency_price = GETPOSTFLOAT("multicurrency_price");
327 $multicurrency_code = GETPOST("multicurrency_code", 'alpha');
328
329 $ret = $object->update_buyprice((float) $quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOSTINT("oselDispo"), $ref_fourn, (float) $tva_tx, GETPOST("charges"), (float) $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, GETPOST("multicurrency_price_base_type"), $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type, $extrafield_values);
330 } else {
331 $ret = $object->update_buyprice((float) $quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOSTINT("oselDispo"), $ref_fourn, (float) $tva_tx, GETPOST("charges"), (float) $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type, $extrafield_values);
332 }
333 if ($ret < 0) {
334 $error++;
335 setEventMessages($object->error, $object->errors, 'errors');
336 } else {
337 if (isModEnabled('dynamicprices') && $price_expression !== '') {
338 //Check the expression validity by parsing it
339 require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
340 $priceparser = new PriceParser($db);
341 $object->fk_supplier_price_expression = $price_expression;
342 $price_result = $priceparser->parseProductSupplier($object);
343 if ($price_result < 0) { //Expression is not valid
344 $error++;
345 setEventMessages($priceparser->translatedError(), null, 'errors');
346 }
347 }
348 if (!$error && isModEnabled('dynamicprices')) {
349 //Set the price expression for this supplier price
350 $ret = $object->setSupplierPriceExpression($price_expression);
351 if ($ret < 0) {
352 $error++;
353 setEventMessages($object->error, $object->errors, 'errors');
354 }
355 }
356 }
357 }
358
359 if (!$error) {
360 $db->commit();
361 $action = '';
362 } else {
363 $db->rollback();
364 }
365 } else {
366 $action = 'create_price';
367 }
368 }
369}
370
371
372/*
373 * view
374 */
375
376$form = new Form($db);
377
378$title = $langs->trans('ProductServiceCard');
379$helpurl = '';
380$shortlabel = dol_trunc($object->label, 16);
381if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
382 $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('BuyingPrices');
383 $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
384}
385if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
386 $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('BuyingPrices');
387 $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Lesitungen';
388}
389
390llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'classforhorizontalscrolloftabs mod-product page-price_suppliers');
391
392if ($id > 0 || $ref) {
393 if ($action == 'ask_remove_pf' && $usercancreate) {
394 $form = new Form($db);
395 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&rowid='.$rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1);
396 echo $formconfirm;
397 }
398
399 if ($action != 'edit' && $action != 're-edit') {
400 $head = product_prepare_head($object);
401 $titre = $langs->trans("CardProduct".$object->type);
402 $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
403
404 print dol_get_fiche_head($head, 'suppliers', $titre, -1, $picto);
405
406 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
407 $prod->next_prev_filter = "(te.fk_product_type:=:".((int) $object->type).")"; // use $prod instead $object
408
409 $shownav = 1;
410 if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
411 $shownav = 0;
412 }
413
414 dol_banner_tab($prod, 'ref', $linkback, $shownav, 'ref');
415
416 print '<div class="fichecenter">';
417
418 print '<div class="underbanner clearboth"></div>';
419 print '<table class="border tableforfield centpercent">';
420
421 // Type
422 if (isModEnabled("product") && isModEnabled("service")) {
423 $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
424 print '<tr><td class="">';
425 print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type');
426 print '</td><td>';
427 print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
428 print '</td></tr>';
429 }
430
431 // Cost price. Can be used for margin module for option "calculate margin on explicit cost price
432 print '<tr><td>';
433 $textdesc = $langs->trans("CostPriceDescription");
434 $textdesc .= "<br>".$langs->trans("CostPriceUsage");
435 $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', '');
436 print $form->editfieldkey($text, 'cost_price', (string) $object->cost_price, $object, (int) $usercancreate, 'amount:6');
437 print '</td><td>';
438 print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
439 print '</td></tr>';
440
441 // PMP
442 $usercaneditpmp = 0;
443 if (getDolGlobalString('PRODUCT_CAN_EDIT_WAP')) {
444 $usercaneditpmp = $usercancreate;
445 }
446 print '<tr><td class="titlefieldcreate">';
447 $textdesc = $langs->trans("AverageUnitPricePMPDesc");
448 $text = $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $textdesc, 1, 'help', '');
449 print $form->editfieldkey($text, 'pmp', (string) $object->pmp, $object, $usercaneditpmp, 'amount:6');
450 print '</td><td>';
451 print $form->editfieldval($text, 'pmp', ($object->pmp > 0 ? $object->pmp : ''), $object, $usercaneditpmp, 'amount:6');
452 if ($object->pmp > 0) {
453 print ' '.$langs->trans("HT");
454 }
455 /*
456 .$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>';
457 print '<td>';
458 if ($object->pmp > 0) {
459 print price($object->pmp).' '.$langs->trans("HT");
460 }*/
461 print '</td>';
462 print '</tr>';
463
464 // Best buying Price
465 print '<tr><td class="titlefieldcreate">'.$langs->trans("BuyingPriceMin").'</td>';
466 print '<td>';
467 $product_fourn = new ProductFournisseur($db);
468 if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) {
469 if ($product_fourn->product_fourn_price_id > 0) {
470 print $product_fourn->display_price_product_fournisseur();
471 } else {
472 print $langs->trans("NotDefined");
473 }
474 }
475 print '</td></tr>';
476
477 print '</table>';
478
479 print '</div>';
480 print '<div class="clearboth"></div>';
481
482 print dol_get_fiche_end();
483
484
485 // Form to add or update a price
486 if (($action == 'create_price' || $action == 'edit_price') && $usercancreate) {
487 $langs->load("suppliers");
488
489 print "<!-- form to add a supplier price -->\n";
490 print '<br>';
491
492 if ($rowid) {
493 $object->fetch_product_fournisseur_price($rowid, 1); //Ignore the math expression when getting the price
494 print load_fiche_titre($langs->trans("ChangeSupplierPrice"));
495 } else {
496 print load_fiche_titre($langs->trans("AddSupplierPrice"));
497 }
498
499 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">';
500 print '<input type="hidden" name="token" value="'.newToken().'">';
501 print '<input type="hidden" name="action" value="save_price">';
502
503 print dol_get_fiche_head();
504
505 print '<table class="border centpercent">';
506
507 // Supplier
508 print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Supplier").'</td><td>';
509 if ($rowid) {
510 $supplier = new Fournisseur($db);
511 $supplier->fetch($socid);
512 print $supplier->getNomUrl(1);
513 print '<input type="hidden" name="id_fourn" value="'.$socid.'">';
514 print '<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.'">';
515 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
516 print '<input type="hidden" name="socid" value="'.$socid.'">';
517 } else {
518 $events = array();
519 $events[] = array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array());
520 $filter = '(fournisseur:=:1) AND (status:=:1)';
521 print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', $filter, $langs->transnoentitiesnoconv('SelectThirdParty'), 0, 0, $events);
522
523 $parameters = array('filter' => $filter, 'html_name' => 'id_fourn', 'selected' => GETPOST("id_fourn"), 'showempty' => 1, 'prod_id' => $object->id);
524 $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action);
525 if (empty($reshook)) {
526 if (empty($form->result)) {
527 print '<a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&type=f&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action='.urlencode($action).($action == 'create_price' ? '&token='.newToken() : '')).'">';
528 print img_picto($langs->trans("CreateDolibarrThirdPartySupplier"), 'add', 'class="marginleftonly"');
529 print '</a>';
530 }
531 }
532 print '<script type="text/javascript">
533 $(document).ready(function () {
534 console.log("Requesting default VAT rate for the supplier...")
535 $("#search_id_fourn").change(load_vat)
536 });
537 function load_vat() {
538 // get soc id
539 let socid = $("#id_fourn")[0].value
540
541 // load available VAT rates
542 let vat_url = "'.dol_buildpath('/core/ajax/vatrates.php', 1).'"
543 // make GET request with params
544 let options = "";
545 options += "id=" + socid
546 options += "&htmlname=tva_tx"
547 options += "&token='.currentToken().'"
548 options += "&action=getBuyerVATRates" // not defined in vatrates.php, default behavior.
549
550 var get = $.getJSON(
551 vat_url,
552 options,
553 (data) => {
554 rate_options = $.parseHTML(data.value)
555 rate_options.forEach(opt => {
556 if (opt.selected) {
557 replaceVATWithSupplierValue(opt.value);
558 return;
559 }
560 })
561 }
562 );
563
564 }
565 function replaceVATWithSupplierValue(vat_rate) {
566 console.log("Default VAT rate for the supplier: " + vat_rate + "%")
567 $("[name=\'tva_tx\']")[0].value = vat_rate;
568 }
569 </script>';
570 }
571 print '</td></tr>';
572
573 // Ref supplier
574 print '<tr><td class="fieldrequired">'.$langs->trans("SupplierRef").'</td><td>';
575 if ($rowid) {
576 print '<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.'">';
577 print '<input class="flat width150" maxlength="128" name="ref_fourn" value="'.$object->ref_supplier.'">';
578 } else {
579 print '<input class="flat width150" maxlength="128" name="ref_fourn" value="'.(GETPOST("ref_fourn") ? GETPOST("ref_fourn") : '').'">';
580 }
581 print '</td>';
582 print '</tr>';
583
584 // Availability
585 if (getDolGlobalInt('FOURN_PRODUCT_AVAILABILITY')) {
586 $langs->load("propal");
587 print '<tr><td>'.$langs->trans("Availability").'</td><td>';
588 $form->selectAvailabilityDelay($object->fk_availability, "oselDispo", 1);
589 print '</td></tr>'."\n";
590 }
591
592 // Qty min
593 print '<tr>';
594 print '<td class="fieldrequired">'.$langs->trans("QtyMin").'</td>';
595 print '<td>';
596 $quantity = GETPOSTISSET('qty') ? price2num(GETPOST('qty', 'alphanohtml'), 'MS') : "1";
597 if ($rowid) {
598 print '<input type="hidden" name="qty" value="'.$object->fourn_qty.'">';
599 print $object->fourn_qty;
600 } else {
601 print '<input class="flat" name="qty" size="5" value="'.$quantity.'">';
602 }
603 // Units
604 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
605 $unit = $object->getLabelOfUnit('long', $langs);
606 if ($unit !== '') {
607 print '&nbsp;&nbsp;'.$unit;
608 }
609 }
610 print '</td></tr>';
611
612 if (getDolGlobalString('PRODUCT_USE_SUPPLIER_PACKAGING')) {
613 // Packaging/Conditionnement
614 print '<tr>';
615
616 print '<td>'.$form->textwithpicto($langs->trans("PackagingForThisProduct"), $langs->trans("PackagingForThisProductDesc")).'</td>';
617 print '<td>';
618 $packaging = GETPOSTISSET('packaging') ? price2num(GETPOST('packaging', 'alphanohtml'), 'MS') : ((empty($rowid)) ? "" : price2num($object->packaging, 'MS'));
619 print '<input class="flat" name="packaging" size="5" value="'.$packaging.'">';
620
621 // Units
622 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
623 $unit = $object->getLabelOfUnit('long', $langs);
624 if ($unit !== '') {
625 print '&nbsp;&nbsp;'.$unit;
626 }
627 }
628 }
629 // Vat rate
630 $default_vat = '';
631
632 // We don't have supplier, so we try to guess.
633 // For this we build a fictive supplier with same properties than user but using vat)
634 $mysoc2 = clone $mysoc;
635 $mysoc2->name = 'Fictive seller with same country';
636 $mysoc2->tva_assuj = 1;
637 $default_vat = get_default_tva($mysoc2, $mysoc, $object->id, 0);
638 $default_npr = get_default_npr($mysoc2, $mysoc, $object->id, 0);
639 if (empty($default_vat)) {
640 $default_npr = $default_vat;
641 }
642
643 print '<tr><td class="fieldrequired">'.$langs->trans("VATRateForSupplierProduct").'</td>';
644 print '<td>';
645 //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
646 if (!empty($rowid)) { // If we have a supplier, it is an update, we must show the vat of current supplier price
647 $tmpproductsupplier = new ProductFournisseur($db);
648 $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
649 $default_vat = $tmpproductsupplier->fourn_tva_tx;
650 $default_npr = $tmpproductsupplier->fourn_tva_npr;
651 } else {
652 if (empty($default_vat)) {
653 $default_vat = $object->tva_tx;
654 }
655 }
656 $vattosuggest = (GETPOSTISSET("tva_tx") ? vatrate(GETPOST("tva_tx")) : ($default_vat != '' ? vatrate($default_vat) : ''));
657 $vattosuggest = preg_replace('/\s*\‍(.*\‍)$/', '', $vattosuggest);
658 print '<input type="text" class="flat" size="5" name="tva_tx" value="'.$vattosuggest.'">';
659 print '</td></tr>';
660
661 if (isModEnabled('dynamicprices')) { //Only show price mode and expression selector if module is enabled
662 // Price mode selector
663 print '<tr><td class="fieldrequired">'.$langs->trans("PriceMode").'</td><td>';
664 $price_expression = new PriceExpression($db);
665 $price_expression_list = array(0 => $langs->trans("PriceNumeric")); //Put the numeric mode as first option
666 foreach ($price_expression->list_price_expression() as $entry) {
667 $price_expression_list[$entry->id] = $entry->title;
668 }
669 $price_expression_preselection = GETPOST('eid') ? GETPOST('eid') : ($object->fk_supplier_price_expression ? $object->fk_supplier_price_expression : '0');
670 print $form->selectarray('eid', $price_expression_list, $price_expression_preselection);
671 print '&nbsp; <div id="expression_editor" class="button smallpaddingimp">'.$langs->trans("PriceExpressionEditor").'</div>';
672 print '</td></tr>';
673 // This code hides the numeric price input if is not selected, loads the editor page if editor button is pressed
674 print '<script type="text/javascript">
675 jQuery(document).ready(run);
676 function run() {
677 jQuery("#expression_editor").click(on_click);
678 jQuery("#eid").change(on_change);
679 on_change();
680 }
681 function on_click() {
682 window.location = "'.DOL_URL_ROOT.'/product/dynamic_price/editor.php?id='.$id.'&tab=price_suppliers&eid=" + $("#eid").val();
683 }
684 function on_change() {
685 if ($("#eid").val() == 0) {
686 jQuery("#price_numeric").show();
687 } else {
688 jQuery("#price_numeric").hide();
689 }
690 }
691 </script>';
692 }
693
694 if (isModEnabled("multicurrency")) {
695 // Currency
696 print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
697 print '<td>';
698 $currencycodetouse = GETPOST('multicurrency_code') ? GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : '');
699 if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) {
700 $currencycodetouse = $conf->currency;
701 }
702 print $form->selectMultiCurrency((string) $currencycodetouse, "multicurrency_code", 1);
703 print ' &nbsp; &nbsp; '.$langs->trans("CurrencyRate").' ';
704 print '<input class="flat width50" name="multicurrency_tx" value="';
705 print GETPOST('multicurrency_tx');
706 $vatratetoshow = GETPOST('multicurrency_tx') ? GETPOST('multicurrency_tx') : (isset($object->fourn_multicurrency_tx) ? $object->fourn_multicurrency_tx : '');
707 if ($vatratetoshow !== '') {
708 print vatrate($vatratetoshow);
709 }
710 print '">';
711 print '</td>';
712 print '</tr>';
713
714 // Currency price qty min
715 print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans("PriceQtyMinCurrency"), $langs->transnoentitiesnoconv("WithoutDiscount")).'</td>';
716 $pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ? GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : ''));
717 print '<td><input class="flat" name="multicurrency_price" size="8" value="'.price($pricesupplierincurrencytouse).'">';
718 print '&nbsp;';
719 print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type') ? GETPOST('multicurrency_price_base_type') : 'HT'), "multicurrency_price_base_type", 1); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices
720 print '</td></tr>';
721
722 // Price qty min
723 print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans("PriceQtyMin"), $langs->transnoentitiesnoconv("WithoutDiscount")).'</td>';
724 print '<td><input class="flat" name="disabled_price" size="8" value="">';
725 print '<input type="hidden" name="price" value="">';
726 print '<input type="hidden" name="price_base_type" value="">';
727 print '&nbsp;';
728 print $form->selectPriceBaseType('', "disabled_price_base_type", 1);
729 print '</td></tr>';
730
731 $currencies = array();
732 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE entity = ".((int) $conf->entity);
733 $resql = $db->query($sql);
734 if ($resql) {
735 $currency = new MultiCurrency($db);
736 while ($obj = $db->fetch_object($resql)) {
737 $currency->fetch($obj->rowid);
738 $currencies[$currency->code] = ((float) $currency->rate->rate);
739 }
740 }
741 $currencies = json_encode($currencies);
742 print "<!-- javascript to autocalculate the minimum price -->
743 <script type='text/javascript'>
744 function edit_price_from_multicurrency() {
745 console.log('edit_price_from_multicurrency');
746 var multicurrency_price = price2numjs($('input[name=\"multicurrency_price\"]').val());
747 var multicurrency_tx = price2numjs($('input[name=\"multicurrency_tx\"]').val());
748 if (multicurrency_tx != 0) {
749 $('input[name=\"price\"]').val(multicurrency_price / multicurrency_tx);
750 $('input[name=\"disabled_price\"]').val(multicurrency_price / multicurrency_tx);
751 } else {
752 $('input[name=\"price\"]').val('');
753 $('input[name=\"disabled_price\"]').val('');
754 }
755 }
756
757 jQuery(document).ready(function () {
758 $('input[name=\"disabled_price\"]').prop('disabled', true);
759 $('select[name=\"disabled_price_base_type\"]').prop('disabled', true);
760 edit_price_from_multicurrency();
761
762 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').keyup(function () {
763 edit_price_from_multicurrency();
764 });
765 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').change(function () {
766 edit_price_from_multicurrency();
767 });
768 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').on('paste', function () {
769 edit_price_from_multicurrency();
770 });
771
772 $('select[name=\"multicurrency_price_base_type\"]').change(function () {
773 $('input[name=\"price_base_type\"]').val($(this).val());
774 $('select[name=\"disabled_price_base_type\"]').val($(this).val());
775 });
776
777 var currencies_array = $currencies;
778 $('select[name=\"multicurrency_code\"]').change(function () {
779 console.log(\"We change the currency\");
780 $('input[name=\"multicurrency_tx\"]').val(currencies_array[$(this).val()]);
781 edit_price_from_multicurrency();
782 });
783 });
784 </script>";
785 } else {
786 // Price qty min
787 print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
788 print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price') ? price(GETPOST('price')) : (isset($object->fourn_price) ? price($object->fourn_price) : '')).'">';
789 print '&nbsp;';
790 print $form->selectPriceBaseType((GETPOSTISSET('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type", 1); // We keep 'HT' here, price_base_type is not yet supported for supplier prices
791 print '</td></tr>';
792 }
793
794 // Option to define a transport cost on supplier price
795 if (getDolGlobalString('PRODUCT_CHARGES')) {
796 print '<tr>';
797 print '<td>'.$langs->trans("Charges").'</td>';
798 print '<td><input class="flat" name="charges" size="8" value="'.(GETPOST('charges') ? price(GETPOST('charges')) : (isset($object->fourn_charges) ? price((string) $object->fourn_charges) : '')).'">';
799 print '</td>';
800 print '</tr>';
801 }
802
803 // Discount qty min
804 print '<tr><td>'.$langs->trans("DiscountQtyMin").'</td>';
805 print '<td><input class="flat" name="remise_percent" size="4" value="'.(GETPOSTISSET('remise_percent') ? vatrate(price2num(GETPOST('remise_percent'), '', 2)) : (isset($object->fourn_remise_percent) ? vatrate(price2num($object->fourn_remise_percent)) : '')).'"> %';
806 print '</td>';
807 print '</tr>';
808
809 // Delivery delay in days
810 print '<tr>';
811 print '<td>'.$langs->trans('NbDaysToDelivery').'</td>';
812 print '<td><input class="flat" name="delivery_time_days" size="4" value="'.(GETPOSTISSET('delivery_time_days') ? GETPOST('delivery_time_days') : ($rowid ? $object->delivery_time_days : '')).'">&nbsp;'.$langs->trans('days').'</td>';
813 print '</tr>';
814
815 // Reputation
816 print '<tr><td>'.$langs->trans("ReferenceReputation").'</td><td>';
817 echo $form->selectarray('supplier_reputation', $object->reputations, !empty($supplier_reputation) ? $supplier_reputation : $object->supplier_reputation);
818 print '</td></tr>';
819
820 // Barcode
821 if (isModEnabled('barcode')) {
822 $formbarcode = new FormBarCode($db);
823
824 // Barcode type
825 print '<tr>';
826 print '<td>'.$langs->trans('GencodBuyPrice').'</td>';
827 print '<td>';
828 print img_picto('', 'barcode', 'class="pictofixedwidth"');
829 print $formbarcode->selectBarcodeType((GETPOSTISSET('fk_barcode_type') ? GETPOSTINT('fk_barcode_type') : ($rowid ? $object->supplier_fk_barcode_type : getDolGlobalInt("PRODUIT_DEFAULT_BARCODE_TYPE"))), 'fk_barcode_type', 1);
830 print ' <input class="flat" name="barcode" value="'.(GETPOSTISSET('barcode') ? GETPOST('barcode') : ($rowid ? $object->supplier_barcode : '')).'"></td>';
831 print '</tr>';
832 }
833
834 // Product description of the supplier
835 if (getDolGlobalString('PRODUIT_FOURN_TEXTS')) {
836 //WYSIWYG Editor
837 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
838
839 print '<tr>';
840 print '<td>'.$langs->trans('ProductSupplierDescription').'</td>';
841 print '<td>';
842
843 $doleditor = new DolEditor('supplier_description', $object->desc_supplier, '', 160, 'dolibarr_details', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_DETAILS'), ROWS_4, '90%');
844 $doleditor->Create();
845
846 print '</td>';
847 print '</tr>';
848 }
849
850 // Extrafields
851 $extrafields->fetch_name_optionals_label("product_fournisseur_price");
852 $extralabels = !empty($extrafields->attributes["product_fournisseur_price"]['label']) ? $extrafields->attributes["product_fournisseur_price"]['label'] : '';
853 $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price");
854 if (!empty($extralabels)) {
855 if (empty($rowid)) {
856 foreach ($extralabels as $key => $value) {
857 if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "edit_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
858 if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) {
859 $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
860 }
861
862 print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
863 if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) {
864 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
865 } else {
866 print $langs->trans($value);
867 }
868 print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
869 }
870 }
871 } else {
872 $sql = "SELECT";
873 $sql .= " fk_object";
874 foreach ($extralabels as $key => $value) {
875 $sql .= ", ".$db->sanitize($key);
876 }
877 $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields";
878 $sql .= " WHERE fk_object = ".((int) $rowid);
879 $resql = $db->query($sql);
880 if ($resql) {
881 $obj = $db->fetch_object($resql);
882 foreach ($extralabels as $key => $value) {
883 if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "edit_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
884 if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) {
885 $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
886 }
887
888 print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
889 if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) {
890 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
891 } else {
892 print $langs->trans($value);
893 }
894 print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_'.$key) ? $extrafield_values['options_'.$key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price');
895
896 print '</td></tr>';
897 }
898 }
899 $db->free($resql);
900 }
901 }
902 }
903
904 if (is_object($hookmanager)) {
905 $parameters = array('id_fourn' => !empty($id_fourn) ? $id_fourn : 0, 'prod_id' => $object->id);
906 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
907 print $hookmanager->resPrint;
908 }
909
910 print '</table>';
911
912 print dol_get_fiche_end();
913
914 print '<div class="center">';
915 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
916 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
917 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
918 print '</div>';
919
920 print '</form>'."\n";
921 }
922
923
924 // Actions buttons
925
926 print '<div class="tabsAction">'."\n";
927
928 if ($action != 'create_price' && $action != 'edit_price') {
929 $parameters = array();
930 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
931 if (empty($reshook)) {
932 // Display add button only when user can write supplier prices
933 if ($usercancreate) {
934 print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/price_suppliers.php?id='.((int) $object->id).'&action=create_price&token='.newToken().'">';
935 print $langs->trans("AddSupplierPrice").'</a>';
936 } else {
937 print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">';
938 print $langs->trans("AddSupplierPrice").'</a>';
939 }
940 }
941 }
942
943 print "</div>\n";
944
945
946 if ($user->hasRight("fournisseur", "read")) { // Duplicate ? this check is already in the head of this file
947 $param = '';
948 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
949 $param .= '&contextpage='.urlencode($contextpage);
950 }
951 if ($limit > 0 && $limit != $conf->liste_limit) {
952 $param .= '&limit='.((int) $limit);
953 }
954 $param .= '&ref='.urlencode($object->ref);
955
956 $product_fourn = new ProductFournisseur($db);
957 $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, $limit, $offset);
958 $product_fourn_list_all = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, 0, 0);
959 $nbtotalofrecords = count($product_fourn_list_all);
960 $num = count($product_fourn_list);
961 if (($num + ($offset * $limit)) < $nbtotalofrecords) {
962 $num++;
963 }
964
965 print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1);
966
967 // Definition of fields for lists
968 // Some fields are missing because they are not included in the database query
969 $arrayfields = array(
970 'pfp.datec' => array('label' => $langs->trans("AppliedPricesFrom"), 'checked' => '1', 'position' => 1),
971 's.nom' => array('label' => $langs->trans("Suppliers"), 'checked' => '1', 'position' => 2),
972 'pfp.fk_availability' => array('label' => $langs->trans("Availability"), 'enabled' => (string) getDolGlobalInt('FOURN_PRODUCT_AVAILABILITY'), 'checked' => '0', 'position' => 4),
973 'pfp.quantity' => array('label' => $langs->trans("QtyMin"), 'checked' => '1', 'position' => 5),
974 'pfp.unitprice' => array('label' => $langs->trans("UnitPriceHT"), 'checked' => '1', 'position' => 9),
975 'pfp.multicurrency_unitprice' => array('label' => $langs->trans("UnitPriceHTCurrency"), 'enabled' => (string) (int) isModEnabled('multicurrency'), 'checked' => '0', 'position' => 10),
976 'pfp.charges' => array('label' => $langs->trans("Charges"), 'enabled' => getDolGlobalString('PRODUCT_CHARGES'), 'checked' => '0', 'position' => 11),
977 'pfp.delivery_time_days' => array('label' => $langs->trans("NbDaysToDelivery"), 'checked' => '-1', 'position' => 13),
978 'pfp.supplier_reputation' => array('label' => $langs->trans("ReputationForThisProduct"), 'checked' => '-1', 'position' => 14),
979 'pfp.fk_barcode_type' => array('label' => $langs->trans("BarcodeType"), 'enabled' => (string) (int) isModEnabled('barcode'), 'checked' => '0', 'position' => 15),
980 'pfp.barcode' => array('label' => $langs->trans("BarcodeValue"), 'enabled' => (string) (int) isModEnabled('barcode'), 'checked' => '0', 'position' => 16),
981 'pfp.packaging' => array('label' => $langs->trans("PackagingForThisProduct"), 'enabled' => (string) getDolGlobalInt('PRODUCT_USE_SUPPLIER_PACKAGING'), 'checked' => (getDolGlobalInt('PRODUCT_USE_SUPPLIER_PACKAGING') ? '1' : '0'), 'position' => 17),
982 'pfp.price' => array('label' => $langs->trans("PriceQtyMinHT"), 'enabled' => '1', 'checked' => '1', 'position' => 60),
983 'pfp.multicurrency_price' => array('label' => $langs->trans("PriceQtyMinHTCurrency"), 'enabled' => (string) (int) isModEnabled('multicurrency'), 'checked' => '1', 'position' => 70),
984 'pfp.tms' => array('label' => $langs->trans("DateModification"), 'enabled' => '1', 'checked' => '-1', 'position' => 80),
985 'pfp.status' => array('label' => $langs->trans("Status"), 'enabled' => '1', 'checked' => '0', 'position' => 200),
986 );
987
988 // fetch optionals attributes and labels
989 $extrafields->fetch_name_optionals_label("product_fournisseur_price");
990 if ($extrafields->attributes["product_fournisseur_price"] && array_key_exists('label', $extrafields->attributes["product_fournisseur_price"])) {
991 $extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
992
993 if (!empty($extralabels)) {
994 foreach ($extralabels as $key => $value) {
995 // Show field if not hidden
996 if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
997 $extratitle = $langs->trans($value);
998 $arrayfields['ef.' . $key] = array('label' => $extratitle, 'checked' => '0',
999 'position' => (end($arrayfields)['position'] + 1),
1000 'langfile' => $extrafields->attributes["product_fournisseur_price"]['langfile'][$key],
1001 'help' => $extrafields->attributes["product_fournisseur_price"]['help'][$key]);
1002 }
1003 }
1004 }
1005 }
1006
1007 // Selection of new fields
1008 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
1009
1010 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1011 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
1012
1013 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formulaire">';
1014 print '<input type="hidden" name="token" value="'.newToken().'">';
1015 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1016 print '<input type="hidden" name="action" value="list">';
1017 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1018 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1019
1020 // Suppliers list title
1021 print '<!-- List of supplier prices -->'."\n";
1022 print '<div class="div-table-responsive">';
1023 print '<table class="liste centpercent noborder">';
1024
1025 $param = "&id=".$object->id;
1026
1027 $nbfields = 0;
1028
1029 print '<tr class="liste_titre">';
1030
1031 // Action column
1032 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1033 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
1034 $nbfields++;
1035 }
1036 if (!empty($arrayfields['pfp.datec']['checked'])) {
1037 print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder, '', '', 1);
1038 $nbfields++;
1039 }
1040 if (!empty($arrayfields['s.nom']['checked'])) {
1041 print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder, '', '', 1);
1042 $nbfields++;
1043 }
1044 print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, '', '', 1);
1045 $nbfields++;
1046 if (!empty($arrayfields['pfp.fk_availability']['checked'])) {
1047 print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder);
1048 $nbfields++;
1049 }
1050 if (!empty($arrayfields['pfp.quantity']['checked'])) {
1051 print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right ');
1052 $nbfields++;
1053 }
1054 print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1055 $nbfields++;
1056 if (!empty($arrayfields['pfp.price']['checked'])) {
1057 print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1058 $nbfields++;
1059 }
1060 if (isModEnabled("multicurrency") && !empty($arrayfields['pfp.multicurrency_price']['checked'])) {
1061 print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1062 $nbfields++;
1063 }
1064 if (!empty($arrayfields['pfp.unitprice']['checked'])) {
1065 print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
1066 $nbfields++;
1067 }
1068 if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
1069 print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right ');
1070 $nbfields++;
1071 }
1072 if (isModEnabled("multicurrency")) {
1073 print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1074 $nbfields++;
1075 }
1076 if (!empty($arrayfields['pfp.charges']['checked'])) { // possible only when $conf->global->PRODUCT_CHARGES is set
1077 print_liste_field_titre("Charges", $_SERVER["PHP_SELF"], "pfp.charges", "", $param, '', $sortfield, $sortorder, 'right ');
1078 $nbfields++;
1079 }
1080 print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
1081 $nbfields++;
1082 if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) {
1083 print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right ');
1084 $nbfields++;
1085 }
1086 if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) {
1087 print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center ');
1088 $nbfields++;
1089 }
1090 if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
1091 print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
1092 $nbfields++;
1093 }
1094 if (!empty($arrayfields['pfp.barcode']['checked'])) {
1095 print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
1096 $nbfields++;
1097 }
1098 if (!empty($arrayfields['pfp.packaging']['checked'])) {
1099 print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, '', $sortfield, $sortorder, 'center ');
1100 $nbfields++;
1101 }
1102 if (!empty($arrayfields['pfp.status']['checked'])) {
1103 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "pfp.status", "", $param, '', $sortfield, $sortorder, 'center ', '', 1);
1104 $nbfields++;
1105 }
1106 if (!empty($arrayfields['pfp.tms']['checked'])) {
1107 print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ', '', 1);
1108 $nbfields++;
1109 }
1110
1111 // fetch optionals attributes and labels
1112 $extrafields->fetch_name_optionals_label("product_fournisseur_price");
1113 if ($extrafields->attributes["product_fournisseur_price"] && array_key_exists('label', $extrafields->attributes["product_fournisseur_price"])) {
1114 $extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
1115
1116 if (!empty($extralabels)) {
1117 foreach ($extralabels as $key => $value) {
1118 // Show field if not hidden
1119 if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1120 if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) {
1121 $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
1122 }
1123 if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) {
1124 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
1125 } else {
1126 $extratitle = $langs->trans($value);
1127 }
1128 if (!empty($arrayfields['ef.' . $key]['checked'])) {
1129 print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.' . $key, '', $param, '', $sortfield, $sortorder, 'right ');
1130 $nbfields++;
1131 }
1132 }
1133 }
1134 }
1135 }
1136
1137 if (is_object($hookmanager)) {
1138 $parameters = array('id_fourn' => (!empty($id_fourn) ? $id_fourn : ''), 'prod_id' => $object->id, 'nbfields' => $nbfields);
1139 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action);
1140 }
1141 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1142 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
1143 $nbfields++;
1144 }
1145 print "</tr>\n";
1146
1147 if (is_array($product_fourn_list)) {
1148 foreach ($product_fourn_list as $productfourn) {
1149 print '<tr class="oddeven">';
1150
1151 // Action column
1152 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1153 print '<td class="center nowraponall">';
1154 // EN: Allow editing and deletion when user can write supplier prices
1155 if ($usercancreate) {
1156 print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=edit_price&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_edit()."</a>";
1157 print ' &nbsp; ';
1158 print '<a href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=ask_remove_pf&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_picto($langs->trans("Remove"), 'delete').'</a>';
1159 }
1160
1161 print '</td>';
1162 }
1163
1164 // Date from
1165 if (!empty($arrayfields['pfp.datec']['checked'])) {
1166 print '<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour', 'tzuserrel').'</td>';
1167 }
1168
1169 // Supplier
1170 if (!empty($arrayfields['s.nom']['checked'])) {
1171 print '<td class="tdoverflowmax150">'.$productfourn->getSocNomUrl(1, 'supplier').'</td>';
1172 }
1173
1174 // Supplier ref
1175 if ($usercancreate) { // EN: Supplier link allowed when user can write supplier prices
1176 print '<td class="tdoverflowmax150">'.$productfourn->getNomUrl().'</td>';
1177 } else {
1178 print '<td class="tdoverflowmax150">'.dol_escape_htmltag($productfourn->fourn_ref).'</td>';
1179 }
1180
1181 // Availability
1182 if (!empty($arrayfields['pfp.fk_availability']['checked'])) {
1183 $form->load_cache_availability();
1184 $availability = $form->cache_availability[$productfourn->fk_availability]['label'];
1185 print '<td class="left">'.$availability.'</td>';
1186 }
1187
1188 // Quantity
1189 if (!empty($arrayfields['pfp.quantity']['checked'])) {
1190 print '<td class="right">';
1191 print dolPrintHTML($productfourn->fourn_qty);
1192 // Units
1193 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
1194 $unit = $object->getLabelOfUnit('long', $langs);
1195 if ($unit !== '') {
1196 print '&nbsp;&nbsp;'.$unit;
1197 }
1198 }
1199 print '</td>';
1200 }
1201
1202 // VAT rate
1203 print '<td class="right">';
1204 print vatrate($productfourn->fourn_tva_tx, true);
1205 print '</td>';
1206
1207 // Price for the quantity
1208 if (!empty($arrayfields['pfp.price']['checked'])) {
1209 print '<td class="right">';
1210 print $productfourn->fourn_price ? '<span class="amount">'.price($productfourn->fourn_price).'</span>' : "";
1211 print '</td>';
1212 }
1213
1214 if (isModEnabled("multicurrency") && !empty($arrayfields['pfp.multicurrency_price']['checked'])) {
1215 // Price for the quantity in currency
1216 print '<td class="right">';
1217 print $productfourn->fourn_multicurrency_price ? '<span class="amount">'.price($productfourn->fourn_multicurrency_price).'</span>' : "";
1218 print '</td>';
1219 }
1220
1221 // Unit price
1222 if (!empty($arrayfields['pfp.unitprice']['checked'])) {
1223 print '<td class="right">';
1224 print price($productfourn->fourn_unitprice);
1225 //print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):"&nbsp;");
1226 print '</td>';
1227 }
1228
1229 // Unit price in currency
1230 if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) {
1231 print '<td class="right">';
1232 print price($productfourn->fourn_multicurrency_unitprice);
1233 print '</td>';
1234 }
1235
1236 // Currency
1237 if (isModEnabled("multicurrency")) {
1238 print '<td class="right nowraponall">';
1239 print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : '';
1240 print '</td>';
1241 }
1242
1243 // Charges
1244 if (!empty($arrayfields['pfp.charges']['checked'])) { // Possible only when getDolGlobalString('PRODUCT_CHARGES') is set
1245 print '<td class="right">';
1246 print price((string) $productfourn->fourn_charges);
1247 print '</td>';
1248 }
1249
1250 // Discount
1251 print '<td class="right">';
1252 print price2num($productfourn->fourn_remise_percent).'%';
1253 print '</td>';
1254
1255 // Delivery delay
1256 if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) {
1257 print '<td class="right">';
1258 print $productfourn->delivery_time_days;
1259 print '</td>';
1260 }
1261
1262 // Reputation
1263 if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) {
1264 print '<td class="center">';
1265 if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) {
1266 print $object->reputations[$productfourn->supplier_reputation];
1267 }
1268 print'</td>';
1269 }
1270
1271 // Barcode type
1272 if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) {
1273 print '<td class="center">';
1274 $productfourn->barcode_type = !empty($productfourn->supplier_fk_barcode_type) ? $productfourn->supplier_fk_barcode_type : 0;
1275 $productfourn->fetchBarCode();
1276 print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->supplier_barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : '');
1277 print '</td>';
1278 }
1279
1280 // Barcode
1281 if (!empty($arrayfields['pfp.barcode']['checked'])) {
1282 print '<td class="right">';
1283 print $productfourn->supplier_barcode;
1284 print '</td>';
1285 }
1286
1287 // Packaging
1288 if (!empty($arrayfields['pfp.packaging']['checked'])) {
1289 print '<td class="center">';
1290 print price2num($productfourn->packaging);
1291 print '</td>';
1292 }
1293
1294 // Status
1295 if (!empty($arrayfields['pfp.status']['checked'])) {
1296 print '<td class="center">';
1297 print $productfourn->getLibStatut(3);
1298 print '</td>';
1299 }
1300
1301 // Date modification
1302 if (!empty($arrayfields['pfp.tms']['checked'])) {
1303 print '<td class="right nowraponall">';
1304 print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour", "tzuserrel");
1305 print '</td>';
1306 }
1307
1308 // Extrafields
1309 if (!empty($extralabels)) {
1310 $sql = "SELECT";
1311 $sql .= " fk_object";
1312 foreach ($extralabels as $key => $value) {
1313 $sql .= ", ".$db->sanitize($key);
1314 }
1315 $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields";
1316 $sql .= " WHERE fk_object = ".((int) $productfourn->product_fourn_price_id);
1317 $resql = $db->query($sql);
1318 if ($resql) {
1319 if ($db->num_rows($resql) != 1) {
1320 foreach ($extralabels as $key => $value) {
1321 if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1322 print "<td></td>";
1323 }
1324 }
1325 } else {
1326 $obj = $db->fetch_object($resql);
1327 foreach ($extralabels as $key => $value) {
1328 if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
1329 print '<td align="right">'.$extrafields->showOutputField($key, $obj->{$key}, '', 'product_fournisseur_price')."</td>";
1330 }
1331 }
1332 }
1333 $db->free($resql);
1334 }
1335 }
1336
1337 if (is_object($hookmanager)) {
1338 $parameters = array('id_pfp' => $productfourn->product_fourn_price_id, 'id_fourn' => (!empty($id_fourn) ? $id_fourn : ''), 'prod_id' => $object->id);
1339 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action);
1340 }
1341
1342 // Modify-Remove
1343 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1344 print '<td class="center nowraponall">';
1345 // EN: Allow editing and deletion when user can write supplier prices
1346 if ($usercancreate) {
1347 print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=edit_price&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_edit()."</a>";
1348 print ' &nbsp; ';
1349 print '<a href="'.$_SERVER['PHP_SELF'].'?id='.((int) $object->id).'&socid='.((int) $productfourn->fourn_id).'&action=ask_remove_pf&token='.newToken().'&rowid='.((int) $productfourn->product_fourn_price_id).'">'.img_picto($langs->trans("Remove"), 'delete').'</a>';
1350 }
1351
1352 print '</td>';
1353 }
1354
1355 print '</tr>';
1356 }
1357
1358 if (empty($product_fourn_list)) {
1359 print '<tr><td colspan="'.$nbfields.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
1360 }
1361 } else {
1362 dol_print_error($db);
1363 }
1364
1365 print '</table>';
1366 print '</div>';
1367 print '</form>';
1368 }
1369 }
1370} else {
1371 print $langs->trans("ErrorUnknown");
1372}
1373
1374// End of page
1375llxFooter();
1376$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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 a WYSIWYG editor.
Class to manage standard extra fields.
Class to manage barcode HTML.
Class to manage generation of HTML components Only common components must be here.
Class to manage suppliers.
Class Currency.
Class for accessing price expression table.
Class to parse product price expressions.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
currency_name($code_iso, $withcode=0, $outputlangs=null)
Return label of currency or code+label.
global $mysoc
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
product_prepare_head($object)
Prepare array with list of tabs.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.