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')) {
49$langs->loadLangs(array(
'products',
'suppliers',
'bills',
'margins',
'stocks'));
54$action =
GETPOST(
'action',
'aZ09');
55$cancel =
GETPOST(
'cancel',
'alpha');
56$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'pricesuppliercard';
62$backtopage =
GETPOST(
'backtopage',
'alpha');
69 $_GET[
'id_fourn'] =
GETPOSTINT(
'search_fourn_id');
70 $_POST[
'id_fourn'] =
GETPOSTINT(
'search_fourn_id');
74$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
75$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
77 $socid = $user->socid;
80if (!$user->hasRight(
'fournisseur',
'lire') && (!isModEnabled(
'margin') && !$user->hasRight(
"margin",
"liretous"))) {
85$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
86$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88if (empty($page) || $page == -1) {
91$offset = $limit * $page;
102$hookmanager->initHooks(array(
'pricesuppliercard',
'globalcard'));
106if ($id > 0 || $ref) {
108 $prod->fetch($id, $ref);
115 if (
$object->type == $object::TYPE_PRODUCT) {
118 if (
$object->type == $object::TYPE_SERVICE) {
122 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
134$parameters = array(
'socid'=>$socid,
'id_prod'=>$id);
135$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
140if (empty($reshook)) {
141 if ($action ==
'setcost_price' && $usercancreate) {
146 $object->cost_price = $cost_price;
157 if ($action ==
'setpmp' && $usercancreate) {
161 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product SET pmp = ".((float)
$object->pmp).
" WHERE rowid = ".((int) $id);
162 $resql = $db->query($sql);
174 if ($action ==
'confirm_remove_pf' && $usercancreate) {
177 $result =
$object->remove_product_fournisseur_price($rowid);
179 $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields WHERE fk_object = ".((
int) $rowid));
188 if ($action ==
'save_price' && $usercancreate) {
189 $ref_fourn_price_id =
GETPOSTINT(
'ref_fourn_price_id');
190 $id_fourn =
GETPOST(
"id_fourn");
191 if (empty($id_fourn)) {
192 $id_fourn =
GETPOST(
"search_id_fourn");
194 $ref_fourn =
GETPOST(
"ref_fourn");
195 if (empty($ref_fourn)) {
196 $ref_fourn =
GETPOST(
"search_ref_fourn");
198 $ref_fourn_old =
GETPOST(
"ref_fourn_old");
199 if (empty($ref_fourn_old)) {
200 $ref_fourn_old = $ref_fourn;
205 $npr = preg_match(
'/\*/',
GETPOST(
'tva_tx',
'alpha')) ? 1 : 0;
206 $tva_tx = str_replace(
'*',
'',
GETPOST(
'tva_tx',
'alpha'));
207 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
213 $supplier_reputation =
GETPOST(
'supplier_reputation');
214 $supplier_description =
GETPOST(
'supplier_description',
'restricthtml');
215 $barcode =
GETPOST(
'barcode',
'alpha');
216 $fk_barcode_type =
GETPOSTINT(
'fk_barcode_type');
221 $langs->load(
"errors");
222 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"VATRateForSupplierProduct")),
null,
'errors');
224 if (!is_numeric($tva_tx)) {
226 $langs->load(
"errors");
227 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"VATRateForSupplierProduct")),
null,
'errors');
229 if (empty($quantity)) {
231 $langs->load(
"errors");
232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
234 if (empty($ref_fourn)) {
236 $langs->load(
"errors");
237 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefSupplier")),
null,
'errors');
239 if ($id_fourn <= 0) {
241 $langs->load(
"errors");
242 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Supplier")),
null,
'errors');
245 if ($price_expression ===
'') {
247 $langs->load(
"errors");
248 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
253 if (isModEnabled(
"multicurrency")) {
254 if (!
GETPOST(
"multicurrency_code")) {
256 $langs->load(
"errors");
257 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Currency")),
null,
'errors');
261 $langs->load(
"errors");
262 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CurrencyRate")),
null,
'errors');
266 $langs->load(
"errors");
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PriceCurrency")),
null,
'errors');
274 if (empty($ref_fourn_price_id)) {
275 $ret =
$object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity);
280 $tmpobject->fetch(
$object->product_id_already_linked);
281 $productLink = $tmpobject->getNomUrl(1,
'supplier');
283 $texttoshow = $langs->trans(
"ReferenceSupplierIsAlreadyAssociatedWithAProduct",
'{s1}');
284 $texttoshow = str_replace(
'{s1}', $productLink, $texttoshow);
286 } elseif ($ret < 0) {
294 $result = $supplier->fetch($id_fourn);
295 if (GETPOSTISSET(
'ref_fourn_price_id')) {
296 $object->fetch_product_fournisseur_price($ref_fourn_price_id);
298 $extralabels = $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
299 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_fournisseur_price");
303 if (empty($packaging)) {
310 $object->packaging = $packaging;
312 if (isModEnabled(
"multicurrency")) {
314 $multicurrency_price =
GETPOSTFLOAT(
"multicurrency_price");
315 $multicurrency_code =
GETPOST(
"multicurrency_code",
'alpha');
317 $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);
319 $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);
325 if (isModEnabled(
'dynamicprices') && $price_expression !==
'') {
327 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
329 $object->fk_supplier_price_expression = $price_expression;
330 $price_result = $priceparser->parseProductSupplier($object);
331 if ($price_result < 0) {
336 if (!$error && isModEnabled(
'dynamicprices')) {
338 $ret =
$object->setSupplierPriceExpression($price_expression);
354 $action =
'create_price';
364$form =
new Form($db);
366$title = $langs->trans(
'ProductServiceCard');
370 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'BuyingPrices');
371 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
374 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'BuyingPrices');
375 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Lesitungen';
378llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price_suppliers');
380if ($id > 0 || $ref) {
382 if ($action ==
'ask_remove_pf') {
383 $form =
new Form($db);
384 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&rowid='.$rowid, $langs->trans(
'DeleteProductBuyPrice'), $langs->trans(
'ConfirmDeleteProductBuyPrice'),
'confirm_remove_pf',
'', 0, 1);
388 if ($action !=
'edit' && $action !=
're-edit') {
390 $titre = $langs->trans(
"CardProduct".
$object->type);
395 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
396 $object->next_prev_filter =
"fk_product_type = ".((int)
$object->type);
399 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
403 dol_banner_tab($prod,
'ref', $linkback, $shownav,
'ref');
405 print
'<div class="fichecenter">';
407 print
'<div class="underbanner clearboth"></div>';
408 print
'<table class="border tableforfield centpercent">';
411 if (isModEnabled(
"product") && isModEnabled(
"service")) {
412 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
413 print
'<tr><td class="">';
414 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
416 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
422 $textdesc = $langs->trans(
"CostPriceDescription");
423 $textdesc .=
"<br>".$langs->trans(
"CostPriceUsage");
424 $text = $form->textwithpicto($langs->trans(
"CostPrice"), $textdesc, 1,
'help',
'');
425 print $form->editfieldkey($text,
'cost_price',
$object->cost_price, $object, $usercancreate,
'amount:6');
427 print $form->editfieldval($text,
'cost_price',
$object->cost_price, $object, $usercancreate,
'amount:6');
433 $usercaneditpmp = $usercancreate;
435 print
'<tr><td class="titlefieldcreate">';
436 $textdesc = $langs->trans(
"AverageUnitPricePMPDesc");
437 $text = $form->textwithpicto($langs->trans(
"AverageUnitPricePMPShort"), $textdesc, 1,
'help',
'');
438 print $form->editfieldkey($text,
'pmp',
$object->pmp, $object, $usercaneditpmp,
'amount:6');
440 print $form->editfieldval($text,
'pmp', (
$object->pmp > 0 ?
$object->pmp :
''),
$object, $usercaneditpmp,
'amount:6');
442 print
' '.$langs->trans(
"HT");
454 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"BuyingPriceMin").
'</td>';
457 if ($product_fourn->find_min_price_product_fournisseur(
$object->id) > 0) {
458 if ($product_fourn->product_fourn_price_id > 0) {
459 print $product_fourn->display_price_product_fournisseur();
461 print $langs->trans(
"NotDefined");
469 print
'<div class="clearboth"></div>';
475 if (($action ==
'create_price' || $action ==
'edit_price') && $usercancreate) {
476 $langs->load(
"suppliers");
478 print
"<!-- form to add a supplier price -->\n";
482 $object->fetch_product_fournisseur_price($rowid, 1);
488 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">';
489 print
'<input type="hidden" name="token" value="'.newToken().
'">';
490 print
'<input type="hidden" name="action" value="save_price">';
494 print
'<table class="border centpercent">';
497 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Supplier").
'</td><td>';
500 $supplier->fetch($socid);
501 print $supplier->getNomUrl(1);
502 print
'<input type="hidden" name="id_fourn" value="'.$socid.
'">';
503 print
'<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.
'">';
504 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
505 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
508 $events[] = array(
'method' =>
'getVatRates',
'url' =>
dol_buildpath(
'/core/ajax/vatrates.php', 1),
'htmlname' =>
'tva_tx',
'params' => array());
509 $filter =
'(fournisseur:=:1) AND (status:=:1)';
510 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOST(
"id_fourn",
'alpha'),
'id_fourn', $filter, $langs->transnoentitiesnoconv(
'SelectThirdParty'), 0, 0, $events);
512 $parameters = array(
'filter'=>$filter,
'html_name'=>
'id_fourn',
'selected'=>
GETPOST(
"id_fourn"),
'showempty'=>1,
'prod_id'=>
$object->id);
513 $reshook = $hookmanager->executeHooks(
'formCreateThirdpartyOptions', $parameters, $object, $action);
514 if (empty($reshook)) {
515 if (empty($form->result)) {
516 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() :
'')).
'">';
517 print
img_picto($langs->trans(
"CreateDolibarrThirdPartySupplier"),
'add',
'class="marginleftonly"');
521 print
'<script type="text/javascript">
522 $(document).ready(function () {
523 console.log("Requesting default VAT rate for the supplier...")
524 $("#search_id_fourn").change(load_vat)
526 function load_vat() {
528 let socid = $("#id_fourn")[0].value
530 // load available VAT rates
531 let vat_url = "'.dol_buildpath(
'/core/ajax/vatrates.php', 1).
'"
532 // make GET request with params
534 options += "id=" + socid
535 options += "&htmlname=tva_tx"
537 options += "&action=getBuyerVATRates" // not defined in vatrates.php, default behavior.
543 rate_options = $.parseHTML(data.value)
544 rate_options.forEach(opt => {
546 replaceVATWithSupplierValue(opt.value);
554 function replaceVATWithSupplierValue(vat_rate) {
555 console.log("Default VAT rate for the supplier: " + vat_rate + "%")
556 $("[name=\'tva_tx\']")[0].value = vat_rate;
563 print
'<tr><td class="fieldrequired">'.$langs->trans(
"SupplierRef").
'</td><td>';
565 print
'<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.
'">';
566 print
'<input class="flat width150" maxlength="128" name="ref_fourn" value="'.$object->ref_supplier.
'">';
568 print
'<input class="flat width150" maxlength="128" name="ref_fourn" value="'.(GETPOST(
"ref_fourn") ?
GETPOST(
"ref_fourn") :
'').
'">';
575 $langs->load(
"propal");
576 print
'<tr><td>'.$langs->trans(
"Availability").
'</td><td>';
577 $form->selectAvailabilityDelay(
$object->fk_availability,
"oselDispo", 1);
578 print
'</td></tr>'.
"\n";
583 print
'<td class="fieldrequired">'.$langs->trans(
"QtyMin").
'</td>';
585 $quantity = GETPOSTISSET(
'qty') ?
price2num(
GETPOST(
'qty',
'alphanohtml'),
'MS') :
"1";
587 print
'<input type="hidden" name="qty" value="'.$object->fourn_qty.
'">';
590 print
'<input class="flat" name="qty" size="5" value="'.$quantity.
'">';
594 $unit =
$object->getLabelOfUnit();
596 print
' '.$langs->trans($unit);
605 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc")).
'</td>';
607 $packaging = GETPOSTISSET(
'packaging') ?
price2num(
GETPOST(
'packaging',
'alphanohtml'),
'MS') : ((empty($rowid)) ?
"1" :
price2num(
$object->packaging,
'MS'));
608 print
'<input class="flat" name="packaging" size="5" value="'.$packaging.
'">';
612 $unit =
$object->getLabelOfUnit();
614 print
' '.$langs->trans($unit);
623 $mysoc2 = clone $mysoc;
624 $mysoc2->name =
'Fictive seller with same country';
625 $mysoc2->tva_assuj = 1;
628 if (empty($default_vat)) {
629 $default_npr = $default_vat;
632 print
'<tr><td class="fieldrequired">'.$langs->trans(
"VATRateForSupplierProduct").
'</td>';
635 if (!empty($rowid)) {
637 $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1);
638 $default_vat = $tmpproductsupplier->fourn_tva_tx;
639 $default_npr = $tmpproductsupplier->fourn_tva_npr;
641 if (empty($default_vat)) {
642 $default_vat =
$object->tva_tx;
645 $vattosuggest = (GETPOSTISSET(
"tva_tx") ?
vatrate(
GETPOST(
"tva_tx")) : ($default_vat !=
'' ?
vatrate($default_vat) :
''));
646 $vattosuggest = preg_replace(
'/\s*\(.*\)$/',
'', $vattosuggest);
647 print
'<input type="text" class="flat" size="5" name="tva_tx" value="'.$vattosuggest.
'">';
650 if (isModEnabled(
'dynamicprices')) {
652 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PriceMode").
'</td><td>';
654 $price_expression_list = array(0 => $langs->trans(
"PriceNumeric"));
655 foreach ($price_expression->list_price_expression() as $entry) {
656 $price_expression_list[$entry->id] = $entry->title;
658 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : (
$object->fk_supplier_price_expression ?
$object->fk_supplier_price_expression :
'0');
659 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
660 print
' <div id="expression_editor" class="button smallpaddingimp">'.$langs->trans(
"PriceExpressionEditor").
'</div>';
663 print
'<script type="text/javascript">
664 jQuery(document).ready(run);
666 jQuery("#expression_editor").click(on_click);
667 jQuery("#eid").change(on_change);
670 function on_click() {
671 window.location = "'.DOL_URL_ROOT.
'/product/dynamic_price/editor.php?id='.
$id.
'&tab=fournisseurs&eid=" + $("#eid").val();
673 function on_change() {
674 if ($("#eid").val() == 0) {
675 jQuery("#price_numeric").show();
677 jQuery("#price_numeric").hide();
683 if (isModEnabled(
"multicurrency")) {
685 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
687 $currencycodetouse =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (isset(
$object->fourn_multicurrency_code) ?
$object->fourn_multicurrency_code :
'');
688 if (empty($currencycodetouse) &&
$object->fourn_multicurrency_tx == 1) {
689 $currencycodetouse = $conf->currency;
691 print $form->selectMultiCurrency($currencycodetouse,
"multicurrency_code", 1);
692 print
' '.$langs->trans(
"CurrencyRate").
' ';
693 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 :
'')).
'">';
698 print
'<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PriceQtyMinCurrency"), $langs->transnoentitiesnoconv(
"WithoutDiscount")).
'</td>';
699 $pricesupplierincurrencytouse = (
GETPOST(
'multicurrency_price') ?
GETPOST(
'multicurrency_price') : (isset(
$object->fourn_multicurrency_price) ?
$object->fourn_multicurrency_price :
''));
700 print
'<td><input class="flat" name="multicurrency_price" size="8" value="'.price($pricesupplierincurrencytouse).
'">';
702 print $form->selectPriceBaseType((
GETPOST(
'multicurrency_price_base_type') ?
GETPOST(
'multicurrency_price_base_type') :
'HT'),
"multicurrency_price_base_type");
706 print
'<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PriceQtyMin"), $langs->transnoentitiesnoconv(
"WithoutDiscount")).
'</td>';
707 print
'<td><input class="flat" name="disabled_price" size="8" value="">';
708 print
'<input type="hidden" name="price" value="">';
709 print
'<input type="hidden" name="price_base_type" value="">';
711 print $form->selectPriceBaseType(
'',
"disabled_price_base_type");
714 $currencies = array();
715 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"multicurrency WHERE entity = ".((int) $conf->entity);
716 $resql = $db->query($sql);
719 while ($obj = $db->fetch_object($resql)) {
720 $currency->fetch($obj->rowid);
721 $currencies[$currency->code] = ((float) $currency->rate->rate);
724 $currencies = json_encode($currencies);
725 print
"<!-- javascript to autocalculate the minimum price -->
726 <script type='text/javascript'>
727 function edit_price_from_multicurrency() {
728 console.log('edit_price_from_multicurrency');
729 var multicurrency_price = price2numjs($('input[name=\"multicurrency_price\"]').val());
730 var multicurrency_tx = price2numjs($('input[name=\"multicurrency_tx\"]').val());
731 if (multicurrency_tx != 0) {
732 $('input[name=\"price\"]').val(multicurrency_price / multicurrency_tx);
733 $('input[name=\"disabled_price\"]').val(multicurrency_price / multicurrency_tx);
735 $('input[name=\"price\"]').val('');
736 $('input[name=\"disabled_price\"]').val('');
740 jQuery(document).ready(function () {
741 $('input[name=\"disabled_price\"]').prop('disabled', true);
742 $('select[name=\"disabled_price_base_type\"]').prop('disabled', true);
743 edit_price_from_multicurrency();
745 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').keyup(function () {
746 edit_price_from_multicurrency();
748 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').change(function () {
749 edit_price_from_multicurrency();
751 $('input[name=\"multicurrency_price\"], input[name=\"multicurrency_tx\"]').on('paste', function () {
752 edit_price_from_multicurrency();
755 $('select[name=\"multicurrency_price_base_type\"]').change(function () {
756 $('input[name=\"price_base_type\"]').val($(this).val());
757 $('select[name=\"disabled_price_base_type\"]').val($(this).val());
760 var currencies_array = $currencies;
761 $('select[name=\"multicurrency_code\"]').change(function () {
762 console.log(\"We change the currency\");
763 $('input[name=\"multicurrency_tx\"]').val(currencies_array[$(this).val()]);
764 edit_price_from_multicurrency();
770 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PriceQtyMin").
'</td>';
771 print
'<td><input class="flat" name="price" size="8" value="'.(GETPOST(
'price') ?
price(
GETPOST(
'price')) : (isset(
$object->fourn_price) ?
price(
$object->fourn_price) :
'')).
'">';
773 print $form->selectPriceBaseType((GETPOSTISSET(
'price_base_type') ?
GETPOST(
'price_base_type') :
'HT'),
"price_base_type");
780 print
'<td>'.$langs->trans(
"Charges").
'</td>';
781 print
'<td><input class="flat" name="charges" size="8" value="'.(GETPOST(
'charges') ?
price(
GETPOST(
'charges')) : (isset(
$object->fourn_charges) ?
price(
$object->fourn_charges) :
'')).
'">';
787 print
'<tr><td>'.$langs->trans(
"DiscountQtyMin").
'</td>';
788 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)) :
'')).
'"> %';
794 print
'<td>'.$langs->trans(
'NbDaysToDelivery').
'</td>';
795 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>';
799 print
'<tr><td>'.$langs->trans(
"ReferenceReputation").
'</td><td>';
800 echo $form->selectarray(
'supplier_reputation',
$object->reputations, !empty($supplier_reputation) ? $supplier_reputation :
$object->supplier_reputation);
804 if (isModEnabled(
'barcode')) {
809 print
'<td>'.$langs->trans(
'GencodBuyPrice').
'</td>';
811 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
812 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);
813 print
' <input class="flat" name="barcode" value="'.(GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') : ($rowid ?
$object->supplier_barcode :
'')).
'"></td>';
820 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
823 print
'<td>'.$langs->trans(
'ProductSupplierDescription').
'</td>';
826 $doleditor =
new DolEditor(
'supplier_description',
$object->desc_supplier,
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
827 $doleditor->Create();
834 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
835 $extralabels = !empty($extrafields->attributes[
"product_fournisseur_price"][
'label']) ? $extrafields->attributes[
"product_fournisseur_price"][
'label'] :
'';
836 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_fournisseur_price");
837 if (!empty($extralabels)) {
839 foreach ($extralabels as $key => $value) {
840 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))) {
841 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
842 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
845 print
'<tr><td'.($extrafields->attributes[
"product_fournisseur_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
846 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
847 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
849 print $langs->trans($value);
851 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_fournisseur_price').
'</td></tr>';
856 $sql .=
" fk_object";
857 foreach ($extralabels as $key => $value) {
860 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields";
861 $sql .=
" WHERE fk_object = ".((int) $rowid);
862 $resql = $db->query($sql);
864 $obj = $db->fetch_object($resql);
865 foreach ($extralabels as $key => $value) {
866 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))) {
867 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
868 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
871 print
'<tr><td'.($extrafields->attributes[
"product_fournisseur_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
872 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
873 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
875 print $langs->trans($value);
877 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_fournisseur_price');
887 if (is_object($hookmanager)) {
888 $parameters = array(
'id_fourn'=>!empty($id_fourn) ? $id_fourn : 0,
'prod_id'=>
$object->id);
889 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
890 print $hookmanager->resPrint;
897 print
'<div class="center">';
898 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
899 print
' ';
900 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
903 print
'</form>'.
"\n";
909 print
'<div class="tabsAction">'.
"\n";
911 if ($action !=
'create_price' && $action !=
'edit_price') {
912 $parameters = array();
913 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
914 if (empty($reshook)) {
915 if ($usercancreate) {
916 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/product/price_suppliers.php?id='.((int)
$object->id).
'&action=create_price&token='.
newToken().
'">';
917 print $langs->trans(
"AddSupplierPrice").
'</a>';
924 if ($user->hasRight(
"fournisseur",
"read")) {
926 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
927 $param .=
'&contextpage='.urlencode($contextpage);
929 if ($limit > 0 && $limit != $conf->liste_limit) {
930 $param .=
'&limit='.((int) $limit);
932 $param .=
'&ref='.urlencode(
$object->ref);
935 $product_fourn_list = $product_fourn->list_product_fournisseur_price(
$object->id, $sortfield, $sortorder, $limit, $offset);
936 $product_fourn_list_all = $product_fourn->list_product_fournisseur_price(
$object->id, $sortfield, $sortorder, 0, 0);
937 $nbtotalofrecords = count($product_fourn_list_all);
938 $num = count($product_fourn_list);
939 if (($num + ($offset * $limit)) < $nbtotalofrecords) {
943 print_barre_liste($langs->trans(
'SupplierPrices'), $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_accountancy.png', 0,
'',
'', $limit, 1);
947 $arrayfields = array(
948 'pfp.datec'=>array(
'label'=>$langs->trans(
"AppliedPricesFrom"),
'checked'=>1,
'position'=>1),
949 's.nom'=>array(
'label'=>$langs->trans(
"Suppliers"),
'checked'=>1,
'position'=>2),
950 'pfp.fk_availability'=>array(
'label'=>$langs->trans(
"Availability"),
'enabled' =>
getDolGlobalInt(
'FOURN_PRODUCT_AVAILABILITY'),
'checked'=>0,
'position'=>4),
951 'pfp.quantity'=>array(
'label'=>$langs->trans(
"QtyMin"),
'checked'=>1,
'position'=>5),
952 'pfp.unitprice'=>array(
'label'=>$langs->trans(
"UnitPriceHT"),
'checked'=>1,
'position'=>9),
953 'pfp.multicurrency_unitprice'=>array(
'label'=>$langs->trans(
"UnitPriceHTCurrency"),
'enabled' => isModEnabled(
'multicurrency'),
'checked'=>0,
'position'=>10),
954 'pfp.charges'=>array(
'label'=>$langs->trans(
"Charges"),
'enabled' =>
getDolGlobalString(
'PRODUCT_CHARGES'),
'checked'=>0,
'position'=>11),
955 'pfp.delivery_time_days'=>array(
'label'=>$langs->trans(
"NbDaysToDelivery"),
'checked'=>-1,
'position'=>13),
956 'pfp.supplier_reputation'=>array(
'label'=>$langs->trans(
"ReputationForThisProduct"),
'checked'=>-1,
'position'=>14),
957 'pfp.fk_barcode_type'=>array(
'label'=>$langs->trans(
"BarcodeType"),
'enabled' => isModEnabled(
'barcode'),
'checked'=>0,
'position'=>15),
958 'pfp.barcode'=>array(
'label'=>$langs->trans(
"BarcodeValue"),
'enabled' => isModEnabled(
'barcode'),
'checked'=>0,
'position'=>16),
959 'pfp.packaging'=>array(
'label'=>$langs->trans(
"PackagingForThisProduct"),
'enabled' =>
getDolGlobalInt(
'PRODUCT_USE_SUPPLIER_PACKAGING'),
'checked'=>0,
'position'=>17),
960 'pfp.status'=>array(
'label'=>$langs->trans(
"Status"),
'enabled' => 1,
'checked'=>0,
'position'=>40),
961 'pfp.tms'=>array(
'label'=>$langs->trans(
"DateModification"),
'enabled' => isModEnabled(
'barcode'),
'checked'=>1,
'position'=>50),
962 'pfp.price'=>array(
'label'=>$langs->trans(
"PriceQtyMinHT"),
'checked'=>1,
'position'=>60),
963 'pfp.multicurrency_price'=>array(
'label'=>$langs->trans(
"PriceQtyMinHTCurrency"),
'enabled' => isModEnabled(
'multicurrency'),
'checked'=>1,
'position'=>70),
968 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
969 if ($extrafields->attributes[
"product_fournisseur_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_fournisseur_price"])) {
970 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
972 if (!empty($extralabels)) {
973 foreach ($extralabels as $key => $value) {
975 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
976 $extratitle = $langs->trans($value);
977 $arrayfields[
'ef.' . $key] = array(
'label' => $extratitle,
'checked' => 0,
978 'position' => (end($arrayfields)[
'position'] + 1),
979 'langfile' => $extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key],
980 'help' => $extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]);
987 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
989 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
990 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
992 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" name="formulaire">';
993 print
'<input type="hidden" name="token" value="'.newToken().
'">';
994 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
995 print
'<input type="hidden" name="action" value="list">';
996 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
997 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1000 print
'<!-- List of supplier prices -->'.
"\n";
1001 print
'<div class="div-table-responsive">';
1002 print
'<table class="liste centpercent noborder">';
1004 $param =
"&id=".$object->id;
1008 print
'<tr class="liste_titre">';
1012 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch actioncolumn ');
1015 if (!empty($arrayfields[
'pfp.datec'][
'checked'])) {
1016 print_liste_field_titre(
"AppliedPricesFrom", $_SERVER[
"PHP_SELF"],
"pfp.datec",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1019 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1020 print_liste_field_titre(
"Suppliers", $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1023 print_liste_field_titre(
"SupplierRef", $_SERVER[
"PHP_SELF"],
"",
"", $param,
"", $sortfield, $sortorder,
'',
'', 1);
1025 if (!empty($arrayfields[
'pfp.fk_availability'][
'checked'])) {
1026 print_liste_field_titre(
"Availability", $_SERVER[
"PHP_SELF"],
"pfp.fk_availability",
"", $param,
"", $sortfield, $sortorder);
1029 if (!empty($arrayfields[
'pfp.quantity'][
'checked'])) {
1030 print_liste_field_titre(
"QtyMin", $_SERVER[
"PHP_SELF"],
"pfp.quantity",
"", $param,
'', $sortfield, $sortorder,
'right ');
1033 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1035 if (!empty($arrayfields[
'pfp.price'][
'checked'])) {
1036 print_liste_field_titre(
"PriceQtyMinHT", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1039 if (isModEnabled(
"multicurrency") && !empty($arrayfields[
'pfp.multicurrency_price'][
'checked'])) {
1040 print_liste_field_titre(
"PriceQtyMinHTCurrency", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1043 if (!empty($arrayfields[
'pfp.unitprice'][
'checked'])) {
1044 print_liste_field_titre(
"UnitPriceHT", $_SERVER[
"PHP_SELF"],
"pfp.unitprice",
"", $param,
'', $sortfield, $sortorder,
'right ');
1047 if (!empty($arrayfields[
'pfp.multicurrency_unitprice'][
'checked'])) {
1048 print_liste_field_titre(
"UnitPriceHTCurrency", $_SERVER[
"PHP_SELF"],
"pfp.multicurrency_unitprice",
"", $param,
'', $sortfield, $sortorder,
'right ');
1051 if (isModEnabled(
"multicurrency")) {
1052 print_liste_field_titre(
"Currency", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1055 if (!empty($arrayfields[
'pfp.charges'][
'checked'])) {
1056 print_liste_field_titre(
"Charges", $_SERVER[
"PHP_SELF"],
"pfp.charges",
"", $param,
'', $sortfield, $sortorder,
'right ');
1059 print_liste_field_titre(
"DiscountQtyMin", $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1061 if (!empty($arrayfields[
'pfp.delivery_time_days'][
'checked'])) {
1062 print_liste_field_titre(
"NbDaysToDelivery", $_SERVER[
"PHP_SELF"],
"pfp.delivery_time_days",
"", $param,
'', $sortfield, $sortorder,
'right ');
1065 if (!empty($arrayfields[
'pfp.supplier_reputation'][
'checked'])) {
1066 print_liste_field_titre(
"ReputationForThisProduct", $_SERVER[
"PHP_SELF"],
"pfp.supplier_reputation",
"", $param,
'', $sortfield, $sortorder,
'center ');
1069 if (!empty($arrayfields[
'pfp.fk_barcode_type'][
'checked'])) {
1070 print_liste_field_titre(
"BarcodeType", $_SERVER[
"PHP_SELF"],
"pfp.fk_barcode_type",
"", $param,
'', $sortfield, $sortorder,
'center ');
1073 if (!empty($arrayfields[
'pfp.barcode'][
'checked'])) {
1074 print_liste_field_titre(
"BarcodeValue", $_SERVER[
"PHP_SELF"],
"pfp.barcode",
"", $param,
'', $sortfield, $sortorder,
'center ');
1077 if (!empty($arrayfields[
'pfp.packaging'][
'checked'])) {
1078 print_liste_field_titre(
"PackagingForThisProduct", $_SERVER[
"PHP_SELF"],
"pfp.packaging",
"", $param,
'', $sortfield, $sortorder,
'center ');
1081 if (!empty($arrayfields[
'pfp.status'][
'checked'])) {
1082 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"pfp.status",
"", $param,
'', $sortfield, $sortorder,
'center ',
'', 1);
1085 if (!empty($arrayfields[
'pfp.tms'][
'checked'])) {
1086 print_liste_field_titre(
"DateModification", $_SERVER[
"PHP_SELF"],
"pfp.tms",
"", $param,
'', $sortfield, $sortorder,
'right ',
'', 1);
1091 $extrafields->fetch_name_optionals_label(
"product_fournisseur_price");
1092 if ($extrafields->attributes[
"product_fournisseur_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_fournisseur_price"])) {
1093 $extralabels = $extrafields->attributes[
"product_fournisseur_price"][
'label'];
1095 if (!empty($extralabels)) {
1096 foreach ($extralabels as $key => $value) {
1098 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
1099 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key])) {
1100 $langs->load($extrafields->attributes[
"product_fournisseur_price"][
'langfile'][$key]);
1102 if (!empty($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key])) {
1103 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_fournisseur_price"][
'help'][$key]));
1105 $extratitle = $langs->trans($value);
1107 if (!empty($arrayfields[
'ef.' . $key][
'checked'])) {
1108 print_liste_field_titre($extratitle, $_SERVER[
"PHP_SELF"],
'ef.' . $key,
'', $param,
'', $sortfield, $sortorder,
'right ');
1116 if (is_object($hookmanager)) {
1117 $parameters = array(
'id_fourn'=>(!empty($id_fourn) ? $id_fourn :
''),
'prod_id'=>
$object->id,
'nbfields'=>$nbfields);
1118 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1121 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1126 if (is_array($product_fourn_list)) {
1127 foreach ($product_fourn_list as $productfourn) {
1128 print
'<tr class="oddeven">';
1132 print
'<td class="center nowraponall">';
1133 if ($usercancreate) {
1134 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>";
1136 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>';
1143 if (!empty($arrayfields[
'pfp.datec'][
'checked'])) {
1144 print
'<td>'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation),
'dayhour',
'tzuserrel').
'</td>';
1148 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1149 print
'<td class="tdoverflowmax150">'.$productfourn->getSocNomUrl(1,
'supplier').
'</td>';
1153 if ($usercancreate) {
1154 print
'<td class="tdoverflowmax150">'.$productfourn->getNomUrl().
'</td>';
1156 print
'<td class="tdoverflowmax150">'.dol_escape_htmltag($productfourn->fourn_ref).
'</td>';
1160 if (!empty($arrayfields[
'pfp.fk_availability'][
'checked'])) {
1161 $form->load_cache_availability();
1162 $availability = $form->cache_availability[$productfourn->fk_availability][
'label'];
1163 print
'<td class="left">'.$availability.
'</td>';
1167 if (!empty($arrayfields[
'pfp.quantity'][
'checked'])) {
1168 print
'<td class="right">';
1169 print $productfourn->fourn_qty;
1172 $unit =
$object->getLabelOfUnit();
1174 print
' '.$langs->trans($unit);
1181 print
'<td class="right">';
1182 print
vatrate($productfourn->fourn_tva_tx,
true);
1186 if (!empty($arrayfields[
'pfp.price'][
'checked'])) {
1187 print
'<td class="right">';
1188 print $productfourn->fourn_price ?
'<span class="amount">'.price($productfourn->fourn_price).
'</span>' :
"";
1192 if (isModEnabled(
"multicurrency") && !empty($arrayfields[
'pfp.multicurrency_price'][
'checked'])) {
1194 print
'<td class="right">';
1195 print $productfourn->fourn_multicurrency_price ?
'<span class="amount">'.price($productfourn->fourn_multicurrency_price).
'</span>' :
"";
1200 if (!empty($arrayfields[
'pfp.unitprice'][
'checked'])) {
1201 print
'<td class="right">';
1202 print
price($productfourn->fourn_unitprice);
1208 if (!empty($arrayfields[
'pfp.multicurrency_unitprice'][
'checked'])) {
1209 print
'<td class="right">';
1210 print
price($productfourn->fourn_multicurrency_unitprice);
1215 if (isModEnabled(
"multicurrency")) {
1216 print
'<td class="right nowraponall">';
1217 print $productfourn->fourn_multicurrency_code ?
currency_name($productfourn->fourn_multicurrency_code) :
'';
1222 if (!empty($arrayfields[
'pfp.charges'][
'checked'])) {
1223 print
'<td class="right">';
1224 print
price($productfourn->fourn_charges);
1229 print
'<td class="right">';
1230 print
price2num($productfourn->fourn_remise_percent).
'%';
1234 if (!empty($arrayfields[
'pfp.delivery_time_days'][
'checked'])) {
1235 print
'<td class="right">';
1236 print $productfourn->delivery_time_days;
1241 if (!empty($arrayfields[
'pfp.supplier_reputation'][
'checked'])) {
1242 print
'<td class="center">';
1243 if (!empty($productfourn->supplier_reputation) && !empty(
$object->reputations[$productfourn->supplier_reputation])) {
1244 print
$object->reputations[$productfourn->supplier_reputation];
1250 if (!empty($arrayfields[
'pfp.fk_barcode_type'][
'checked'])) {
1251 print
'<td class="center">';
1252 $productfourn->barcode_type = !empty($productfourn->supplier_fk_barcode_type) ? $productfourn->supplier_fk_barcode_type : 0;
1253 $productfourn->fetch_barcode();
1254 print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->supplier_barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
1259 if (!empty($arrayfields[
'pfp.barcode'][
'checked'])) {
1260 print
'<td class="right">';
1261 print $productfourn->supplier_barcode;
1266 if (!empty($arrayfields[
'pfp.packaging'][
'checked'])) {
1267 print
'<td class="center">';
1268 print
price2num($productfourn->packaging);
1273 if (!empty($arrayfields[
'pfp.status'][
'checked'])) {
1274 print
'<td class="center">';
1275 print $productfourn->getLibStatut(3);
1280 if (!empty($arrayfields[
'pfp.tms'][
'checked'])) {
1281 print
'<td class="right nowraponall">';
1282 print
dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification),
"dayhour",
"tzuserrel");
1287 if (!empty($extralabels)) {
1289 $sql .=
" fk_object";
1290 foreach ($extralabels as $key => $value) {
1293 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_extrafields";
1294 $sql .=
" WHERE fk_object = ".((int) $productfourn->product_fourn_price_id);
1295 $resql = $db->query($sql);
1297 if ($db->num_rows($resql) != 1) {
1298 foreach ($extralabels as $key => $value) {
1299 if (!empty($arrayfields[
'ef.'.$key][
'checked']) && !empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
1304 $obj = $db->fetch_object($resql);
1305 foreach ($extralabels as $key => $value) {
1306 if (!empty($arrayfields[
'ef.'.$key][
'checked']) && !empty($extrafields->attributes[
"product_fournisseur_price"][
'list'][$key]) && $extrafields->attributes[
"product_fournisseur_price"][
'list'][$key] != 3) {
1307 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_fournisseur_price').
"</td>";
1315 if (is_object($hookmanager)) {
1316 $parameters = array(
'id_pfp'=>$productfourn->product_fourn_price_id,
'id_fourn'=>(!empty($id_fourn) ? $id_fourn :
''),
'prod_id'=>
$object->id);
1317 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1322 print
'<td class="center nowraponall">';
1323 if ($usercancreate) {
1324 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>";
1326 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>';
1335 if (empty($product_fourn_list)) {
1336 print
'<tr><td colspan="'.$nbfields.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1349 print $langs->trans(
"ErrorUnknown");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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)
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.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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_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...
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.