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