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();
339 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
340 $sql .=
" WHERE rowid = ".((int) $rowid).
" AND fk_product = ".((int) $this->
id);
341 $resql = $this->db->query($sql);
342 if (!$resql || !$this->db->num_rows($resql)) {
343 $this->error =
'ErrorRecordNotFound';
351 $result = $this->call_trigger(
'PRODUCT_BUYPRICE_DELETE', $user);
358 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
359 $sql .=
" WHERE rowid = ".((int) $rowid);
361 dol_syslog(get_class($this).
"::remove_product_fournisseur_price", LOG_DEBUG);
362 $resql = $this->db->query($sql);
364 $this->error = $this->db->lasterror();
373 $this->db->rollback();
422 $delivery_time_days = 0,
423 $supplier_reputation =
'',
424 $localtaxes_array = array(),
425 $newdefaultvatcode =
'',
426 $multicurrency_buyprice = 0,
427 $multicurrency_price_base_type =
'HT',
428 $multicurrency_tx = 1,
429 $multicurrency_code =
'',
432 $fk_barcode_type = 0,
443 if (empty($buyprice)) {
446 if (empty($charges)) {
449 if (empty($availability)) {
452 if (empty($remise_percent)) {
455 if (empty($supplier_reputation) || $supplier_reputation == -1) {
456 $supplier_reputation =
'';
458 if ($delivery_time_days !=
'' && !is_numeric($delivery_time_days)) {
459 $delivery_time_days = 0;
461 if ($price_base_type ==
'TTC') {
463 $buyprice /= (1 + ($ttx / 100));
467 $multicurrency_unitBuyPrice =
null;
468 $fk_multicurrency =
null;
470 if (empty($multicurrency_tx)) {
471 $multicurrency_tx = 1;
473 if (empty($multicurrency_buyprice)) {
474 $multicurrency_buyprice = 0;
476 if ($multicurrency_price_base_type ==
'TTC') {
478 $multicurrency_buyprice /= (1 + ($ttx / 100));
480 $multicurrency_buyprice = (float)
price2num($multicurrency_buyprice,
'MU');
481 $multicurrency_unitBuyPrice = (float)
price2num((
float) $multicurrency_buyprice / $qty,
'MU');
483 $buyprice = (float) $multicurrency_buyprice / $multicurrency_tx;
487 $buyprice = (float)
price2num($buyprice,
'MU');
488 $charges = (float)
price2num($charges,
'MU');
490 $unitBuyPrice = (float)
price2num($buyprice / $qty,
'MU');
493 $packaging =
price2num((empty($this->product_fourn_packaging) ? $qty : $this->product_fourn_packaging),
'MS');
500 if (count($localtaxes_array) > 0) {
501 $localtaxtype1 = $localtaxes_array[
'0'];
502 $localtax1 = $localtaxes_array[
'1'];
503 $localtaxtype2 = $localtaxes_array[
'2'];
504 $localtax2 = $localtaxes_array[
'3'];
506 $localtaxtype1 =
'0';
508 $localtaxtype2 =
'0';
511 if (empty($localtax1)) {
514 if (empty($localtax2)) {
520 if ($this->product_fourn_price_id > 0) {
523 if (is_array($logPrices) && count($logPrices) == 0) {
524 $currentPfp =
new self($this->db);
525 $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id);
526 if ($result > 0 && $currentPfp->fourn_price != 0) {
527 $currentPfpUser =
new User($this->db);
528 $result = $currentPfpUser->fetch($currentPfp->user_id);
530 $currentPfp->logPrice(
532 $currentPfp->date_creation,
533 (
float) $currentPfp->fourn_price,
534 $currentPfp->fourn_qty,
535 $currentPfp->fourn_multicurrency_price,
536 $currentPfp->fourn_multicurrency_unitprice,
537 $currentPfp->fourn_multicurrency_tx,
538 $currentPfp->fourn_multicurrency_id,
539 $currentPfp->fourn_multicurrency_code
544 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
545 $sql .=
" SET fk_user = ".((int) $user->id).
" ,";
546 $sql .=
" datec = '".$this->db->idate($now).
"' ,";
547 $sql .=
" ref_fourn = '".$this->db->escape($ref_fourn).
"',";
548 $sql .=
" desc_fourn = '".$this->db->escape($desc_fourn).
"',";
549 $sql .=
" price = ".((float) $buyprice).
",";
550 $sql .=
" quantity = ".((float) $qty).
",";
551 $sql .=
" remise_percent = ".((float) $remise_percent).
",";
552 $sql .=
" remise = ".((float) $remise).
",";
553 $sql .=
" unitprice = ".((float) $unitBuyPrice).
",";
554 $sql .=
" fk_availability = ".((int) $availability).
",";
555 $sql .=
" multicurrency_price = ".(isset($multicurrency_buyprice) ?
"'".$this->db->escape(
price2num($multicurrency_buyprice)).
"'" :
'null').
",";
556 $sql .=
" multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ?
"'".$this->db->escape(
price2num($multicurrency_unitBuyPrice)).
"'" :
'null').
",";
557 $sql .=
" multicurrency_tx = ".(isset($multicurrency_tx) ?
"'".$this->db->escape((
string) $multicurrency_tx).
"'" :
'1').
",";
558 $sql .=
" fk_multicurrency = ".(isset($fk_multicurrency) ? (int) $fk_multicurrency :
'null').
",";
559 $sql .=
" multicurrency_code = ".(isset($multicurrency_code) ?
"'".$this->db->escape($multicurrency_code).
"'" :
'null').
",";
560 $sql .=
" entity = ".((int)
$conf->entity).
",";
561 $sql .=
" tva_tx = ".((float)
price2num($tva_tx)).
",";
567 $sql .=
" default_vat_code = ".($newdefaultvatcode ?
"'".$this->db->escape($newdefaultvatcode).
"'" :
"null").
",";
568 $sql .=
" info_bits = ".((int) $newnpr).
",";
569 $sql .=
" charges = ".((float) $charges).
",";
570 $sql .=
" delivery_time_days = ".($delivery_time_days !=
'' ? ((int) $delivery_time_days) :
'null').
",";
571 $sql .=
" supplier_reputation = ".(empty($supplier_reputation) ?
'NULL' :
"'".$this->db->escape($supplier_reputation).
"'").
",";
572 $sql .=
" barcode = ".(empty($barcode) ?
'NULL' :
"'".$this->db->escape($barcode).
"'").
",";
573 $sql .=
" fk_barcode_type = ".(empty($fk_barcode_type) ?
'NULL' :
"'".$this->db->escape((
string) $fk_barcode_type).
"'");
575 $sql .=
", packaging = ".(empty($packaging) ? 1 : ((float) $packaging));
577 $sql .=
" WHERE rowid = ".((int) $this->product_fourn_price_id);
580 if (!empty($options) && is_array($options)) {
582 $res = $productfournisseurprice->fetch($this->product_fourn_price_id);
584 foreach ($options as $key => $value) {
585 $productfournisseurprice->array_options[$key] = $value;
587 $res = $productfournisseurprice->update($user);
598 dol_syslog(get_class($this).
'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG);
599 $resql = $this->db->query($sql);
602 $result = $this->call_trigger(
'PRODUCT_BUYPRICE_MODIFY', $user);
608 $result = $this->
logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, (
float) $multicurrency_unitBuyPrice, $multicurrency_tx, (
int) $fk_multicurrency, $multicurrency_code);
615 return $this->product_fourn_price_id;
617 $this->db->rollback();
621 $this->error = $this->db->error().
" sql=".$sql;
622 $this->db->rollback();
626 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);
629 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
630 $sql .=
" WHERE fk_soc = ".((int) $fourn->id).
" AND ref_fourn = '".$this->db->escape($ref_fourn).
"' AND quantity = ".((float) $qty).
" AND entity = ".((int)
$conf->entity);
631 $resql = $this->db->query($sql);
634 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_fournisseur_price(";
635 $sql .=
" multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
636 $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";
638 $sql .=
", packaging";
641 $sql .= (isset($multicurrency_buyprice) ?
"'".$this->db->escape(
price2num($multicurrency_buyprice)).
"'" :
'null').
",";
642 $sql .= (isset($multicurrency_unitBuyPrice) ?
"'".$this->db->escape(
price2num($multicurrency_unitBuyPrice)).
"'" :
'null').
",";
643 $sql .= (isset($multicurrency_tx) ?
"'".$this->db->escape((
string) $multicurrency_tx).
"'" :
'1').
",";
644 $sql .= (isset($fk_multicurrency) ?
"'".$this->db->escape((
string) $fk_multicurrency).
"'" :
'null').
",";
645 $sql .= (isset($multicurrency_code) ?
"'".$this->db->escape($multicurrency_code).
"'" :
'null').
",";
646 $sql .=
" '".$this->db->idate($now).
"',";
647 $sql .=
" ".((int) $this->
id).
",";
648 $sql .=
" ".((int) $fourn->id).
",";
649 $sql .=
" '".$this->db->escape($ref_fourn).
"',";
650 $sql .=
" '".$this->db->escape($desc_fourn).
"',";
651 $sql .=
" ".((int) $user->id).
",";
652 $sql .=
" ".price2num($buyprice).
",";
653 $sql .=
" ".((float) $qty).
",";
654 $sql .=
" ".((float) $remise_percent).
",";
655 $sql .=
" ".((float) $remise).
",";
656 $sql .=
" ".price2num($unitBuyPrice).
",";
657 $sql .=
" ".price2num($tva_tx).
",";
658 $sql .=
" ".price2num($charges).
",";
659 $sql .=
" ".((int) $availability).
",";
660 $sql .=
" ".($newdefaultvatcode ?
"'".$this->db->escape($newdefaultvatcode).
"'" :
"null").
",";
661 $sql .=
" ".((int) $newnpr).
",";
662 $sql .= ((int)
$conf->entity).
",";
663 $sql .= ($delivery_time_days !=
'' ? ((int) $delivery_time_days) :
'null').
",";
664 $sql .= (empty($supplier_reputation) ?
'NULL' :
"'".$this->db->escape($supplier_reputation).
"'").
",";
665 $sql .= (empty($barcode) ?
'NULL' :
"'".$this->db->escape($barcode).
"'").
",";
666 $sql .= (empty($fk_barcode_type) ?
'NULL' :
"'".$this->db->escape((
string) $fk_barcode_type).
"'");
668 $sql .=
", ".(empty($this->packaging) ?
'1' :
"'".$this->db->escape((
string) $this->packaging).
"'");
672 $this->product_fourn_price_id = 0;
674 $resql = $this->db->query($sql);
676 $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"product_fournisseur_price");
678 $this->error = $this->db->lasterror();
683 if (!empty($options) && is_array($options)) {
685 $res = $productfournisseurprice->fetch($this->product_fourn_price_id);
687 foreach ($options as $key => $value) {
688 $productfournisseurprice->array_options[$key] = $value;
690 $res = $productfournisseurprice->update($user);
692 $this->error = $productfournisseurprice->error;
693 $this->errors = $productfournisseurprice->errors;
703 $result = $this->
logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, (
float) $multicurrency_unitBuyPrice, $multicurrency_tx, (
int) $fk_multicurrency, $multicurrency_code);
711 $result = $this->call_trigger(
'PRODUCT_BUYPRICE_CREATE', $user);
719 return $this->product_fourn_price_id;
721 $this->db->rollback();
725 $this->error = $this->db->lasterror().
" sql=".$sql;
726 $this->db->rollback();
730 $this->error = $this->db->lasterror().
" sql=".$sql;
731 $this->db->rollback();
748 $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,";
749 $sql .=
" pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
750 $sql .=
" pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
751 $sql .=
" pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
752 $sql .=
" pfp.barcode, pfp.fk_barcode_type, pfp.packaging,";
753 $sql .=
" p.ref as product_ref, p.tosell as status, p.tobuy as status_buy";
754 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp, ".MAIN_DB_PREFIX.
"product as p";
755 $sql .=
" WHERE pfp.rowid = ".(int) $rowid;
756 $sql .=
" AND pfp.fk_product = p.rowid";
758 dol_syslog(get_class($this).
"::fetch_product_fournisseur_price", LOG_DEBUG);
759 $resql = $this->db->query($sql);
761 $obj = $this->db->fetch_object($resql);
763 $this->product_fourn_price_id = $rowid;
764 $this->
id = $obj->fk_product;
766 $this->fk_product = $obj->fk_product;
767 $this->product_id = $obj->fk_product;
768 $this->product_ref = $obj->product_ref;
769 $this->
status = $obj->status;
770 $this->status_buy = $obj->status_buy;
771 $this->fourn_id = $obj->fk_soc;
772 $this->fourn_ref = $obj->ref_fourn;
773 $this->ref_supplier = $obj->ref_fourn;
774 $this->desc_supplier = $obj->desc_fourn;
775 $this->fourn_price = $obj->price;
776 $this->fourn_charges = $obj->charges;
777 $this->fourn_qty = $obj->quantity;
778 $this->fourn_remise_percent = $obj->remise_percent;
779 $this->fourn_remise = $obj->remise;
780 $this->fourn_unitprice = $obj->unitprice;
781 $this->fourn_tva_tx = $obj->tva_tx;
782 $this->fourn_tva_npr = $obj->fourn_tva_npr;
784 $this->fk_availability = $obj->fk_availability;
785 $this->delivery_time_days = $obj->delivery_time_days;
786 $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
787 $this->supplier_reputation = $obj->supplier_reputation;
788 $this->default_vat_code = $obj->default_vat_code;
789 $this->user_id = $obj->fk_user;
790 $this->date_creation = $this->db->jdate($obj->datec);
791 $this->fourn_multicurrency_price = $obj->multicurrency_price;
792 $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice;
793 $this->fourn_multicurrency_tx = $obj->multicurrency_tx;
794 $this->fourn_multicurrency_id = $obj->fk_multicurrency;
795 $this->fourn_multicurrency_code = $obj->multicurrency_code;
797 $this->fourn_barcode = $obj->barcode;
798 $this->fourn_fk_barcode_type = $obj->fk_barcode_type;
799 $this->supplier_barcode = $obj->barcode;
800 $this->supplier_fk_barcode_type = $obj->fk_barcode_type;
802 $this->packaging = (float) $obj->packaging;
804 if (
isModEnabled(
'dynamicprices') && empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) {
805 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
807 $price_result = $priceparser->parseProductSupplier($this);
808 if ($price_result >= 0) {
809 $this->fourn_price = $price_result;
811 if ($this->fourn_qty != 0) {
812 $this->fourn_unitprice =
price2num($this->fourn_price / $this->fourn_qty,
'MU');
814 $this->fourn_unitprice =
"";
824 $this->error = $this->db->lasterror();
846 $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.tobatch as status_batch, p.fk_unit as product_fk_unit,";
847 $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,";
848 $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,";
849 $sql .=
" pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
850 $sql .=
" pfp.barcode, pfp.fk_barcode_type, pfp.packaging, pfp.status as pfstatus";
851 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp, ".MAIN_DB_PREFIX.
"product as p, ".MAIN_DB_PREFIX.
"societe as s";
852 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productsupplierprice').
")";
853 $sql .=
" AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid";
854 $sql .= ($socid > 0 ?
' AND pfp.fk_soc = '.((int) $socid) :
'');
855 $sql .=
" AND s.status = 1";
856 $sql .=
" AND pfp.fk_product = ".((int) $prodid);
857 if (empty($sortfield)) {
858 $sql .=
" ORDER BY s.nom, pfp.quantity, pfp.price";
860 $sql .= $this->db->order($sortfield, $sortorder);
862 $sql .= $this->db->plimit($limit, $offset);
863 dol_syslog(get_class($this).
"::list_product_fournisseur_price", LOG_DEBUG);
865 $resql = $this->db->query($sql);
869 while ($record = $this->db->fetch_array($resql)) {
873 $prodfourn->product_ref = $record[
"product_ref"];
874 $prodfourn->product_fourn_price_id = $record[
"product_fourn_pri_id"];
875 $prodfourn->status = $record[
"status"];
876 $prodfourn->status_buy = $record[
"status_buy"];
877 $prodfourn->status_batch = $record[
"status_batch"];
878 $prodfourn->product_fourn_id = $record[
"product_fourn_id"];
879 $prodfourn->product_fourn_entity = $record[
"entity"];
880 $prodfourn->ref_supplier = $record[
"ref_fourn"];
881 $prodfourn->fourn_ref = $record[
"ref_fourn"];
882 $prodfourn->desc_supplier = $record[
"desc_fourn"];
883 $prodfourn->fourn_price = $record[
"price"];
884 $prodfourn->fourn_qty = $record[
"quantity"];
885 $prodfourn->fourn_remise_percent = $record[
"remise_percent"];
886 $prodfourn->fourn_remise = $record[
"remise"];
887 $prodfourn->fourn_unitprice = $record[
"unitprice"];
888 $prodfourn->fourn_charges = $record[
"charges"];
889 $prodfourn->fourn_tva_tx = $record[
"tva_tx"];
890 $prodfourn->fourn_id = $record[
"fourn_id"];
891 $prodfourn->fourn_name = $record[
"supplier_name"];
892 $prodfourn->fk_availability = $record[
"fk_availability"];
893 $prodfourn->delivery_time_days = $record[
"delivery_time_days"];
894 $prodfourn->id = $prodid;
895 $prodfourn->fourn_tva_npr = $record[
"info_bits"];
896 $prodfourn->fk_supplier_price_expression = $record[
"fk_supplier_price_expression"];
897 $prodfourn->supplier_reputation = $record[
"supplier_reputation"];
898 $prodfourn->fourn_date_creation = $this->db->jdate($record[
'datec']);
899 $prodfourn->fourn_date_modification = $this->db->jdate($record[
'tms']);
904 $prodfourn->fk_unit = $record[
"product_fk_unit"];
906 $prodfourn->fourn_multicurrency_price = $record[
"multicurrency_price"];
907 $prodfourn->fourn_multicurrency_unitprice = $record[
"multicurrency_unitprice"];
908 $prodfourn->fourn_multicurrency_tx = $record[
"multicurrency_tx"];
909 $prodfourn->fourn_multicurrency_id = $record[
"fk_multicurrency"];
910 $prodfourn->fourn_multicurrency_code = $record[
"multicurrency_code"];
912 $prodfourn->packaging = (float) $record[
"packaging"];
913 $prodfourn->status = $record[
"pfstatus"];
916 $prodfourn->supplier_barcode = $record[
"barcode"];
917 $prodfourn->supplier_fk_barcode_type = $record[
"fk_barcode_type"];
920 if (
isModEnabled(
'dynamicprices') && !empty($prodfourn->fk_supplier_price_expression)) {
921 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
923 $price_result = $priceparser->parseProductSupplier($prodfourn);
924 if ($price_result >= 0) {
925 $prodfourn->fourn_price = $price_result;
927 $prodfourn->fourn_unitprice =
null;
931 if (!isset($prodfourn->fourn_unitprice)) {
932 if ($prodfourn->fourn_qty != 0) {
933 $prodfourn->fourn_unitprice =
price2num($prodfourn->fourn_price / $prodfourn->fourn_qty,
'MU');
935 $prodfourn->fourn_unitprice =
"";
939 $retarray[] = $prodfourn;
942 $this->db->free($resql);
945 $this->error = $this->db->error();
963 if (empty($prodid)) {
964 dol_syslog(
"Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING);
968 $this->product_fourn_price_id = 0;
969 $this->product_fourn_id = 0;
970 $this->fourn_ref =
'';
971 $this->fourn_price = 0;
972 $this->fourn_qty = 0;
973 $this->fourn_remise_percent = 0;
974 $this->fourn_remise = 0;
975 $this->fourn_unitprice = 0;
977 $this->fourn_name =
'';
978 $this->delivery_time_days = 0;
981 $this->fourn_multicurrency_price = 0;
982 $this->fourn_multicurrency_unitprice = 0;
983 $this->fourn_multicurrency_tx = 0;
984 $this->fourn_multicurrency_id = 0;
985 $this->fourn_multicurrency_code =
'';
987 $sql =
"SELECT s.nom as supplier_name, s.rowid as fourn_id,";
988 $sql .=
" pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
989 $sql .=
" pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
990 $sql .=
" pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
991 $sql .=
" pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
992 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp";
993 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
994 $sql .=
" AND pfp.entity IN (".getEntity(
'productsupplierprice').
")";
995 $sql .=
" AND pfp.fk_product = ".((int) $prodid);
996 $sql .=
" AND pfp.fk_soc = s.rowid";
997 $sql .=
" AND s.status = 1";
999 $sql .=
" AND pfp.quantity <= ".((float) $qty);
1002 $sql .=
' AND pfp.fk_soc = '.((int) $socid);
1005 dol_syslog(get_class($this).
"::find_min_price_product_fournisseur", LOG_DEBUG);
1007 $resql = $this->db->query($sql);
1009 $record_array = array();
1012 while ($record = $this->db->fetch_array($resql)) {
1013 $record_array[] = $record;
1016 if (count($record_array) == 0) {
1017 $this->db->free($resql);
1021 foreach ($record_array as $record) {
1022 $fourn_price = $record[
"price"];
1024 $fourn_unitprice = $record[
"unitprice"];
1025 $fourn_unitprice_with_discount = $record[
"unitprice"] * (1 - $record[
"remise_percent"] / 100);
1027 if (
isModEnabled(
'dynamicprices') && !empty($record[
"fk_supplier_price_expression"])) {
1029 $prod_supplier->product_fourn_price_id = $record[
"product_fourn_price_id"];
1030 $prod_supplier->id = $prodid;
1031 $prod_supplier->fourn_qty = $record[
"quantity"];
1032 $prod_supplier->fourn_tva_tx = $record[
"tva_tx"];
1033 $prod_supplier->fk_supplier_price_expression = $record[
"fk_supplier_price_expression"];
1035 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
1037 $price_result = $priceparser->parseProductSupplier($prod_supplier);
1038 if ($price_result >= 0) {
1039 $fourn_price =
price2num($price_result,
'MU');
1040 if ($record[
"quantity"] != 0) {
1041 $fourn_unitprice =
price2num((
float) $fourn_price / $record[
"quantity"],
'MU');
1043 $fourn_unitprice = $fourn_price;
1045 $fourn_unitprice_with_discount = (float) $fourn_unitprice * (1 - $record[
"remise_percent"] / 100);
1049 if ($fourn_unitprice_with_discount < $min || $min == -1) {
1050 $this->
id = $prodid;
1051 $this->product_fourn_price_id = $record[
"product_fourn_price_id"];
1052 $this->ref_supplier = $record[
"ref_fourn"];
1053 $this->ref_fourn = $record[
"ref_fourn"];
1054 $this->fourn_ref = $record[
"ref_fourn"];
1055 $this->fourn_price = $fourn_price;
1056 $this->fourn_qty = $record[
"quantity"];
1057 $this->fourn_remise_percent = $record[
"remise_percent"];
1058 $this->fourn_remise = $record[
"remise"];
1059 $this->fourn_unitprice = $fourn_unitprice;
1060 $this->fourn_unitprice_with_discount = $fourn_unitprice_with_discount;
1061 $this->fourn_charges = $record[
"charges"];
1062 $this->fourn_tva_tx = $record[
"tva_tx"];
1063 $this->fourn_id = $record[
"fourn_id"];
1064 $this->fourn_name = $record[
"supplier_name"];
1065 $this->delivery_time_days = $record[
"delivery_time_days"];
1067 $this->fk_supplier_price_expression = $record[
"fk_supplier_price_expression"];
1068 $this->fourn_multicurrency_price = $record[
"multicurrency_price"];
1069 $this->fourn_multicurrency_unitprice = $record[
"multicurrency_unitprice"];
1070 $this->fourn_multicurrency_tx = $record[
"multicurrency_tx"];
1071 $this->fourn_multicurrency_id = $record[
"fk_multicurrency"];
1072 $this->fourn_multicurrency_code = $record[
"multicurrency_code"];
1074 $min = $fourn_unitprice_with_discount;
1079 $this->db->free($resql);
1081 return $this->product_fourn_price_id;
1083 $this->error = $this->db->error();
1098 $expression_id = $expression_id != 0 ? $expression_id :
'NULL';
1100 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
1101 $sql .=
" SET fk_supplier_price_expression = ".((int) $expression_id);
1102 $sql .=
" WHERE rowid = ".((int) $this->product_fourn_price_id);
1104 dol_syslog(get_class($this).
"::setSupplierPriceExpression", LOG_DEBUG);
1106 $resql = $this->db->query($sql);
1108 $this->db->commit();
1111 $this->error = $this->db->error().
" sql=".$sql;
1112 $this->db->rollback();
1127 public function getSocNomUrl($withpicto = 0, $option =
'supplier', $maxlen = 0, $notooltip = 0)
1130 $thirdparty->fetch($this->fourn_id);
1132 return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip);
1150 global
$conf, $langs, $user;
1153 $langs->load(
"suppliers");
1154 if (count($productFournList) > 0) {
1155 $out .=
'<table class="centpercent liste nomarginbottom">';
1156 $out .=
'<tr class="liste_titre"><td class="liste_titre right">'.($showunitprice ? $langs->trans(
"Price").
' '.$langs->trans(
"HT") :
'').
'</td>';
1157 $out .=
'<td class="liste_titre right">'.($showunitprice ? $langs->trans(
"QtyMin") :
'').
'</td>';
1158 $out .=
'<td class="liste_titre">'.$langs->trans(
"Supplier").
'</td>';
1159 $out .=
'<td class="liste_titre">'.$langs->trans(
"SupplierRef").
'</td></tr>';
1160 foreach ($productFournList as $productFourn) {
1161 $out .=
'<tr><td class="right">'.($showunitprice ?
price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) :
'').
'</td>';
1162 $out .=
'<td class="right">'.($showunitprice ? $productFourn->fourn_qty :
'').
'</td>';
1163 $out .=
'<td>'.$productFourn->getSocNomUrl(1,
'supplier', $maxlen, $notooltip).
'</td>';
1164 $out .=
'<td>'.dolPrintHTML($productFourn->fourn_ref).
'</td></tr>';
1168 $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") :
'');
1169 if ($user->hasRight(
"fournisseur",
"read")) {
1170 $out .= ($showunitprice ?
' <span class="opacitymedium">(</span>' :
'');
1171 $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;
1172 $out .= ($showunitprice ?
'<span class="opacitymedium">)</span>' :
'');
1194 $sqlselect =
"SELECT pfp_origin.rowid";
1195 $sqlselect .=
" FROM ".$dbs->prefix().
"product_fournisseur_price AS pfp_origin";
1196 $sqlselect .=
" INNER JOIN ".$dbs->prefix().
"product_fournisseur_price AS pfp_dest";
1197 $sqlselect .=
" ON pfp_dest.fk_soc = ".((int) $dest_id);
1198 $sqlselect .=
" AND pfp_dest.ref_fourn = pfp_origin.ref_fourn";
1199 $sqlselect .=
" AND pfp_dest.quantity = pfp_origin.quantity";
1200 $sqlselect .=
" AND pfp_dest.entity = pfp_origin.entity";
1201 $sqlselect .=
" WHERE pfp_origin.fk_soc = ".((int) $origin_id);
1203 $resql = $dbs->
query($sqlselect);
1207 $colliding = array();
1209 $colliding[] = (int) $obj->rowid;
1213 foreach ($colliding as $rowid) {
1214 $sqldel =
"DELETE FROM ".$dbs->prefix().
"product_fournisseur_price";
1215 $sqldel .=
" WHERE rowid = ".((int) $rowid);
1216 if (!$dbs->
query($sqldel)) {
1222 'product_fournisseur_price'
1239 'product_fournisseur_price'
1258 $sql .=
" u.lastname,";
1259 $sql .=
" pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec,";
1260 $sql .=
" pfpl.price, pfpl.quantity,";
1261 $sql .=
" pfpl.fk_multicurrency, pfpl.multicurrency_code, pfpl.multicurrency_tx, pfpl.multicurrency_price, pfpl.multicurrency_unitprice";
1262 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price_log as pfpl,";
1263 $sql .=
" ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp,";
1264 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1265 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productprice').
")";
1266 $sql .=
" AND pfpl.fk_user = u.rowid";
1267 $sql .=
" AND pfp.rowid = pfpl.fk_product_fournisseur";
1268 $sql .=
" AND pfpl.fk_product_fournisseur = ".((int) $product_fourn_price_id);
1269 if (empty($sortfield)) {
1270 $sql .=
" ORDER BY pfpl.datec";
1272 $sql .= $this->db->order($sortfield, $sortorder);
1274 $sql .= $this->db->plimit($limit, $offset);
1275 dol_syslog(get_class($this).
"::list_product_fournisseur_price_log", LOG_DEBUG);
1277 $resql = $this->db->query($sql);
1279 $retarray = array();
1281 while ($obj = $this->db->fetch_object($resql)) {
1282 $tmparray = array();
1283 $tmparray[
'rowid'] = $obj->rowid;
1284 $tmparray[
'supplier_ref'] = $obj->supplier_ref;
1285 $tmparray[
'datec'] = $this->db->jdate($obj->datec);
1286 $tmparray[
'lastname'] = $obj->lastname;
1287 $tmparray[
'price'] = $obj->price;
1288 $tmparray[
'quantity'] = $obj->quantity;
1289 $tmparray[
'fk_multicurrency'] = $obj->fk_multicurrency;
1290 $tmparray[
'multicurrency_code'] = $obj->multicurrency_code;
1291 $tmparray[
'multicurrency_tx'] = $obj->multicurrency_tx;
1292 $tmparray[
'multicurrency_price'] = $obj->multicurrency_price;
1293 $tmparray[
'multicurrency_unitprice'] = $obj->multicurrency_unitprice;
1295 $retarray[] = $tmparray;
1298 $this->db->free($resql);
1301 $this->error = $this->db->error();
1315 global
$conf, $langs;
1318 $langs->load(
"suppliers");
1319 if (count($productFournLogList) > 0) {
1320 $out .=
'<table class="noborder centpercent">';
1321 $out .=
'<tr class="liste_titre"><td class="liste_titre">'.$langs->trans(
"Date").
'</td>';
1322 $out .=
'<td class="liste_titre right">'.$langs->trans(
"Price").
'</td>';
1324 $out .=
'<td class="liste_titre">'.$langs->trans(
"User").
'</td></tr>';
1325 foreach ($productFournLogList as $productFournLog) {
1326 $out .=
'<tr><td>'.dol_print_date($productFournLog[
'datec'],
'dayhour',
'tzuser').
'</td>';
1327 $out .=
'<td class="right">'.price($productFournLog[
'price'], 0, $langs, 1, -1, -1,
$conf->currency);
1328 if ($productFournLog[
'multicurrency_code'] !=
$conf->currency) {
1329 $out .=
' ('.price($productFournLog[
'multicurrency_price'], 0, $langs, 1, -1, -1, $productFournLog[
'multicurrency_code']).
')';
1333 $out .=
'<td>'.$productFournLog[
'lastname'].
'</td></tr>';
1356 public function getNomUrl($withpicto = 0, $option =
'', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'', $add_label = 0, $sep =
' - ', $addlinktonotes = 0)
1358 global
$conf, $langs, $hookmanager, $user;
1360 if (!empty(
$conf->dol_no_mouse_hover)) {
1367 $newref = (string) $this->
ref;
1369 $newref =
dol_trunc($newref, $maxlength,
'middle');
1372 if (!empty($this->entity)) {
1373 $tmpphoto = $this->
show_photos(
'product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80);
1374 if ($this->nbphoto > 0) {
1375 $label .=
'<div class="photointooltip">';
1376 $label .= $tmpphoto;
1377 $label .=
'</div><div style="clear: both;"></div>';
1382 $label .= img_picto(
'',
'product').
' <u class="paddingrightonly">'.$langs->trans(
"Product").
'</u>';
1384 $label .= img_picto(
'',
'service').
' <u class="paddingrightonly">'.$langs->trans(
"Service").
'</u>';
1386 if (isset($this->
status) && isset($this->status_buy)) {
1387 $label .=
' '.$this->getLibStatut(5, 0);
1388 $label .=
' '.$this->getLibStatut(5, 1);
1391 if (!empty($this->
ref)) {
1392 $label .=
'<br><b>'.$langs->trans(
'ProductRef').
':</b> '.($this->
ref ? $this->
ref : $this->product_ref);
1394 if (!empty($this->label)) {
1395 $label .=
'<br><b>'.$langs->trans(
'ProductLabel').
':</b> '.$this->label;
1397 $label .=
'<br><b>'.$langs->trans(
'RefSupplier').
':</b> '.$this->ref_supplier;
1401 $langs->load(
"productbatch");
1402 $label .=
"<br><b>".$langs->trans(
"ManageLotSerial").
'</b>: '.$this->
getLibStatut(0, 2);
1406 $label .=
'<br><b>'.$langs->trans(
'BarCode').
':</b> '.$this->barcode;
1410 if ($this->weight) {
1411 $label .=
"<br><b>".$langs->trans(
"Weight").
'</b>: '.$this->weight.
' '.
measuringUnitString(0,
"weight", $this->weight_units);
1414 if ($this->length) {
1415 $labelsize .= ($labelsize ?
" - " :
"").
"<b>".$langs->trans(
"Length").
'</b>: '.$this->length.
' '.
measuringUnitString(0,
'size', $this->length_units);
1418 $labelsize .= ($labelsize ?
" - " :
"").
"<b>".$langs->trans(
"Width").
'</b>: '.$this->width.
' '.
measuringUnitString(0,
'size', $this->width_units);
1420 if ($this->height) {
1421 $labelsize .= ($labelsize ?
" - " :
"").
"<b>".$langs->trans(
"Height").
'</b>: '.$this->height.
' '.
measuringUnitString(0,
'size', $this->height_units);
1424 $label .=
"<br>".$labelsize;
1427 $labelsurfacevolume =
"";
1428 if ($this->surface) {
1429 $labelsurfacevolume .= ($labelsurfacevolume ?
" - " :
"").
"<b>".$langs->trans(
"Surface").
'</b>: '.$this->surface.
' '.
measuringUnitString(0,
'surface', $this->surface_units);
1431 if ($this->volume) {
1432 $labelsurfacevolume .= ($labelsurfacevolume ?
" - " :
"").
"<b>".$langs->trans(
"Volume").
'</b>: '.$this->volume.
' '.
measuringUnitString(0,
'volume', $this->volume_units);
1434 if ($labelsurfacevolume) {
1435 $label .=
"<br>".$labelsurfacevolume;
1440 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1441 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancySellCode').
':</b> '.
length_accountg($this->accountancy_code_sell);
1442 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancySellIntraCode').
':</b> '.
length_accountg($this->accountancy_code_sell_intra);
1443 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancySellExportCode').
':</b> '.
length_accountg($this->accountancy_code_sell_export);
1446 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
1447 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancyBuyCode').
':</b> '.
length_accountg($this->accountancy_code_buy);
1448 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancyBuyIntraCode').
':</b> '.
length_accountg($this->accountancy_code_buy_intra);
1449 $label .=
'<br><b>'.$langs->trans(
'ProductAccountancyBuyExportCode').
':</b> '.
length_accountg($this->accountancy_code_buy_export);
1453 if (is_array($logPrices) && count($logPrices) > 0) {
1454 $label .=
'<br><br>';
1455 $label .=
'<u>'.$langs->trans(
"History").
'</u>';
1459 $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);
1461 if ($option !=
'nolink') {
1463 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1464 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1465 $add_save_lastsearch_values = 1;
1467 if ($add_save_lastsearch_values) {
1468 $url .=
'&save_lastsearch_values=1';
1472 $allowothertags = array(
'table',
'tr',
'td');
1474 if (empty($notooltip)) {
1476 $label = $langs->trans(
"SupplierRef");
1477 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label, 0, $allowothertags).
'"';
1479 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label, 0, $allowothertags).
'"';
1480 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1482 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1485 $linkstart =
'<a href="'.$url.
'"';
1486 $linkstart .= $linkclose.
'>';
1489 $result .= $linkstart;
1491 $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);
1493 if ($withpicto != 2) {
1494 $result .= $newref.($this->ref_supplier ?
' ('.$this->ref_supplier.
')' :
'');
1496 $result .= $linkend;
1497 if ($withpicto != 2) {
1498 $result .= (($add_label && $this->label) ? $sep.dol_trunc($this->label, ($add_label > 1 ? $add_label : 0)) :
'');
1501 if ($addlinktonotes) {
1502 $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private);
1505 $result .=
' <span class="note inline-block">';
1506 $result .=
'<a href="'.DOL_URL_ROOT.
'/product/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
1507 $result .= img_picto(
'',
'note');
1509 $result .=
'</span>';
1514 $hookmanager->initHooks(array($this->element .
'dao'));
1515 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1516 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1518 $result = $hookmanager->resPrint;
1520 $result .= $hookmanager->resPrint;
1584 private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice =
null, $multicurrency_unitBuyPrice =
null, $multicurrency_tx =
null, $fk_multicurrency =
null, $multicurrency_code =
null)
1587 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_fournisseur_price_log(";
1588 $sql .=
" multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
1589 $sql .=
"datec, fk_product_fournisseur,fk_user,price,quantity)";
1591 $sql .= (isset($multicurrency_buyprice) ?
"'".$this->db->escape(
price2num($multicurrency_buyprice)).
"'" :
'null').
",";
1592 $sql .= (isset($multicurrency_unitBuyPrice) ?
"'".$this->db->escape(
price2num($multicurrency_unitBuyPrice)).
"'" :
'null').
",";
1593 $sql .= (isset($multicurrency_tx) ?
"'".$this->db->escape((
string) $multicurrency_tx).
"'" :
'1').
",";
1594 $sql .= (isset($fk_multicurrency) ?
"'".$this->db->escape((
string) $fk_multicurrency).
"'" :
'null').
",";
1595 $sql .= (isset($multicurrency_code) ?
"'".$this->db->escape($multicurrency_code).
"'" :
'null').
",";
1596 $sql .=
"'".$this->db->idate($datec).
"',";
1597 $sql .=
" ".((int) $this->product_fourn_price_id).
",";
1598 $sql .=
" ".((int) $user->id).
",";
1599 $sql .=
" ".price2num($buyprice).
",";
1600 $sql .=
" ".price2num($qty);
1603 $resql = $this->db->query($sql);
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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.
getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1, $notooltip=0, $morecss='', $add_label=0, $sep=' - ', $addlinktonotes=0)
Return a link to the object card (with optionally the picto).
logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice=null, $multicurrency_unitBuyPrice=null, $multicurrency_tx=null, $fk_multicurrency=null, $multicurrency_code=null)
Return the label of the status.
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.
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.
getLibStatut($mode=0, $type=0)
Return label of status of object.
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.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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'.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
query($query, $usesavepoint=0, $type='auto', $result_mode=0)
Execute a SQL request and return the resultset.
fetch_object($resultset)
Returns the current line (as an object) for the resultset cursor.
free($resultset=null)
Free last resultset used.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.