37require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
45if (isModEnabled(
'barcode')) {
59$langs->loadLangs(array(
'products',
'suppliers',
'bills',
'margins',
'stocks'));
64$action =
GETPOST(
'action',
'aZ09');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'pricesuppliercard';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
79 $_GET[
'id_fourn'] =
GETPOSTINT(
'search_fourn_id');
80 $_POST[
'id_fourn'] =
GETPOSTINT(
'search_fourn_id');
84$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
85$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
87 $socid = $user->socid;
90if (!$user->hasRight(
'fournisseur',
'lire') && (!isModEnabled(
'margin') && !$user->hasRight(
"margin",
"liretous"))) {
95$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
96$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
98if (empty($page) || $page == -1) {
101$offset = $limit * $page;
102$pageprev = $page - 1;
103$pagenext = $page + 1;
105 $sortfield =
"s.nom";
112$hookmanager->initHooks(array(
'pricesuppliercard',
'globalcard'));
116if ($id > 0 || $ref) {
118 $prod->fetch($id, $ref);
125 if (
$object->type == $object::TYPE_PRODUCT) {
128 if (
$object->type == $object::TYPE_SERVICE) {
132 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
144$parameters = array(
'socid'=>$socid,
'id_prod'=>$id);
145$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
150if (empty($reshook)) {
151 if ($action ==
'setcost_price' && $usercancreate) {
156 $object->cost_price = $cost_price;
167 if ($action ==
'setpmp' && $usercancreate) {
171 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product SET pmp = ".((float)
$object->pmp).
" WHERE rowid = ".((int) $id);
172 $resql = $db->query($sql);
184 if ($action ==
'confirm_remove_pf' && $usercancreate) {
187 $result =
$object->remove_product_fournisseur_price($rowid);
189 $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields WHERE fk_object = ".((
int) $rowid));
198 if ($action ==
'save_price' && $usercancreate) {
199 $ref_fourn_price_id =
GETPOSTINT(
'ref_fourn_price_id');
200 $id_fourn =
GETPOST(
"id_fourn");
201 if (empty($id_fourn)) {
202 $id_fourn =
GETPOST(
"search_id_fourn");
204 $ref_fourn =
GETPOST(
"ref_fourn");
205 if (empty($ref_fourn)) {
206 $ref_fourn =
GETPOST(
"search_ref_fourn");
208 $ref_fourn_old =
GETPOST(
"ref_fourn_old");
209 if (empty($ref_fourn_old)) {
210 $ref_fourn_old = $ref_fourn;
215 $npr = preg_match(
'/\*/',
GETPOST(
'tva_tx',
'alpha')) ? 1 : 0;
216 $tva_tx = str_replace(
'*',
'',
GETPOST(
'tva_tx',
'alpha'));
217 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
223 $supplier_reputation =
GETPOST(
'supplier_reputation');
224 $supplier_description =
GETPOST(
'supplier_description',
'restricthtml');
225 $barcode =
GETPOST(
'barcode',
'alpha');
226 $fk_barcode_type =
GETPOSTINT(
'fk_barcode_type');
231 $langs->load(
"errors");
232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"VATRateForSupplierProduct")),
null,
'errors');
234 if (!is_numeric($tva_tx)) {
236 $langs->load(
"errors");
237 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"VATRateForSupplierProduct")),
null,
'errors');
239 if (empty($quantity)) {
241 $langs->load(
"errors");
242 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
244 if (empty($ref_fourn)) {
246 $langs->load(
"errors");
247 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefSupplier")),
null,
'errors');
249 if ($id_fourn <= 0) {
251 $langs->load(
"errors");
252 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Supplier")),
null,
'errors');
255 if ($price_expression ===
'') {
257 $langs->load(
"errors");
258 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
263 if (isModEnabled(
"multicurrency")) {
264 if (!
GETPOST(
"multicurrency_code")) {
266 $langs->load(
"errors");
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Currency")),
null,
'errors');
271 $langs->load(
"errors");
272 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CurrencyRate")),
null,
'errors');
276 $langs->load(
"errors");
277 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PriceCurrency")),
null,
'errors');
284 if (empty($ref_fourn_price_id)) {
285 $ret =
$object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity);
290 $tmpobject->fetch(
$object->product_id_already_linked);
291 $productLink = $tmpobject->getNomUrl(1,
'supplier');
293 $texttoshow = $langs->trans(
"ReferenceSupplierIsAlreadyAssociatedWithAProduct",
'{s1}');
294 $texttoshow = str_replace(
'{s1}', $productLink, $texttoshow);
296 } elseif ($ret < 0) {
304 $result = $supplier->fetch($id_fourn);
305 if (GETPOSTISSET(
'ref_fourn_price_id')) {
306 $object->fetch_product_fournisseur_price($ref_fourn_price_id);
308 $extralabels = $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
309 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_fournisseur_price");
313 if (empty($packaging)) {
320 $object->packaging = $packaging;
322 if (isModEnabled(
"multicurrency")) {
324 $multicurrency_price =
GETPOSTFLOAT(
"multicurrency_price");
325 $multicurrency_code =
GETPOST(
"multicurrency_code",
'alpha');
327 $ret =
$object->update_buyprice($quantity, $newprice, $user,
GETPOST(
"price_base_type"), $supplier,
GETPOST(
"oselDispo"), $ref_fourn, $tva_tx,
GETPOST(
"charges"), $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 $ret =
$object->update_buyprice($quantity, $newprice, $user,
GETPOST(
"price_base_type"), $supplier,
GETPOST(
"oselDispo"), $ref_fourn, $tva_tx,
GETPOST(
"charges"), $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(),
'', 0,
'HT', 1,
'', $supplier_description, $barcode, $fk_barcode_type, $extrafield_values);
335 if (isModEnabled(
'dynamicprices') && $price_expression !==
'') {
337 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
339 $object->fk_supplier_price_expression = $price_expression;
340 $price_result = $priceparser->parseProductSupplier($object);
341 if ($price_result < 0) {
346 if (!$error && isModEnabled(
'dynamicprices')) {
348 $ret =
$object->setSupplierPriceExpression($price_expression);
364 $action =
'create_price';
374$form =
new Form($db);
376$title = $langs->trans(
'ProductServiceCard');
380 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'BuyingPrices');
381 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
384 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'BuyingPrices');
385 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Lesitungen';
388llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price_suppliers');
390if ($id > 0 || $ref) {
391 if ($action ==
'ask_remove_pf') {
392 $form =
new Form($db);
393 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&rowid='.$rowid, $langs->trans(
'DeleteProductBuyPrice'), $langs->trans(
'ConfirmDeleteProductBuyPrice'),
'confirm_remove_pf',
'', 0, 1);
397 if ($action !=
'edit' && $action !=
're-edit') {
399 $titre = $langs->trans(
"CardProduct".
$object->type);
404 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
405 $prod->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
408 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
412 dol_banner_tab($prod,
'ref', $linkback, $shownav,
'ref');
414 print
'<div class="fichecenter">';
416 print
'<div class="underbanner clearboth"></div>';
417 print
'<table class="border tableforfield centpercent">';
420 if (isModEnabled(
"product") && isModEnabled(
"service")) {
421 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
422 print
'<tr><td class="">';
423 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
425 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
431 $textdesc = $langs->trans(
"CostPriceDescription");
432 $textdesc .=
"<br>".$langs->trans(
"CostPriceUsage");
433 $text = $form->textwithpicto($langs->trans(
"CostPrice"), $textdesc, 1,
'help',
'');
434 print $form->editfieldkey($text,
'cost_price',
$object->cost_price, $object, $usercancreate,
'amount:6');
436 print $form->editfieldval($text,
'cost_price',
$object->cost_price, $object, $usercancreate,
'amount:6');
442 $usercaneditpmp = $usercancreate;
444 print
'<tr><td class="titlefieldcreate">';
445 $textdesc = $langs->trans(
"AverageUnitPricePMPDesc");
446 $text = $form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $textdesc, 1,
'help',
'');
447 print $form->editfieldkey($text,
'pmp',
$object->pmp, $object, $usercaneditpmp,
'amount:6');
449 print $form->editfieldval($text,
'pmp', (
$object->pmp > 0 ?
$object->pmp :
''),
$object, $usercaneditpmp,
'amount:6');
451 print
' '.$langs->trans(
"HT");
463 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"BuyingPriceMin").
'</td>';
466 if ($product_fourn->find_min_price_product_fournisseur(
$object->id) > 0) {
467 if ($product_fourn->product_fourn_price_id > 0) {
468 print $product_fourn->display_price_product_fournisseur();
470 print $langs->trans(
"NotDefined");
478 print
'<div class="clearboth"></div>';
484 if (($action ==
'create_price' || $action ==
'edit_price') && $usercancreate) {
485 $langs->load(
"suppliers");
487 print
"<!-- form to add a supplier price -->\n";
491 $object->fetch_product_fournisseur_price($rowid, 1);
497 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">';
498 print
'<input type="hidden" name="token" value="'.newToken().
'">';
499 print
'<input type="hidden" name="action" value="save_price">';
503 print
'<table class="border centpercent">';
506 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Supplier").
'</td><td>';
509 $supplier->fetch($socid);
510 print $supplier->getNomUrl(1);
511 print
'<input type="hidden" name="id_fourn" value="'.$socid.
'">';
512 print
'<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.
'">';
513 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
514 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
517 $events[] = array(
'method' =>
'getVatRates',
'url' =>
dol_buildpath(
'/core/ajax/vatrates.php', 1),
'htmlname' =>
'tva_tx',
'params' => array());
518 $filter =
'(fournisseur:=:1) AND (status:=:1)';
519 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOST(
"id_fourn",
'alpha'),
'id_fourn', $filter, $langs->transnoentitiesnoconv(
'SelectThirdParty'), 0, 0, $events);
521 $parameters = array(
'filter'=>$filter,
'html_name'=>
'id_fourn',
'selected'=>
GETPOST(
"id_fourn"),
'showempty'=>1,
'prod_id'=>
$object->id);
522 $reshook = $hookmanager->executeHooks(
'formCreateThirdpartyOptions', $parameters, $object, $action);
523 if (empty($reshook)) {
524 if (empty($form->result)) {
525 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() :
'')).
'">';
526 print
img_picto($langs->trans(
"CreateDolibarrThirdPartySupplier"),
'add',
'class="marginleftonly"');
530 print
'<script type="text/javascript">
531 $(document).ready(function () {
532 console.log("Requesting default VAT rate for the supplier...")
533 $("#search_id_fourn").change(load_vat)
535 function load_vat() {
537 let socid = $("#id_fourn")[0].value
539 // load available VAT rates
540 let vat_url = "'.dol_buildpath(
'/core/ajax/vatrates.php', 1).
'"
541 // make GET request with params
543 options += "id=" + socid
544 options += "&htmlname=tva_tx"
546 options += "&action=getBuyerVATRates" // not defined in vatrates.php, default behavior.
552 rate_options = $.parseHTML(data.value)
553 rate_options.forEach(opt => {
555 replaceVATWithSupplierValue(opt.value);
563 function replaceVATWithSupplierValue(vat_rate) {
564 console.log("Default VAT rate for the supplier: " + vat_rate + "%")
565 $("[name=\'tva_tx\']")[0].value = vat_rate;
572 print
'<tr><td class="fieldrequired">'.$langs->trans(
"SupplierRef").
'</td><td>';
574 print
'<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.
'">';
575 print
'<input class="flat width150" maxlength="128" name="ref_fourn" value="'.$object->ref_supplier.
'">';
577 print
'<input class="flat width150" maxlength="128" name="ref_fourn" value="'.(GETPOST(
"ref_fourn") ?
GETPOST(
"ref_fourn") :
'').
'">';
584 $langs->load(
"propal");
585 print
'<tr><td>'.$langs->trans(
"Availability").
'</td><td>';
586 $form->selectAvailabilityDelay(
$object->fk_availability,
"oselDispo", 1);
587 print
'</td></tr>'.
"\n";
592 print
'<td class="fieldrequired">'.$langs->trans(
"QtyMin").
'</td>';
594 $quantity = GETPOSTISSET(
'qty') ?
price2num(
GETPOST(
'qty',
'alphanohtml'),
'MS') :
"1";
596 print
'<input type="hidden" name="qty" value="'.$object->fourn_qty.
'">';
599 print
'<input class="flat" name="qty" size="5" value="'.$quantity.
'">';
603 $unit =
$object->getLabelOfUnit(
'long', $langs);
605 print
' '.$unit;
614 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc")).
'</td>';
616 $packaging = GETPOSTISSET(
'packaging') ?
price2num(
GETPOST(
'packaging',
'alphanohtml'),
'MS') : ((empty($rowid)) ?
"1" :
price2num(
$object->packaging,
'MS'));
617 print
'<input class="flat" name="packaging" size="5" value="'.$packaging.
'">';
621 $unit =
$object->getLabelOfUnit(
'long', $langs);
623 print
' '.$unit;
632 $mysoc2 = clone $mysoc;
633 $mysoc2->name =
'Fictive seller with same country';
634 $mysoc2->tva_assuj = 1;
637 if (empty($default_vat)) {
638 $default_npr = $default_vat;
641 print
'<tr><td class="fieldrequired">'.$langs->trans(
"VATRateForSupplierProduct").
'</td>';
644 if (!empty($rowid)) {
646 $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
647 $default_vat = $tmpproductsupplier->fourn_tva_tx;
648 $default_npr = $tmpproductsupplier->fourn_tva_npr;
650 if (empty($default_vat)) {
651 $default_vat =
$object->tva_tx;
654 $vattosuggest = (GETPOSTISSET(
"tva_tx") ?
vatrate(
GETPOST(
"tva_tx")) : ($default_vat !=
'' ?
vatrate($default_vat) :
''));
655 $vattosuggest = preg_replace(
'/\s*\(.*\)$/',
'', $vattosuggest);
656 print
'<input type="text" class="flat" size="5" name="tva_tx" value="'.$vattosuggest.
'">';
659 if (isModEnabled(
'dynamicprices')) {
661 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PriceMode").
'</td><td>';
663 $price_expression_list = array(0 => $langs->trans(
"PriceNumeric"));
664 foreach ($price_expression->list_price_expression() as $entry) {
665 $price_expression_list[$entry->id] = $entry->title;
667 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : (
$object->fk_supplier_price_expression ?
$object->fk_supplier_price_expression :
'0');
668 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
669 print
' <div id="expression_editor" class="button smallpaddingimp">'.$langs->trans(
"PriceExpressionEditor").
'</div>';
672 print
'<script type="text/javascript">
673 jQuery(document).ready(run);
675 jQuery("#expression_editor").click(on_click);
676 jQuery("#eid").change(on_change);
679 function on_click() {
680 window.location = "'.DOL_URL_ROOT.
'/product/dynamic_price/editor.php?id='.
$id.
'&tab=fournisseurs&eid=" + $("#eid").val();
682 function on_change() {
683 if ($("#eid").val() == 0) {
684 jQuery("#price_numeric").show();
686 jQuery("#price_numeric").hide();
692 if (isModEnabled(
"multicurrency")) {
694 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
696 $currencycodetouse =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (isset(
$object->fourn_multicurrency_code) ?
$object->fourn_multicurrency_code :
'');
697 if (empty($currencycodetouse) &&
$object->fourn_multicurrency_tx == 1) {
698 $currencycodetouse =
$conf->currency;
700 print $form->selectMultiCurrency($currencycodetouse,
"multicurrency_code", 1);
701 print
' '.$langs->trans(
"CurrencyRate").
' ';
702 print
'<input class="flat width50" name="multicurrency_tx" value="';
703 print
GETPOST(
'multicurrency_tx');
704 $vatratetoshow =
GETPOST(
'multicurrency_tx') ?
GETPOST(
'multicurrency_tx') : (isset(
$object->fourn_multicurrency_tx) ?
$object->fourn_multicurrency_tx :
'');
705 if ($vatratetoshow !==
'') {
713 print
'<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PriceQtyMinCurrency"), $langs->transnoentitiesnoconv(
"WithoutDiscount")).
'</td>';
714 $pricesupplierincurrencytouse = (
GETPOST(
'multicurrency_price') ?
GETPOST(
'multicurrency_price') : (isset(
$object->fourn_multicurrency_price) ?
$object->fourn_multicurrency_price :
''));
715 print
'<td><input class="flat" name="multicurrency_price" size="8" value="'.price($pricesupplierincurrencytouse).
'">';
717 print $form->selectPriceBaseType((
GETPOST(
'multicurrency_price_base_type') ?
GETPOST(
'multicurrency_price_base_type') :
'HT'),
"multicurrency_price_base_type", 1);
721 print
'<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PriceQtyMin"), $langs->transnoentitiesnoconv(
"WithoutDiscount")).
'</td>';
722 print
'<td><input class="flat" name="disabled_price" size="8" value="">';
723 print
'<input type="hidden" name="price" value="">';
724 print
'<input type="hidden" name="price_base_type" value="">';
726 print $form->selectPriceBaseType(
'',
"disabled_price_base_type", 1);
729 $currencies = array();
730 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"multicurrency WHERE entity = ".((int)
$conf->entity);
731 $resql = $db->query($sql);
734 while ($obj = $db->fetch_object($resql)) {
735 $currency->fetch($obj->rowid);
736 $currencies[$currency->code] = ((float) $currency->rate->rate);
739 $currencies = json_encode($currencies);
740 print
"<!-- javascript to autocalculate the minimum price -->
741 <script type='text/javascript'>
742 function edit_price_from_multicurrency() {
743 console.log('edit_price_from_multicurrency');
744 var multicurrency_price = price2numjs($('input[name=\"multicurrency_price\"]').val());
745 var multicurrency_tx = price2numjs($('input[name=\"multicurrency_tx\"]').val());
746 if (multicurrency_tx != 0) {
747 $('input[name=\"price\"]').val(multicurrency_price / multicurrency_tx);
748 $('input[name=\"disabled_price\"]').val(multicurrency_price / multicurrency_tx);
750 $('input[name=\"price\"]').val('');
751 $('input[name=\"disabled_price\"]').val('');
755 jQuery(document).ready(function () {
756 $('input[name=\"disabled_price\"]').prop('disabled', true);
757 $('select[name=\"disabled_price_base_type\"]').prop('disabled', true);
758 edit_price_from_multicurrency();
760 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').keyup(function () {
761 edit_price_from_multicurrency();
763 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').change(function () {
764 edit_price_from_multicurrency();
766 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').on('paste', function () {
767 edit_price_from_multicurrency();
770 $('select[name=\"multicurrency_price_base_type\"]').change(function () {
771 $('input[name=\"price_base_type\"]').val($(this).val());
772 $('select[name=\"disabled_price_base_type\"]').val($(this).val());
775 var currencies_array = $currencies;
776 $('select[name=\"multicurrency_code\"]').change(function () {
777 console.log(\"We change the currency\");
778 $('input[name=\"multicurrency_tx\"]').val(currencies_array[$(this).val()]);
779 edit_price_from_multicurrency();
785 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PriceQtyMin").
'</td>';
786 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 $form->selectPriceBaseType((GETPOSTISSET(
'price_base_type') ?
GETPOST(
'price_base_type') :
'HT'),
"price_base_type", 1);
795 print
'<td>'.$langs->trans(
"Charges").
'</td>';
796 print
'<td><input class="flat" name="charges" size="8" value="'.(GETPOST(
'charges') ?
price(
GETPOST(
'charges')) : (isset(
$object->fourn_charges) ?
price(
$object->fourn_charges) :
'')).
'">';
802 print
'<tr><td>'.$langs->trans(
"DiscountQtyMin").
'</td>';
803 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)) :
'')).
'"> %';
809 print
'<td>'.$langs->trans(
'NbDaysToDelivery').
'</td>';
810 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 :
'')).
'"> '.$langs->trans(
'days').
'</td>';
814 print
'<tr><td>'.$langs->trans(
"ReferenceReputation").
'</td><td>';
815 echo $form->selectarray(
'supplier_reputation',
$object->reputations, !empty($supplier_reputation) ? $supplier_reputation :
$object->supplier_reputation);
819 if (isModEnabled(
'barcode')) {
824 print
'<td>'.$langs->trans(
'GencodBuyPrice').
'</td>';
826 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
827 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);
828 print
' <input class="flat" name="barcode" value="'.(GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') : ($rowid ?
$object->supplier_barcode :
'')).
'"></td>';
835 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
838 print
'<td>'.$langs->trans(
'ProductSupplierDescription').
'</td>';
841 $doleditor =
new DolEditor(
'supplier_description',
$object->desc_supplier,
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
842 $doleditor->Create();
849 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
850 $extralabels = !empty($extrafields->attributes[
"product_fournisseur_price"][
'label']) ? $extrafields->attributes[
"product_fournisseur_price"][
'label'] :
'';
851 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_fournisseur_price");
852 if (!empty($extralabels)) {
854 foreach ($extralabels as $key => $value) {
855 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))) {
856 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
857 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
860 print
'<tr><td'.($extrafields->attributes[
"product_fournisseur_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
861 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
862 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
864 print $langs->trans($value);
866 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_fournisseur_price').
'</td></tr>';
871 $sql .=
" fk_object";
872 foreach ($extralabels as $key => $value) {
875 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields";
876 $sql .=
" WHERE fk_object = ".((int) $rowid);
877 $resql = $db->query($sql);
879 $obj = $db->fetch_object($resql);
880 foreach ($extralabels as $key => $value) {
881 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))) {
882 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
883 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
886 print
'<tr><td'.($extrafields->attributes[
"product_fournisseur_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
887 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
888 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
890 print $langs->trans($value);
892 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_fournisseur_price');
902 if (is_object($hookmanager)) {
903 $parameters = array(
'id_fourn'=>!empty($id_fourn) ? $id_fourn : 0,
'prod_id'=>
$object->id);
904 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
905 print $hookmanager->resPrint;
912 print
'<div class="center">';
913 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
914 print
' ';
915 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
918 print
'</form>'.
"\n";
924 print
'<div class="tabsAction">'.
"\n";
926 if ($action !=
'create_price' && $action !=
'edit_price') {
927 $parameters = array();
928 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
929 if (empty($reshook)) {
930 if ($usercancreate) {
931 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/product/price_suppliers.php?id='.((int)
$object->id).
'&action=create_price&token='.
newToken().
'">';
932 print $langs->trans(
"AddSupplierPrice").
'</a>';
939 if ($user->hasRight(
"fournisseur",
"read")) {
941 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
942 $param .=
'&contextpage='.urlencode($contextpage);
944 if ($limit > 0 && $limit !=
$conf->liste_limit) {
945 $param .=
'&limit='.((int) $limit);
947 $param .=
'&ref='.urlencode(
$object->ref);
950 $product_fourn_list = $product_fourn->list_product_fournisseur_price(
$object->id, $sortfield, $sortorder, $limit, $offset);
951 $product_fourn_list_all = $product_fourn->list_product_fournisseur_price(
$object->id, $sortfield, $sortorder, 0, 0);
952 $nbtotalofrecords = count($product_fourn_list_all);
953 $num = count($product_fourn_list);
954 if (($num + ($offset * $limit)) < $nbtotalofrecords) {
958 print_barre_liste($langs->trans(
'SupplierPrices'), $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_accountancy.png', 0,
'',
'', $limit, 1);
962 $arrayfields = array(
963 'pfp.datec'=>array(
'label'=>$langs->trans(
"AppliedPricesFrom"),
'checked'=>1,
'position'=>1),
964 's.nom'=>array(
'label'=>$langs->trans(
"Suppliers"),
'checked'=>1,
'position'=>2),
965 'pfp.fk_availability'=>array(
'label'=>$langs->trans(
"Availability"),
'enabled' =>
getDolGlobalInt(
'FOURN_PRODUCT_AVAILABILITY'),
'checked'=>0,
'position'=>4),
966 'pfp.quantity'=>array(
'label'=>$langs->trans(
"QtyMin"),
'checked'=>1,
'position'=>5),
967 'pfp.unitprice'=>array(
'label'=>$langs->trans(
"UnitPriceHT"),
'checked'=>1,
'position'=>9),
968 'pfp.multicurrency_unitprice'=>array(
'label'=>$langs->trans(
"UnitPriceHTCurrency"),
'enabled' => isModEnabled(
'multicurrency'),
'checked'=>0,
'position'=>10),
969 'pfp.charges'=>array(
'label'=>$langs->trans(
"Charges"),
'enabled' =>
getDolGlobalString(
'PRODUCT_CHARGES'),
'checked'=>0,
'position'=>11),
970 'pfp.delivery_time_days'=>array(
'label'=>$langs->trans(
"NbDaysToDelivery"),
'checked'=>-1,
'position'=>13),
971 'pfp.supplier_reputation'=>array(
'label'=>$langs->trans(
"ReputationForThisProduct"),
'checked'=>-1,
'position'=>14),
972 'pfp.fk_barcode_type'=>array(
'label'=>$langs->trans(
"BarcodeType"),
'enabled' => isModEnabled(
'barcode'),
'checked'=>0,
'position'=>15),
973 'pfp.barcode'=>array(
'label'=>$langs->trans(
"BarcodeValue"),
'enabled' => isModEnabled(
'barcode'),
'checked'=>0,
'position'=>16),
974 'pfp.packaging'=>array(
'label'=>$langs->trans(
"PackagingForThisProduct"),
'enabled' =>
getDolGlobalInt(
'PRODUCT_USE_SUPPLIER_PACKAGING'),
'checked'=>0,
'position'=>17),
975 'pfp.status'=>array(
'label'=>$langs->trans(
"Status"),
'enabled' => 1,
'checked'=>0,
'position'=>40),
976 'pfp.tms'=>array(
'label'=>$langs->trans(
"DateModification"),
'enabled' => 1,
'checked'=>1,
'position'=>50),
977 'pfp.price'=>array(
'label'=>$langs->trans(
"PriceQtyMinHT"),
'checked'=>1,
'position'=>60),
978 'pfp.multicurrency_price'=>array(
'label'=>$langs->trans(
"PriceQtyMinHTCurrency"),
'enabled' => isModEnabled(
'multicurrency'),
'checked'=>1,
'position'=>70),
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'];
987 if (!empty($extralabels)) {
988 foreach ($extralabels as $key => $value) {
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]);
1002 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
1004 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1005 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
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.
'">';
1015 print
'<!-- List of supplier prices -->'.
"\n";
1016 print
'<div class="div-table-responsive">';
1017 print
'<table class="liste centpercent noborder">';
1019 $param =
"&id=".$object->id;
1023 print
'<tr class="liste_titre">';
1027 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');
1030 if (!empty($arrayfields[
'pfp.datec'][
'checked'])) {
1031 print_liste_field_titre(
"AppliedPricesFrom", $_SERVER[
"PHP_SELF"],
"pfp.datec",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1034 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1035 print_liste_field_titre(
"Suppliers", $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1038 print_liste_field_titre(
"SupplierRef", $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1040 if (!empty($arrayfields[
'pfp.fk_availability'][
'checked'])) {
1041 print_liste_field_titre(
"Availability", $_SERVER[
"PHP_SELF"],
"pfp.fk_availability",
"", $param,
"", $sortfield, $sortorder);
1044 if (!empty($arrayfields[
'pfp.quantity'][
'checked'])) {
1045 print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"pfp.quantity",
"", $param,
'', $sortfield, $sortorder,
'right ');
1048 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1050 if (!empty($arrayfields[
'pfp.price'][
'checked'])) {
1051 print_liste_field_titre(
"PriceQtyMinHT", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1054 if (isModEnabled(
"multicurrency") && !empty($arrayfields[
'pfp.multicurrency_price'][
'checked'])) {
1055 print_liste_field_titre(
"PriceQtyMinHTCurrency", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1058 if (!empty($arrayfields[
'pfp.unitprice'][
'checked'])) {
1059 print_liste_field_titre(
"UnitPriceHT", $_SERVER[
"PHP_SELF"],
"pfp.unitprice",
"", $param,
'', $sortfield, $sortorder,
'right ');
1062 if (!empty($arrayfields[
'pfp.multicurrency_unitprice'][
'checked'])) {
1063 print_liste_field_titre(
"UnitPriceHTCurrency", $_SERVER[
"PHP_SELF"],
"pfp.multicurrency_unitprice",
"", $param,
'', $sortfield, $sortorder,
'right ');
1066 if (isModEnabled(
"multicurrency")) {
1067 print_liste_field_titre(
"Currency", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1070 if (!empty($arrayfields[
'pfp.charges'][
'checked'])) {
1071 print_liste_field_titre(
"Charges", $_SERVER[
"PHP_SELF"],
"pfp.charges",
"", $param,
'', $sortfield, $sortorder,
'right ');
1074 print_liste_field_titre(
"DiscountQtyMin", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
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 ');
1080 if (!empty($arrayfields[
'pfp.supplier_reputation'][
'checked'])) {
1081 print_liste_field_titre(
"ReputationForThisProduct", $_SERVER[
"PHP_SELF"],
"pfp.supplier_reputation",
"", $param,
'', $sortfield, $sortorder,
'center ');
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 ');
1088 if (!empty($arrayfields[
'pfp.barcode'][
'checked'])) {
1089 print_liste_field_titre(
"BarcodeValue", $_SERVER[
"PHP_SELF"],
"pfp.barcode",
"", $param,
'', $sortfield, $sortorder,
'center ');
1092 if (!empty($arrayfields[
'pfp.packaging'][
'checked'])) {
1093 print_liste_field_titre(
"PackagingForThisProduct", $_SERVER[
"PHP_SELF"],
"pfp.packaging",
"", $param,
'', $sortfield, $sortorder,
'center ');
1096 if (!empty($arrayfields[
'pfp.status'][
'checked'])) {
1097 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"pfp.status",
"", $param,
'', $sortfield, $sortorder,
'center ',
'', 1);
1100 if (!empty($arrayfields[
'pfp.tms'][
'checked'])) {
1101 print_liste_field_titre(
"DateModification", $_SERVER[
"PHP_SELF"],
"pfp.tms",
"", $param,
'', $sortfield, $sortorder,
'right ',
'', 1);
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'];
1110 if (!empty($extralabels)) {
1111 foreach ($extralabels as $key => $value) {
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]);
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]));
1120 $extratitle = $langs->trans($value);
1122 if (!empty($arrayfields[
'ef.' . $key][
'checked'])) {
1123 print_liste_field_titre($extratitle, $_SERVER[
"PHP_SELF"],
'ef.' . $key,
'', $param,
'', $sortfield, $sortorder,
'right ');
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);
1136 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1141 if (is_array($product_fourn_list)) {
1142 foreach ($product_fourn_list as $productfourn) {
1143 print
'<tr class="oddeven">';
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>";
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>';
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>';
1163 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1164 print
'<td class="tdoverflowmax150">'.$productfourn->getSocNomUrl(1,
'supplier').
'</td>';
1168 if ($usercancreate) {
1169 print
'<td class="tdoverflowmax150">'.$productfourn->getNomUrl().
'</td>';
1171 print
'<td class="tdoverflowmax150">'.dol_escape_htmltag($productfourn->fourn_ref).
'</td>';
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>';
1182 if (!empty($arrayfields[
'pfp.quantity'][
'checked'])) {
1183 print
'<td class="right">';
1187 $unit =
$object->getLabelOfUnit(
'long', $langs);
1189 print
' '.$unit;
1196 print
'<td class="right">';
1197 print
vatrate($productfourn->fourn_tva_tx,
true);
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>' :
"";
1207 if (isModEnabled(
"multicurrency") && !empty($arrayfields[
'pfp.multicurrency_price'][
'checked'])) {
1209 print
'<td class="right">';
1210 print $productfourn->fourn_multicurrency_price ?
'<span class="amount">'.price($productfourn->fourn_multicurrency_price).
'</span>' :
"";
1215 if (!empty($arrayfields[
'pfp.unitprice'][
'checked'])) {
1216 print
'<td class="right">';
1217 print
price($productfourn->fourn_unitprice);
1223 if (!empty($arrayfields[
'pfp.multicurrency_unitprice'][
'checked'])) {
1224 print
'<td class="right">';
1225 print
price($productfourn->fourn_multicurrency_unitprice);
1230 if (isModEnabled(
"multicurrency")) {
1231 print
'<td class="right nowraponall">';
1232 print $productfourn->fourn_multicurrency_code ?
currency_name($productfourn->fourn_multicurrency_code) :
'';
1237 if (!empty($arrayfields[
'pfp.charges'][
'checked'])) {
1238 print
'<td class="right">';
1239 print
price($productfourn->fourn_charges);
1244 print
'<td class="right">';
1245 print
price2num($productfourn->fourn_remise_percent).
'%';
1249 if (!empty($arrayfields[
'pfp.delivery_time_days'][
'checked'])) {
1250 print
'<td class="right">';
1251 print $productfourn->delivery_time_days;
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];
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>' :
'');
1274 if (!empty($arrayfields[
'pfp.barcode'][
'checked'])) {
1275 print
'<td class="right">';
1276 print $productfourn->supplier_barcode;
1281 if (!empty($arrayfields[
'pfp.packaging'][
'checked'])) {
1282 print
'<td class="center">';
1283 print
price2num($productfourn->packaging);
1288 if (!empty($arrayfields[
'pfp.status'][
'checked'])) {
1289 print
'<td class="center">';
1290 print $productfourn->getLibStatut(3);
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");
1302 if (!empty($extralabels)) {
1304 $sql .=
" fk_object";
1305 foreach ($extralabels as $key => $value) {
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);
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) {
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>";
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);
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>";
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>';
1350 if (empty($product_fourn_list)) {
1351 print
'<tr><td colspan="'.$nbfields.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1363 print $langs->trans(
"ErrorUnknown");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage a WYSIWYG editor.
Class to manage suppliers.
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_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)
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'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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...
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.