38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/margin/lib/margins.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonincoterm.class.php';
56 public $element =
'supplier_proposal';
61 public $table_element =
'supplier_proposal';
66 public $table_element_line =
'supplier_proposaldet';
71 public $fk_element =
'fk_supplier_proposal';
76 public $picto =
'supplier_proposal';
82 public $ismultientitymanaged = 1;
88 public $restrictiononfksoc = 1;
104 public $ref_supplier;
116 public $date_livraison;
121 public $delivery_date;
132 public $date_creation;
143 public $date_validation;
146 public $user_author_id;
147 public $user_valid_id;
148 public $user_close_id;
168 public $cond_reglement_code;
169 public $mode_reglement_code;
171 public $remise_percent = 0;
172 public $remise_absolue = 0;
174 public $extraparams = array();
175 public $lines = array();
178 public $labelStatus = array();
179 public $labelStatusShort = array();
188 public $fk_multicurrency;
190 public $multicurrency_code;
191 public $multicurrency_tx;
192 public $multicurrency_total_ht;
193 public $multicurrency_total_tva;
194 public $multicurrency_total_ttc;
230 public function __construct($db, $socid =
"", $supplier_proposalid = 0)
232 global $conf, $langs;
236 $this->socid = $socid;
237 $this->
id = $supplier_proposalid;
252 public function add_product($idproduct, $qty, $remise_percent = 0)
255 global $conf, $mysoc;
259 dol_syslog(get_class($this).
"::add_product $idproduct, $qty, $remise_percent");
263 $prod->fetch($idproduct);
265 $productdesc = $prod->description;
269 if (empty($tva_tx)) $tva_npr = 0;
270 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $this->thirdparty, $tva_npr);
271 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $this->thirdparty, $tva_npr);
274 if ($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level)
276 $price = $prod->multiprices[$this->thirdparty->price_level];
283 $line->fk_product = $idproduct;
284 $line->desc = $productdesc;
287 $line->remise_percent = $remise_percent;
288 $line->tva_tx = $tva_tx;
290 $this->lines[] = $line;
306 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
307 include_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
312 $result = $remise->fetch($idremise);
316 if ($remise->fk_facture)
318 $this->error = $langs->trans(
"ErrorDiscountAlreadyUsed");
319 $this->
db->rollback();
324 $supplier_proposalligne->fk_supplier_proposal = $this->id;
325 $supplier_proposalligne->fk_remise_except = $remise->id;
326 $supplier_proposalligne->desc = $remise->description;
327 $supplier_proposalligne->tva_tx = $remise->tva_tx;
328 $supplier_proposalligne->subprice = -$remise->amount_ht;
329 $supplier_proposalligne->fk_product = 0;
330 $supplier_proposalligne->qty = 1;
331 $supplier_proposalligne->remise = 0;
332 $supplier_proposalligne->remise_percent = 0;
333 $supplier_proposalligne->rang = -1;
334 $supplier_proposalligne->info_bits = 2;
336 $supplier_proposalligne->total_ht = -$remise->amount_ht;
337 $supplier_proposalligne->total_tva = -$remise->amount_tva;
338 $supplier_proposalligne->total_ttc = -$remise->amount_ttc;
340 $result = $supplier_proposalligne->insert();
349 $this->
db->rollback();
353 $this->error = $supplier_proposalligne->error;
354 $this->
db->rollback();
358 $this->
db->rollback();
400 public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type =
'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label =
'', $array_options = 0, $ref_supplier =
'', $fk_unit =
'', $origin =
'', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0)
402 global $mysoc, $conf, $langs;
404 dol_syslog(get_class($this).
"::addline supplier_proposalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
405 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
408 if (empty($remise_percent)) $remise_percent = 0;
409 if (empty($qty)) $qty = 0;
410 if (empty($info_bits)) $info_bits = 0;
411 if (empty($rang)) $rang = 0;
412 if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0;
413 if (empty($pu_ht)) $pu_ht = 0;
415 $remise_percent =
price2num($remise_percent);
419 if (!preg_match(
'/\((.*)\)/', $txtva)) {
425 if ($price_base_type ==
'HT')
433 if ($type < 0)
return -1;
435 if ($this->
statut == self::STATUS_DRAFT)
441 if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY))
444 dol_syslog(get_class($this).
"::addline we check supplier prices fk_product=".$fk_product.
" fk_fournprice=".$fk_fournprice.
" qty=".$qty.
" ref_supplier=".$ref_supplier);
446 if ($prod->fetch($fk_product) > 0)
448 $product_type = $prod->type;
449 $label = $prod->label;
450 $fk_prod_fourn_price = $fk_fournprice;
454 $result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product,
'none', ($this->fk_soc ? $this->fk_soc : $this->socid));
457 $pu = $prod->fourn_pu;
458 $ref_supplier = $prod->ref_supplier;
460 if ($remise_percent == 0 && $prod->remise_percent != 0)
461 $remise_percent = $prod->remise_percent;
465 $langs->load(
"errors");
466 $this->error =
"Ref ".$prod->ref.
" ".$langs->trans(
"ErrorQtyTooLowForThisSupplier");
467 $this->
db->rollback();
468 dol_syslog(get_class($this).
"::addline we did not found supplier price, so we can't guess unit price");
475 $langs->load(
"errors");
476 $this->error =
"Ref ".$prod->ref.
" ".$langs->trans(
"ErrorQtyTooLowForThisSupplier");
477 $this->
db->rollback();
478 dol_syslog(get_class($this).
"::addline result=".$result.
" - ".$this->error, LOG_DEBUG);
483 $this->error = $prod->error;
484 $this->errors = $prod->errors;
485 $this->
db->rollback();
486 dol_syslog(get_class($this).
"::addline result=".$result.
" - ".$this->error, LOG_ERR);
490 $this->error = $prod->error;
491 $this->errors = $prod->errors;
492 $this->
db->rollback();
497 $product_type = $type;
510 if (preg_match(
'/\((.*)\)/', $txtva, $reg))
512 $vat_src_code = $reg[1];
513 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
516 if (!empty($conf->multicurrency->enabled) && $pu_ht_devise > 0) {
520 $tabprice =
calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
521 $total_ht = $tabprice[0];
522 $total_tva = $tabprice[1];
523 $total_ttc = $tabprice[2];
524 $total_localtax1 = $tabprice[9];
525 $total_localtax2 = $tabprice[10];
526 $pu = $pu_ht = $tabprice[3];
529 $multicurrency_total_ht = $tabprice[16];
530 $multicurrency_total_tva = $tabprice[17];
531 $multicurrency_total_ttc = $tabprice[18];
532 $pu_ht_devise = $tabprice[19];
536 if ($ranktouse == -1)
538 $rangmax = $this->
line_max($fk_parent_line);
539 $ranktouse = $rangmax + 1;
546 if ($remise_percent > 0)
548 $remise = round(($pu * $remise_percent / 100), 2);
555 $this->line->fk_supplier_proposal = $this->id;
556 $this->line->label = $label;
557 $this->line->desc = $desc;
558 $this->line->qty = $qty;
560 $this->line->vat_src_code = $vat_src_code;
561 $this->line->tva_tx = $txtva;
562 $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
563 $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
564 $this->line->localtax1_type = empty($localtaxes_type[0]) ?
'' : $localtaxes_type[0];
565 $this->line->localtax2_type = empty($localtaxes_type[2]) ?
'' : $localtaxes_type[2];
566 $this->line->fk_product = $fk_product;
567 $this->line->remise_percent = $remise_percent;
568 $this->line->subprice = $pu_ht;
569 $this->line->rang = $ranktouse;
570 $this->line->info_bits = $info_bits;
571 $this->line->total_ht = $total_ht;
572 $this->line->total_tva = $total_tva;
573 $this->line->total_localtax1 = $total_localtax1;
574 $this->line->total_localtax2 = $total_localtax2;
575 $this->line->total_ttc = $total_ttc;
576 $this->line->product_type = $type;
577 $this->line->special_code = $special_code;
578 $this->line->fk_parent_line = $fk_parent_line;
579 $this->line->fk_unit = $fk_unit;
580 $this->line->origin = $origin;
581 $this->line->origin_id = $origin_id;
582 $this->line->ref_fourn = $this->
db->escape($ref_supplier);
583 $this->line->date_start = $date_start;
584 $this->line->date_end = $date_end;
587 if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
589 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
591 $productFournisseur->find_min_price_product_fournisseur($fk_product);
592 $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
594 $this->line->fk_fournprice = ($fk_fournprice > 0 ? $fk_fournprice : 0);
596 $this->line->pa_ht = $pa_ht;
600 $this->line->fk_multicurrency = $this->fk_multicurrency;
601 $this->line->multicurrency_code = $this->multicurrency_code;
602 $this->line->multicurrency_subprice = $pu_ht_devise;
603 $this->line->multicurrency_total_ht = $multicurrency_total_ht;
604 $this->line->multicurrency_total_tva = $multicurrency_total_tva;
605 $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
608 if (empty($qty) && empty($special_code)) $this->line->special_code = 3;
610 if (is_array($array_options) && count($array_options) > 0) {
611 $this->line->array_options = $array_options;
614 $result = $this->line->insert();
618 if (!empty($fk_parent_line)) $this->
line_order(
true,
'DESC');
621 $result = $this->
update_price(1,
'auto', 0, $this->thirdparty);
625 return $this->line->id;
627 $this->error = $this->error();
628 $this->errors = $this->errors();
629 $this->
db->rollback();
633 $this->error = $this->line->error;
634 $this->errors = $this->line->errors;
635 $this->
db->rollback();
639 $this->error =
'BadStatusOfObjectToAddLine';
671 public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc =
'', $price_base_type =
'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label =
'', $type = 0, $array_options = 0, $ref_supplier =
'', $fk_unit =
'', $pu_ht_devise = 0)
673 global $conf, $user, $langs, $mysoc;
675 dol_syslog(get_class($this).
"::updateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits");
676 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
679 $remise_percent =
price2num($remise_percent);
682 if (!preg_match(
'/\((.*)\)/', $txtva)) {
688 if (empty($qty) && empty($special_code)) $special_code = 3;
689 if (!empty($qty) && $special_code == 3) $special_code = 0;
705 if (preg_match(
'/\((.*)\)/', $txtva, $reg))
707 $vat_src_code = $reg[1];
708 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
711 if (!empty($conf->multicurrency->enabled) && $pu_ht_devise > 0) {
715 $tabprice =
calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
716 $total_ht = $tabprice[0];
717 $total_tva = $tabprice[1];
718 $total_ttc = $tabprice[2];
719 $total_localtax1 = $tabprice[9];
720 $total_localtax2 = $tabprice[10];
723 $multicurrency_total_ht = $tabprice[16];
724 $multicurrency_total_tva = $tabprice[17];
725 $multicurrency_total_ttc = $tabprice[18];
726 $pu_ht_devise = $tabprice[19];
730 $line->fetch($rowid);
731 $line->fetch_optionals();
734 $staticline = clone $line;
736 $line->oldline = $staticline;
738 $this->line->context = $this->context;
741 if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
743 $rangmax = $this->
line_max($fk_parent_line);
744 $this->line->rang = $rangmax + 1;
747 $this->line->id = $rowid;
748 $this->line->label = $label;
749 $this->line->desc = $desc;
750 $this->line->qty = $qty;
751 $this->line->product_type = $type;
753 $this->line->vat_src_code = $vat_src_code;
754 $this->line->tva_tx = $txtva;
755 $this->line->localtax1_tx = $txlocaltax1;
756 $this->line->localtax2_tx = $txlocaltax2;
757 $this->line->localtax1_type = empty($localtaxes_type[0]) ?
'' : $localtaxes_type[0];
758 $this->line->localtax2_type = empty($localtaxes_type[2]) ?
'' : $localtaxes_type[2];
759 $this->line->remise_percent = $remise_percent;
760 $this->line->subprice = $pu;
761 $this->line->info_bits = $info_bits;
762 $this->line->total_ht = $total_ht;
763 $this->line->total_tva = $total_tva;
764 $this->line->total_localtax1 = $total_localtax1;
765 $this->line->total_localtax2 = $total_localtax2;
766 $this->line->total_ttc = $total_ttc;
767 $this->line->special_code = $special_code;
768 $this->line->fk_parent_line = $fk_parent_line;
769 $this->line->skip_update_total = $skip_update_total;
770 $this->line->ref_fourn = $ref_supplier;
771 $this->line->fk_unit = $fk_unit;
774 if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
776 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
778 $productFournisseur->find_min_price_product_fournisseur($fk_product);
779 $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
781 $this->line->fk_fournprice = $fk_fournprice;
783 $this->line->pa_ht = $pa_ht;
785 if (is_array($array_options) && count($array_options) > 0) {
787 foreach ($array_options as $key => $value) {
788 $this->line->array_options[$key] = $array_options[$key];
793 $this->line->multicurrency_subprice = $pu_ht_devise;
794 $this->line->multicurrency_total_ht = $multicurrency_total_ht;
795 $this->line->multicurrency_total_tva = $multicurrency_total_tva;
796 $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
798 $result = $this->line->update();
802 if (!empty($fk_parent_line)) $this->
line_order(
true,
'DESC');
806 $this->fk_supplier_proposal = $this->id;
811 $this->error = $this->
db->error();
812 $this->
db->rollback();
816 dol_syslog(get_class($this).
"::updateline Erreur -2 SupplierProposal en mode incompatible pour cette action");
835 $line->fetch($lineid);
837 if ($line->delete() > 0)
859 public function create($user, $notrigger = 0)
861 global $langs, $conf, $mysoc, $hookmanager;
872 $this->error =
"Failed to fetch company";
873 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
876 if (!empty($this->ref))
878 $result = self::isExistingObject($this->element, 0, $this->ref);
881 $this->error =
'ErrorRefAlreadyExists';
882 dol_syslog(get_class($this).
"::create ".$this->error, LOG_WARNING);
883 $this->
db->rollback();
889 $delivery_date = empty($this->delivery_date) ? $this->date_livraison : $this->delivery_date;
892 if (!empty($this->multicurrency_code)) list($this->fk_multicurrency, $this->multicurrency_tx) =
MultiCurrency::getIdAndTxFromCode($this->
db, $this->multicurrency_code, $now);
893 if (empty($this->fk_multicurrency))
895 $this->multicurrency_code = $conf->currency;
896 $this->fk_multicurrency = 0;
897 $this->multicurrency_tx = 1;
903 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"supplier_proposal (";
907 $sql .=
", remise_percent";
908 $sql .=
", remise_absolue";
913 $sql .=
", fk_user_author";
914 $sql .=
", note_private";
915 $sql .=
", note_public";
916 $sql .=
", model_pdf";
917 $sql .=
", fk_cond_reglement";
918 $sql .=
", fk_mode_reglement";
919 $sql .=
", fk_account";
920 $sql .=
", date_livraison";
921 $sql .=
", fk_shipping_method";
922 $sql .=
", fk_projet";
924 $sql .=
", fk_multicurrency";
925 $sql .=
", multicurrency_code";
926 $sql .=
", multicurrency_tx";
929 $sql .= $this->socid;
931 $sql .=
", ".$this->remise;
932 $sql .=
", ".($this->remise_percent ? $this->
db->escape($this->remise_percent) :
'null');
933 $sql .=
", ".($this->remise_absolue ? $this->
db->escape($this->remise_absolue) :
'null');
936 $sql .=
", '".$this->db->idate($now).
"'";
937 $sql .=
", '(PROV)'";
938 $sql .=
", ".($user->id > 0 ? ((int) $user->id) :
"null");
939 $sql .=
", '".$this->db->escape($this->note_private).
"'";
940 $sql .=
", '".$this->db->escape($this->note_public).
"'";
941 $sql .=
", '".$this->db->escape($this->model_pdf).
"'";
942 $sql .=
", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id :
'NULL');
943 $sql .=
", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id :
'NULL');
944 $sql .=
", ".($this->fk_account > 0 ? $this->fk_account :
'NULL');
945 $sql .=
", ".($delivery_date ?
"'".$this->db->idate($delivery_date).
"'" :
"null");
946 $sql .=
", ".($this->shipping_method_id > 0 ? $this->shipping_method_id :
'NULL');
947 $sql .=
", ".($this->fk_project ? $this->fk_project :
"null");
948 $sql .=
", ".$conf->entity;
949 $sql .=
", ".(int) $this->fk_multicurrency;
950 $sql .=
", '".$this->db->escape($this->multicurrency_code).
"'";
951 $sql .=
", ".(double) $this->multicurrency_tx;
954 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
958 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"supplier_proposal");
962 $this->ref =
'(PROV'.$this->id.
')';
963 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"supplier_proposal SET ref='".$this->
db->escape($this->ref).
"' WHERE rowid=".$this->id;
965 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
969 if (!empty($this->linkedObjectsIds) && empty($this->linked_objects))
971 $this->linked_objects = $this->linkedObjectsIds;
975 if (!$error && $this->
id && !empty($this->linked_objects) && is_array($this->linked_objects))
977 foreach ($this->linked_objects as $origin => $tmp_origin_id)
979 if (is_array($tmp_origin_id))
981 foreach ($tmp_origin_id as $origin_id)
1000 $num = count($this->lines);
1002 for ($i = 0; $i < $num; $i++)
1005 if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) {
1006 $fk_parent_line = 0;
1010 $this->lines[$i]->desc,
1011 $this->lines[$i]->subprice,
1012 $this->lines[$i]->qty,
1013 $this->lines[$i]->tva_tx,
1014 $this->lines[$i]->localtax1_tx,
1015 $this->lines[$i]->localtax2_tx,
1016 $this->lines[$i]->fk_product,
1017 $this->lines[$i]->remise_percent,
1021 $this->lines[$i]->product_type,
1022 $this->lines[$i]->rang,
1023 $this->lines[$i]->special_code,
1025 $this->lines[$i]->fk_fournprice,
1026 $this->lines[$i]->pa_ht,
1027 empty($this->lines[$i]->label) ?
'' : $this->lines[$i]->label,
1028 $this->lines[$i]->array_options,
1029 $this->lines[$i]->ref_fourn,
1030 $this->lines[$i]->fk_unit,
1031 'supplier_proposal',
1032 $this->lines[$i]->
rowid
1038 $this->error = $this->
db->error;
1043 if ($result > 0 && $this->lines[$i]->product_type == 9) {
1044 $fk_parent_line = $result;
1067 if (!$error && !$notrigger)
1070 $result = $this->
call_trigger(
'PROPOSAL_SUPPLIER_CREATE', $user);
1071 if ($result < 0) { $error++; }
1075 $this->error = $this->
db->lasterror();
1080 $this->error = $this->
db->lasterror();
1086 $this->
db->commit();
1087 dol_syslog(get_class($this).
"::create done id=".$this->
id);
1090 $this->
db->rollback();
1094 $this->error = $this->
db->lasterror();
1095 $this->
db->rollback();
1109 global $conf, $hookmanager;
1117 foreach ($this->lines as $line)
1118 $line->fetch_optionals();
1121 $objFrom = clone $this;
1126 if (!empty($fromid) && $fromid != $this->socid)
1128 if ($objsoc->fetch($fromid) > 0)
1130 $this->socid = $objsoc->id;
1131 $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
1132 $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
1133 $this->fk_project =
'';
1138 $objsoc->fetch($this->socid);
1144 if (empty($conf->global->SUPPLIER_PROPOSAL_ADDON) || !is_readable(DOL_DOCUMENT_ROOT.
"/core/modules/supplier_proposal/".$conf->global->SUPPLIER_PROPOSAL_ADDON.
".php"))
1146 $this->error =
'ErrorSetupNotComplete';
1151 $this->user_author = $user->id;
1152 $this->user_valid =
'';
1156 require_once DOL_DOCUMENT_ROOT.
"/core/modules/supplier_proposal/".$conf->global->SUPPLIER_PROPOSAL_ADDON.
'.php';
1157 $obj = $conf->global->SUPPLIER_PROPOSAL_ADDON;
1158 $modSupplierProposal =
new $obj;
1159 $this->ref = $modSupplierProposal->getNextValue($objsoc, $this);
1162 $this->context[
'createfromclone'] =
'createfromclone';
1163 $result = $this->
create($user);
1164 if ($result < 0) $error++;
1169 if (is_object($hookmanager))
1171 $parameters = array(
'objFrom'=>$objFrom);
1173 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $this, $action);
1174 if ($reshook < 0) $error++;
1178 unset($this->context[
'createfromclone']);
1183 $this->
db->commit();
1186 $this->
db->rollback();
1198 public function fetch($rowid, $ref =
'')
1202 $sql =
"SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc";
1203 $sql .=
", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht";
1204 $sql .=
", p.datec";
1205 $sql .=
", p.date_valid as datev";
1206 $sql .=
", p.date_livraison as delivery_date";
1207 $sql .=
", p.model_pdf, p.extraparams";
1208 $sql .=
", p.note_private, p.note_public";
1209 $sql .=
", p.fk_projet as fk_project, p.fk_statut";
1210 $sql .=
", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture";
1211 $sql .=
", p.fk_cond_reglement";
1212 $sql .=
", p.fk_mode_reglement";
1213 $sql .=
', p.fk_account';
1214 $sql .=
", p.fk_shipping_method";
1215 $sql .=
", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc";
1216 $sql .=
", c.label as statut_label";
1217 $sql .=
", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
1218 $sql .=
", cp.code as mode_reglement_code, cp.libelle as mode_reglement";
1219 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_propalst as c, ".MAIN_DB_PREFIX.
"supplier_proposal as p";
1220 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as cp ON p.fk_mode_reglement = cp.id';
1221 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid';
1222 $sql .=
" WHERE p.fk_statut = c.id";
1223 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
1224 if ($ref) $sql .=
" AND p.ref='".$ref.
"'";
1225 else $sql .=
" AND p.rowid=".$rowid;
1227 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1233 $obj = $this->
db->fetch_object(
$resql);
1235 $this->
id = $obj->rowid;
1236 $this->entity = $obj->entity;
1238 $this->ref = $obj->ref;
1239 $this->remise = $obj->remise;
1240 $this->remise_percent = $obj->remise_percent;
1241 $this->remise_absolue = $obj->remise_absolue;
1242 $this->total = $obj->total;
1243 $this->total_ht = $obj->total_ht;
1244 $this->total_tva = $obj->tva;
1245 $this->total_localtax1 = $obj->localtax1;
1246 $this->total_localtax2 = $obj->localtax2;
1247 $this->total_ttc = $obj->total;
1248 $this->socid = $obj->fk_soc;
1249 $this->fk_project = $obj->fk_project;
1250 $this->model_pdf = $obj->model_pdf;
1251 $this->modelpdf = $obj->model_pdf;
1252 $this->
note = $obj->note_private;
1253 $this->note_private = $obj->note_private;
1254 $this->note_public = $obj->note_public;
1255 $this->
statut = (int) $obj->fk_statut;
1256 $this->statut_libelle = $obj->statut_label;
1257 $this->datec = $this->db->jdate($obj->datec);
1258 $this->datev = $this->
db->jdate($obj->datev);
1259 $this->date_creation = $this->
db->jdate($obj->datec);
1260 $this->date_validation = $this->
db->jdate($obj->datev);
1261 $this->date_livraison = $this->
db->jdate($obj->delivery_date);
1262 $this->delivery_date = $this->
db->jdate($obj->delivery_date);
1263 $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null;
1265 $this->mode_reglement_id = $obj->fk_mode_reglement;
1266 $this->mode_reglement_code = $obj->mode_reglement_code;
1267 $this->mode_reglement = $obj->mode_reglement;
1268 $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null;
1269 $this->cond_reglement_id = $obj->fk_cond_reglement;
1270 $this->cond_reglement_code = $obj->cond_reglement_code;
1271 $this->cond_reglement = $obj->cond_reglement;
1272 $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
1274 $this->extraparams = (array) json_decode($obj->extraparams,
true);
1276 $this->user_author_id = $obj->fk_user_author;
1277 $this->user_valid_id = $obj->fk_user_valid;
1278 $this->user_close_id = $obj->fk_user_cloture;
1281 $this->fk_multicurrency = $obj->fk_multicurrency;
1282 $this->multicurrency_code = $obj->multicurrency_code;
1283 $this->multicurrency_tx = $obj->multicurrency_tx;
1284 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
1285 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
1286 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1288 if ($obj->fk_statut == 0)
1290 $this->brouillon = 1;
1299 $this->lines = array();
1302 $sql =
"SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
1303 $sql .=
" d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,";
1304 $sql .=
' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
1305 $sql .=
' d.ref_fourn as ref_produit_fourn,';
1306 $sql .=
' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit';
1307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposaldet as d";
1308 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON d.fk_product = p.rowid";
1309 $sql .=
" WHERE d.fk_supplier_proposal = ".$this->id;
1310 $sql .=
" ORDER by d.rang";
1312 $result = $this->
db->query($sql);
1315 $num = $this->
db->num_rows($result);
1320 $objp = $this->
db->fetch_object($result);
1324 $line->rowid = $objp->rowid;
1325 $line->id = $objp->rowid;
1326 $line->fk_supplier_proposal = $objp->fk_supplier_proposal;
1327 $line->fk_parent_line = $objp->fk_parent_line;
1328 $line->product_type = $objp->product_type;
1329 $line->label = $objp->custom_label;
1330 $line->desc = $objp->description;
1331 $line->qty = $objp->qty;
1332 $line->tva_tx = $objp->tva_tx;
1333 $line->localtax1_tx = $objp->localtax1_tx;
1334 $line->localtax2_tx = $objp->localtax2_tx;
1335 $line->subprice = $objp->subprice;
1336 $line->fk_remise_except = $objp->fk_remise_except;
1337 $line->remise_percent = $objp->remise_percent;
1339 $line->info_bits = $objp->info_bits;
1340 $line->total_ht = $objp->total_ht;
1341 $line->total_tva = $objp->total_tva;
1342 $line->total_localtax1 = $objp->total_localtax1;
1343 $line->total_localtax2 = $objp->total_localtax2;
1344 $line->total_ttc = $objp->total_ttc;
1345 $line->fk_fournprice = $objp->fk_fournprice;
1346 $marginInfos =
getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
1347 $line->pa_ht = $marginInfos[0];
1348 $line->marge_tx = $marginInfos[1];
1349 $line->marque_tx = $marginInfos[2];
1350 $line->special_code = $objp->special_code;
1351 $line->rang = $objp->rang;
1353 $line->fk_product = $objp->fk_product;
1355 $line->ref = $objp->product_ref;
1356 $line->product_ref = $objp->product_ref;
1357 $line->libelle = $objp->product_label;
1358 $line->product_label = $objp->product_label;
1359 $line->product_desc = $objp->product_desc;
1360 $line->fk_product_type = $objp->fk_product_type;
1362 $line->ref_fourn = $objp->ref_produit_fourn;
1365 $line->fk_multicurrency = $objp->fk_multicurrency;
1366 $line->multicurrency_code = $objp->multicurrency_code;
1367 $line->multicurrency_subprice = $objp->multicurrency_subprice;
1368 $line->multicurrency_total_ht = $objp->multicurrency_total_ht;
1369 $line->multicurrency_total_tva = $objp->multicurrency_total_tva;
1370 $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
1371 $line->fk_unit = $objp->fk_unit;
1373 $this->lines[$i] = $line;
1377 $this->
db->free($result);
1379 $this->error = $this->
db->error();
1390 $this->error =
"Record Not Found";
1393 $this->error = $this->
db->error();
1405 public function valid($user, $notrigger = 0)
1407 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1409 global $conf, $langs;
1414 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer))
1415 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)))
1421 $soc->fetch($this->socid);
1424 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->ref) || empty($this->ref)))
1432 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal";
1433 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
1434 $sql .=
" fk_statut = 1, date_valid='".$this->db->idate($now).
"', fk_user_valid=".$user->id;
1435 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = 0";
1437 dol_syslog(get_class($this).
"::valid", LOG_DEBUG);
1446 if (!$error && !$notrigger)
1449 $result = $this->
call_trigger(
'PROPOSAL_SUPPLIER_VALIDATE', $user);
1450 if ($result < 0) { $error++; }
1456 $this->oldref = $this->ref;
1459 if (preg_match(
'/^[\(]?PROV/i', $this->ref))
1462 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->
db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->ref) + 1).
")), filepath = 'supplier_proposal/".$this->
db->escape($this->newref).
"'";
1463 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->ref).
"%' AND filepath = 'supplier_proposal/".$this->
db->escape($this->ref).
"' and entity = ".$conf->entity;
1465 if (!
$resql) { $error++; $this->error = $this->
db->lasterror(); }
1470 $dirsource = $conf->supplier_proposal->dir_output.
'/'.$oldref;
1471 $dirdest = $conf->supplier_proposal->dir_output.
'/'.$newref;
1472 if (!$error && file_exists($dirsource))
1474 dol_syslog(get_class($this).
"::valid rename dir ".$dirsource.
" into ".$dirdest);
1475 if (@rename($dirsource, $dirdest))
1479 $listoffiles =
dol_dir_list($conf->supplier_proposal->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
1480 foreach ($listoffiles as $fileentry)
1482 $dirsource = $fileentry[
'name'];
1483 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
1484 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
1485 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
1486 @rename($dirsource, $dirdest);
1493 $this->brouillon = 0;
1495 $this->user_valid_id = $user->id;
1496 $this->datev = $now;
1498 $this->
db->commit();
1501 $this->
db->rollback();
1505 dol_syslog(
"You don't have permission to validate supplier proposal", LOG_WARNING);
1534 if (!empty($user->rights->supplier_proposal->creer))
1536 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal ";
1537 $sql .=
" SET date_livraison = ".($delivery_date !=
'' ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
1538 $sql .=
" WHERE rowid = ".$this->id;
1540 if ($this->
db->query($sql))
1542 $this->date_livraison = $delivery_date;
1543 $this->delivery_date = $delivery_date;
1546 $this->error = $this->
db->error();
1547 dol_syslog(get_class($this).
"::setDeliveryDate Erreur SQL");
1564 $remise = trim($remise) ?trim($remise) : 0;
1566 if (!empty($user->rights->supplier_proposal->creer))
1570 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal SET remise_percent = ".$remise;
1571 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = 0";
1573 if ($this->
db->query($sql))
1575 $this->remise_percent = $remise;
1579 $this->error = $this->
db->error();
1597 $remise = trim($remise) ?trim($remise) : 0;
1599 if (!empty($user->rights->supplier_proposal->creer))
1603 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal ";
1604 $sql .=
" SET remise_absolue = ".$remise;
1605 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = 0";
1607 if ($this->
db->query($sql))
1609 $this->remise_absolue = $remise;
1613 $this->error = $this->
db->error();
1632 global $langs, $conf;
1637 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal";
1638 $sql .=
" SET fk_statut = ".$this->statut.
",";
1639 if (!empty(
$note)) $sql .=
" note_private = '".$this->db->escape(
$note).
"',";
1640 $sql .=
" date_cloture=NULL, fk_user_cloture=NULL";
1641 $sql .=
" WHERE rowid = ".$this->id;
1645 dol_syslog(get_class($this).
"::reopen", LOG_DEBUG);
1648 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
1655 $result = $this->
call_trigger(
'PROPOSAL_SUPPLIER_REOPEN', $user);
1656 if ($result < 0) { $error++; }
1664 if (!empty($this->errors))
1666 foreach ($this->errors as $errmsg)
1668 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1669 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1672 $this->
db->rollback();
1675 $this->
db->commit();
1691 global $langs, $conf;
1699 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal";
1700 $sql .=
" SET fk_statut = ".$status.
", note_private = '".$this->
db->escape(
$note).
"', date_cloture='".$this->
db->idate($now).
"', fk_user_cloture=".$user->id;
1701 $sql .=
" WHERE rowid = ".$this->id;
1706 $modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED : (empty($this->modelpdf) ?
'' : $this->modelpdf);
1707 $triggerName =
'PROPOSAL_SUPPLIER_CLOSE_REFUSED';
1711 $triggerName =
'PROPOSAL_SUPPLIER_CLOSE_SIGNED';
1712 $modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL : (empty($this->modelpdf) ?
'' : $this->modelpdf);
1714 if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL))
1721 $triggerName =
'PROPOSAL_SUPPLIER_CLASSIFY_BILLED';
1724 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
1727 $outputlangs = $langs;
1728 if (!empty($conf->global->MAIN_MULTILANGS)) {
1729 $outputlangs =
new Translate(
"", $conf);
1730 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $this->thirdparty->default_lang);
1731 $outputlangs->setDefaultLang($newlang);
1734 $this->
generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1739 if ($result < 0) { $error++; }
1744 $this->
db->commit();
1747 $this->
db->rollback();
1751 $this->error = $this->
db->lasterror();
1752 $this->errors[] = $this->
db->lasterror();
1753 $this->
db->rollback();
1768 dol_syslog(get_class($this).
"::updateOrCreatePriceFournisseur", LOG_DEBUG);
1769 foreach ($this->lines as $product)
1771 if ($product->subprice <= 0)
continue;
1774 $multicurrency_tx = 1;
1775 $fk_multicurrency = 0;
1779 $ref_fourn = $product->ref_fourn;
1780 if (empty($ref_fourn)) $ref_fourn = $product->ref_supplier;
1781 if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) =
MultiCurrency::getIdAndTxFromCode($this->
db, $product->multicurrency_code);
1782 $productsupplier->id = $product->fk_product;
1784 $productsupplier->update_buyprice($product->qty, $product->total_ht, $user,
'HT', $this->thirdparty,
'', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits,
'',
'', array(),
'', $product->multicurrency_total_ht,
'HT', $multicurrency_tx, $product->multicurrency_code,
'',
'',
'');
1801 $unitPrice =
price2num($product->subprice,
'MU');
1803 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'product_fournisseur_price SET '.(!empty($product->ref_fourn) ?
'ref_fourn = "'.$product->ref_fourn.
'", ' :
'').
' price ='.
$price.
', unitprice ='.$unitPrice.
' WHERE rowid = '.$idProductFournPrice;
1805 $resql = $this->db->query($sql);
1807 $this->error = $this->
db->error();
1808 $this->
db->rollback();
1826 $unitPrice =
price2num($product->subprice,
'MU');
1831 "'".$this->
db->idate($now).
"'",
1832 $product->fk_product,
1833 $this->thirdparty->id,
1834 "'".$product->ref_fourn.
"'",
1841 if (!empty($conf->multicurrency->enabled)) {
1842 if (!empty($product->multicurrency_code)) {
1843 include_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
1845 $multicurrency->fetch(0, $product->multicurrency_code);
1846 if (!empty($multicurrency->id)) {
1847 $values[] = $multicurrency->id;
1848 $values[] =
"'".$product->multicurrency_code.
"'";
1849 $values[] = $product->multicurrency_subprice;
1850 $values[] = $product->multicurrency_total_ht;
1851 $values[] = $multicurrency->rate->rate;
1853 for ($i = 0; $i < 5; $i++) $values[] =
'NULL';
1858 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'product_fournisseur_price ';
1859 $sql .=
'(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user';
1860 if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) $sql .=
',fk_multicurrency, multicurrency_code, multicurrency_unitprice, multicurrency_price, multicurrency_tx';
1861 $sql .=
') VALUES ('.implode(
',', $values).
')';
1865 $this->error = $this->
db->error();
1866 $this->
db->rollback();
1881 global $conf, $langs;
1885 if ($this->
statut == self::STATUS_DRAFT)
1887 dol_syslog(get_class($this).
"::setDraft already draft status", LOG_WARNING);
1891 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposal";
1892 $sql .=
" SET fk_statut = ".self::STATUS_DRAFT;
1893 $sql .=
" WHERE rowid = ".$this->id;
1895 if ($this->
db->query($sql))
1898 $this->oldcopy = clone $this;
1903 $result = $this->
call_trigger(
'PROPOSAL_SUPPLIER_UNVALIDATE', $user);
1904 if ($result < 0) $error++;
1908 $this->
statut = self::STATUS_DRAFT;
1909 $this->brouillon = 1;
1910 $this->
db->commit();
1913 $this->
db->rollback();
1936 public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield =
'p.datec', $sortorder =
'DESC')
1939 global $conf, $user;
1943 $sql =
"SELECT s.rowid, s.nom as name, s.client,";
1944 $sql .=
" p.rowid as supplier_proposalid, p.fk_statut, p.total_ht, p.ref, p.remise, ";
1945 $sql .=
" p.datep as dp, p.fin_validite as datelimite";
1946 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", sc.fk_soc, sc.fk_user";
1947 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"supplier_proposal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
1948 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1949 $sql .=
" WHERE p.entity IN (".getEntity(
'supplier_proposal').
")";
1950 $sql .=
" AND p.fk_soc = s.rowid";
1951 $sql .=
" AND p.fk_statut = c.id";
1952 if (!$user->rights->societe->client->voir && !$socid)
1954 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
1956 if ($socid) $sql .=
" AND s.rowid = ".$socid;
1957 if ($draft) $sql .=
" AND p.fk_statut = 0";
1958 if ($notcurrentuser > 0) $sql .=
" AND p.fk_user_author <> ".$user->id;
1959 $sql .= $this->
db->order($sortfield, $sortorder);
1960 $sql .= $this->
db->plimit($limit, $offset);
1962 $result = $this->
db->query($sql);
1965 $num = $this->
db->num_rows($result);
1971 $obj = $this->
db->fetch_object($result);
1973 if ($shortlist == 1)
1975 $ga[$obj->supplier_proposalid] = $obj->ref;
1976 } elseif ($shortlist == 2)
1978 $ga[$obj->supplier_proposalid] = $obj->ref.
' ('.$obj->name.
')';
1980 $ga[$i][
'id'] = $obj->supplier_proposalid;
1981 $ga[$i][
'ref'] = $obj->ref;
1982 $ga[$i][
'name'] = $obj->name;
2002 public function delete($user, $notrigger = 0)
2004 global $conf, $langs;
2005 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2014 $result = $this->
call_trigger(
'PROPOSAL_SUPPLIER_DELETE', $user);
2015 if ($result < 0) { $error++; }
2021 $main = MAIN_DB_PREFIX.
'supplier_proposaldet';
2022 $ef = $main.
"_extrafields";
2023 $sqlef =
"DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_supplier_proposal = ".$this->id.
")";
2024 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"supplier_proposaldet WHERE fk_supplier_proposal = ".$this->id;
2025 if ($this->
db->query($sql))
2027 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"supplier_proposal WHERE rowid = ".$this->id;
2028 if ($this->
db->query($sqlef) && $this->
db->query($sql))
2032 if ($res < 0) $error++;
2041 if ($conf->supplier_proposal->dir_output && !empty($this->ref))
2043 $dir = $conf->supplier_proposal->dir_output.
"/".$ref;
2044 $file = $dir.
"/".$ref.
".pdf";
2045 if (file_exists($file))
2051 $this->error =
'ErrorFailToDeleteFile';
2052 $this->errors = array(
'ErrorFailToDeleteFile');
2053 $this->
db->rollback();
2057 if (file_exists($dir))
2062 $this->error =
'ErrorFailToDeleteDir';
2063 $this->errors = array(
'ErrorFailToDeleteDir');
2064 $this->
db->rollback();
2079 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
2085 dol_syslog(get_class($this).
"::delete ".$this->
id.
" by ".$user->id, LOG_DEBUG);
2086 $this->
db->commit();
2089 $this->error = $this->
db->lasterror();
2090 $this->
db->rollback();
2094 $this->error = $this->
db->lasterror();
2095 $this->
db->rollback();
2099 $this->error = $this->
db->lasterror();
2100 $this->
db->rollback();
2104 $this->
db->rollback();
2117 $sql =
"SELECT c.rowid, ";
2118 $sql .=
" c.datec, c.date_valid as datev, c.date_cloture as dateo,";
2119 $sql .=
" c.fk_user_author, c.fk_user_valid, c.fk_user_cloture";
2120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
2121 $sql .=
" WHERE c.rowid = ".((int) $id);
2123 $result = $this->
db->query($sql);
2127 if ($this->
db->num_rows($result))
2129 $obj = $this->
db->fetch_object($result);
2131 $this->
id = $obj->rowid;
2133 $this->date_creation = $this->
db->jdate($obj->datec);
2134 $this->date_validation = $this->
db->jdate($obj->datev);
2135 $this->date_cloture = $this->
db->jdate($obj->dateo);
2137 $cuser =
new User($this->
db);
2138 $cuser->fetch($obj->fk_user_author);
2139 $this->user_creation = $cuser;
2141 if ($obj->fk_user_valid)
2143 $vuser =
new User($this->
db);
2144 $vuser->fetch($obj->fk_user_valid);
2145 $this->user_validation = $vuser;
2148 if ($obj->fk_user_cloture)
2150 $cluser =
new User($this->
db);
2151 $cluser->fetch($obj->fk_user_cloture);
2152 $this->user_cloture = $cluser;
2155 $this->
db->free($result);
2186 if (empty($this->labelStatus) || empty($this->labelStatusShort))
2189 $langs->load(
"supplier_proposal");
2190 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusDraft");
2191 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusValidated");
2192 $this->labelStatus[self::STATUS_SIGNED] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusSigned");
2193 $this->labelStatus[self::STATUS_NOTSIGNED] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusNotSigned");
2194 $this->labelStatus[self::STATUS_CLOSE] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusClosed");
2195 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusDraftShort");
2196 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
"Opened");
2197 $this->labelStatusShort[self::STATUS_SIGNED] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusSignedShort");
2198 $this->labelStatusShort[self::STATUS_NOTSIGNED] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusNotSignedShort");
2199 $this->labelStatusShort[self::STATUS_CLOSE] = $langs->transnoentitiesnoconv(
"SupplierProposalStatusClosedShort");
2203 if ($status == self::STATUS_DRAFT) $statusnew =
'status0';
2204 elseif ($status == self::STATUS_VALIDATED) $statusnew =
'status1';
2205 elseif ($status == self::STATUS_SIGNED) $statusnew =
'status4';
2206 elseif ($status == self::STATUS_NOTSIGNED) $statusnew =
'status9';
2207 elseif ($status == self::STATUS_CLOSE) $statusnew =
'status6';
2209 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusnew, $mode);
2224 global $conf, $user, $langs;
2228 $this->nbtodo = $this->nbtodolate = 0;
2231 $sql =
"SELECT p.rowid, p.ref, p.datec as datec";
2232 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p";
2233 if (!$user->rights->societe->client->voir && !$user->socid)
2235 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
2236 $sql .=
" WHERE sc.fk_user = ".$user->id;
2239 $sql .= $clause.
" p.entity IN (".
getEntity(
'supplier_proposal').
")";
2240 if ($mode ==
'opened') $sql .=
" AND p.fk_statut = 1";
2241 if ($mode ==
'signed') $sql .=
" AND p.fk_statut = 2";
2242 if ($user->socid) $sql .=
" AND p.fk_soc = ".$user->socid;
2247 $label = $labelShort =
'';
2249 if ($mode ==
'opened') {
2250 $delay_warning = $conf->supplier_proposal->cloture->warning_delay;
2251 $status = self::STATUS_VALIDATED;
2252 $label = $langs->trans(
"SupplierProposalsToClose");
2253 $labelShort = $langs->trans(
"ToAcceptRefuse");
2255 if ($mode ==
'signed') {
2256 $delay_warning = $conf->supplier_proposal->facturation->warning_delay;
2257 $status = self::STATUS_SIGNED;
2258 $label = $langs->trans(
"SupplierProposalsToProcess");
2259 $labelShort = $langs->trans(
"ToClose");
2263 $response->warning_delay = $delay_warning / 60 / 60 / 24;
2264 $response->label = $label;
2265 $response->labelShort = $labelShort;
2266 $response->url = DOL_URL_ROOT.
'/supplier_proposal/list.php?search_status='.$status;
2270 while ($obj = $this->
db->fetch_object(
$resql))
2272 $response->nbtodo++;
2273 if ($mode ==
'opened')
2275 $datelimit = $this->
db->jdate($obj->datefin);
2276 if ($datelimit < ($now - $delay_warning))
2278 $response->nbtodolate++;
2286 $this->error = $this->
db->lasterror();
2301 global $user, $langs, $conf;
2306 $sql =
"SELECT rowid";
2307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
2308 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
2309 $sql .= $this->
db->plimit(100);
2314 $num_prods = $this->
db->num_rows(
$resql);
2316 while ($i < $num_prods)
2319 $row = $this->
db->fetch_row(
$resql);
2320 $prodids[$i] = $row[0];
2326 $this->ref =
'SPECIMEN';
2327 $this->specimen = 1;
2329 $this->date = time();
2330 $this->cond_reglement_id = 1;
2331 $this->cond_reglement_code =
'RECEP';
2332 $this->mode_reglement_id = 7;
2333 $this->mode_reglement_code =
'CHQ';
2334 $this->note_public =
'This is a comment (public)';
2335 $this->note_private =
'This is a comment (private)';
2339 while ($xnbp < $nbp)
2342 $line->desc = $langs->trans(
"Description").
" ".$xnbp;
2344 $line->subprice = 100;
2345 $line->tva_tx = 19.6;
2346 $line->localtax1_tx = 0;
2347 $line->localtax2_tx = 0;
2350 $line->total_ht = 50;
2351 $line->total_ttc = 59.8;
2352 $line->total_tva = 9.8;
2353 $line->remise_percent = 50;
2355 $line->total_ht = 100;
2356 $line->total_ttc = 119.6;
2357 $line->total_tva = 19.6;
2358 $line->remise_percent = 00;
2363 $prodid = mt_rand(1, $num_prods);
2364 $line->fk_product = $prodids[$prodid];
2367 $this->lines[$xnbp] = $line;
2369 $this->total_ht += $line->total_ht;
2370 $this->total_tva += $line->total_tva;
2371 $this->total_ttc += $line->total_ttc;
2386 global $conf, $user;
2388 $this->nb = array();
2391 $sql =
"SELECT count(p.rowid) as nb";
2392 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p";
2393 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
2394 if (!$user->rights->societe->client->voir && !$user->socid)
2396 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
2397 $sql .=
" WHERE sc.fk_user = ".$user->id;
2400 $sql .=
" ".$clause.
" p.entity IN (".
getEntity(
'supplier_proposal').
")";
2406 while ($obj = $this->
db->fetch_object(
$resql))
2408 $this->nb[
"supplier_proposals"] = $obj->nb;
2414 $this->error = $this->
db->lasterror();
2429 global $conf, $db, $langs;
2430 $langs->load(
"supplier_proposal");
2432 if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON))
2436 $file = $conf->global->SUPPLIER_PROPOSAL_ADDON.
".php";
2437 $classname = $conf->global->SUPPLIER_PROPOSAL_ADDON;
2440 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
2441 foreach ($dirmodels as $reldir) {
2442 $dir =
dol_buildpath($reldir.
"core/modules/supplier_proposal/");
2445 $mybool |= @include_once $dir.$file;
2454 $obj =
new $classname();
2456 $numref = $obj->getNextValue($soc, $this);
2462 $this->error = $obj->error;
2466 $langs->load(
"errors");
2467 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"SupplierProposal"));
2483 public function getNomUrl($withpicto = 0, $option =
'', $get_params =
'', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0)
2485 global $langs, $conf, $user;
2487 if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1;
2492 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"SupplierProposal").
'</u>';
2493 if (isset($this->status)) {
2494 $label .=
' '.$this->getLibStatut(5);
2496 if (!empty($this->ref)) $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2497 if (!empty($this->ref_fourn)) $label .=
'<br><b>'.$langs->trans(
'RefSupplier').
':</b> '.$this->ref_fourn;
2498 if (!empty($this->total_ht)) $label .=
'<br><b>'.$langs->trans(
'AmountHT').
':</b> '.
price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
2499 if (!empty($this->total_tva)) $label .=
'<br><b>'.$langs->trans(
'VAT').
':</b> '.
price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
2500 if (!empty($this->total_ttc)) $label .=
'<br><b>'.$langs->trans(
'AmountTTC').
':</b> '.
price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
2502 if ($option ==
'') {
2503 $url = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.$this->
id.$get_params;
2505 if ($option ==
'document') {
2506 $url = DOL_URL_ROOT.
'/supplier_proposal/document.php?id='.$this->
id.$get_params;
2509 if ($option !==
'nolink')
2512 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2513 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
2514 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
2518 if (empty($notooltip) && $user->rights->propal->lire)
2520 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
2522 $label = $langs->trans(
"ShowSupplierProposal");
2523 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2525 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2526 $linkclose .=
' class="classfortooltip"';
2529 $linkstart =
'<a href="'.$url.
'"';
2530 $linkstart .= $linkclose.
'>';
2533 $result .= $linkstart;
2534 if ($withpicto) $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
2535 if ($withpicto != 2) $result .= $this->ref;
2536 $result .= $linkend;
2538 if ($addlinktonotes)
2540 $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private);
2544 $result .=
' <span class="note inline-block">';
2545 $result .=
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2550 $result .=
'</span>';
2566 $sql =
'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
2567 $sql .=
' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
2568 $sql .=
' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
2569 $sql .=
' pt.product_type, pt.rang, pt.fk_parent_line,';
2570 $sql .=
' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
2571 $sql .=
' p.description as product_desc, pt.ref_fourn as ref_supplier,';
2572 $sql .=
' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit';
2573 $sql .=
' FROM '.MAIN_DB_PREFIX.
'supplier_proposaldet as pt';
2574 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON pt.fk_product=p.rowid';
2575 $sql .=
' WHERE pt.fk_supplier_proposal = '.$this->id;
2576 $sql .=
' ORDER BY pt.rang ASC, pt.rowid';
2578 dol_syslog(get_class($this).
'::getLinesArray', LOG_DEBUG);
2582 $num = $this->
db->num_rows(
$resql);
2587 $obj = $this->
db->fetch_object(
$resql);
2590 $this->lines[$i]->id = $obj->rowid;
2591 $this->lines[$i]->rowid = $obj->rowid;
2592 $this->lines[$i]->label = $obj->custom_label;
2593 $this->lines[$i]->description = $obj->description;
2594 $this->lines[$i]->fk_product = $obj->fk_product;
2595 $this->lines[$i]->ref = $obj->ref;
2596 $this->lines[$i]->product_label = $obj->product_label;
2597 $this->lines[$i]->product_desc = $obj->product_desc;
2598 $this->lines[$i]->fk_product_type = $obj->fk_product_type;
2599 $this->lines[$i]->product_type = $obj->product_type;
2600 $this->lines[$i]->qty = $obj->qty;
2601 $this->lines[$i]->subprice = $obj->subprice;
2602 $this->lines[$i]->fk_remise_except = $obj->fk_remise_except;
2603 $this->lines[$i]->remise_percent = $obj->remise_percent;
2604 $this->lines[$i]->tva_tx = $obj->tva_tx;
2605 $this->lines[$i]->info_bits = $obj->info_bits;
2606 $this->lines[$i]->total_ht = $obj->total_ht;
2607 $this->lines[$i]->total_tva = $obj->total_tva;
2608 $this->lines[$i]->total_ttc = $obj->total_ttc;
2609 $this->lines[$i]->fk_fournprice = $obj->fk_fournprice;
2610 $marginInfos =
getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht);
2611 $this->lines[$i]->pa_ht = $marginInfos[0];
2612 $this->lines[$i]->marge_tx = $marginInfos[1];
2613 $this->lines[$i]->marque_tx = $marginInfos[2];
2614 $this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
2615 $this->lines[$i]->special_code = $obj->special_code;
2616 $this->lines[$i]->rang = $obj->rang;
2618 $this->lines[$i]->ref_fourn = $obj->ref_supplier;
2619 $this->lines[$i]->ref_supplier = $obj->ref_supplier;
2622 $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency;
2623 $this->lines[$i]->multicurrency_code = $obj->multicurrency_code;
2624 $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice;
2625 $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht;
2626 $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva;
2627 $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
2628 $this->lines[$i]->fk_unit = $obj->fk_unit;
2636 $this->error = $this->
db->error();
2652 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
2654 global $conf, $langs;
2656 $langs->load(
"supplier_proposal");
2657 $outputlangs->load(
"products");
2662 if ($this->model_pdf) {
2663 $modele = $this->model_pdf;
2664 } elseif (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) {
2665 $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF;
2669 $modelpath =
"core/modules/supplier_proposal/doc/";
2671 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2712 public $element =
'supplier_proposaldet';
2717 public $table_element =
'supplier_proposaldet';
2729 public $fk_supplier_proposal;
2734 public $fk_parent_line;
2757 public $vat_src_code;
2760 public $remise_percent;
2765 public $fk_remise_except;
2772 public $fk_fournprice;
2778 public $special_code;
2783 public $info_bits = 0;
2805 public $product_ref;
2817 public $product_label;
2823 public $product_desc;
2825 public $localtax1_tx;
2826 public $localtax2_tx;
2827 public $localtax1_type;
2828 public $localtax2_type;
2829 public $total_localtax1;
2830 public $total_localtax2;
2832 public $skip_update_total;
2835 public $ref_supplier;
2841 public $fk_multicurrency;
2843 public $multicurrency_code;
2844 public $multicurrency_subprice;
2845 public $multicurrency_total_ht;
2846 public $multicurrency_total_tva;
2847 public $multicurrency_total_ttc;
2867 $sql =
'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,';
2868 $sql .=
' pd.date_start, pd.date_end,';
2869 $sql .=
' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
2870 $sql .=
' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,';
2871 $sql .=
' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,';
2872 $sql .=
' p.ref as product_ref, p.label as product_label, p.description as product_desc,';
2873 $sql .=
' pd.product_type, pd.ref_fourn as ref_produit_fourn,';
2874 $sql .=
' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit';
2875 $sql .=
' FROM '.MAIN_DB_PREFIX.
'supplier_proposaldet as pd';
2876 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON pd.fk_product = p.rowid';
2877 $sql .=
' WHERE pd.rowid = '.$rowid;
2879 $result = $this->
db->query($sql);
2882 $objp = $this->
db->fetch_object($result);
2884 $this->
id = $objp->rowid;
2885 $this->fk_supplier_proposal = $objp->fk_supplier_proposal;
2886 $this->fk_parent_line = $objp->fk_parent_line;
2887 $this->label = $objp->custom_label;
2888 $this->desc = $objp->description;
2889 $this->qty = $objp->qty;
2890 $this->subprice = $objp->subprice;
2891 $this->tva_tx = $objp->tva_tx;
2892 $this->remise_percent = $objp->remise_percent;
2893 $this->fk_remise_except = $objp->fk_remise_except;
2894 $this->fk_product = $objp->fk_product;
2895 $this->info_bits = $objp->info_bits;
2896 $this->date_start = $this->
db->jdate($objp->date_start);
2897 $this->date_end = $this->
db->jdate($objp->date_end);
2899 $this->total_ht = $objp->total_ht;
2900 $this->total_tva = $objp->total_tva;
2901 $this->total_ttc = $objp->total_ttc;
2903 $this->fk_fournprice = $objp->fk_fournprice;
2905 $marginInfos =
getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
2906 $this->pa_ht = $marginInfos[0];
2907 $this->marge_tx = $marginInfos[1];
2908 $this->marque_tx = $marginInfos[2];
2910 $this->special_code = $objp->special_code;
2911 $this->product_type = $objp->product_type;
2912 $this->rang = $objp->rang;
2914 $this->ref = $objp->product_ref;
2915 $this->product_ref = $objp->product_ref;
2916 $this->libelle = $objp->product_label;
2917 $this->product_label = $objp->product_label;
2918 $this->product_desc = $objp->product_desc;
2920 $this->ref_fourn = $objp->ref_produit_forun;
2923 $this->fk_multicurrency = $objp->fk_multicurrency;
2924 $this->multicurrency_code = $objp->multicurrency_code;
2925 $this->multicurrency_subprice = $objp->multicurrency_subprice;
2926 $this->multicurrency_total_ht = $objp->multicurrency_total_ht;
2927 $this->multicurrency_total_tva = $objp->multicurrency_total_tva;
2928 $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
2929 $this->fk_unit = $objp->fk_unit;
2931 $this->
db->free($result);
2945 global $conf, $langs, $user;
2949 dol_syslog(get_class($this).
"::insert rang=".$this->rang);
2952 if (empty($this->tva_tx)) $this->tva_tx = 0;
2953 if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
2954 if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
2955 if (empty($this->localtax1_type)) $this->localtax1_type = 0;
2956 if (empty($this->localtax2_type)) $this->localtax2_type = 0;
2957 if (empty($this->total_localtax1)) $this->total_localtax1 = 0;
2958 if (empty($this->total_localtax2)) $this->total_localtax2 = 0;
2959 if (empty($this->rang)) $this->rang = 0;
2960 if (empty($this->remise)) $this->remise = 0;
2961 if (empty($this->remise_percent)) $this->remise_percent = 0;
2962 if (empty($this->info_bits)) $this->info_bits = 0;
2963 if (empty($this->special_code)) $this->special_code = 0;
2964 if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
2965 if (empty($this->fk_fournprice)) $this->fk_fournprice = 0;
2966 if (empty($this->fk_unit)) $this->fk_unit = 0;
2967 if (empty($this->subprice)) $this->subprice = 0;
2969 if (empty($this->pa_ht)) $this->pa_ht = 0;
2972 if ($this->pa_ht == 0)
2974 if (($result = $this->
defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
2978 $this->pa_ht = $result;
2983 if ($this->product_type < 0)
return -1;
2988 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'supplier_proposaldet';
2989 $sql .=
' (fk_supplier_proposal, fk_parent_line, label, description, fk_product, product_type,';
2990 $sql .=
' date_start, date_end,';
2991 $sql .=
' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
2992 $sql .=
' subprice, remise_percent, ';
2993 $sql .=
' info_bits, ';
2994 $sql .=
' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,';
2995 $sql .=
' ref_fourn,';
2996 $sql .=
' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)';
2997 $sql .=
" VALUES (".$this->fk_supplier_proposal.
",";
2998 $sql .=
" ".($this->fk_parent_line > 0 ?
"'".$this->db->escape($this->fk_parent_line).
"'" :
"null").
",";
2999 $sql .=
" ".(!empty($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
3000 $sql .=
" '".$this->db->escape($this->desc).
"',";
3001 $sql .=
" ".($this->fk_product ?
"'".$this->db->escape($this->fk_product).
"'" :
"null").
",";
3002 $sql .=
" '".$this->db->escape($this->product_type).
"',";
3003 $sql .=
" ".($this->date_start ?
"'".$this->db->idate($this->date_start).
"'" :
"null").
",";
3004 $sql .=
" ".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
"null").
",";
3005 $sql .=
" ".($this->fk_remise_except ?
"'".$this->db->escape($this->fk_remise_except).
"'" :
"null").
",";
3006 $sql .=
" ".price2num($this->qty).
",";
3007 $sql .=
" ".price2num($this->tva_tx).
",";
3008 $sql .=
" ".price2num($this->localtax1_tx).
",";
3009 $sql .=
" ".price2num($this->localtax2_tx).
",";
3010 $sql .=
" '".$this->db->escape($this->localtax1_type).
"',";
3011 $sql .=
" '".$this->db->escape($this->localtax2_type).
"',";
3012 $sql .=
" ".(!empty($this->subprice) ?
price2num($this->subprice) :
"null").
",";
3013 $sql .=
" ".price2num($this->remise_percent).
",";
3014 $sql .=
" ".(isset($this->info_bits) ?
"'".$this->db->escape($this->info_bits).
"'" :
"null").
",";
3015 $sql .=
" ".price2num($this->total_ht).
",";
3016 $sql .=
" ".price2num($this->total_tva).
",";
3017 $sql .=
" ".price2num($this->total_localtax1).
",";
3018 $sql .=
" ".price2num($this->total_localtax2).
",";
3019 $sql .=
" ".price2num($this->total_ttc).
",";
3020 $sql .=
" ".(!empty($this->fk_fournprice) ?
"'".$this->db->escape($this->fk_fournprice).
"'" :
"null").
",";
3021 $sql .=
" ".(isset($this->pa_ht) ?
"'".price2num($this->pa_ht).
"'" :
"null").
",";
3022 $sql .=
' '.$this->special_code.
',';
3023 $sql .=
' '.$this->rang.
',';
3024 $sql .=
" '".$this->db->escape($this->ref_fourn).
"'";
3025 $sql .=
", ".($this->fk_multicurrency > 0 ? $this->fk_multicurrency :
'null');
3026 $sql .=
", '".$this->db->escape($this->multicurrency_code).
"'";
3027 $sql .=
", ".$this->multicurrency_subprice;
3028 $sql .=
", ".$this->multicurrency_total_ht;
3029 $sql .=
", ".$this->multicurrency_total_tva;
3030 $sql .=
", ".$this->multicurrency_total_ttc;
3031 $sql .=
", ".($this->fk_unit ? $this->fk_unit :
'null');
3034 dol_syslog(get_class($this).
'::insert', LOG_DEBUG);
3038 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'supplier_proposaldet');
3049 if (!$error && !$notrigger)
3052 $result = $this->
call_trigger(
'LINESUPPLIER_PROPOSAL_INSERT', $user);
3055 $this->
db->rollback();
3061 $this->
db->commit();
3064 $this->error = $this->
db->error().
" sql=".$sql;
3065 $this->
db->rollback();
3075 public function delete()
3077 global $conf, $langs, $user;
3082 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"supplier_proposaldet WHERE rowid = ".$this->id;
3083 dol_syslog(
"SupplierProposalLine::delete", LOG_DEBUG);
3084 if ($this->
db->query($sql))
3093 dol_syslog(get_class($this).
"::delete error -4 ".$this->error, LOG_ERR);
3098 $result = $this->
call_trigger(
'LINESUPPLIER_PROPOSAL_DELETE', $user);
3101 $this->
db->rollback();
3106 $this->
db->commit();
3110 $this->error = $this->
db->error().
" sql=".$sql;
3111 $this->
db->rollback();
3124 global $conf, $langs, $user;
3129 if (empty($this->tva_tx)) $this->tva_tx = 0;
3130 if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
3131 if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
3132 if (empty($this->total_localtax1)) $this->total_localtax1 = 0;
3133 if (empty($this->total_localtax2)) $this->total_localtax2 = 0;
3134 if (empty($this->localtax1_type)) $this->localtax1_type = 0;
3135 if (empty($this->localtax2_type)) $this->localtax2_type = 0;
3136 if (empty($this->marque_tx)) $this->marque_tx = 0;
3137 if (empty($this->marge_tx)) $this->marge_tx = 0;
3138 if (empty($this->remise_percent)) $this->remise_percent = 0;
3139 if (empty($this->info_bits)) $this->info_bits = 0;
3140 if (empty($this->special_code)) $this->special_code = 0;
3141 if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
3142 if (empty($this->fk_fournprice)) $this->fk_fournprice = 0;
3143 if (empty($this->fk_unit)) $this->fk_unit = 0;
3144 if (empty($this->subprice)) $this->subprice = 0;
3146 if (empty($this->pa_ht)) $this->pa_ht = 0;
3149 if ($this->pa_ht == 0)
3151 if (($result = $this->
defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
3155 $this->pa_ht = $result;
3162 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposaldet SET";
3163 $sql .=
" description='".$this->db->escape($this->desc).
"'";
3164 $sql .=
" , label=".(!empty($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null");
3165 $sql .=
" , product_type=".$this->product_type;
3166 $sql .=
" , date_start=".($this->date_start ?
"'".$this->db->idate($this->date_start).
"'" :
"null");
3167 $sql .=
" , date_end=".($this->date_end ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
3168 $sql .=
" , tva_tx='".price2num($this->tva_tx).
"'";
3169 $sql .=
" , localtax1_tx=".price2num($this->localtax1_tx);
3170 $sql .=
" , localtax2_tx=".price2num($this->localtax2_tx);
3171 $sql .=
" , localtax1_type='".$this->db->escape($this->localtax1_type).
"'";
3172 $sql .=
" , localtax2_type='".$this->db->escape($this->localtax2_type).
"'";
3173 $sql .=
" , qty='".price2num($this->qty).
"'";
3174 $sql .=
" , subprice=".price2num($this->subprice).
"";
3175 $sql .=
" , remise_percent=".price2num($this->remise_percent).
"";
3176 $sql .=
" , info_bits='".$this->db->escape($this->info_bits).
"'";
3177 if (empty($this->skip_update_total))
3179 $sql .=
" , total_ht=".price2num($this->total_ht).
"";
3180 $sql .=
" , total_tva=".price2num($this->total_tva).
"";
3181 $sql .=
" , total_ttc=".price2num($this->total_ttc).
"";
3182 $sql .=
" , total_localtax1=".price2num($this->total_localtax1).
"";
3183 $sql .=
" , total_localtax2=".price2num($this->total_localtax2).
"";
3185 $sql .=
" , fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ?
"'".$this->db->escape($this->fk_fournprice).
"'" :
"null");
3186 $sql .=
" , buy_price_ht=".price2num($this->pa_ht);
3187 if (strlen($this->special_code)) $sql .=
" , special_code=".$this->special_code;
3188 $sql .=
" , fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line :
"null");
3189 if (!empty($this->rang)) $sql .=
", rang=".$this->rang;
3190 $sql .=
" , ref_fourn=".(!empty($this->ref_fourn) ?
"'".$this->db->escape($this->ref_fourn).
"'" :
"null");
3191 $sql .=
" , fk_unit=".($this->fk_unit ? $this->fk_unit :
'null');
3194 $sql .=
" , multicurrency_subprice=".price2num($this->multicurrency_subprice).
"";
3195 $sql .=
" , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).
"";
3196 $sql .=
" , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).
"";
3197 $sql .=
" , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).
"";
3199 $sql .=
" WHERE rowid = ".$this->id;
3201 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
3214 if (!$error && !$notrigger)
3217 $result = $this->
call_trigger(
'LINESUPPLIER_PROPOSAL_UPDATE', $user);
3220 $this->
db->rollback();
3226 $this->
db->commit();
3229 $this->error = $this->
db->error();
3230 $this->
db->rollback();
3248 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"supplier_proposaldet SET";
3249 $sql .=
" total_ht=".price2num($this->total_ht,
'MT');
3250 $sql .=
",total_tva=".price2num($this->total_tva,
'MT');
3251 $sql .=
",total_ttc=".price2num($this->total_ttc,
'MT');
3252 $sql .=
" WHERE rowid = ".$this->id;
3254 dol_syslog(
"SupplierProposalLine::update_total", LOG_DEBUG);
3259 $this->
db->commit();
3262 $this->error = $this->
db->error();
3263 $this->
db->rollback();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
fetch($rowid)
Retrieve the propal line object.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type= 'HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label= '', $array_options=0, $ref_supplier= '', $fk_unit= '', $origin= '', $origin_id=0, $pu_ht_devise=0, $date_start=0, $date_end=0)
Add a proposal line into database (linked to product/service or not) Les parametres sont deja cense e...
LibStatut($status, $mode=1)
Return label of a status (draft, validated, ...)
const STATUS_NOTSIGNED
Not signed quote, canceled.
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $fk_pa, $paht)
Return an array with margins information of a line.
setDraft($user)
Set draft status.
static getIdAndTxFromCode($db, $code, $date_document= '')
Get id and rate of currency from code.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
updatePriceFournisseur($idProductFournPrice, $product, $user)
Upate ProductFournisseur.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield= 'p.datec', $sortorder= 'DESC')
Return list of askprice (eventually filtered on user) into an array.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
line_order($renum=false, $rowidorder= 'ASC', $fk_parent_line=true)
Save a new position (field rang) for details lines.
dol_delete_preview($object)
Delete all preview files linked to object instance.
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller= '', $localtaxes_array= '', $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code= '')
Calculate totals (net, vat, ...) of a line.
Class to manage Dolibarr users.
__construct($db)
Class line Contructor.
Class to manage Dolibarr database access.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
__construct($db, $socid="", $supplier_proposalid=0)
Constructor.
const STATUS_CLOSE
Billed or closed/processed quote.
info($id)
Object SupplierProposal Information.
const TYPE_PRODUCT
Regular product.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
update($notrigger=0)
Update propal line object into DB.
load_state_board()
Load indicator this->nb of global stats widget.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
reopen($user, $statut, $note= '', $notrigger=0)
Reopen the commercial proposal.
create($user, $notrigger=0)
Create commercial proposal into database this->ref can be set or empty.
$conf db
API class for accounts.
getNomUrl($withpicto=0, $option= '', $get_params= '', $notooltip=0, $save_lastsearch_value=-1, $addlinktonotes=0)
Return clicable link of object (with eventually picto)
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...
static replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
insertExtraFields($trigger= '', $userused=null)
Add/Update all extra fields values for the current object.
getLinesArray()
Retrieve an array of supplier proposal lines.
const STATUS_SIGNED
Signed quote.
insert($notrigger=0)
Insert object line propal in database.
Class to manage third parties objects (customers, suppliers, prospects...)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
createFromClone(User $user, $fromid=0)
Load an object from its id and create a new one in database.
update_total()
Update DB line fields total_xxx Used by migration.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
createPriceFournisseur($product, $user)
Create ProductFournisseur.
add_product($idproduct, $qty, $remise_percent=0)
Add line into array ->lines.
const STATUS_VALIDATED
Validated status.
deleteEcmFiles($mode=0)
Delete related files of object in database.
insert_discount($idremise)
Adding line of fixed discount in the proposal in DB.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
valid($user, $notrigger=0)
Set status to validated.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
deleteExtraFields()
Delete all extra fields values for the current object.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
set_remise_absolue($user, $remise)
Set an absolute overall discount on the proposal.
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteObjectLinked($sourceid=null, $sourcetype= '', $targetid=null, $targettype= '', $rowid= '')
Delete all links between an object $this.
set_date_livraison($user, $delivery_date)
Set delivery date.
defineBuyPrice($unitPrice=0.0, $discountPercent=0.0, $fk_product=0)
Get buy price to use for margin calculation.
Class to manage supplier_proposal lines.
print $_SERVER["PHP_SELF"]
Edit parameters.
trait CommonIncoterm
Superclass for incoterm classes.
setDeliveryDate($user, $delivery_date)
Set delivery date.
print
Draft customers invoices.
call_trigger($triggerName, $user)
Call trigger based on this instance.
const STATUS_DRAFT
Draft status.
getLibStatut($mode=0)
Return label of status of proposal (draft, validated, ...)
Class to manage price ask supplier.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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) Si ...
Class to manage absolute discounts.
initAsSpecimen()
Initialise an instance with random values.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
cloture($user, $status, $note)
Close the askprice.
updateOrCreatePriceFournisseur($user)
Add or update supplier price according to result of proposal.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
getNextNumRef($soc)
Returns the reference to the following non used Proposal used depending on the active numbering modul...
add_object_linked($origin=null, $origin_id=null)
Add objects linked in llx_element_element.
deleteline($lineid)
Delete detail line.
update_price($exclspec=0, $roundingadjust= 'none', $nodatabaseupdate=0, $seller=null)
Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines)...
updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc= '', $price_base_type= 'HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label= '', $type=0, $array_options=0, $ref_supplier= '', $fk_unit= '', $pu_ht_devise=0)
Update a proposal line.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
fetch($rowid, $ref= '')
Load a proposal from database and its ligne array.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
Class to manage predefined suppliers products.
if(!empty($search_group)) natural_search(array("g.nom"g note
set_remise_percent($user, $remise)
Set an overall discount on the proposal.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...