37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
49 $langs->loadLangs(array(
'products',
'suppliers',
'bills',
'margins',
'stocks'));
53 $rowid =
GETPOST(
'rowid',
'int');
54 $action =
GETPOST(
'action',
'aZ09');
55 $cancel =
GETPOST(
'cancel',
'alpha');
56 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'pricesuppliercard';
58 $socid =
GETPOST(
'socid',
'int');
62 $backtopage =
GETPOST(
'backtopage',
'alpha');
68 if (
GETPOST(
'search_fourn_id',
'int')) {
69 $_GET[
'id_fourn'] =
GETPOST(
'search_fourn_id',
'int');
70 $_POST[
'id_fourn'] =
GETPOST(
'search_fourn_id',
'int');
74 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
75 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
77 $socid = $user->socid;
80 if (empty($user->rights->fournisseur->lire) && (empty($conf->margin->enabled) && !$user->hasRight(
"margin",
"liretous"))) {
84 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
85 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
86 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88 if (empty($page) || $page == -1) {
91 $offset = $limit * $page;
92 $pageprev = $page - 1;
93 $pagenext = $page + 1;
102 $hookmanager->initHooks(array(
'pricesuppliercard',
'globalcard'));
105 if ($id > 0 || $ref) {
106 $object->fetch($id, $ref);
112 if ($object->id > 0) {
113 if ($object->type == $object::TYPE_PRODUCT) {
114 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
116 if ($object->type == $object::TYPE_SERVICE) {
117 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
120 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
132 $parameters = array(
'socid'=>$socid,
'id_prod'=>$id);
133 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
138 if (empty($reshook)) {
139 if ($action ==
'setcost_price') {
141 $result = $object->fetch($id);
142 $object->cost_price =
price2num($cost_price);
143 $result = $object->update($object->id, $user);
153 if ($action ==
'setpmp') {
155 $result = $object->fetch($id);
157 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product SET pmp = ".((
float) $object->pmp).
" WHERE rowid = ".((int) $id);
158 $resql = $db->query($sql);
170 if ($action ==
'confirm_remove_pf') {
173 $result = $object->remove_product_fournisseur_price($rowid);
175 $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields WHERE fk_object = ".((
int) $rowid));
184 if ($action ==
'save_price') {
185 $ref_fourn_price_id =
GETPOSTINT(
'ref_fourn_price_id');
186 $id_fourn =
GETPOST(
"id_fourn");
187 if (empty($id_fourn)) {
188 $id_fourn =
GETPOST(
"search_id_fourn");
190 $ref_fourn =
GETPOST(
"ref_fourn");
191 if (empty($ref_fourn)) {
192 $ref_fourn =
GETPOST(
"search_ref_fourn");
194 $ref_fourn_old =
GETPOST(
"ref_fourn_old");
195 if (empty($ref_fourn_old)) {
196 $ref_fourn_old = $ref_fourn;
201 $npr = preg_match(
'/\*/',
GETPOST(
'tva_tx',
'alpha')) ? 1 : 0;
202 $tva_tx = str_replace(
'*',
'',
GETPOST(
'tva_tx',
'alpha'));
203 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
207 $price_expression =
GETPOST(
'eid',
'int') ?
GETPOST(
'eid',
'int') :
'';
208 $delivery_time_days =
GETPOST(
'delivery_time_days',
'int') ?
GETPOST(
'delivery_time_days',
'int') :
'';
209 $supplier_reputation =
GETPOST(
'supplier_reputation');
210 $supplier_description =
GETPOST(
'supplier_description',
'restricthtml');
211 $barcode =
GETPOST(
'barcode',
'alpha');
212 $fk_barcode_type =
GETPOST(
'fk_barcode_type',
'int');
217 $langs->load(
"errors");
218 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"VATRateForSupplierProduct")),
null,
'errors');
220 if (!is_numeric($tva_tx)) {
222 $langs->load(
"errors");
223 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"VATRateForSupplierProduct")),
null,
'errors');
225 if (empty($quantity)) {
227 $langs->load(
"errors");
228 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
230 if (empty($ref_fourn)) {
232 $langs->load(
"errors");
233 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefSupplier")),
null,
'errors');
235 if ($id_fourn <= 0) {
237 $langs->load(
"errors");
238 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Supplier")),
null,
'errors');
241 if ($price_expression ===
'') {
243 $langs->load(
"errors");
244 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
250 if (!
GETPOST(
"multicurrency_code")) {
252 $langs->load(
"errors");
253 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Currency")),
null,
'errors');
257 $langs->load(
"errors");
258 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CurrencyRate")),
null,
'errors');
262 $langs->load(
"errors");
263 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PriceCurrency")),
null,
'errors');
270 if (empty($ref_fourn_price_id)) {
271 $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity);
276 $tmpobject->fetch($object->product_id_already_linked);
277 $productLink = $tmpobject->getNomUrl(1,
'supplier');
279 $texttoshow = $langs->trans(
"ReferenceSupplierIsAlreadyAssociatedWithAProduct",
'{s1}');
280 $texttoshow = str_replace(
'{s1}', $productLink, $texttoshow);
282 } elseif ($ret < 0) {
290 $result = $supplier->fetch($id_fourn);
291 if ($ref_fourn_price_id > 0) {
292 $object->fetch_product_fournisseur_price($ref_fourn_price_id);
294 $extralabels = $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
295 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_fournisseur_price");
299 if (empty($packaging)) {
306 $object->packaging = $packaging;
311 $multicurrency_code =
GETPOST(
"multicurrency_code",
'alpha');
313 $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);
315 $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);
321 if (
isModEnabled(
'dynamicprices') && $price_expression !==
'') {
323 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
325 $object->fk_supplier_price_expression = $price_expression;
326 $price_result = $priceparser->parseProductSupplier($object);
327 if ($price_result < 0) {
334 $ret = $object->setSupplierPriceExpression($price_expression);
350 $action =
'add_price';
362 $title = $langs->trans(
'ProductServiceCard');
364 $shortlabel =
dol_trunc($object->label, 16);
366 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'BuyingPrices');
367 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
370 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'BuyingPrices');
371 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Lesitungen';
374 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs');
376 if ($id > 0 || $ref) {
378 if ($action ==
'ask_remove_pf') {
380 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$id.
'&rowid='.$rowid, $langs->trans(
'DeleteProductBuyPrice'), $langs->trans(
'ConfirmDeleteProductBuyPrice'),
'confirm_remove_pf',
'', 0, 1);
384 if ($action !=
'edit' && $action !=
're-edit') {
386 $titre = $langs->trans(
"CardProduct".$object->type);
391 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
392 $object->next_prev_filter =
" fk_product_type = ".$object->type;
395 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
401 print
'<div class="fichecenter">';
403 print
'<div class="underbanner clearboth"></div>';
404 print
'<table class="border tableforfield centpercent">';
408 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
409 print
'<tr><td class="">';
410 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
412 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
418 $textdesc = $langs->trans(
"CostPriceDescription");
419 $textdesc .=
"<br>".$langs->trans(
"CostPriceUsage");
420 $text =
$form->textwithpicto($langs->trans(
"CostPrice"), $textdesc, 1,
'help',
'');
421 print
$form->editfieldkey($text,
'cost_price', $object->cost_price, $object, $usercancreate,
'amount:6');
423 print
$form->editfieldval($text,
'cost_price', $object->cost_price, $object, $usercancreate,
'amount:6');
428 if (!empty($conf->global->PRODUCT_CAN_EDIT_WAP)) {
429 $usercaneditpmp = $usercancreate;
431 print
'<tr><td class="titlefieldcreate">';
432 $textdesc = $langs->trans(
"AverageUnitPricePMPDesc");
433 $text =
$form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $textdesc, 1,
'help',
'');
434 print
$form->editfieldkey($text,
'pmp', $object->pmp, $object, $usercaneditpmp,
'amount:6');
436 print
$form->editfieldval($text,
'pmp', ($object->pmp > 0 ? $object->pmp :
''), $object, $usercaneditpmp,
'amount:6');
437 if ($object->pmp > 0) {
438 print
' '.$langs->trans(
"HT");
450 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"BuyingPriceMin").
'</td>';
453 if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) {
454 if ($product_fourn->product_fourn_price_id > 0) {
455 print $product_fourn->display_price_product_fournisseur();
457 print $langs->trans(
"NotDefined");
465 print
'<div style="clear:both"></div>';
471 if (($action ==
'add_price' || $action ==
'update_price') && $usercancreate) {
472 $langs->load(
"suppliers");
474 print
"<!-- form to add a supplier price -->\n";
478 $object->fetch_product_fournisseur_price($rowid, 1);
484 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST">';
485 print
'<input type="hidden" name="token" value="'.newToken().
'">';
486 print
'<input type="hidden" name="action" value="save_price">';
490 print
'<table class="border centpercent">';
493 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Supplier").
'</td><td>';
496 $supplier->fetch($socid);
497 print $supplier->getNomUrl(1);
498 print
'<input type="hidden" name="id_fourn" value="'.$socid.
'">';
499 print
'<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.
'">';
500 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
501 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
504 $events[] = array(
'method' =>
'getVatRates',
'url' =>
dol_buildpath(
'/core/ajax/vatrates.php', 1),
'htmlname' =>
'tva_tx',
'params' => array());
505 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOST(
"id_fourn",
'alpha'),
'id_fourn',
'fournisseur=1',
'SelectThirdParty', 0, 0, $events);
507 $parameters = array(
'filtre'=>
"fournisseur=1",
'html_name'=>
'id_fourn',
'selected'=>
GETPOST(
"id_fourn"),
'showempty'=>1,
'prod_id'=>$object->id);
508 $reshook = $hookmanager->executeHooks(
'formCreateThirdpartyOptions', $parameters, $object, $action);
509 if (empty($reshook)) {
510 if (empty(
$form->result)) {
511 print
'<a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&type=f&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action='.$action).
'">';
512 print
img_picto($langs->trans(
"CreateDolibarrThirdPartySupplier"),
'add',
'class="marginleftonly"');
516 print
'<script type="text/javascript">
517 $(document).ready(function () {
518 $("#search_id_fourn").change(load_vat)
519 console.log("Requesting default VAT rate for the supplier...")
521 function load_vat() {
523 let socid = $("#id_fourn")[0].value
525 // load available VAT rates
526 let vat_url = "'.dol_buildpath(
'/core/ajax/vatrates.php', 1).
'"
527 //Make GET request with params
529 options += "id=" + socid
530 options += "&htmlname=tva_tx"
531 options += "&action=default" // not defined in vatrates.php, default behavior.
537 rate_options = $.parseHTML(data.value)
538 rate_options.forEach(opt => {
540 replaceVATWithSupplierValue(opt.value)
548 function replaceVATWithSupplierValue(vat_rate) {
549 console.log("Default VAT rate for the supplier: " + vat_rate + "%")
550 $("[name=\'tva_tx\']")[0].value = vat_rate;
557 print
'<tr><td class="fieldrequired">'.$langs->trans(
"SupplierRef").
'</td><td>';
559 print
'<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.
'">';
560 print
'<input class="flat width150" maxlength="128" name="ref_fourn" value="'.$object->ref_supplier.
'">';
562 print
'<input class="flat width150" maxlength="128" name="ref_fourn" value="'.(GETPOST(
"ref_fourn") ?
GETPOST(
"ref_fourn") :
'').
'">';
569 $langs->load(
"propal");
570 print
'<tr><td>'.$langs->trans(
"Availability").
'</td><td>';
571 $form->selectAvailabilityDelay($object->fk_availability,
"oselDispo", 1);
572 print
'</td></tr>'.
"\n";
577 print
'<td class="fieldrequired">'.$langs->trans(
"QtyMin").
'</td>';
581 print
'<input type="hidden" name="qty" value="'.$object->fourn_qty.
'">';
582 print $object->fourn_qty;
584 print
'<input class="flat" name="qty" size="5" value="'.$quantity.
'">';
587 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
588 $unit = $object->getLabelOfUnit();
590 print
' '.$langs->trans($unit);
595 if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
599 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc")).
'</td>';
602 print
'<input class="flat" name="packaging" size="5" value="'.$packaging.
'">';
605 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
606 $unit = $object->getLabelOfUnit();
608 print
' '.$langs->trans($unit);
617 $mysoc2 = clone $mysoc;
618 $mysoc2->name =
'Fictive seller with same country';
619 $mysoc2->tva_assuj = 1;
622 if (empty($default_vat)) {
623 $default_npr = $default_vat;
626 print
'<tr><td class="fieldrequired">'.$langs->trans(
"VATRateForSupplierProduct").
'</td>';
629 if (!empty($rowid)) {
631 $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
632 $default_vat = $tmpproductsupplier->fourn_tva_tx;
633 $default_npr = $tmpproductsupplier->fourn_tva_npr;
635 if (empty($default_vat)) {
636 $default_vat = $object->tva_tx;
640 $vattosuggest = preg_replace(
'/\s*\(.*\)$/',
'', $vattosuggest);
641 print
'<input type="text" class="flat" size="5" name="tva_tx" value="'.$vattosuggest.
'">';
646 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PriceMode").
'</td><td>';
648 $price_expression_list = array(0 => $langs->trans(
"PriceNumeric"));
649 foreach ($price_expression->list_price_expression() as $entry) {
650 $price_expression_list[$entry->id] = $entry->title;
652 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : ($object->fk_supplier_price_expression ? $object->fk_supplier_price_expression :
'0');
653 print
$form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
654 print
' <div id="expression_editor" class="button">'.$langs->trans(
"PriceExpressionEditor").
'</div>';
657 print
'<script type="text/javascript">
658 jQuery(document).ready(run);
660 jQuery("#expression_editor").click(on_click);
661 jQuery("#eid").change(on_change);
664 function on_click() {
665 window.location = "'.DOL_URL_ROOT.
'/product/dynamic_price/editor.php?id='.$id.
'&tab=fournisseurs&eid=" + $("#eid").val();
667 function on_change() {
668 if ($("#eid").val() == 0) {
669 jQuery("#price_numeric").show();
671 jQuery("#price_numeric").hide();
679 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
681 $currencycodetouse =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code :
'');
682 if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) {
683 $currencycodetouse = $conf->currency;
685 print
$form->selectMultiCurrency($currencycodetouse,
"multicurrency_code", 1);
686 print
' '.$langs->trans(
"CurrencyRate").
' ';
687 print
'<input class="flat" name="multicurrency_tx" size="4" value="'.vatrate(
GETPOST(
'multicurrency_tx') ?
GETPOST(
'multicurrency_tx') : (isset($object->fourn_multicurrency_tx) ? $object->fourn_multicurrency_tx :
'')).
'">';
692 print
'<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PriceQtyMinCurrency"), $langs->transnoentitiesnoconv(
"WithoutDiscount")).
'</td>';
693 $pricesupplierincurrencytouse = (
GETPOST(
'multicurrency_price') ?
GETPOST(
'multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price :
''));
694 print
'<td><input class="flat" name="multicurrency_price" size="8" value="'.price($pricesupplierincurrencytouse).
'">';
696 print
$form->selectPriceBaseType((
GETPOST(
'multicurrency_price_base_type') ?
GETPOST(
'multicurrency_price_base_type') :
'HT'),
"multicurrency_price_base_type");
700 print
'<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PriceQtyMin"), $langs->transnoentitiesnoconv(
"WithoutDiscount")).
'</td>';
701 print
'<td><input class="flat" name="disabled_price" size="8" value="">';
702 print
'<input type="hidden" name="price" value="">';
703 print
'<input type="hidden" name="price_base_type" value="">';
705 print
$form->selectPriceBaseType(
'',
"disabled_price_base_type");
708 $currencies = array();
709 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"multicurrency WHERE entity = ".((int) $conf->entity);
710 $resql = $db->query($sql);
713 while ($obj = $db->fetch_object(
$resql)) {
714 $currency->fetch($obj->rowid);
715 $currencies[$currency->code] = ((
float) $currency->rate->rate);
718 $currencies = json_encode($currencies);
721 <!-- javascript to autocalculate the minimum
price -->
722 <script
type=
"text/javascript">
723 function update_price_from_multicurrency() {
724 console.log(
"update_price_from_multicurrency");
725 var multicurrency_price =
price2numjs($(
'input[name="multicurrency_price"]').val());
726 var multicurrency_tx =
price2numjs($(
'input[name="multicurrency_tx"]').val());
727 if (multicurrency_tx != 0) {
728 $(
'input[name="price"]').val(multicurrency_price / multicurrency_tx);
729 $(
'input[name="disabled_price"]').val(multicurrency_price / multicurrency_tx);
731 $(
'input[name="price"]').val(
'');
732 $(
'input[name="disabled_price"]').val(
'');
736 jQuery(document).ready(
function () {
737 $(
'input[name="disabled_price"]').prop(
'disabled',
true);
738 $(
'select[name="disabled_price_base_type"]').prop(
'disabled',
true);
739 update_price_from_multicurrency();
741 $(
'input[name="multicurrency_price"], input[name="multicurrency_tx"]').keyup(
function () {
742 update_price_from_multicurrency();
744 $(
'input[name="multicurrency_price"], input[name="multicurrency_tx"]').change(
function () {
745 update_price_from_multicurrency();
747 $(
'input[name="multicurrency_price"], input[name="multicurrency_tx"]').on(
'paste',
function () {
748 update_price_from_multicurrency();
751 $(
'select[name="multicurrency_price_base_type"]').change(
function () {
752 $(
'input[name="price_base_type"]').val($(
this).val());
753 $(
'select[name="disabled_price_base_type"]').val($(
this).val());
756 var currencies_array = $currencies;
757 $(
'select[name="multicurrency_code"]').change(
function () {
758 console.log(
"We change the currency");
759 $(
'input[name="multicurrency_tx"]').val(currencies_array[$(
this).val()]);
760 update_price_from_multicurrency();
767 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PriceQtyMin").
'</td>';
768 print
'<td><input class="flat" name="price" size="8" value="'.(GETPOST(
'price') ?
price(
GETPOST(
'price')) : (isset($object->fourn_price) ?
price($object->fourn_price) :
'')).
'">';
770 print
$form->selectPriceBaseType((
GETPOSTISSET(
'price_base_type') ?
GETPOST(
'price_base_type') :
'HT'),
"price_base_type");
775 if (!empty($conf->global->PRODUCT_CHARGES)) {
777 print
'<td>'.$langs->trans(
"Charges").
'</td>';
778 print
'<td><input class="flat" name="charges" size="8" value="'.(GETPOST(
'charges') ?
price(
GETPOST(
'charges')) : (isset($object->fourn_charges) ?
price($object->fourn_charges) :
'')).
'">';
784 print
'<tr><td>'.$langs->trans(
"DiscountQtyMin").
'</td>';
785 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($object->fourn_remise_percent) :
'')).
'"> %';
791 print
'<td>'.$langs->trans(
'NbDaysToDelivery').
'</td>';
792 print
'<td><input class="flat" name="delivery_time_days" size="4" value="'.($rowid ? $object->delivery_time_days :
'').
'"> '.$langs->trans(
'days').
'</td>';
796 print
'<tr><td>'.$langs->trans(
"ReferenceReputation").
'</td><td>';
797 echo
$form->selectarray(
'supplier_reputation', $object->reputations, !empty($supplier_reputation) ? $supplier_reputation : $object->supplier_reputation);
806 print
'<td>'.$langs->trans(
'GencodBuyPrice').
'</td>';
808 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
809 print $formbarcode->selectBarcodeType((
GETPOSTISSET(
'fk_barcode_type') ?
GETPOST(
'fk_barcode_type',
'int') : ($rowid ? $object->supplier_fk_barcode_type : getDolGlobalint(
"PRODUIT_DEFAULT_BARCODE_TYPE"))),
'fk_barcode_type', 1);
810 print
' <input class="flat" name="barcode" value="'.(GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') : ($rowid ? $object->supplier_barcode :
'')).
'"></td>';
815 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
817 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
820 print
'<td>'.$langs->trans(
'ProductSupplierDescription').
'</td>';
823 $doleditor =
new DolEditor(
'supplier_description', $object->desc_supplier,
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
824 $doleditor->Create();
831 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
832 $extralabels = !empty($extrafields->attributes[
"product_fournisseur_price"][
'label']) ? $extrafields->attributes[
"product_fournisseur_price"][
'label'] :
'';
833 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_fournisseur_price");
834 if (!empty($extralabels)) {
836 foreach ($extralabels as $key => $value) {
837 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 ==
"update_price" && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] == 4))) {
838 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
839 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
842 print
'<tr><td'.($extrafields->attributes[
"product_fournisseur_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
843 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
844 print
$form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
846 print $langs->trans($value);
848 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_fournisseur_price').
'</td></tr>';
853 $sql .=
" fk_object";
854 foreach ($extralabels as $key => $value) {
857 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields";
858 $sql .=
" WHERE fk_object = ".((int) $rowid);
859 $resql = $db->query($sql);
861 $obj = $db->fetch_object(
$resql);
862 foreach ($extralabels as $key => $value) {
863 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 ==
"update_price" && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] == 4))) {
864 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
865 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
868 print
'<tr><td'.($extrafields->attributes[
"product_fournisseur_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
869 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
870 print
$form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
872 print $langs->trans($value);
874 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_fournisseur_price');
884 if (is_object($hookmanager)) {
885 $parameters = array(
'id_fourn'=>!empty($id_fourn) ? $id_fourn : 0,
'prod_id'=>$object->id);
886 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
887 print $hookmanager->resPrint;
894 print
'<div class="center">';
895 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
896 print
' ';
897 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
900 print
'</form>'.
"\n";
906 print
'<div class="tabsAction">'.
"\n";
908 if ($action !=
'add_price' && $action !=
'update_price') {
909 $parameters = array();
910 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
911 if (empty($reshook)) {
912 if ($usercancreate) {
913 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/product/fournisseurs.php?id='.$object->id.
'&action=add_price&token='.
newToken().
'">';
914 print $langs->trans(
"AddSupplierPrice").
'</a>';
921 if ($user->hasRight(
"fournisseur",
"read")) {
923 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
924 $param .=
'&contextpage='.urlencode($contextpage);
926 if ($limit > 0 && $limit != $conf->liste_limit) {
927 $param .=
'&limit='.urlencode($limit);
929 $param .=
'&ref='.urlencode($object->ref);
932 $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, $limit, $offset);
933 $product_fourn_list_all = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, 0, 0);
935 $num = count($product_fourn_list);
940 print_barre_liste($langs->trans(
'SupplierPrices'), $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'title_accountancy.png', 0,
'',
'', $limit, 1);
944 $arrayfields = array(
945 'pfp.datec'=>array(
'label'=>$langs->trans(
"AppliedPricesFrom"),
'checked'=>1,
'position'=>1),
946 's.nom'=>array(
'label'=>$langs->trans(
"Suppliers"),
'checked'=>1,
'position'=>2),
947 'pfp.fk_availability'=>array(
'label'=>$langs->trans(
"Availability"),
'enabled' =>
getDolGlobalInt(
'FOURN_PRODUCT_AVAILABILITY'),
'checked'=>0,
'position'=>4),
948 'pfp.quantity'=>array(
'label'=>$langs->trans(
"QtyMin"),
'checked'=>1,
'position'=>5),
949 'pfp.unitprice'=>array(
'label'=>$langs->trans(
"UnitPriceHT"),
'checked'=>1,
'position'=>9),
950 'pfp.multicurrency_unitprice'=>array(
'label'=>$langs->trans(
"UnitPriceHTCurrency"),
'enabled' =>
isModEnabled(
'multicurrency'),
'checked'=>0,
'position'=>10),
951 'pfp.charges'=>array(
'label'=>$langs->trans(
"Charges"),
'enabled' => !empty($conf->global->PRODUCT_CHARGES),
'checked'=>0,
'position'=>11),
952 'pfp.delivery_time_days'=>array(
'label'=>$langs->trans(
"NbDaysToDelivery"),
'checked'=>-1,
'position'=>13),
953 'pfp.supplier_reputation'=>array(
'label'=>$langs->trans(
"ReputationForThisProduct"),
'checked'=>-1,
'position'=>14),
954 'pfp.fk_barcode_type'=>array(
'label'=>$langs->trans(
"BarcodeType"),
'enabled' =>
isModEnabled(
'barcode'),
'checked'=>0,
'position'=>15),
955 'pfp.barcode'=>array(
'label'=>$langs->trans(
"BarcodeValue"),
'enabled' =>
isModEnabled(
'barcode'),
'checked'=>0,
'position'=>16),
956 'pfp.packaging'=>array(
'label'=>$langs->trans(
"PackagingForThisProduct"),
'enabled' =>
getDolGlobalInt(
'PRODUCT_USE_SUPPLIER_PACKAGING'),
'checked'=>0,
'position'=>17),
957 'pfp.tms'=>array(
'label'=>$langs->trans(
"DateModification"),
'enabled' =>
isModEnabled(
'barcode'),
'checked'=>1,
'position'=>18),
961 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
962 if ($extrafields->attributes[
"product_fournisseur_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_fournisseur_price"])) {
963 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
965 if (!empty($extralabels)) {
966 foreach ($extralabels as $key => $value) {
968 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
969 $extratitle = $langs->trans($value);
970 $arrayfields[
'ef.' . $key] = array(
'label' => $extratitle,
'checked' => 0,
971 'position' => (end($arrayfields)[
'position'] + 1),
972 'langfile' => $extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key],
973 'help' => $extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]);
980 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
982 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
983 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
985 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post" name="formulaire">';
986 print
'<input type="hidden" name="token" value="'.newToken().
'">';
987 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
988 print
'<input type="hidden" name="action" value="list">';
989 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
990 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
993 print
'<div class="div-table-responsive">';
994 print
'<table class="liste centpercent">';
996 $param =
"&id=".$object->id;
1000 print
'<tr class="liste_titre">';
1001 if (!empty($arrayfields[
'pfp.datec'][
'checked'])) {
1002 print_liste_field_titre(
"AppliedPricesFrom", $_SERVER[
"PHP_SELF"],
"pfp.datec",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1005 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1006 print_liste_field_titre(
"Suppliers", $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1009 print_liste_field_titre(
"SupplierRef", $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1011 if (!empty($arrayfields[
'pfp.fk_availability'][
'checked'])) {
1012 print_liste_field_titre(
"Availability", $_SERVER[
"PHP_SELF"],
"pfp.fk_availability",
"", $param,
"", $sortfield, $sortorder);
1015 if (!empty($arrayfields[
'pfp.quantity'][
'checked'])) {
1016 print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"pfp.quantity",
"", $param,
'', $sortfield, $sortorder,
'right ');
1019 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1021 print_liste_field_titre(
"PriceQtyMinHT", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1024 print_liste_field_titre(
"PriceQtyMinHTCurrency", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1027 if (!empty($arrayfields[
'pfp.unitprice'][
'checked'])) {
1028 print_liste_field_titre(
"UnitPriceHT", $_SERVER[
"PHP_SELF"],
"pfp.unitprice",
"", $param,
'', $sortfield, $sortorder,
'right ');
1031 if (!empty($arrayfields[
'pfp.multicurrency_unitprice'][
'checked'])) {
1032 print_liste_field_titre(
"UnitPriceHTCurrency", $_SERVER[
"PHP_SELF"],
"pfp.multicurrency_unitprice",
"", $param,
'', $sortfield, $sortorder,
'right ');
1036 print_liste_field_titre(
"Currency", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1039 if (!empty($arrayfields[
'pfp.charges'][
'checked'])) {
1040 print_liste_field_titre(
"Charges", $_SERVER[
"PHP_SELF"],
"pfp.charges",
"", $param,
'', $sortfield, $sortorder,
'right ');
1043 print_liste_field_titre(
"DiscountQtyMin", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1045 if (!empty($arrayfields[
'pfp.delivery_time_days'][
'checked'])) {
1046 print_liste_field_titre(
"NbDaysToDelivery", $_SERVER[
"PHP_SELF"],
"pfp.delivery_time_days",
"", $param,
'', $sortfield, $sortorder,
'right ');
1049 if (!empty($arrayfields[
'pfp.supplier_reputation'][
'checked'])) {
1050 print_liste_field_titre(
"ReputationForThisProduct", $_SERVER[
"PHP_SELF"],
"pfp.supplier_reputation",
"", $param,
'', $sortfield, $sortorder,
'center ');
1053 if (!empty($arrayfields[
'pfp.fk_barcode_type'][
'checked'])) {
1054 print_liste_field_titre(
"BarcodeType", $_SERVER[
"PHP_SELF"],
"pfp.fk_barcode_type",
"", $param,
'', $sortfield, $sortorder,
'center ');
1057 if (!empty($arrayfields[
'pfp.barcode'][
'checked'])) {
1058 print_liste_field_titre(
"BarcodeValue", $_SERVER[
"PHP_SELF"],
"pfp.barcode",
"", $param,
'', $sortfield, $sortorder,
'center ');
1061 if (!empty($arrayfields[
'pfp.packaging'][
'checked'])) {
1062 print_liste_field_titre(
"PackagingForThisProduct", $_SERVER[
"PHP_SELF"],
"pfp.packaging",
"", $param,
'align="center"', $sortfield, $sortorder);
1065 if (!empty($arrayfields[
'pfp.tms'][
'checked'])) {
1066 print_liste_field_titre(
"DateModification", $_SERVER[
"PHP_SELF"],
"pfp.tms",
"", $param,
'', $sortfield, $sortorder,
'right ',
'', 1);
1071 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
1072 if ($extrafields->attributes[
"product_fournisseur_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_fournisseur_price"])) {
1073 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
1075 if (!empty($extralabels)) {
1076 foreach ($extralabels as $key => $value) {
1078 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
1079 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
1080 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
1082 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
1083 $extratitle =
$form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
1085 $extratitle = $langs->trans($value);
1087 if (!empty($arrayfields[
'ef.' . $key][
'checked'])) {
1088 print_liste_field_titre($extratitle, $_SERVER[
"PHP_SELF"],
'ef.' . $key,
'', $param,
'', $sortfield, $sortorder,
'right ');
1096 if (is_object($hookmanager)) {
1097 $parameters = array(
'id_fourn'=>(!empty($id_fourn)?$id_fourn:
''),
'prod_id'=>$object->id,
'nbfields'=>$nbfields);
1098 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1100 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1104 if (is_array($product_fourn_list)) {
1105 foreach ($product_fourn_list as $productfourn) {
1106 print
'<tr class="oddeven">';
1109 if (!empty($arrayfields[
'pfp.datec'][
'checked'])) {
1110 print
'<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation),
'dayhour',
'tzuserrel').
'</td>';
1114 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1115 print
'<td class="tdoverflowmax150">'.$productfourn->getSocNomUrl(1,
'supplier').
'</td>';
1119 if ($usercancreate) {
1120 print
'<td class="tdoverflowmax150">'.$productfourn->getNomUrl().
'</td>';
1122 print
'<td class="tdoverflowmax150">'.dol_escape_htmltag($productfourn->fourn_ref).
'</td>';
1126 if (!empty($arrayfields[
'pfp.fk_availability'][
'checked'])) {
1127 $form->load_cache_availability();
1128 $availability =
$form->cache_availability[$productfourn->fk_availability][
'label'];
1129 print
'<td class="left">'.$availability.
'</td>';
1133 if (!empty($arrayfields[
'pfp.quantity'][
'checked'])) {
1134 print
'<td class="right">';
1135 print $productfourn->fourn_qty;
1137 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1138 $unit = $object->getLabelOfUnit();
1140 print
' '.$langs->trans($unit);
1147 print
'<td class="right">';
1148 print
vatrate($productfourn->fourn_tva_tx,
true);
1152 print
'<td class="right">';
1153 print $productfourn->fourn_price ?
'<span class="amount">'.price($productfourn->fourn_price).
'</span>' :
"";
1158 print
'<td class="right">';
1159 print $productfourn->fourn_multicurrency_price ?
'<span class="amount">'.price($productfourn->fourn_multicurrency_price).
'</span>' :
"";
1164 if (!empty($arrayfields[
'pfp.unitprice'][
'checked'])) {
1165 print
'<td class="right">';
1166 print
price($productfourn->fourn_unitprice);
1172 if (!empty($arrayfields[
'pfp.multicurrency_unitprice'][
'checked'])) {
1173 print
'<td class="right">';
1174 print
price($productfourn->fourn_multicurrency_unitprice);
1180 print
'<td class="right nowraponall">';
1181 print $productfourn->fourn_multicurrency_code ?
currency_name($productfourn->fourn_multicurrency_code) :
'';
1186 if (!empty($arrayfields[
'pfp.charges'][
'checked'])) {
1187 print
'<td class="right">';
1188 print
price($productfourn->fourn_charges);
1193 print
'<td class="right">';
1194 print
price2num($productfourn->fourn_remise_percent).
'%';
1198 if (!empty($arrayfields[
'pfp.delivery_time_days'][
'checked'])) {
1199 print
'<td class="right">';
1200 print $productfourn->delivery_time_days;
1205 if (!empty($arrayfields[
'pfp.supplier_reputation'][
'checked'])) {
1206 print
'<td class="center">';
1207 if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) {
1208 print $object->reputations[$productfourn->supplier_reputation];
1214 if (!empty($arrayfields[
'pfp.fk_barcode_type'][
'checked'])) {
1215 print
'<td class="center">';
1216 $productfourn->barcode_type = !empty($productfourn->supplier_fk_barcode_type) ? $productfourn->supplier_fk_barcode_type : 0;
1217 $productfourn->fetch_barcode();
1218 print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->supplier_barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
1223 if (!empty($arrayfields[
'pfp.barcode'][
'checked'])) {
1224 print
'<td align="right">';
1225 print $productfourn->supplier_barcode;
1230 if (!empty($arrayfields[
'pfp.packaging'][
'checked'])) {
1231 print
'<td align="center">';
1232 print
price2num($productfourn->packaging);
1237 if (!empty($arrayfields[
'pfp.tms'][
'checked'])) {
1238 print
'<td class="right nowraponall">';
1239 print
dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification),
"dayhour");
1244 if (!empty($extralabels)) {
1246 $sql .=
" fk_object";
1247 foreach ($extralabels as $key => $value) {
1250 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields";
1251 $sql .=
" WHERE fk_object = ".((int) $productfourn->product_fourn_price_id);
1252 $resql = $db->query($sql);
1254 if ($db->num_rows(
$resql) != 1) {
1255 foreach ($extralabels as $key => $value) {
1256 if (!empty($arrayfields[
'ef.'.$key][
'checked']) && !empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
1261 $obj = $db->fetch_object(
$resql);
1262 foreach ($extralabels as $key => $value) {
1263 if (!empty($arrayfields[
'ef.'.$key][
'checked']) && !empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
1264 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_fournisseur_price').
"</td>";
1272 if (is_object($hookmanager)) {
1273 $parameters = array(
'id_pfp'=>$productfourn->product_fourn_price_id,
'id_fourn'=>(!empty($id_fourn)?$id_fourn:
''),
'prod_id'=>$object->id);
1274 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1278 print
'<td class="center nowraponall">';
1280 if ($usercancreate) {
1281 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.((int) $object->id).
'&socid='.((int) $productfourn->fourn_id).
'&action=update_price&token='.
newToken().
'&rowid='.((int) $productfourn->product_fourn_price_id).
'">'.
img_edit().
"</a>";
1283 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>';
1291 if (empty($product_fourn_list)) {
1292 print
'<tr><td colspan="'.$nbfields.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1305 print $langs->trans(
"ErrorUnknown");
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
Class to manage suppliers.
Class for accesing 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='', $outputlangs=null)
Return label of currency or code+label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Fonction qui renvoie si tva doit etre tva percue recuperable.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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...
price2numjs(amount)
Function similar to PHP price2num()
$formconfirm
if ($action == 'delbookkeepingyear') {
div float
Buy price without taxes.
$nbtotalofrecords
Count total nb of records.
product_prepare_head($object)
Prepare array with list of tabs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.