33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/class/productfournisseurprice.class.php';
52 public $TRIGGER_PREFIX =
'PRODUCT';
62 public $product_fourn_price_id;
79 public $delivery_time_days;
89 public $desc_supplier;
94 public $vatrate_supplier;
141 public $fourn_remise_percent;
146 public $fourn_remise;
151 public $fourn_charges;
159 public $product_fourn_id;
164 public $product_fourn_entity;
169 public $product_fourn_packaging;
180 public $fk_availability;
185 public $fourn_unitprice;
189 public $fourn_unitprice_with_discount;
193 public $fourn_tva_tx;
197 public $fourn_tva_npr;
202 public $fk_supplier_price_expression;
207 public $supplier_reputation;
212 public $reputations = array();
219 public $fourn_multicurrency_id;
224 public $fourn_multicurrency_code;
228 public $fourn_multicurrency_tx;
232 public $fourn_multicurrency_price;
236 public $fourn_multicurrency_unitprice;
243 public $fourn_barcode;
248 public $supplier_barcode;
255 public $fourn_fk_barcode_type;
260 public $supplier_fk_barcode_type;
265 public $labelStatusShort;
271 const STATUS_OPEN = 1;
272 const STATUS_CANCELED = 0;
285 $langs->load(
"suppliers");
286 $this->reputations = array(
'-1' =>
'',
'FAVORITE' => $langs->trans(
'Favorite'),
'NOTTHGOOD' => $langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER' => $langs->trans(
'DoNotOrderThisProductToThisSupplier'));
303 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
304 $sql .=
" WHERE fk_product = ".((int) $this->
id).
" AND fk_soc = ".((int) $id_fourn);
306 dol_syslog(get_class($this).
"::remove_fournisseur", LOG_DEBUG);
307 $resql2 = $this->db->query($sql);
309 $this->error = $this->db->lasterror();
317 $this->db->rollback();
340 $result = $this->call_trigger(
'PRODUCT_BUYPRICE_DELETE', $user);
347 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
348 $sql .=
" WHERE rowid = ".((int) $rowid);
350 dol_syslog(get_class($this).
"::remove_product_fournisseur_price", LOG_DEBUG);
351 $resql = $this->db->query($sql);
353 $this->error = $this->db->lasterror();
362 $this->db->rollback();
411 $delivery_time_days = 0,
412 $supplier_reputation =
'',
413 $localtaxes_array = array(),
414 $newdefaultvatcode =
'',
415 $multicurrency_buyprice = 0,
416 $multicurrency_price_base_type =
'HT',
417 $multicurrency_tx = 1,
418 $multicurrency_code =
'',
421 $fk_barcode_type = 0,
432 if (empty($buyprice)) {
435 if (empty($charges)) {
438 if (empty($availability)) {
441 if (empty($remise_percent)) {
444 if (empty($supplier_reputation) || $supplier_reputation == -1) {
445 $supplier_reputation =
'';
447 if ($delivery_time_days !=
'' && !is_numeric($delivery_time_days)) {
448 $delivery_time_days = 0;
450 if ($price_base_type ==
'TTC') {
452 $buyprice /= (1 + ($ttx / 100));
456 $multicurrency_unitBuyPrice =
null;
457 $fk_multicurrency =
null;
459 if (empty($multicurrency_tx)) {
460 $multicurrency_tx = 1;
462 if (empty($multicurrency_buyprice)) {
463 $multicurrency_buyprice = 0;
465 if ($multicurrency_price_base_type ==
'TTC') {
467 $multicurrency_buyprice /= (1 + ($ttx / 100));
469 $multicurrency_buyprice = (float)
price2num($multicurrency_buyprice,
'MU');
470 $multicurrency_unitBuyPrice = (float)
price2num((
float) $multicurrency_buyprice / $qty,
'MU');
472 $buyprice = (float) $multicurrency_buyprice / $multicurrency_tx;
476 $buyprice = (float)
price2num($buyprice,
'MU');
477 $charges = (float)
price2num($charges,
'MU');
479 $unitBuyPrice = (float)
price2num($buyprice / $qty,
'MU');
482 $packaging =
price2num((empty($this->product_fourn_packaging) ? $qty : $this->product_fourn_packaging),
'MS');
489 if (count($localtaxes_array) > 0) {
490 $localtaxtype1 = $localtaxes_array[
'0'];
491 $localtax1 = $localtaxes_array[
'1'];
492 $localtaxtype2 = $localtaxes_array[
'2'];
493 $localtax2 = $localtaxes_array[
'3'];
495 $localtaxtype1 =
'0';
497 $localtaxtype2 =
'0';
500 if (empty($localtax1)) {
503 if (empty($localtax2)) {
509 if ($this->product_fourn_price_id > 0) {
512 if (is_array($logPrices) && count($logPrices) == 0) {
513 $currentPfp =
new self($this->db);
514 $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id);
515 if ($result > 0 && $currentPfp->fourn_price != 0) {
516 $currentPfpUser =
new User($this->db);
517 $result = $currentPfpUser->fetch($currentPfp->user_id);
519 $currentPfp->logPrice(
521 $currentPfp->date_creation,
522 (
float) $currentPfp->fourn_price,
523 $currentPfp->fourn_qty,
524 $currentPfp->fourn_multicurrency_price,
525 $currentPfp->fourn_multicurrency_unitprice,
526 $currentPfp->fourn_multicurrency_tx,
527 $currentPfp->fourn_multicurrency_id,
528 $currentPfp->fourn_multicurrency_code
533 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
534 $sql .=
" SET fk_user = ".((int) $user->id).
" ,";
535 $sql .=
" datec = '".$this->db->idate($now).
"' ,";
536 $sql .=
" ref_fourn = '".$this->db->escape($ref_fourn).
"',";
537 $sql .=
" desc_fourn = '".$this->db->escape($desc_fourn).
"',";
538 $sql .=
" price = ".((float) $buyprice).
",";
539 $sql .=
" quantity = ".((float) $qty).
",";
540 $sql .=
" remise_percent = ".((float) $remise_percent).
",";
541 $sql .=
" remise = ".((float) $remise).
",";
542 $sql .=
" unitprice = ".((float) $unitBuyPrice).
",";
543 $sql .=
" fk_availability = ".((int) $availability).
",";
544 $sql .=
" multicurrency_price = ".(isset($multicurrency_buyprice) ?
"'".$this->db->escape(
price2num($multicurrency_buyprice)).
"'" :
'null').
",";
545 $sql .=
" multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ?
"'".$this->db->escape(
price2num($multicurrency_unitBuyPrice)).
"'" :
'null').
",";
546 $sql .=
" multicurrency_tx = ".(isset($multicurrency_tx) ?
"'".$this->db->escape((
string) $multicurrency_tx).
"'" :
'1').
",";
547 $sql .=
" fk_multicurrency = ".(isset($fk_multicurrency) ? (int) $fk_multicurrency :
'null').
",";
548 $sql .=
" multicurrency_code = ".(isset($multicurrency_code) ?
"'".$this->db->escape($multicurrency_code).
"'" :
'null').
",";
549 $sql .=
" entity = ".((int) $conf->entity).
",";
550 $sql .=
" tva_tx = ".((float)
price2num($tva_tx)).
",";
556 $sql .=
" default_vat_code = ".($newdefaultvatcode ?
"'".$this->db->escape($newdefaultvatcode).
"'" :
"null").
",";
557 $sql .=
" info_bits = ".((int) $newnpr).
",";
558 $sql .=
" charges = ".((float) $charges).
",";
559 $sql .=
" delivery_time_days = ".($delivery_time_days !=
'' ? ((int) $delivery_time_days) :
'null').
",";
560 $sql .=
" supplier_reputation = ".(empty($supplier_reputation) ?
'NULL' :
"'".$this->db->escape($supplier_reputation).
"'").
",";
561 $sql .=
" barcode = ".(empty($barcode) ?
'NULL' :
"'".$this->db->escape($barcode).
"'").
",";
562 $sql .=
" fk_barcode_type = ".(empty($fk_barcode_type) ?
'NULL' :
"'".$this->db->escape((
string) $fk_barcode_type).
"'");
564 $sql .=
", packaging = ".(empty($packaging) ? 1 : $packaging);
566 $sql .=
" WHERE rowid = ".((int) $this->product_fourn_price_id);
569 if (!empty($options) && is_array($options)) {
571 $res = $productfournisseurprice->fetch($this->product_fourn_price_id);
573 foreach ($options as $key => $value) {
574 $productfournisseurprice->array_options[$key] = $value;
576 $res = $productfournisseurprice->update($user);
587 dol_syslog(get_class($this).
'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG);
588 $resql = $this->db->query($sql);
591 $result = $this->call_trigger(
'PRODUCT_BUYPRICE_MODIFY', $user);
597 $result = $this->
logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, (
float) $multicurrency_unitBuyPrice, $multicurrency_tx, (
int) $fk_multicurrency, $multicurrency_code);
604 return $this->product_fourn_price_id;
606 $this->db->rollback();
610 $this->error = $this->db->error().
" sql=".$sql;
611 $this->db->rollback();
615 dol_syslog(get_class($this).
'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG);
618 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
619 $sql .=
" WHERE fk_soc = ".((int) $fourn->id).
" AND ref_fourn = '".$this->db->escape($ref_fourn).
"' AND quantity = ".((float) $qty).
" AND entity = ".((int) $conf->entity);
620 $resql = $this->db->query($sql);
623 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_fournisseur_price(";
624 $sql .=
" multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
625 $sql .=
"datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type";
627 $sql .=
", packaging";
630 $sql .= (isset($multicurrency_buyprice) ?
"'".$this->db->escape(
price2num($multicurrency_buyprice)).
"'" :
'null').
",";
631 $sql .= (isset($multicurrency_unitBuyPrice) ?
"'".$this->db->escape(
price2num($multicurrency_unitBuyPrice)).
"'" :
'null').
",";
632 $sql .= (isset($multicurrency_tx) ?
"'".$this->db->escape((
string) $multicurrency_tx).
"'" :
'1').
",";
633 $sql .= (isset($fk_multicurrency) ?
"'".$this->db->escape((
string) $fk_multicurrency).
"'" :
'null').
",";
634 $sql .= (isset($multicurrency_code) ?
"'".$this->db->escape($multicurrency_code).
"'" :
'null').
",";
635 $sql .=
" '".$this->db->idate($now).
"',";
636 $sql .=
" ".((int) $this->
id).
",";
637 $sql .=
" ".((int) $fourn->id).
",";
638 $sql .=
" '".$this->db->escape($ref_fourn).
"',";
639 $sql .=
" '".$this->db->escape($desc_fourn).
"',";
640 $sql .=
" ".((int) $user->id).
",";
641 $sql .=
" ".price2num($buyprice).
",";
642 $sql .=
" ".((float) $qty).
",";
643 $sql .=
" ".((float) $remise_percent).
",";
644 $sql .=
" ".((float) $remise).
",";
645 $sql .=
" ".price2num($unitBuyPrice).
",";
646 $sql .=
" ".price2num($tva_tx).
",";
647 $sql .=
" ".price2num($charges).
",";
648 $sql .=
" ".((int) $availability).
",";
649 $sql .=
" ".($newdefaultvatcode ?
"'".$this->db->escape($newdefaultvatcode).
"'" :
"null").
",";
650 $sql .=
" ".((int) $newnpr).
",";
651 $sql .= $conf->entity.
",";
652 $sql .= ($delivery_time_days !=
'' ? ((int) $delivery_time_days) :
'null').
",";
653 $sql .= (empty($supplier_reputation) ?
'NULL' :
"'".$this->db->escape($supplier_reputation).
"'").
",";
654 $sql .= (empty($barcode) ?
'NULL' :
"'".$this->db->escape($barcode).
"'").
",";
655 $sql .= (empty($fk_barcode_type) ?
'NULL' :
"'".$this->db->escape((
string) $fk_barcode_type).
"'");
657 $sql .=
", ".(empty($this->packaging) ?
'1' :
"'".$this->db->escape((
string) $this->packaging).
"'");
661 $this->product_fourn_price_id = 0;
663 $resql = $this->db->query($sql);
665 $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"product_fournisseur_price");
667 $this->error = $this->db->lasterror();
672 if (!empty($options) && is_array($options)) {
674 $res = $productfournisseurprice->fetch($this->product_fourn_price_id);
676 foreach ($options as $key => $value) {
677 $productfournisseurprice->array_options[$key] = $value;
679 $res = $productfournisseurprice->update($user);
681 $this->error = $productfournisseurprice->error;
682 $this->errors = $productfournisseurprice->errors;
692 $result = $this->
logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, (
float) $multicurrency_unitBuyPrice, $multicurrency_tx, (
int) $fk_multicurrency, $multicurrency_code);
700 $result = $this->call_trigger(
'PRODUCT_BUYPRICE_CREATE', $user);
708 return $this->product_fourn_price_id;
710 $this->db->rollback();
714 $this->error = $this->db->lasterror().
" sql=".$sql;
715 $this->db->rollback();
719 $this->error = $this->db->lasterror().
" sql=".$sql;
720 $this->db->rollback();
737 $sql =
"SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,";
738 $sql .=
" pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
739 $sql .=
" pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
740 $sql .=
" pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
741 $sql .=
" pfp.barcode, pfp.fk_barcode_type, pfp.packaging,";
742 $sql .=
" p.ref as product_ref, p.tosell as status, p.tobuy as status_buy";
743 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp, ".MAIN_DB_PREFIX.
"product as p";
744 $sql .=
" WHERE pfp.rowid = ".(int) $rowid;
745 $sql .=
" AND pfp.fk_product = p.rowid";
747 dol_syslog(get_class($this).
"::fetch_product_fournisseur_price", LOG_DEBUG);
748 $resql = $this->db->query($sql);
750 $obj = $this->db->fetch_object($resql);
752 $this->product_fourn_price_id = $rowid;
753 $this->
id = $obj->fk_product;
755 $this->fk_product = $obj->fk_product;
756 $this->product_id = $obj->fk_product;
757 $this->product_ref = $obj->product_ref;
758 $this->
status = $obj->status;
759 $this->status_buy = $obj->status_buy;
760 $this->fourn_id = $obj->fk_soc;
761 $this->fourn_ref = $obj->ref_fourn;
762 $this->ref_supplier = $obj->ref_fourn;
763 $this->desc_supplier = $obj->desc_fourn;
764 $this->fourn_price = $obj->price;
765 $this->fourn_charges = $obj->charges;
766 $this->fourn_qty = $obj->quantity;
767 $this->fourn_remise_percent = $obj->remise_percent;
768 $this->fourn_remise = $obj->remise;
769 $this->fourn_unitprice = $obj->unitprice;
770 $this->fourn_tva_tx = $obj->tva_tx;
771 $this->fourn_tva_npr = $obj->fourn_tva_npr;
773 $this->fk_availability = $obj->fk_availability;
774 $this->delivery_time_days = $obj->delivery_time_days;
775 $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
776 $this->supplier_reputation = $obj->supplier_reputation;
777 $this->default_vat_code = $obj->default_vat_code;
778 $this->user_id = $obj->fk_user;
779 $this->date_creation = $this->db->jdate($obj->datec);
780 $this->fourn_multicurrency_price = $obj->multicurrency_price;
781 $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice;
782 $this->fourn_multicurrency_tx = $obj->multicurrency_tx;
783 $this->fourn_multicurrency_id = $obj->fk_multicurrency;
784 $this->fourn_multicurrency_code = $obj->multicurrency_code;
786 $this->fourn_barcode = $obj->barcode;
787 $this->fourn_fk_barcode_type = $obj->fk_barcode_type;
788 $this->supplier_barcode = $obj->barcode;
789 $this->supplier_fk_barcode_type = $obj->fk_barcode_type;
791 $this->packaging = (float) $obj->packaging;
793 if (
isModEnabled(
'dynamicprices') && empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) {
794 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
796 $price_result = $priceparser->parseProductSupplier($this);
797 if ($price_result >= 0) {
798 $this->fourn_price = $price_result;
800 if ($this->fourn_qty != 0) {
801 $this->fourn_unitprice =
price2num($this->fourn_price / $this->fourn_qty,
'MU');
803 $this->fourn_unitprice =
"";
813 $this->error = $this->db->lasterror();
835 $sql =
"SELECT s.nom as supplier_name, s.rowid as fourn_id, p.ref as product_ref, p.tosell as status, p.tobuy as status_buy, p.fk_unit as product_fk_unit, ";
836 $sql .=
" pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
837 $sql .=
" pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
838 $sql .=
" pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
839 $sql .=
" pfp.barcode, pfp.fk_barcode_type, pfp.packaging, pfp.status as pfstatus";
840 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp, ".MAIN_DB_PREFIX.
"product as p, ".MAIN_DB_PREFIX.
"societe as s";
841 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productsupplierprice').
")";
842 $sql .=
" AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid";
843 $sql .= ($socid > 0 ?
' AND pfp.fk_soc = '.((int) $socid) :
'');
844 $sql .=
" AND s.status = 1";
845 $sql .=
" AND pfp.fk_product = ".((int) $prodid);
846 if (empty($sortfield)) {
847 $sql .=
" ORDER BY s.nom, pfp.quantity, pfp.price";
849 $sql .= $this->db->order($sortfield, $sortorder);
851 $sql .= $this->db->plimit($limit, $offset);
852 dol_syslog(get_class($this).
"::list_product_fournisseur_price", LOG_DEBUG);
854 $resql = $this->db->query($sql);
858 while ($record = $this->db->fetch_array($resql)) {
862 $prodfourn->product_ref = $record[
"product_ref"];
863 $prodfourn->product_fourn_price_id = $record[
"product_fourn_pri_id"];
864 $prodfourn->status = $record[
"status"];
865 $prodfourn->status_buy = $record[
"status_buy"];
866 $prodfourn->product_fourn_id = $record[
"product_fourn_id"];
867 $prodfourn->product_fourn_entity = $record[
"entity"];
868 $prodfourn->ref_supplier = $record[
"ref_fourn"];
869 $prodfourn->fourn_ref = $record[
"ref_fourn"];
870 $prodfourn->desc_supplier = $record[
"desc_fourn"];
871 $prodfourn->fourn_price = $record[
"price"];
872 $prodfourn->fourn_qty = $record[
"quantity"];
873 $prodfourn->fourn_remise_percent = $record[
"remise_percent"];
874 $prodfourn->fourn_remise = $record[
"remise"];
875 $prodfourn->fourn_unitprice = $record[
"unitprice"];
876 $prodfourn->fourn_charges = $record[
"charges"];
877 $prodfourn->fourn_tva_tx = $record[
"tva_tx"];
878 $prodfourn->fourn_id = $record[
"fourn_id"];
879 $prodfourn->fourn_name = $record[
"supplier_name"];
880 $prodfourn->fk_availability = $record[
"fk_availability"];
881 $prodfourn->delivery_time_days = $record[
"delivery_time_days"];
882 $prodfourn->id = $prodid;
883 $prodfourn->fourn_tva_npr = $record[
"info_bits"];
884 $prodfourn->fk_supplier_price_expression = $record[
"fk_supplier_price_expression"];
885 $prodfourn->supplier_reputation = $record[
"supplier_reputation"];
886 $prodfourn->fourn_date_creation = $this->db->jdate($record[
'datec']);
887 $prodfourn->fourn_date_modification = $this->db->jdate($record[
'tms']);
892 $prodfourn->fk_unit = $record[
"product_fk_unit"];
894 $prodfourn->fourn_multicurrency_price = $record[
"multicurrency_price"];
895 $prodfourn->fourn_multicurrency_unitprice = $record[
"multicurrency_unitprice"];
896 $prodfourn->fourn_multicurrency_tx = $record[
"multicurrency_tx"];
897 $prodfourn->fourn_multicurrency_id = $record[
"fk_multicurrency"];
898 $prodfourn->fourn_multicurrency_code = $record[
"multicurrency_code"];
900 $prodfourn->packaging = (float) $record[
"packaging"];
901 $prodfourn->status = $record[
"pfstatus"];
904 $prodfourn->supplier_barcode = $record[
"barcode"];
905 $prodfourn->supplier_fk_barcode_type = $record[
"fk_barcode_type"];
908 if (
isModEnabled(
'dynamicprices') && !empty($prodfourn->fk_supplier_price_expression)) {
909 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
911 $price_result = $priceparser->parseProductSupplier($prodfourn);
912 if ($price_result >= 0) {
913 $prodfourn->fourn_price = $price_result;
915 $prodfourn->fourn_unitprice =
null;
919 if (!isset($prodfourn->fourn_unitprice)) {
920 if ($prodfourn->fourn_qty != 0) {
921 $prodfourn->fourn_unitprice =
price2num($prodfourn->fourn_price / $prodfourn->fourn_qty,
'MU');
923 $prodfourn->fourn_unitprice =
"";
927 $retarray[] = $prodfourn;
930 $this->db->free($resql);
933 $this->error = $this->db->error();
951 if (empty($prodid)) {
952 dol_syslog(
"Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING);
956 $this->product_fourn_price_id = 0;
957 $this->product_fourn_id = 0;
958 $this->fourn_ref =
'';
959 $this->fourn_price = 0;
960 $this->fourn_qty = 0;
961 $this->fourn_remise_percent = 0;
962 $this->fourn_remise = 0;
963 $this->fourn_unitprice = 0;
965 $this->fourn_name =
'';
966 $this->delivery_time_days = 0;
969 $this->fourn_multicurrency_price = 0;
970 $this->fourn_multicurrency_unitprice = 0;
971 $this->fourn_multicurrency_tx = 0;
972 $this->fourn_multicurrency_id = 0;
973 $this->fourn_multicurrency_code =
'';
975 $sql =
"SELECT s.nom as supplier_name, s.rowid as fourn_id,";
976 $sql .=
" pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
977 $sql .=
" pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
978 $sql .=
" pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
979 $sql .=
" pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
980 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp";
981 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
982 $sql .=
" AND pfp.entity IN (".getEntity(
'productsupplierprice').
")";
983 $sql .=
" AND pfp.fk_product = ".((int) $prodid);
984 $sql .=
" AND pfp.fk_soc = s.rowid";
985 $sql .=
" AND s.status = 1";
987 $sql .=
" AND pfp.quantity <= ".((float) $qty);
990 $sql .=
' AND pfp.fk_soc = '.((int) $socid);
993 dol_syslog(get_class($this).
"::find_min_price_product_fournisseur", LOG_DEBUG);
995 $resql = $this->db->query($sql);
997 $record_array = array();
1000 while ($record = $this->db->fetch_array($resql)) {
1001 $record_array[] = $record;
1004 if (count($record_array) == 0) {
1005 $this->db->free($resql);
1009 foreach ($record_array as $record) {
1010 $fourn_price = $record[
"price"];
1012 $fourn_unitprice = $record[
"unitprice"];
1013 $fourn_unitprice_with_discount = $record[
"unitprice"] * (1 - $record[
"remise_percent"] / 100);
1015 if (
isModEnabled(
'dynamicprices') && !empty($record[
"fk_supplier_price_expression"])) {
1017 $prod_supplier->product_fourn_price_id = $record[
"product_fourn_price_id"];
1018 $prod_supplier->id = $prodid;
1019 $prod_supplier->fourn_qty = $record[
"quantity"];
1020 $prod_supplier->fourn_tva_tx = $record[
"tva_tx"];
1021 $prod_supplier->fk_supplier_price_expression = $record[
"fk_supplier_price_expression"];
1023 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
1025 $price_result = $priceparser->parseProductSupplier($prod_supplier);
1026 if ($price_result >= 0) {
1027 $fourn_price =
price2num($price_result,
'MU');
1028 if ($record[
"quantity"] != 0) {
1029 $fourn_unitprice =
price2num((
float) $fourn_price / $record[
"quantity"],
'MU');
1031 $fourn_unitprice = $fourn_price;
1033 $fourn_unitprice_with_discount = (float) $fourn_unitprice * (1 - $record[
"remise_percent"] / 100);
1037 if ($fourn_unitprice_with_discount < $min || $min == -1) {
1038 $this->
id = $prodid;
1039 $this->product_fourn_price_id = $record[
"product_fourn_price_id"];
1040 $this->ref_supplier = $record[
"ref_fourn"];
1041 $this->ref_fourn = $record[
"ref_fourn"];
1042 $this->fourn_ref = $record[
"ref_fourn"];
1043 $this->fourn_price = $fourn_price;
1044 $this->fourn_qty = $record[
"quantity"];
1045 $this->fourn_remise_percent = $record[
"remise_percent"];
1046 $this->fourn_remise = $record[
"remise"];
1047 $this->fourn_unitprice = $fourn_unitprice;
1048 $this->fourn_unitprice_with_discount = $fourn_unitprice_with_discount;
1049 $this->fourn_charges = $record[
"charges"];
1050 $this->fourn_tva_tx = $record[
"tva_tx"];
1051 $this->fourn_id = $record[
"fourn_id"];
1052 $this->fourn_name = $record[
"supplier_name"];
1053 $this->delivery_time_days = $record[
"delivery_time_days"];
1055 $this->fk_supplier_price_expression = $record[
"fk_supplier_price_expression"];
1056 $this->fourn_multicurrency_price = $record[
"multicurrency_price"];
1057 $this->fourn_multicurrency_unitprice = $record[
"multicurrency_unitprice"];
1058 $this->fourn_multicurrency_tx = $record[
"multicurrency_tx"];
1059 $this->fourn_multicurrency_id = $record[
"fk_multicurrency"];
1060 $this->fourn_multicurrency_code = $record[
"multicurrency_code"];
1062 $min = $fourn_unitprice_with_discount;
1067 $this->db->free($resql);
1069 return $this->product_fourn_price_id;
1071 $this->error = $this->db->error();
1086 $expression_id = $expression_id != 0 ? $expression_id :
'NULL';
1088 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
1089 $sql .=
" SET fk_supplier_price_expression = ".((int) $expression_id);
1090 $sql .=
" WHERE rowid = ".((int) $this->product_fourn_price_id);
1092 dol_syslog(get_class($this).
"::setSupplierPriceExpression", LOG_DEBUG);
1094 $resql = $this->db->query($sql);
1096 $this->db->commit();
1099 $this->error = $this->db->error().
" sql=".$sql;
1100 $this->db->rollback();
1115 public function getSocNomUrl($withpicto = 0, $option =
'supplier', $maxlen = 0, $notooltip = 0)
1118 $thirdparty->fetch($this->fourn_id);
1120 return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip);
1138 global $conf, $langs, $user;
1141 $langs->load(
"suppliers");
1142 if (count($productFournList) > 0) {
1143 $out .=
'<table class="centpercent liste nomarginbottom">';
1144 $out .=
'<tr class="liste_titre"><td class="liste_titre right">'.($showunitprice ? $langs->trans(
"Price").
' '.$langs->trans(
"HT") :
'').
'</td>';
1145 $out .=
'<td class="liste_titre right">'.($showunitprice ? $langs->trans(
"QtyMin") :
'').
'</td>';
1146 $out .=
'<td class="liste_titre">'.$langs->trans(
"Supplier").
'</td>';
1147 $out .=
'<td class="liste_titre">'.$langs->trans(
"SupplierRef").
'</td></tr>';
1148 foreach ($productFournList as $productFourn) {
1149 $out .=
'<tr><td class="right">'.($showunitprice ?
price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) :
'').
'</td>';
1150 $out .=
'<td class="right">'.($showunitprice ? $productFourn->fourn_qty :
'').
'</td>';
1151 $out .=
'<td>'.$productFourn->getSocNomUrl(1,
'supplier', $maxlen, $notooltip).
'</td>';
1152 $out .=
'<td>'.dolPrintHTML($productFourn->fourn_ref).
'</td></tr>';
1156 $out = ($showunitprice ?
price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise, 0, $langs, 1, -1, -1, $conf->currency).
' '.$langs->trans(
"HT") :
'');
1157 if ($user->hasRight(
"fournisseur",
"read")) {
1158 $out .= ($showunitprice ?
' <span class="opacitymedium">(</span>' :
'');
1159 $out .= ($showsuptitle ?
'<span class="opacitymedium">'.$langs->trans(
"Supplier").
'</span>: ' :
'').$this->
getSocNomUrl(1,
'supplier', $maxlen, $notooltip).
' / <span class="opacitymedium">'.$langs->trans(
"SupplierRef").
'</span>: '.$this->ref_supplier;
1160 $out .= ($showunitprice ?
'<span class="opacitymedium">)</span>' :
'');
1177 'product_fournisseur_price'
1194 'product_fournisseur_price'
1213 $sql .=
" u.lastname,";
1214 $sql .=
" pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,";
1215 $sql .=
" pfpl.price, pfpl.quantity,";
1216 $sql .=
" pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice";
1217 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_log as pfpl,";
1218 $sql .=
" ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp,";
1219 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1220 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productprice').
")";
1221 $sql .=
" AND pfpl.fk_user = u.rowid";
1222 $sql .=
" AND pfp.rowid = pfpl.fk_product_fournisseur";
1223 $sql .=
" AND pfpl.fk_product_fournisseur = ".((int) $product_fourn_price_id);
1224 if (empty($sortfield)) {
1225 $sql .=
" ORDER BY pfpl.datec";
1227 $sql .= $this->db->order($sortfield, $sortorder);
1229 $sql .= $this->db->plimit($limit, $offset);
1230 dol_syslog(get_class($this).
"::list_product_fournisseur_price_log", LOG_DEBUG);
1232 $resql = $this->db->query($sql);
1234 $retarray = array();
1236 while ($obj = $this->db->fetch_object($resql)) {
1237 $tmparray = array();
1238 $tmparray[
'rowid'] = $obj->rowid;
1239 $tmparray[
'supplier_ref'] = $obj->supplier_ref;
1240 $tmparray[
'datec'] = $this->db->jdate($obj->datec);
1241 $tmparray[
'lastname'] = $obj->lastname;
1242 $tmparray[
'price'] = $obj->price;
1243 $tmparray[
'quantity'] = $obj->quantity;
1244 $tmparray[
'fk_multicurrency'] = $obj->fk_multicurrency;
1245 $tmparray[
'multicurrency_code'] = $obj->multicurrency_code;
1246 $tmparray[
'multicurrency_tx'] = $obj->multicurrency_tx;
1247 $tmparray[
'multicurrency_price'] = $obj->multicurrency_price;
1248 $tmparray[
'multicurrency_unitprice'] = $obj->multicurrency_unitprice;
1250 $retarray[] = $tmparray;
1253 $this->db->free($resql);
1256 $this->error = $this->db->error();
1270 global $conf, $langs;
1273 $langs->load(
"suppliers");
1274 if (count($productFournLogList) > 0) {
1275 $out .=
'<table class="noborder centpercent">';
1276 $out .=
'<tr class="liste_titre"><td class="liste_titre">'.$langs->trans(
"Date").
'</td>';
1277 $out .=
'<td class="liste_titre right">'.$langs->trans(
"Price").
'</td>';
1279 $out .=
'<td class="liste_titre">'.$langs->trans(
"User").
'</td></tr>';
1280 foreach ($productFournLogList as $productFournLog) {
1281 $out .=
'<tr><td>'.dol_print_date($productFournLog[
'datec'],
'dayhour',
'tzuser').
'</td>';
1282 $out .=
'<td class="right">'.price($productFournLog[
'price'], 0, $langs, 1, -1, -1, $conf->currency);
1283 if ($productFournLog[
'multicurrency_code'] != $conf->currency) {
1284 $out .=
' ('.price($productFournLog[
'multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog[
'multicurrency_code']).
')';
1288 $out .=
'<td>'.$productFournLog[
'lastname'].
'</td></tr>';
1310 public function getNomUrl($withpicto = 0, $option =
'', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'', $add_label = 0, $sep =
' - ')
1312 global $conf, $langs, $hookmanager;
1314 if (!empty($conf->dol_no_mouse_hover)) {
1321 $newref = (string) $this->
ref;
1323 $newref =
dol_trunc($newref, $maxlength,
'middle');
1326 if (!empty($this->entity)) {
1327 $tmpphoto = $this->
show_photos(
'product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80);
1328 if ($this->nbphoto > 0) {
1329 $label .=
'<div class="photointooltip">';
1330 $label .= $tmpphoto;
1331 $label .=
'</div><div style="clear: both;"></div>';
1336 $label .=
img_picto(
'',
'product').
' <u class="paddingrightonly">'.$langs->trans(
"Product").
'</u>';
1338 $label .=
img_picto(
'',
'service').
' <u class="paddingrightonly">'.$langs->trans(
"Service").
'</u>';
1340 if (isset($this->
status) && isset($this->status_buy)) {
1341 $label .=
' '.$this->getLibStatut(5, 0);
1342 $label .=
' '.$this->getLibStatut(5, 1);
1345 if (!empty($this->
ref)) {
1346 $label .=
'<br><b>'.$langs->trans(
'ProductRef').
':</b> '.($this->
ref ? $this->
ref : $this->product_ref);
1348 if (!empty($this->label)) {
1349 $label .=
'<br><b>'.$langs->trans(
'ProductLabel').
':</b> '.$this->label;
1351 $label .=
'<br><b>'.$langs->trans(
'RefSupplier').
':</b> '.$this->ref_supplier;
1355 $langs->load(
"productbatch");
1356 $label .=
"<br><b>".$langs->trans(
"ManageLotSerial").
'</b>: '.$this->
getLibStatut(0, 2);
1360 $label .=
'<br><b>'.$langs->trans(
'BarCode').
':</b> '.$this->barcode;
1364 if ($this->weight) {
1365 $label .=
"<br><b>".$langs->trans(
"Weight").
'</b>: '.$this->weight.
' '.
measuringUnitString(0,
"weight", $this->weight_units);
1368 if ($this->length) {
1369 $labelsize .= ($labelsize ?
" - " :
"").
"<b>".$langs->trans(
"Length").
'</b>: '.$this->length.
' '.
measuringUnitString(0,
'size', $this->length_units);
1372 $labelsize .= ($labelsize ?
" - " :
"").
"<b>".$langs->trans(
"Width").
'</b>: '.$this->width.
' '.
measuringUnitString(0,
'size', $this->width_units);
1374 if ($this->height) {
1375 $labelsize .= ($labelsize ?
" - " :
"").
"<b>".$langs->trans(
"Height").
'</b>: '.$this->height.
' '.
measuringUnitString(0,
'size', $this->height_units);
1378 $label .=
"<br>".$labelsize;
1381 $labelsurfacevolume =
"";
1382 if ($this->surface) {
1383 $labelsurfacevolume .= ($labelsurfacevolume ?
" - " :
"").
"<b>".$langs->trans(
"Surface").
'</b>: '.$this->surface.
' '.
measuringUnitString(0,
'surface', $this->surface_units);
1385 if ($this->volume) {
1386 $labelsurfacevolume .= ($labelsurfacevolume ?
" - " :
"").
"<b>".$langs->trans(
"Volume").
'</b>: '.$this->volume.
' '.
measuringUnitString(0,
'volume', $this->volume_units);
1388 if ($labelsurfacevolume) {
1389 $label .=
"<br>".$labelsurfacevolume;
1394 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1395 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancySellCode').
':</b> '.
length_accountg($this->accountancy_code_sell);
1396 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancySellIntraCode').
':</b> '.
length_accountg($this->accountancy_code_sell_intra);
1397 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancySellExportCode').
':</b> '.
length_accountg($this->accountancy_code_sell_export);
1400 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1401 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancyBuyCode').
':</b> '.
length_accountg($this->accountancy_code_buy);
1402 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancyBuyIntraCode').
':</b> '.
length_accountg($this->accountancy_code_buy_intra);
1403 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancyBuyExportCode').
':</b> '.
length_accountg($this->accountancy_code_buy_export);
1407 if (is_array($logPrices) && count($logPrices) > 0) {
1408 $label .=
'<br><br>';
1409 $label .=
'<u>'.$langs->trans(
"History").
'</u>';
1413 $url = DOL_URL_ROOT.
'/product/price_suppliers.php?id='.((int) $this->
id).
'&action=create_price&token='.
newToken().
'&socid='.((int) $this->fourn_id).
'&rowid='.((int) $this->product_fourn_price_id);
1415 if ($option !=
'nolink') {
1417 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1418 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1419 $add_save_lastsearch_values = 1;
1421 if ($add_save_lastsearch_values) {
1422 $url .=
'&save_lastsearch_values=1';
1426 $allowothertags = array(
'table',
'tr',
'td');
1428 if (empty($notooltip)) {
1430 $label = $langs->trans(
"SupplierRef");
1431 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label, 0, $allowothertags).
'"';
1433 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label, 0, $allowothertags).
'"';
1434 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1436 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1439 $linkstart =
'<a href="'.$url.
'"';
1440 $linkstart .= $linkclose.
'>';
1443 $result .= $linkstart;
1445 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1, $allowothertags);
1447 if ($withpicto != 2) {
1448 $result .= $newref.($this->ref_supplier ?
' ('.$this->ref_supplier.
')' :
'');
1450 $result .= $linkend;
1451 if ($withpicto != 2) {
1452 $result .= (($add_label && $this->label) ? $sep.dol_trunc($this->label, ($add_label > 1 ? $add_label : 0)) :
'');
1456 $hookmanager->initHooks(array($this->element .
'dao'));
1457 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1458 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1460 $result = $hookmanager->resPrint;
1462 $result .= $hookmanager->resPrint;
1491 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1494 $this->labelStatus[self::STATUS_OPEN] = $langs->transnoentitiesnoconv(
'Enabled');
1495 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
1496 $this->labelStatusShort[self::STATUS_OPEN] = $langs->transnoentitiesnoconv(
'Enabled');
1497 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
1500 $statusType =
'status4';
1502 if ($status == self::STATUS_CANCELED) {
1503 $statusType =
'status6';
1506 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1524 private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice =
null, $multicurrency_unitBuyPrice =
null, $multicurrency_tx =
null, $fk_multicurrency =
null, $multicurrency_code =
null)
1527 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_fournisseur_price_log(";
1528 $sql .=
" multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
1529 $sql .=
"datec, fk_product_fournisseur,fk_user,price,quantity)";
1531 $sql .= (isset($multicurrency_buyprice) ?
"'".$this->db->escape(
price2num($multicurrency_buyprice)).
"'" :
'null').
",";
1532 $sql .= (isset($multicurrency_unitBuyPrice) ?
"'".$this->db->escape(
price2num($multicurrency_unitBuyPrice)).
"'" :
'null').
",";
1533 $sql .= (isset($multicurrency_tx) ?
"'".$this->db->escape((
string) $multicurrency_tx).
"'" :
'1').
",";
1534 $sql .= (isset($fk_multicurrency) ?
"'".$this->db->escape((
string) $fk_multicurrency).
"'" :
'null').
",";
1535 $sql .= (isset($multicurrency_code) ?
"'".$this->db->escape($multicurrency_code).
"'" :
'null').
",";
1536 $sql .=
"'".$this->db->idate($datec).
"',";
1537 $sql .=
" ".((int) $this->product_fourn_price_id).
",";
1538 $sql .=
" ".((int) $user->id).
",";
1539 $sql .=
" ".price2num($buyprice).
",";
1540 $sql .=
" ".price2num($qty);
1543 $resql = $this->db->query($sql);
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
setErrorsFromObject($object)
setErrorsFromObject
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
show_photos($modulepart, $sdir, $size=0, $nbmax=0, $nbbyrow=5, $showfilename=0, $showaction=0, $maxHeight=120, $maxWidth=160, $nolink=0, $overwritetitle=0, $usesharelink=0, $cache='', $addphotorefcss='photoref')
Show photos of an object (nbmax maximum), into several columns.
static commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a product id with another one.
Class to manage Dolibarr database access.
Class to manage suppliers.
static getIdFromCode($dbs, $code)
Get id of currency from code.
Class to parse product price expressions.
Class to manage predefined suppliers products.
displayPriceProductFournisseurLog($productFournLogList=array())
Display log price of product supplier price.
listProductFournisseurPriceLog($product_fourn_price_id, $sortfield='', $sortorder='', $limit=0, $offset=0)
List supplier prices log of a supplier price.
getSocNomUrl($withpicto=0, $option='supplier', $maxlen=0, $notooltip=0)
Display supplier of product.
LibStatut($status, $mode=0, $type=0)
Return the status.
logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice=null, $multicurrency_unitBuyPrice=null, $multicurrency_tx=null, $fk_multicurrency=null, $multicurrency_code=null)
Private function to log price history.
setSupplierPriceExpression($expression_id)
Sets the supplier price expression.
__construct($db)
Constructor.
find_min_price_product_fournisseur($prodid, $qty=0, $socid=0)
Load properties for minimum price.
list_product_fournisseur_price($prodid, $sortfield='', $sortorder='', $limit=0, $offset=0, $socid=0)
List all supplier prices of a product.
fetch_product_fournisseur_price($rowid, $ignore_expression=0)
Loads the price information of a provider.
remove_fournisseur($id_fourn)
Remove all prices for this couple supplier-product.
getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1, $notooltip=0, $morecss='', $add_label=0, $sep=' - ')
Return a link to the object card (with optionally the picto).
getLibStatut($mode=0, $type=0)
Return the label of the status.
remove_product_fournisseur_price($rowid)
Remove a price for a couple supplier-product.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
static replaceProduct(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a product id with another one.
update_buyprice( $qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='', $localtaxes_array=array(), $newdefaultvatcode='', $multicurrency_buyprice=0, $multicurrency_price_base_type='HT', $multicurrency_tx=1, $multicurrency_code='', $desc_fourn='', $barcode='', $fk_barcode_type=0, $options=array())
Modify the purchase price for a supplier.
display_price_product_fournisseur($showunitprice=1, $showsuptitle=1, $maxlen=0, $notooltip=0, $productFournList=array())
Display price of product.
Class for ProductFournisseurPrice.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...