38 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobjectline.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 =
'propal';
61 public $table_element =
'propal';
66 public $table_element_line =
'propaldet';
71 public $fk_element =
'fk_propal';
76 public $picto =
'propal';
82 public $ismultientitymanaged = 1;
88 public $restrictiononfksoc = 1;
130 public $date_creation;
141 public $date_validation;
158 public $date_livraison;
163 public $delivery_date;
166 public $fin_validite;
168 public $user_author_id;
169 public $user_valid_id;
170 public $user_close_id;
188 public $cond_reglement_code;
189 public $mode_reglement_code;
191 public $remise_percent = 0;
192 public $remise_absolue = 0;
200 public $address_type;
203 public $availability_id;
204 public $availability_code;
206 public $duree_validite;
208 public $demand_reason_id;
209 public $demand_reason_code;
211 public $extraparams = array();
216 public $lines = array();
219 public $labelStatus = array();
220 public $labelStatusShort = array();
226 public $fk_multicurrency;
228 public $multicurrency_code;
229 public $multicurrency_tx;
230 public $multicurrency_total_ht;
231 public $multicurrency_total_tva;
232 public $multicurrency_total_ttc;
265 public $fields = array(
266 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
267 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>15,
'index'=>1),
268 'ref' =>array(
'type'=>
'varchar(30)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'showoncombobox'=>1,
'position'=>20),
269 'ref_client' =>array(
'type'=>
'varchar(255)',
'label'=>
'RefCustomer',
'enabled'=>1,
'visible'=>-1,
'position'=>22),
270 'ref_ext' =>array(
'type'=>
'varchar(255)',
'label'=>
'RefExt',
'enabled'=>1,
'visible'=>0,
'position'=>40),
271 'fk_soc' =>array(
'type'=>
'integer:Societe:societe/class/societe.class.php',
'label'=>
'ThirdParty',
'enabled'=>1,
'visible'=>-1,
'position'=>23),
272 'fk_projet' =>array(
'type'=>
'integer:Project:projet/class/project.class.php:1:fk_statut=1',
'label'=>
'Fk projet',
'enabled'=>1,
'visible'=>-1,
'position'=>24),
273 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>25),
274 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
275 'datep' =>array(
'type'=>
'date',
'label'=>
'Date',
'enabled'=>1,
'visible'=>-1,
'position'=>60),
276 'fin_validite' =>array(
'type'=>
'datetime',
'label'=>
'DateEnd',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
277 'date_valid' =>array(
'type'=>
'datetime',
'label'=>
'DateValidation',
'enabled'=>1,
'visible'=>-1,
'position'=>70),
278 'date_cloture' =>array(
'type'=>
'datetime',
'label'=>
'DateClosing',
'enabled'=>1,
'visible'=>-1,
'position'=>75),
279 'fk_user_author' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'Fk user author',
'enabled'=>1,
'visible'=>-1,
'position'=>80),
280 'fk_user_modif' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'position'=>85),
281 'fk_user_valid' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserValidation',
'enabled'=>1,
'visible'=>-1,
'position'=>90),
282 'fk_user_cloture' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'Fk user cloture',
'enabled'=>1,
'visible'=>-1,
'position'=>95),
283 'price' =>array(
'type'=>
'double',
'label'=>
'Price',
'enabled'=>1,
'visible'=>-1,
'position'=>105),
284 'remise_percent' =>array(
'type'=>
'double',
'label'=>
'RelativeDiscount',
'enabled'=>1,
'visible'=>-1,
'position'=>110),
285 'remise_absolue' =>array(
'type'=>
'double',
'label'=>
'CustomerRelativeDiscount',
'enabled'=>1,
'visible'=>-1,
'position'=>115),
287 'total_ht' =>array(
'type'=>
'double(24,8)',
'label'=>
'TotalHT',
'enabled'=>1,
'visible'=>-1,
'position'=>125,
'isameasure'=>1),
288 'tva' =>array(
'type'=>
'double(24,8)',
'label'=>
'VAT',
'enabled'=>1,
'visible'=>-1,
'position'=>130,
'isameasure'=>1),
289 'localtax1' =>array(
'type'=>
'double(24,8)',
'label'=>
'LocalTax1',
'enabled'=>1,
'visible'=>-1,
'position'=>135,
'isameasure'=>1),
290 'localtax2' =>array(
'type'=>
'double(24,8)',
'label'=>
'LocalTax2',
'enabled'=>1,
'visible'=>-1,
'position'=>140,
'isameasure'=>1),
291 'total' =>array(
'type'=>
'double(24,8)',
'label'=>
'TotalTTC',
'enabled'=>1,
'visible'=>-1,
'position'=>145,
'isameasure'=>1),
292 'fk_account' =>array(
'type'=>
'integer',
'label'=>
'BankAccount',
'enabled'=>1,
'visible'=>-1,
'position'=>150),
293 'fk_currency' =>array(
'type'=>
'varchar(3)',
'label'=>
'Currency',
'enabled'=>1,
'visible'=>-1,
'position'=>155),
294 'fk_cond_reglement' =>array(
'type'=>
'integer',
'label'=>
'PaymentTerm',
'enabled'=>1,
'visible'=>-1,
'position'=>160),
295 'fk_mode_reglement' =>array(
'type'=>
'integer',
'label'=>
'PaymentMode',
'enabled'=>1,
'visible'=>-1,
'position'=>165),
296 'note_private' =>array(
'type'=>
'text',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>0,
'position'=>170),
297 'note_public' =>array(
'type'=>
'text',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>0,
'position'=>175),
298 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'PDFTemplate',
'enabled'=>1,
'visible'=>0,
'position'=>180),
299 'date_livraison' =>array(
'type'=>
'date',
'label'=>
'DateDeliveryPlanned',
'enabled'=>1,
'visible'=>-1,
'position'=>185),
300 'fk_shipping_method' =>array(
'type'=>
'integer',
'label'=>
'ShippingMethod',
'enabled'=>1,
'visible'=>-1,
'position'=>190),
301 'fk_availability' =>array(
'type'=>
'integer',
'label'=>
'Availability',
'enabled'=>1,
'visible'=>-1,
'position'=>195),
302 'fk_delivery_address' =>array(
'type'=>
'integer',
'label'=>
'DeliveryAddress',
'enabled'=>1,
'visible'=>0,
'position'=>200),
303 'fk_input_reason' =>array(
'type'=>
'integer',
'label'=>
'InputReason',
'enabled'=>1,
'visible'=>-1,
'position'=>205),
304 'extraparams' =>array(
'type'=>
'varchar(255)',
'label'=>
'Extraparams',
'enabled'=>1,
'visible'=>-1,
'position'=>215),
305 'fk_incoterms' =>array(
'type'=>
'integer',
'label'=>
'IncotermCode',
'enabled'=>
'$conf->incoterm->enabled',
'visible'=>-1,
'position'=>220),
306 'location_incoterms' =>array(
'type'=>
'varchar(255)',
'label'=>
'IncotermLabel',
'enabled'=>
'$conf->incoterm->enabled',
'visible'=>-1,
'position'=>225),
307 'fk_multicurrency' =>array(
'type'=>
'integer',
'label'=>
'MulticurrencyID',
'enabled'=>1,
'visible'=>-1,
'position'=>230),
308 'multicurrency_code' =>array(
'type'=>
'varchar(255)',
'label'=>
'MulticurrencyCurrency',
'enabled'=>
'$conf->multicurrency->enabled',
'visible'=>-1,
'position'=>235),
309 'multicurrency_tx' =>array(
'type'=>
'double(24,8)',
'label'=>
'MulticurrencyRate',
'enabled'=>
'$conf->multicurrency->enabled',
'visible'=>-1,
'position'=>240,
'isameasure'=>1),
310 'multicurrency_total_ht' =>array(
'type'=>
'double(24,8)',
'label'=>
'MulticurrencyAmountHT',
'enabled'=>
'$conf->multicurrency->enabled',
'visible'=>-1,
'position'=>245,
'isameasure'=>1),
311 'multicurrency_total_tva' =>array(
'type'=>
'double(24,8)',
'label'=>
'MulticurrencyAmountVAT',
'enabled'=>
'$conf->multicurrency->enabled',
'visible'=>-1,
'position'=>250,
'isameasure'=>1),
312 'multicurrency_total_ttc' =>array(
'type'=>
'double(24,8)',
'label'=>
'MulticurrencyAmountTTC',
'enabled'=>
'$conf->multicurrency->enabled',
'visible'=>-1,
'position'=>255,
'isameasure'=>1),
313 'last_main_doc' =>array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>1,
'visible'=>-1,
'position'=>260),
314 'fk_statut' =>array(
'type'=>
'smallint(6)',
'label'=>
'Status',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>500),
315 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>900),
350 global $conf, $langs;
354 $this->socid = $socid;
355 $this->
id = $propalid;
357 $this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION);
373 public function add_product($idproduct, $qty, $remise_percent = 0)
376 global $conf, $mysoc;
380 dol_syslog(get_class($this).
"::add_product $idproduct, $qty, $remise_percent");
384 $prod->fetch($idproduct);
386 $productdesc = $prod->description;
390 if (empty($tva_tx)) $tva_npr = 0;
393 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $this->thirdparty, $tva_npr);
394 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $this->thirdparty, $tva_npr);
397 if ($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level)
399 $price = $prod->multiprices[$this->thirdparty->price_level];
406 $line->fk_product = $idproduct;
407 $line->desc = $productdesc;
410 $line->remise_percent = $remise_percent;
411 $line->vat_src_code = $vat_src_code;
412 $line->tva_tx = $tva_tx;
413 $line->fk_unit = $prod->fk_unit;
414 if ($tva_npr) $line->info_bits = 1;
416 $this->lines[] = $line;
432 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
433 include_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
438 $result = $remise->fetch($idremise);
442 if ($remise->fk_facture)
444 $this->error = $langs->trans(
"ErrorDiscountAlreadyUsed");
445 $this->
db->rollback();
451 $this->line->context = $this->context;
453 $line->fk_propal = $this->id;
454 $line->fk_remise_except = $remise->id;
455 $line->desc = $remise->description;
456 $line->vat_src_code = $remise->vat_src_code;
457 $line->tva_tx = $remise->tva_tx;
458 $line->subprice = -$remise->amount_ht;
459 $line->fk_product = 0;
462 $line->remise_percent = 0;
464 $line->info_bits = 2;
467 $line->price = -$remise->amount_ht;
469 $line->total_ht = -$remise->amount_ht;
470 $line->total_tva = -$remise->amount_tva;
471 $line->total_ttc = -$remise->amount_ttc;
473 $result = $line->insert();
482 $this->
db->rollback();
486 $this->error = $line->error;
487 $this->errors = $line->errors;
488 $this->
db->rollback();
492 $this->
db->rollback();
533 public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type =
'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label =
'', $date_start =
'', $date_end =
'', $array_options = 0, $fk_unit = null, $origin =
'', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0)
535 global $mysoc, $conf, $langs;
537 dol_syslog(get_class($this).
"::addline propalid=$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, fk_remise_except=".$fk_remise_except);
539 if ($this->
statut == self::STATUS_DRAFT)
541 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
544 if (empty($remise_percent)) $remise_percent = 0;
545 if (empty($qty)) $qty = 0;
546 if (empty($info_bits)) $info_bits = 0;
547 if (empty($rang)) $rang = 0;
548 if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0;
550 $remise_percent =
price2num($remise_percent);
553 $pu_ht_devise =
price2num($pu_ht_devise);
555 if (!preg_match(
'/\((.*)\)/', $txtva)) {
561 if ($price_base_type ==
'HT')
569 if ($type < 0)
return -1;
571 if ($date_start && $date_end && $date_start > $date_end) {
572 $langs->load(
"errors");
573 $this->error = $langs->trans(
'ErrorStartDateGreaterEnd');
579 $product_type = $type;
580 if (!empty($fk_product))
583 $result = $product->fetch($fk_product);
584 $product_type = $product->type;
586 if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_PROPOSAL) && $product_type == 0 && $product->stock_reel < $qty) {
587 $langs->load(
"errors");
588 $this->error = $langs->trans(
'ErrorStockIsNotEnoughToAddProductOnProposal', $product->ref);
589 $this->
db->rollback();
605 if (preg_match(
'/\((.*)\)/', $txtva, $reg))
607 $vat_src_code = $reg[1];
608 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
611 $tabprice =
calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
613 $total_ht = $tabprice[0];
614 $total_tva = $tabprice[1];
615 $total_ttc = $tabprice[2];
616 $total_localtax1 = $tabprice[9];
617 $total_localtax2 = $tabprice[10];
618 $pu_ht = $tabprice[3];
619 $pu_tva = $tabprice[4];
620 $pu_ttc = $tabprice[5];
623 $multicurrency_total_ht = $tabprice[16];
624 $multicurrency_total_tva = $tabprice[17];
625 $multicurrency_total_ttc = $tabprice[18];
626 $pu_ht_devise = $tabprice[19];
630 if ($ranktouse == -1)
632 $rangmax = $this->
line_max($fk_parent_line);
633 $ranktouse = $rangmax + 1;
640 if ($remise_percent > 0)
642 $remise = round(($pu * $remise_percent / 100), 2);
649 $this->line->context = $this->context;
651 $this->line->fk_propal = $this->id;
652 $this->line->label = $label;
653 $this->line->desc = $desc;
654 $this->line->qty = $qty;
656 $this->line->vat_src_code = $vat_src_code;
657 $this->line->tva_tx = $txtva;
658 $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
659 $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
660 $this->line->localtax1_type = empty($localtaxes_type[0]) ?
'' : $localtaxes_type[0];
661 $this->line->localtax2_type = empty($localtaxes_type[2]) ?
'' : $localtaxes_type[2];
662 $this->line->fk_product = $fk_product;
663 $this->line->product_type = $type;
664 $this->line->fk_remise_except = $fk_remise_except;
665 $this->line->remise_percent = $remise_percent;
666 $this->line->subprice = $pu_ht;
667 $this->line->rang = $ranktouse;
668 $this->line->info_bits = $info_bits;
669 $this->line->total_ht = $total_ht;
670 $this->line->total_tva = $total_tva;
671 $this->line->total_localtax1 = $total_localtax1;
672 $this->line->total_localtax2 = $total_localtax2;
673 $this->line->total_ttc = $total_ttc;
674 $this->line->special_code = $special_code;
675 $this->line->fk_parent_line = $fk_parent_line;
676 $this->line->fk_unit = $fk_unit;
678 $this->line->date_start = $date_start;
679 $this->line->date_end = $date_end;
681 $this->line->fk_fournprice = $fk_fournprice;
682 $this->line->pa_ht = $pa_ht;
684 $this->line->origin_id = $origin_id;
685 $this->line->origin = $origin;
688 $this->line->fk_multicurrency = $this->fk_multicurrency;
689 $this->line->multicurrency_code = $this->multicurrency_code;
690 $this->line->multicurrency_subprice = $pu_ht_devise;
691 $this->line->multicurrency_total_ht = $multicurrency_total_ht;
692 $this->line->multicurrency_total_tva = $multicurrency_total_tva;
693 $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
696 if (empty($qty) && empty($special_code)) $this->line->special_code = 3;
699 $this->line->price =
$price;
700 $this->line->remise = $remise;
702 if (is_array($array_options) && count($array_options) > 0) {
703 $this->line->array_options = $array_options;
706 $result = $this->line->insert();
710 if (!empty($fk_parent_line)) $this->
line_order(
true,
'DESC');
717 return $this->line->id;
719 $this->error = $this->
db->error();
720 $this->
db->rollback();
724 $this->error = $this->line->error;
725 $this->errors = $this->line->errors;
726 $this->
db->rollback();
730 dol_syslog(get_class($this).
"::addline status of proposal must be Draft to allow use of ->addline()", LOG_ERR);
764 public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.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, $date_start =
'', $date_end =
'', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0)
766 global $mysoc, $langs;
768 dol_syslog(get_class($this).
"::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent,
769 txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end");
770 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
773 $remise_percent =
price2num($remise_percent);
776 $pu_ht_devise =
price2num($pu_ht_devise);
777 if (!preg_match(
'/\((.*)\)/', $txtva)) {
783 if (empty($qty) && empty($special_code)) $special_code = 3;
784 if (!empty($qty) && $special_code == 3) $special_code = 0;
785 if (empty($type)) $type = 0;
787 if ($date_start && $date_end && $date_start > $date_end) {
788 $langs->load(
"errors");
789 $this->error = $langs->trans(
'ErrorStartDateGreaterEnd');
793 if ($this->
statut == self::STATUS_DRAFT)
807 if (preg_match(
'/\((.*)\)/', $txtva, $reg))
809 $vat_src_code = $reg[1];
810 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
813 $tabprice =
calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
814 $total_ht = $tabprice[0];
815 $total_tva = $tabprice[1];
816 $total_ttc = $tabprice[2];
817 $total_localtax1 = $tabprice[9];
818 $total_localtax2 = $tabprice[10];
819 $pu_ht = $tabprice[3];
820 $pu_tva = $tabprice[4];
821 $pu_ttc = $tabprice[5];
824 $multicurrency_total_ht = $tabprice[16];
825 $multicurrency_total_tva = $tabprice[17];
826 $multicurrency_total_ttc = $tabprice[18];
827 $pu_ht_devise = $tabprice[19];
832 if ($remise_percent > 0)
834 $remise = round(($pu * $remise_percent / 100), 2);
840 $line->fetch($rowid);
842 $staticline = clone $line;
844 $line->oldline = $staticline;
846 $this->line->context = $this->context;
849 if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
851 $rangmax = $this->
line_max($fk_parent_line);
852 $this->line->rang = $rangmax + 1;
855 $this->line->id = $rowid;
856 $this->line->label = $label;
857 $this->line->desc = $desc;
858 $this->line->qty = $qty;
859 $this->line->product_type = $type;
860 $this->line->vat_src_code = $vat_src_code;
861 $this->line->tva_tx = $txtva;
862 $this->line->localtax1_tx = $txlocaltax1;
863 $this->line->localtax2_tx = $txlocaltax2;
864 $this->line->localtax1_type = $localtaxes_type[0];
865 $this->line->localtax2_type = $localtaxes_type[2];
866 $this->line->remise_percent = $remise_percent;
867 $this->line->subprice = $pu_ht;
868 $this->line->info_bits = $info_bits;
870 $this->line->total_ht = $total_ht;
871 $this->line->total_tva = $total_tva;
872 $this->line->total_localtax1 = $total_localtax1;
873 $this->line->total_localtax2 = $total_localtax2;
874 $this->line->total_ttc = $total_ttc;
875 $this->line->special_code = $special_code;
876 $this->line->fk_parent_line = $fk_parent_line;
877 $this->line->skip_update_total = $skip_update_total;
878 $this->line->fk_unit = $fk_unit;
880 $this->line->fk_fournprice = $fk_fournprice;
881 $this->line->pa_ht = $pa_ht;
883 $this->line->date_start = $date_start;
884 $this->line->date_end = $date_end;
887 $this->line->price =
$price;
888 $this->line->remise = $remise;
890 if (is_array($array_options) && count($array_options) > 0) {
892 foreach ($array_options as $key => $value) {
893 $this->line->array_options[$key] = $array_options[$key];
898 $this->line->multicurrency_subprice = $pu_ht_devise;
899 $this->line->multicurrency_total_ht = $multicurrency_total_ht;
900 $this->line->multicurrency_total_tva = $multicurrency_total_tva;
901 $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
903 $result = $this->line->update($notrigger);
907 if (!empty($fk_parent_line)) $this->
line_order(
true,
'DESC');
911 $this->fk_propal = $this->id;
912 $this->
rowid = $rowid;
917 $this->error = $this->line->error;
918 $this->errors = $this->line->errors;
919 $this->
db->rollback();
923 dol_syslog(get_class($this).
"::updateline Erreur -2 Propal en mode incompatible pour cette action");
939 if ($this->
statut == self::STATUS_DRAFT)
946 $line->fetch($lineid);
948 if ($line->delete($user) > 0)
955 $this->
db->rollback();
959 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
973 public function create($user, $notrigger = 0)
975 global $conf, $hookmanager;
982 $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
983 if (empty($this->availability_id)) $this->availability_id = 0;
984 if (empty($this->demand_reason_id)) $this->demand_reason_id = 0;
987 if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) =
MultiCurrency::getIdAndTxFromCode($this->
db, $this->multicurrency_code, $this->date);
989 if (empty($this->fk_multicurrency))
991 $this->multicurrency_code = $conf->currency;
992 $this->fk_multicurrency = 0;
993 $this->multicurrency_tx = 1;
997 $delivery_date = empty($this->delivery_date) ? $this->date_livraison : $this->delivery_date;
1005 $this->error =
"Failed to fetch company";
1006 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
1011 if (!empty($this->ref))
1013 $result = self::isExistingObject($this->element, 0, $this->ref);
1016 $this->error =
'ErrorRefAlreadyExists';
1017 dol_syslog(get_class($this).
"::create ".$this->error, LOG_WARNING);
1018 $this->
db->rollback();
1023 if (empty($this->date))
1025 $this->error =
"Date of proposal is required";
1026 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
1034 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"propal (";
1038 $sql .=
", remise_percent";
1039 $sql .=
", remise_absolue";
1045 $sql .=
", fk_user_author";
1046 $sql .=
", note_private";
1047 $sql .=
", note_public";
1048 $sql .=
", model_pdf";
1049 $sql .=
", fin_validite";
1050 $sql .=
", fk_cond_reglement";
1051 $sql .=
", fk_mode_reglement";
1052 $sql .=
", fk_account";
1053 $sql .=
", ref_client";
1054 $sql .=
", date_livraison";
1055 $sql .=
", fk_shipping_method";
1056 $sql .=
", fk_availability";
1057 $sql .=
", fk_input_reason";
1058 $sql .=
", fk_projet";
1059 $sql .=
", fk_incoterms";
1060 $sql .=
", location_incoterms";
1062 $sql .=
", fk_multicurrency";
1063 $sql .=
", multicurrency_code";
1064 $sql .=
", multicurrency_tx";
1066 $sql .=
" VALUES (";
1067 $sql .= $this->socid;
1069 $sql .=
", ".$this->remise;
1070 $sql .=
", ".($this->remise_percent ? $this->
db->escape($this->remise_percent) :
'NULL');
1071 $sql .=
", ".($this->remise_absolue ? $this->
db->escape($this->remise_absolue) :
'NULL');
1074 $sql .=
", '".$this->db->idate($this->date).
"'";
1075 $sql .=
", '".$this->db->idate($now).
"'";
1076 $sql .=
", '(PROV)'";
1077 $sql .=
", ".($user->id > 0 ?
"'".$this->db->escape($user->id).
"'" :
"NULL");
1078 $sql .=
", '".$this->db->escape($this->note_private).
"'";
1079 $sql .=
", '".$this->db->escape($this->note_public).
"'";
1080 $sql .=
", '".$this->db->escape($this->model_pdf).
"'";
1081 $sql .=
", ".($this->fin_validite !=
'' ?
"'".$this->db->idate($this->fin_validite).
"'" :
"NULL");
1082 $sql .=
", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id :
'NULL');
1083 $sql .=
", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id :
'NULL');
1084 $sql .=
", ".($this->fk_account > 0 ? $this->fk_account :
'NULL');
1085 $sql .=
", '".$this->db->escape($this->ref_client).
"'";
1086 $sql .=
", ".(empty($delivery_date) ?
"NULL" :
"'".$this->db->idate($delivery_date).
"'");
1087 $sql .=
", ".($this->shipping_method_id > 0 ? $this->shipping_method_id :
'NULL');
1088 $sql .=
", ".$this->availability_id;
1089 $sql .=
", ".$this->demand_reason_id;
1090 $sql .=
", ".($this->fk_project ? $this->fk_project :
"null");
1091 $sql .=
", ".(int) $this->fk_incoterms;
1092 $sql .=
", '".$this->db->escape($this->location_incoterms).
"'";
1093 $sql .=
", ".setEntity($this);
1094 $sql .=
", ".(int) $this->fk_multicurrency;
1095 $sql .=
", '".$this->db->escape($this->multicurrency_code).
"'";
1096 $sql .=
", ".(double) $this->multicurrency_tx;
1099 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
1103 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"propal");
1107 $this->ref =
'(PROV'.$this->id.
')';
1108 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"propal SET ref='".$this->
db->escape($this->ref).
"' WHERE rowid=".((int) $this->
id);
1110 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
1114 if (!empty($this->linkedObjectsIds) && empty($this->linked_objects))
1116 $this->linked_objects = $this->linkedObjectsIds;
1120 if (!$error && $this->
id && !empty($this->linked_objects) && is_array($this->linked_objects))
1122 foreach ($this->linked_objects as $origin => $tmp_origin_id)
1124 if (is_array($tmp_origin_id))
1126 foreach ($tmp_origin_id as $origin_id)
1131 $this->error = $this->
db->lasterror();
1137 $origin_id = $tmp_origin_id;
1141 $this->error = $this->
db->lasterror();
1154 $fk_parent_line = 0;
1155 $num = count($this->lines);
1157 for ($i = 0; $i < $num; $i++)
1159 if (!is_object($this->lines[$i]))
1161 $line = (object) $this->lines[$i];
1163 $line = $this->lines[$i];
1166 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
1167 $fk_parent_line = 0;
1170 $vatrate = $line->tva_tx;
1171 if ($line->vat_src_code && !preg_match(
'/\(.*\)/', $vatrate)) $vatrate .=
' ('.$line->vat_src_code.
')';
1173 if (!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
1174 $originid = $line->origin_id;
1175 $origintype = $line->origin;
1177 $originid = $line->id;
1178 $origintype = $this->element;
1186 $line->localtax1_tx,
1187 $line->localtax2_tx,
1189 $line->remise_percent,
1193 $line->product_type,
1195 $line->special_code,
1197 $line->fk_fournprice,
1202 $line->array_options,
1211 $this->error = $this->
db->error;
1216 if ($result > 0 && $line->product_type == 9) {
1217 $fk_parent_line = $result;
1251 if (!$error && !$notrigger)
1255 if ($result < 0) { $error++; }
1259 $this->error = $this->
db->lasterror();
1264 $this->error = $this->
db->lasterror();
1270 $this->
db->commit();
1271 dol_syslog(get_class($this).
"::create done id=".$this->
id);
1274 $this->
db->rollback();
1278 $this->error = $this->
db->lasterror();
1279 $this->
db->rollback();
1294 global $conf, $hookmanager;
1303 $object =
new self($this->db);
1308 $object->fetch($this->
id);
1313 if (!empty($socid) && $socid != $object->socid)
1315 if ($objsoc->fetch($socid) > 0)
1317 $object->socid = $objsoc->id;
1318 $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
1319 $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
1320 $object->fk_delivery_address =
'';
1332 $object->fk_project =
'';
1336 $object->ref_client =
'';
1340 $objsoc->fetch($object->socid);
1345 $object->entity = (!empty($forceentity) ? $forceentity : $object->entity);
1346 $object->statut = self::STATUS_DRAFT;
1349 $object->user_author = $user->id;
1350 $object->user_valid =
'';
1351 $object->date = $now;
1352 $object->datep = $now;
1353 $object->fin_validite = $object->date + ($object->duree_validite * 24 * 3600);
1354 if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $object->ref_client =
'';
1355 if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1)
1357 $object->note_private =
'';
1358 $object->note_public =
'';
1361 $object->context[
'createfromclone'] =
'createfromclone';
1362 $result = $object->create($user);
1365 $this->error = $object->error;
1366 $this->errors = array_merge($this->errors, $object->errors);
1373 if ($object->copy_linked_contact($this,
'internal') < 0)
1382 if ($this->socid == $object->socid)
1384 if ($object->copy_linked_contact($this,
'external') < 0)
1392 if (is_object($hookmanager))
1394 $parameters = array(
'objFrom'=>$this,
'clonedObj'=>$object);
1396 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
1397 if ($reshook < 0) $error++;
1401 unset($object->context[
'createfromclone']);
1406 $this->
db->commit();
1409 $this->
db->rollback();
1422 public function fetch($rowid, $ref =
'', $ref_ext =
'')
1424 $sql =
"SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc";
1425 $sql .=
", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht";
1426 $sql .=
", p.datec";
1427 $sql .=
", p.date_valid as datev";
1428 $sql .=
", p.datep as dp";
1429 $sql .=
", p.fin_validite as dfv";
1430 $sql .=
", p.date_livraison as delivery_date";
1431 $sql .=
", p.model_pdf, p.last_main_doc, p.ref_client, p.extraparams";
1432 $sql .=
", p.note_private, p.note_public";
1433 $sql .=
", p.fk_projet as fk_project, p.fk_statut";
1434 $sql .=
", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture";
1435 $sql .=
", p.fk_delivery_address";
1436 $sql .=
", p.fk_availability";
1437 $sql .=
", p.fk_input_reason";
1438 $sql .=
", p.fk_cond_reglement";
1439 $sql .=
", p.fk_mode_reglement";
1440 $sql .=
', p.fk_account';
1441 $sql .=
", p.fk_shipping_method";
1442 $sql .=
", p.fk_incoterms, p.location_incoterms";
1443 $sql .=
", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc";
1444 $sql .=
", p.tms as date_modification";
1445 $sql .=
", i.libelle as label_incoterms";
1446 $sql .=
", c.label as statut_label";
1447 $sql .=
", ca.code as availability_code, ca.label as availability";
1448 $sql .=
", dr.code as demand_reason_code, dr.label as demand_reason";
1449 $sql .=
", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
1450 $sql .=
", cp.code as mode_reglement_code, cp.libelle as mode_reglement";
1451 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p";
1452 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_propalst as c ON p.fk_statut = c.id';
1453 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity IN ('.
getEntity(
'c_paiement').
')';
1454 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity IN ('.
getEntity(
'c_payment_term').
')';
1455 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_availability as ca ON p.fk_availability = ca.rowid';
1456 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
1457 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_incoterms as i ON p.fk_incoterms = i.rowid';
1460 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
1461 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
1462 }
else $sql .=
" WHERE p.rowid=".$rowid;
1464 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1470 $obj = $this->
db->fetch_object(
$resql);
1472 $this->
id = $obj->rowid;
1473 $this->entity = $obj->entity;
1475 $this->ref = $obj->ref;
1476 $this->ref_client = $obj->ref_client;
1477 $this->remise = $obj->remise;
1478 $this->remise_percent = $obj->remise_percent;
1479 $this->remise_absolue = $obj->remise_absolue;
1480 $this->total = $obj->total;
1481 $this->total_ht = $obj->total_ht;
1482 $this->total_tva = $obj->tva;
1483 $this->total_localtax1 = $obj->localtax1;
1484 $this->total_localtax2 = $obj->localtax2;
1485 $this->total_ttc = $obj->total;
1487 $this->socid = $obj->fk_soc;
1488 $this->thirdparty = null;
1490 $this->fk_project = $obj->fk_project;
1491 $this->project = null;
1493 $this->model_pdf = $obj->model_pdf;
1494 $this->modelpdf = $obj->model_pdf;
1495 $this->last_main_doc = $obj->last_main_doc;
1496 $this->
note = $obj->note_private;
1497 $this->note_private = $obj->note_private;
1498 $this->note_public = $obj->note_public;
1500 $this->status = (int) $obj->fk_statut;
1501 $this->statut = $this->status;
1502 $this->statut_libelle = $obj->statut_label;
1504 $this->datec = $this->db->jdate($obj->datec);
1505 $this->datev = $this->
db->jdate($obj->datev);
1506 $this->date_creation = $this->
db->jdate($obj->datec);
1507 $this->date_validation = $this->
db->jdate($obj->datev);
1508 $this->date_modification = $this->
db->jdate($obj->date_modification);
1509 $this->date = $this->
db->jdate($obj->dp);
1510 $this->datep = $this->
db->jdate($obj->dp);
1511 $this->fin_validite = $this->
db->jdate($obj->dfv);
1512 $this->date_livraison = $this->
db->jdate($obj->delivery_date);
1513 $this->delivery_date = $this->
db->jdate($obj->delivery_date);
1514 $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null;
1515 $this->availability_id = $obj->fk_availability;
1516 $this->availability_code = $obj->availability_code;
1517 $this->availability = $obj->availability;
1518 $this->demand_reason_id = $obj->fk_input_reason;
1519 $this->demand_reason_code = $obj->demand_reason_code;
1520 $this->demand_reason = $obj->demand_reason;
1521 $this->fk_address = $obj->fk_delivery_address;
1523 $this->mode_reglement_id = $obj->fk_mode_reglement;
1524 $this->mode_reglement_code = $obj->mode_reglement_code;
1525 $this->mode_reglement = $obj->mode_reglement;
1526 $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null;
1527 $this->cond_reglement_id = $obj->fk_cond_reglement;
1528 $this->cond_reglement_code = $obj->cond_reglement_code;
1529 $this->cond_reglement = $obj->cond_reglement;
1530 $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
1532 $this->extraparams = (array) json_decode($obj->extraparams,
true);
1534 $this->user_author_id = $obj->fk_user_author;
1535 $this->user_valid_id = $obj->fk_user_valid;
1536 $this->user_close_id = $obj->fk_user_cloture;
1539 $this->fk_incoterms = $obj->fk_incoterms;
1540 $this->location_incoterms = $obj->location_incoterms;
1541 $this->label_incoterms = $obj->label_incoterms;
1544 $this->fk_multicurrency = $obj->fk_multicurrency;
1545 $this->multicurrency_code = $obj->multicurrency_code;
1546 $this->multicurrency_tx = $obj->multicurrency_tx;
1547 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
1548 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
1549 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1551 if ($obj->fk_statut == self::STATUS_DRAFT)
1553 $this->brouillon = 1;
1562 $this->lines = array();
1574 $this->error =
"Record Not Found";
1577 $this->error = $this->
db->lasterror();
1596 if (isset($this->ref)) $this->ref = trim($this->ref);
1597 if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client);
1598 if (isset($this->
note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->
note));
1599 if (isset($this->note_public)) $this->note_public = trim($this->note_public);
1600 if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
1601 if (isset($this->import_key)) $this->import_key = trim($this->import_key);
1602 if (!empty($this->duree_validite) && is_numeric($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
1608 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal SET";
1609 $sql .=
" ref=".(isset($this->ref) ?
"'".$this->db->escape($this->ref).
"'" :
"null").
",";
1610 $sql .=
" ref_client=".(isset($this->ref_client) ?
"'".$this->db->escape($this->ref_client).
"'" :
"null").
",";
1611 $sql .=
" ref_ext=".(isset($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
"null").
",";
1612 $sql .=
" fk_soc=".(isset($this->socid) ? $this->socid :
"null").
",";
1613 $sql .=
" datep=".(strval($this->date) !=
'' ?
"'".$this->db->idate($this->date).
"'" :
'null').
",";
1614 if (!empty($this->fin_validite)) $sql .=
" fin_validite=".(strval($this->fin_validite) !=
'' ?
"'".$this->db->idate($this->fin_validite).
"'" :
'null').
",";
1615 $sql .=
" date_valid=".(strval($this->date_validation) !=
'' ?
"'".$this->db->idate($this->date_validation).
"'" :
'null').
",";
1616 $sql .=
" tva=".(isset($this->total_tva) ? $this->total_tva :
"null").
",";
1617 $sql .=
" localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 :
"null").
",";
1618 $sql .=
" localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 :
"null").
",";
1619 $sql .=
" total_ht=".(isset($this->total_ht) ? $this->total_ht :
"null").
",";
1620 $sql .=
" total=".(isset($this->total_ttc) ? $this->total_ttc :
"null").
",";
1621 $sql .=
" fk_statut=".(isset($this->
statut) ? $this->
statut :
"null").
",";
1622 $sql .=
" fk_user_author=".(isset($this->user_author_id) ? $this->user_author_id :
"null").
",";
1623 $sql .=
" fk_user_valid=".(isset($this->user_valid) ? $this->user_valid :
"null").
",";
1624 $sql .=
" fk_projet=".(isset($this->fk_project) ? $this->fk_project :
"null").
",";
1625 $sql .=
" fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id :
"null").
",";
1626 $sql .=
" fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id :
"null").
",";
1627 $sql .=
" fk_input_reason=".(isset($this->demand_reason_id) ? $this->demand_reason_id :
"null").
",";
1628 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
1629 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
1630 $sql .=
" model_pdf=".(isset($this->modelpdf) ?
"'".$this->db->escape($this->modelpdf).
"'" :
"null").
",";
1631 $sql .=
" import_key=".(isset($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null").
"";
1632 $sql .=
" WHERE rowid=".$this->id;
1636 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
1639 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
1651 if (!$error && !$notrigger)
1655 if ($result < 0) $error++;
1662 foreach ($this->errors as $errmsg)
1664 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1665 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1667 $this->
db->rollback();
1670 $this->
db->commit();
1685 public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
1687 global $langs, $conf;
1689 $this->lines = array();
1691 $sql =
'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
1692 $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,';
1693 $sql .=
' d.fk_unit,';
1694 $sql .=
' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch, p.barcode as product_barcode,';
1695 $sql .=
' p.weight, p.weight_units, p.volume, p.volume_units,';
1696 $sql .=
' d.date_start, d.date_end,';
1697 $sql .=
' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
1698 $sql .=
' FROM '.MAIN_DB_PREFIX.
'propaldet as d';
1699 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON (d.fk_product = p.rowid)';
1700 $sql .=
' WHERE d.fk_propal = '.$this->id;
1701 if ($only_product) $sql .=
' AND p.fk_product_type = 0';
1702 $sql .=
' ORDER by d.rang';
1704 dol_syslog(get_class($this).
"::fetch_lines", LOG_DEBUG);
1705 $result = $this->
db->query($sql);
1708 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
1710 $num = $this->
db->num_rows($result);
1715 $objp = $this->
db->fetch_object($result);
1719 $line->rowid = $objp->rowid;
1720 $line->id = $objp->rowid;
1721 $line->fk_propal = $objp->fk_propal;
1722 $line->fk_parent_line = $objp->fk_parent_line;
1723 $line->product_type = $objp->product_type;
1724 $line->label = $objp->custom_label;
1725 $line->desc = $objp->description;
1726 $line->description = $objp->description;
1727 $line->qty = $objp->qty;
1728 $line->vat_src_code = $objp->vat_src_code;
1729 $line->tva_tx = $objp->tva_tx;
1730 $line->localtax1_tx = $objp->localtax1_tx;
1731 $line->localtax2_tx = $objp->localtax2_tx;
1732 $line->localtax1_type = $objp->localtax1_type;
1733 $line->localtax2_type = $objp->localtax2_type;
1734 $line->subprice = $objp->subprice;
1735 $line->fk_remise_except = $objp->fk_remise_except;
1736 $line->remise_percent = $objp->remise_percent;
1737 $line->price = $objp->price;
1739 $line->info_bits = $objp->info_bits;
1740 $line->total_ht = $objp->total_ht;
1741 $line->total_tva = $objp->total_tva;
1742 $line->total_localtax1 = $objp->total_localtax1;
1743 $line->total_localtax2 = $objp->total_localtax2;
1744 $line->total_ttc = $objp->total_ttc;
1745 $line->fk_fournprice = $objp->fk_fournprice;
1746 $marginInfos =
getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
1747 $line->pa_ht = $marginInfos[0];
1748 $line->marge_tx = $marginInfos[1];
1749 $line->marque_tx = $marginInfos[2];
1750 $line->special_code = $objp->special_code;
1751 $line->rang = $objp->rang;
1753 $line->fk_product = $objp->fk_product;
1755 $line->ref = $objp->product_ref;
1756 $line->libelle = $objp->product_label;
1758 $line->product_ref = $objp->product_ref;
1759 $line->product_label = $objp->product_label;
1760 $line->product_desc = $objp->product_desc;
1761 $line->product_tobatch = $objp->product_tobatch;
1762 $line->product_barcode = $objp->product_barcode;
1764 $line->fk_product_type = $objp->fk_product_type;
1765 $line->fk_unit = $objp->fk_unit;
1766 $line->weight = $objp->weight;
1767 $line->weight_units = $objp->weight_units;
1768 $line->volume = $objp->volume;
1769 $line->volume_units = $objp->volume_units;
1771 $line->date_start = $this->
db->jdate($objp->date_start);
1772 $line->date_end = $this->
db->jdate($objp->date_end);
1775 $line->fk_multicurrency = $objp->fk_multicurrency;
1776 $line->multicurrency_code = $objp->multicurrency_code;
1777 $line->multicurrency_subprice = $objp->multicurrency_subprice;
1778 $line->multicurrency_total_ht = $objp->multicurrency_total_ht;
1779 $line->multicurrency_total_tva = $objp->multicurrency_total_tva;
1780 $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
1782 $line->fetch_optionals();
1785 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) {
1787 $line->fetch($objp->fk_product);
1788 $line->getMultiLangs();
1791 $this->lines[$i] = $line;
1797 $this->
db->free($result);
1801 $this->error = $this->
db->lasterror();
1813 public function valid($user, $notrigger = 0)
1817 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1822 if ($this->
statut == self::STATUS_VALIDATED)
1824 dol_syslog(get_class($this).
"::valid action abandonned: already validated", LOG_WARNING);
1828 if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->creer))
1829 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate))))
1831 $this->error =
'ErrorPermissionDenied';
1832 dol_syslog(get_class($this).
"::valid ".$this->error, LOG_ERR);
1842 $soc->fetch($this->socid);
1845 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->ref) || empty($this->ref)))
1853 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal";
1854 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
1855 $sql .=
" fk_statut = ".self::STATUS_VALIDATED.
", date_valid='".$this->
db->idate($now).
"', fk_user_valid=".$user->id;
1856 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = ".self::STATUS_DRAFT;
1858 dol_syslog(get_class($this).
"::valid", LOG_DEBUG);
1867 if (!$error && !$notrigger)
1870 $result = $this->
call_trigger(
'PROPAL_VALIDATE', $user);
1871 if ($result < 0) { $error++; }
1877 $this->oldref = $this->ref;
1880 if (preg_match(
'/^[\(]?PROV/i', $this->ref))
1883 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->
db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->ref) + 1).
")), filepath = 'propale/".$this->
db->escape($this->newref).
"'";
1884 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->ref).
"%' AND filepath = 'propale/".$this->
db->escape($this->ref).
"' and entity = ".$conf->entity;
1886 if (!
$resql) { $error++; $this->error = $this->
db->lasterror(); }
1891 $dirsource = $conf->propal->multidir_output[$this->entity].
'/'.$oldref;
1892 $dirdest = $conf->propal->multidir_output[$this->entity].
'/'.$newref;
1893 if (!$error && file_exists($dirsource))
1895 dol_syslog(get_class($this).
"::validate rename dir ".$dirsource.
" into ".$dirdest);
1896 if (@rename($dirsource, $dirdest))
1900 $listoffiles =
dol_dir_list($dirdest,
'files', 1,
'^'.preg_quote($oldref,
'/'));
1901 foreach ($listoffiles as $fileentry)
1903 $dirsource = $fileentry[
'name'];
1904 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
1905 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
1906 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
1907 @rename($dirsource, $dirdest);
1914 $this->brouillon = 0;
1915 $this->
statut = self::STATUS_VALIDATED;
1916 $this->user_valid_id = $user->id;
1917 $this->datev = $now;
1919 $this->
db->commit();
1922 $this->
db->rollback();
1942 $this->error =
'ErrorBadParameter';
1943 dol_syslog(get_class($this).
"::set_date ".$this->error, LOG_ERR);
1947 if (!empty($user->rights->propal->creer))
1953 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal SET datep = '".$this->
db->idate($date).
"'";
1954 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = ".self::STATUS_DRAFT;
1960 $this->errors[] = $this->
db->error();
1966 $this->oldcopy = clone $this;
1967 $this->date = $date;
1968 $this->datep = $date;
1971 if (!$notrigger && empty($error))
1975 if ($result < 0) $error++;
1981 $this->
db->commit();
1984 foreach ($this->errors as $errmsg)
1986 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
1987 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1989 $this->
db->rollback();
2007 if (!empty($user->rights->propal->creer))
2013 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal SET fin_validite = ".($date_fin_validite !=
'' ?
"'".$this->db->idate($date_fin_validite).
"'" :
'null');
2014 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = ".self::STATUS_DRAFT;
2020 $this->errors[] = $this->
db->error();
2027 $this->oldcopy = clone $this;
2028 $this->fin_validite = $date_fin_validite;
2031 if (!$notrigger && empty($error))
2035 if ($result < 0) $error++;
2041 $this->
db->commit();
2044 foreach ($this->errors as $errmsg)
2046 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2047 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2049 $this->
db->rollback();
2081 if (!empty($user->rights->propal->creer))
2087 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal ";
2088 $sql .=
" SET date_livraison = ".($delivery_date !=
'' ?
"'".$this->db->idate($delivery_date).
"'" :
'null');
2089 $sql .=
" WHERE rowid = ".$this->id;
2095 $this->errors[] = $this->
db->error();
2101 $this->oldcopy = clone $this;
2102 $this->date_livraison = $delivery_date;
2103 $this->delivery_date = $delivery_date;
2106 if (!$notrigger && empty($error))
2110 if ($result < 0) $error++;
2116 $this->
db->commit();
2119 foreach ($this->errors as $errmsg)
2121 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2122 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2124 $this->
db->rollback();
2142 if (!empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
2148 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal ";
2149 $sql .=
" SET fk_availability = '".$id.
"'";
2150 $sql .=
" WHERE rowid = ".$this->id;
2152 dol_syslog(__METHOD__.
' availability('.$id.
')', LOG_DEBUG);
2156 $this->errors[] = $this->
db->error();
2162 $this->oldcopy = clone $this;
2163 $this->fk_availability = $id;
2164 $this->availability_id = $id;
2167 if (!$notrigger && empty($error))
2171 if ($result < 0) $error++;
2177 $this->
db->commit();
2180 foreach ($this->errors as $errmsg)
2182 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2183 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2185 $this->
db->rollback();
2189 $error_str =
'Propal status do not meet requirement '.$this->statut;
2191 $this->error = $error_str;
2192 $this->errors[] = $this->error;
2209 if (!empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
2215 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal ";
2216 $sql .=
" SET fk_input_reason = ".$id;
2217 $sql .=
" WHERE rowid = ".$this->id;
2223 $this->errors[] = $this->
db->error();
2230 $this->oldcopy = clone $this;
2231 $this->fk_input_reason = $id;
2232 $this->demand_reason_id = $id;
2236 if (!$notrigger && empty($error))
2240 if ($result < 0) $error++;
2246 $this->
db->commit();
2249 foreach ($this->errors as $errmsg)
2251 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2252 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2254 $this->
db->rollback();
2258 $error_str =
'Propal status do not meet requirement '.$this->statut;
2260 $this->error = $error_str;
2261 $this->errors[] = $this->error;
2278 if (!empty($user->rights->propal->creer))
2284 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'propal SET ref_client = '.(empty($ref_client) ?
'NULL' :
'\''.$this->db->escape($ref_client).
'\'');
2285 $sql .=
' WHERE rowid = '.$this->id;
2287 dol_syslog(__METHOD__.
' $this->id='.$this->id.
', ref_client='.$ref_client, LOG_DEBUG);
2291 $this->errors[] = $this->
db->error();
2297 $this->oldcopy = clone $this;
2298 $this->ref_client = $ref_client;
2301 if (!$notrigger && empty($error))
2305 if ($result < 0) $error++;
2311 $this->
db->commit();
2314 foreach ($this->errors as $errmsg)
2316 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2317 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2319 $this->
db->rollback();
2339 $remise = trim($remise) ?trim($remise) : 0;
2341 if (!empty($user->rights->propal->creer))
2349 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal SET remise_percent = ".$remise;
2350 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = ".self::STATUS_DRAFT;
2356 $this->errors[] = $this->
db->error();
2362 $this->oldcopy = clone $this;
2363 $this->remise_percent = $remise;
2367 if (!$notrigger && empty($error))
2371 if ($result < 0) $error++;
2377 $this->
db->commit();
2380 foreach ($this->errors as $errmsg)
2382 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2383 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2385 $this->
db->rollback();
2404 $remise = trim($remise) ?trim($remise) : 0;
2406 if (!empty($user->rights->propal->creer))
2414 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal ";
2415 $sql .=
" SET remise_absolue = ".$remise;
2416 $sql .=
" WHERE rowid = ".$this->id.
" AND fk_statut = ".self::STATUS_DRAFT;
2422 $this->errors[] = $this->
db->error();
2428 $this->oldcopy = clone $this;
2429 $this->remise_absolue = $remise;
2433 if (!$notrigger && empty($error))
2437 if ($result < 0) $error++;
2443 $this->
db->commit();
2446 foreach ($this->errors as $errmsg)
2448 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2449 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2451 $this->
db->rollback();
2474 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal";
2475 $sql .=
" SET fk_statut = ".$this->statut.
",";
2476 if (!empty(
$note)) $sql .=
" note_private = '".$this->db->escape(
$note).
"',";
2477 $sql .=
" date_cloture=NULL, fk_user_cloture=NULL";
2478 $sql .=
" WHERE rowid = ".$this->id;
2482 dol_syslog(get_class($this).
"::reopen", LOG_DEBUG);
2485 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
2493 if ($result < 0) { $error++; }
2501 if (!empty($this->errors))
2503 foreach ($this->errors as $errmsg)
2505 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
2506 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2509 $this->
db->rollback();
2512 $this->
db->commit();
2529 global $langs, $conf;
2538 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal";
2539 $sql .=
" SET fk_statut = ".$status.
", note_private = '".$this->
db->escape($newprivatenote).
"', date_cloture='".$this->
db->idate($now).
"', fk_user_cloture=".$user->id;
2540 $sql .=
" WHERE rowid = ".$this->id;
2545 $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf;
2546 $triggerName =
'PROPAL_CLOSE_REFUSED';
2548 if ($status == self::STATUS_SIGNED)
2550 $triggerName =
'PROPAL_CLOSE_SIGNED';
2551 $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->model_pdf;
2555 $soc->id = $this->socid;
2556 $result = $soc->set_as_client();
2560 $this->error = $this->
db->lasterror();
2561 $this->
db->rollback();
2565 if ($status == self::STATUS_BILLED)
2567 $triggerName =
'PROPAL_CLASSIFY_BILLED';
2570 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
2573 $outputlangs = $langs;
2574 if (!empty($conf->global->MAIN_MULTILANGS))
2576 $outputlangs =
new Translate(
"", $conf);
2577 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $this->thirdparty->default_lang);
2578 $outputlangs->setDefaultLang($newlang);
2586 $this->oldcopy = clone $this;
2588 $this->date_cloture = $now;
2589 $this->note_private = $newprivatenote;
2592 if (!$notrigger && empty($error))
2596 if ($result < 0) { $error++; }
2602 $this->
db->commit();
2605 $this->
statut = $this->oldcopy->statut;
2606 $this->date_cloture = $this->oldcopy->date_cloture;
2607 $this->note_private = $this->oldcopy->note_private;
2609 $this->
db->rollback();
2613 $this->error = $this->
db->lasterror();
2614 $this->
db->rollback();
2632 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'propal SET fk_statut = '.self::STATUS_BILLED;
2633 $sql .=
' WHERE rowid = '.$this->id.
' AND fk_statut > '.self::STATUS_DRAFT;
2639 $this->errors[] = $this->
db->error();
2645 $this->oldcopy = clone $this;
2646 $this->
statut = self::STATUS_BILLED;
2649 if (!$notrigger && empty($error))
2653 if ($result < 0) $error++;
2659 $this->
db->commit();
2662 foreach ($this->errors as $errmsg)
2664 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2665 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2667 $this->
db->rollback();
2686 if ($this->
statut <= self::STATUS_DRAFT)
2691 dol_syslog(get_class($this).
"::setDraft", LOG_DEBUG);
2695 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propal";
2696 $sql .=
" SET fk_statut = ".self::STATUS_DRAFT;
2697 $sql .=
" WHERE rowid = ".$this->id;
2702 $this->errors[] = $this->
db->error();
2708 $this->oldcopy = clone $this;
2711 if (!$notrigger && empty($error))
2715 if ($result < 0) $error++;
2721 $this->
statut = self::STATUS_DRAFT;
2722 $this->brouillon = 1;
2724 $this->
db->commit();
2727 foreach ($this->errors as $errmsg)
2729 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
2730 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
2732 $this->
db->rollback();
2752 public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield =
'p.datep', $sortorder =
'DESC')
2759 $sql =
"SELECT s.rowid, s.nom as name, s.client,";
2760 $sql .=
" p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, ";
2761 $sql .=
" p.datep as dp, p.fin_validite as datelimite";
2762 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", sc.fk_soc, sc.fk_user";
2763 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"c_propalst as c";
2764 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
2765 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
2766 $sql .=
" AND p.fk_soc = s.rowid";
2767 $sql .=
" AND p.fk_statut = c.id";
2768 if (!$user->rights->societe->client->voir && !$socid)
2770 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
2772 if ($socid) $sql .=
" AND s.rowid = ".$socid;
2773 if ($draft) $sql .=
" AND p.fk_statut = ".self::STATUS_DRAFT;
2774 if ($notcurrentuser > 0) $sql .=
" AND p.fk_user_author <> ".$user->id;
2775 $sql .= $this->
db->order($sortfield, $sortorder);
2776 $sql .= $this->
db->plimit($limit, $offset);
2778 $result = $this->
db->query($sql);
2781 $num = $this->
db->num_rows($result);
2787 $obj = $this->
db->fetch_object($result);
2789 if ($shortlist == 1)
2791 $ga[$obj->propalid] = $obj->ref;
2792 } elseif ($shortlist == 2)
2794 $ga[$obj->propalid] = $obj->ref.
' ('.$obj->name.
')';
2796 $ga[$i][
'id'] = $obj->propalid;
2797 $ga[$i][
'ref'] = $obj->ref;
2798 $ga[$i][
'name'] = $obj->name;
2832 $linkedInvoices = array();
2835 foreach ($this->linkedObjectsIds as $objecttype => $objectid)
2839 foreach ($objectid as $key => $object)
2842 if ($objecttype ==
'facture')
2844 $linkedInvoices[] = $object;
2848 foreach ($this->linkedObjectsIds as $subobjecttype => $subobjectid)
2850 foreach ($subobjectid as $subkey => $subobject)
2852 if ($subobjecttype ==
'facture')
2854 $linkedInvoices[] = $subobject;
2862 if (count($linkedInvoices) > 0)
2864 $sql =
"SELECT rowid as facid, ref, total, datef as df, fk_user_author, fk_statut, paye";
2865 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
2866 $sql .=
" WHERE rowid IN (".implode(
',', $linkedInvoices).
")";
2868 dol_syslog(get_class($this).
"::InvoiceArrayList", LOG_DEBUG);
2873 $tab_sqlobj = array();
2874 $nump = $this->
db->num_rows(
$resql);
2875 for ($i = 0; $i < $nump; $i++)
2877 $sqlobj = $this->
db->fetch_object(
$resql);
2878 $tab_sqlobj[] = $sqlobj;
2882 $nump = count($tab_sqlobj);
2889 $obj = array_shift($tab_sqlobj);
2910 public function delete($user, $notrigger = 0)
2913 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2922 if ($result < 0) { $error++; }
2927 if (!$error && !empty($this->table_element_line)) {
2928 $tabletodelete = $this->table_element_line;
2929 $sqlef =
"DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete.
"_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete.
" WHERE ".$this->fk_element.
" = ".$this->
id.
")";
2930 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete.
" WHERE ".$this->fk_element.
" = ".$this->id;
2931 if (!$this->
db->query($sqlef) || !$this->
db->query($sql)) {
2933 $this->error = $this->
db->lasterror();
2934 $this->errors[] = $this->error;
2935 dol_syslog(get_class($this).
"::delete error ".$this->error, LOG_ERR);
2942 if ($res < 0) $error++;
2948 if ($res < 0) $error++;
2956 dol_syslog(get_class($this).
"::delete error ".$this->error, LOG_ERR);
2962 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element.
" WHERE rowid = ".$this->id;
2963 $res = $this->
db->query($sql);
2966 $this->error = $this->
db->lasterror();
2967 $this->errors[] = $this->error;
2968 dol_syslog(get_class($this).
"::delete error ".$this->error, LOG_ERR);
2983 if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) {
2984 $dir = $conf->propal->multidir_output[$this->entity].
"/".$ref;
2985 $file = $dir.
"/".$ref.
".pdf";
2986 if (file_exists($file)) {
2990 $this->error =
'ErrorFailToDeleteFile';
2991 $this->errors[] = $this->error;
2992 $this->
db->rollback();
2996 if (file_exists($dir)) {
2999 $this->error =
'ErrorFailToDeleteDir';
3000 $this->errors[] = $this->error;
3001 $this->
db->rollback();
3009 dol_syslog(get_class($this).
"::delete ".$this->
id.
" by ".$user->id, LOG_DEBUG);
3010 $this->
db->commit();
3013 $this->
db->rollback();
3030 if ($this->
statut >= self::STATUS_DRAFT)
3036 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'propal';
3037 $sql .=
' SET fk_availability = '.$availability_id;
3038 $sql .=
' WHERE rowid='.$this->id;
3040 dol_syslog(__METHOD__.
' availability('.$availability_id.
')', LOG_DEBUG);
3044 $this->errors[] = $this->
db->error();
3050 $this->oldcopy = clone $this;
3051 $this->availability_id = $availability_id;
3054 if (!$notrigger && empty($error))
3058 if ($result < 0) $error++;
3064 $this->
db->commit();
3067 foreach ($this->errors as $errmsg)
3069 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
3070 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
3072 $this->
db->rollback();
3076 $error_str =
'Propal status do not meet requirement '.$this->statut;
3078 $this->error = $error_str;
3079 $this->errors[] = $this->error;
3098 if ($this->
statut >= self::STATUS_DRAFT)
3104 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'propal';
3105 $sql .=
' SET fk_input_reason = '.$demand_reason_id;
3106 $sql .=
' WHERE rowid='.$this->id;
3108 dol_syslog(__METHOD__.
' demand_reason('.$demand_reason_id.
')', LOG_DEBUG);
3112 $this->errors[] = $this->
db->error();
3118 $this->oldcopy = clone $this;
3119 $this->demand_reason_id = $demand_reason_id;
3122 if (!$notrigger && empty($error))
3126 if ($result < 0) $error++;
3132 $this->
db->commit();
3135 foreach ($this->errors as $errmsg)
3137 dol_syslog(__METHOD__.
' Error: '.$errmsg, LOG_ERR);
3138 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
3140 $this->
db->rollback();
3144 $error_str =
'Propal status do not meet requirement '.$this->statut;
3146 $this->error = $error_str;
3147 $this->errors[] = $this->error;
3161 $sql =
"SELECT c.rowid, ";
3162 $sql .=
" c.datec, c.date_valid as datev, c.date_cloture as dateo,";
3163 $sql .=
" c.fk_user_author, c.fk_user_valid, c.fk_user_cloture";
3164 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as c";
3165 $sql .=
" WHERE c.rowid = ".((int) $id);
3167 $result = $this->
db->query($sql);
3171 if ($this->
db->num_rows($result))
3173 $obj = $this->
db->fetch_object($result);
3175 $this->
id = $obj->rowid;
3177 $this->date_creation = $this->
db->jdate($obj->datec);
3178 $this->date_validation = $this->
db->jdate($obj->datev);
3179 $this->date_cloture = $this->
db->jdate($obj->dateo);
3181 $cuser =
new User($this->
db);
3182 $cuser->fetch($obj->fk_user_author);
3183 $this->user_creation = $cuser;
3185 if ($obj->fk_user_valid)
3187 $vuser =
new User($this->
db);
3188 $vuser->fetch($obj->fk_user_valid);
3189 $this->user_validation = $vuser;
3192 if ($obj->fk_user_cloture)
3194 $cluser =
new User($this->
db);
3195 $cluser->fetch($obj->fk_user_cloture);
3196 $this->user_cloture = $cluser;
3199 $this->
db->free($result);
3231 if (empty($this->labelStatus) || empty($this->labelStatusShort))
3234 $langs->load(
"propal");
3235 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
"PropalStatusDraft");
3236 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
"PropalStatusValidated");
3237 $this->labelStatus[2] = $langs->transnoentitiesnoconv(
"PropalStatusSigned");
3238 $this->labelStatus[3] = $langs->transnoentitiesnoconv(
"PropalStatusNotSigned");
3239 $this->labelStatus[4] = $langs->transnoentitiesnoconv(
"PropalStatusBilled");
3240 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
"PropalStatusDraftShort");
3241 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
"PropalStatusValidatedShort");
3242 $this->labelStatusShort[2] = $langs->transnoentitiesnoconv(
"PropalStatusSignedShort");
3243 $this->labelStatusShort[3] = $langs->transnoentitiesnoconv(
"PropalStatusNotSignedShort");
3244 $this->labelStatusShort[4] = $langs->transnoentitiesnoconv(
"PropalStatusBilledShort");
3248 if ($status == self::STATUS_DRAFT) $statusType =
'status0';
3249 elseif ($status == self::STATUS_VALIDATED) $statusType =
'status1';
3250 elseif ($status == self::STATUS_SIGNED) $statusType =
'status4';
3251 elseif ($status == self::STATUS_NOTSIGNED) $statusType =
'status9';
3252 elseif ($status == self::STATUS_BILLED) $statusType =
'status6';
3254 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
3269 global $conf, $langs;
3273 $sql =
"SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin, p.total_ht";
3274 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p";
3275 if (!$user->rights->societe->client->voir && !$user->socid)
3277 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
3278 $sql .=
" WHERE sc.fk_user = ".$user->id;
3281 $sql .= $clause.
" p.entity IN (".
getEntity(
'propal').
")";
3282 if ($mode ==
'opened') $sql .=
" AND p.fk_statut = ".self::STATUS_VALIDATED;
3283 if ($mode ==
'signed') $sql .=
" AND p.fk_statut = ".self::STATUS_SIGNED;
3284 if ($user->socid) $sql .=
" AND p.fk_soc = ".$user->socid;
3289 $langs->load(
"propal");
3294 $label = $labelShort =
'';
3295 if ($mode ==
'opened') {
3296 $delay_warning = $conf->propal->cloture->warning_delay;
3297 $status = self::STATUS_VALIDATED;
3298 $label = $langs->transnoentitiesnoconv(
"PropalsToClose");
3299 $labelShort = $langs->transnoentitiesnoconv(
"ToAcceptRefuse");
3301 if ($mode ==
'signed') {
3302 $delay_warning = $conf->propal->facturation->warning_delay;
3303 $status = self::STATUS_SIGNED;
3304 $label = $langs->trans(
"PropalsToBill");
3305 $labelShort = $langs->trans(
"ToBill");
3309 $response->warning_delay = $delay_warning / 60 / 60 / 24;
3310 $response->label = $label;
3311 $response->labelShort = $labelShort;
3312 $response->url = DOL_URL_ROOT.
'/comm/propal/list.php?search_status='.$status.
'&mainmenu=commercial&leftmenu=propals';
3313 $response->url_late = DOL_URL_ROOT.
'/comm/propal/list.php?search_status='.$status.
'&mainmenu=commercial&leftmenu=propals&sortfield=p.datep&sortorder=asc';
3317 while ($obj = $this->
db->fetch_object(
$resql))
3319 $response->nbtodo++;
3320 $response->total += $obj->total_ht;
3322 if ($mode ==
'opened')
3324 $datelimit = $this->
db->jdate($obj->datefin);
3325 if ($datelimit < ($now - $delay_warning))
3327 $response->nbtodolate++;
3336 $this->error = $this->
db->error();
3351 global $conf, $langs;
3356 $sql =
"SELECT rowid";
3357 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product";
3358 $sql .=
" WHERE entity IN (".getEntity(
'product').
")";
3359 $sql .= $this->
db->plimit(100);
3364 $num_prods = $this->
db->num_rows(
$resql);
3366 while ($i < $num_prods)
3369 $row = $this->
db->fetch_row(
$resql);
3370 $prodids[$i] = $row[0];
3376 $this->ref =
'SPECIMEN';
3377 $this->ref_client =
'NEMICEPS';
3378 $this->specimen = 1;
3380 $this->date = time();
3381 $this->fin_validite = $this->date + 3600 * 24 * 30;
3382 $this->cond_reglement_id = 1;
3383 $this->cond_reglement_code =
'RECEP';
3384 $this->mode_reglement_id = 7;
3385 $this->mode_reglement_code =
'CHQ';
3386 $this->availability_id = 1;
3387 $this->availability_code =
'AV_NOW';
3388 $this->demand_reason_id = 1;
3389 $this->demand_reason_code =
'SRC_00';
3390 $this->note_public =
'This is a comment (public)';
3391 $this->note_private =
'This is a comment (private)';
3393 $this->multicurrency_tx = 1;
3394 $this->multicurrency_code = $conf->currency;
3399 while ($xnbp < $nbp)
3402 $line->desc = $langs->trans(
"Description").
" ".$xnbp;
3404 $line->subprice = 100;
3407 $line->localtax1_tx = 0;
3408 $line->localtax2_tx = 0;
3411 $line->total_ht = 50;
3412 $line->total_ttc = 60;
3413 $line->total_tva = 10;
3414 $line->remise_percent = 50;
3416 $line->total_ht = 100;
3417 $line->total_ttc = 120;
3418 $line->total_tva = 20;
3419 $line->remise_percent = 00;
3424 $prodid = mt_rand(1, $num_prods);
3425 $line->fk_product = $prodids[$prodid];
3426 $line->product_ref =
'SPECIMEN';
3429 $this->lines[$xnbp] = $line;
3431 $this->total_ht += $line->total_ht;
3432 $this->total_tva += $line->total_tva;
3433 $this->total_ttc += $line->total_ttc;
3450 $this->nb = array();
3453 $sql =
"SELECT count(p.rowid) as nb";
3454 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p";
3455 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
3456 if (!$user->rights->societe->client->voir && !$user->socid)
3458 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
3459 $sql .=
" WHERE sc.fk_user = ".$user->id;
3462 $sql .=
" ".$clause.
" p.entity IN (".
getEntity(
'propal').
")";
3468 while ($obj = $this->
db->fetch_object(
$resql))
3470 $this->nb[
"proposals"] = $obj->nb;
3476 $this->error = $this->
db->error();
3491 global $conf, $langs;
3492 $langs->load(
"propal");
3494 $classname = $conf->global->PROPALE_ADDON;
3496 if (!empty($classname))
3500 $file = $classname.
".php";
3503 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
3504 foreach ($dirmodels as $reldir) {
3508 $mybool |= @include_once $dir.$file;
3517 $obj =
new $classname();
3519 $numref = $obj->getNextValue($soc, $this);
3525 $this->error = $obj->error;
3530 $langs->load(
"errors");
3531 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Proposal"));
3547 public function getNomUrl($withpicto = 0, $option =
'', $get_params =
'', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1)
3549 global $langs, $conf, $user;
3551 if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1;
3557 if ($user->rights->propal->lire)
3559 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Proposal").
'</u>';
3560 if (isset($this->
statut)) {
3561 $label .=
' '.$this->getLibStatut(5);
3563 if (!empty($this->ref)) {
3564 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
3566 if (!empty($this->ref_client)) {
3567 $label .=
'<br><b>'.$langs->trans(
'RefCustomer').
':</b> '.$this->ref_client;
3569 if (!empty($this->total_ht)) {
3570 $label .=
'<br><b>'.$langs->trans(
'AmountHT').
':</b> '.
price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
3572 if (!empty($this->total_tva)) {
3573 $label .=
'<br><b>'.$langs->trans(
'VAT').
':</b> '.
price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
3575 if (!empty($this->total_ttc)) {
3576 $label .=
'<br><b>'.$langs->trans(
'AmountTTC').
':</b> '.
price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
3578 if (!empty($this->delivery_date)) {
3579 $label .=
'<br><b>'.$langs->trans(
'DeliveryDate').
':</b> '.
dol_print_date($this->delivery_date,
'dayhour');
3582 if ($option ==
'') {
3583 $url = DOL_URL_ROOT.
'/comm/propal/card.php?id='.$this->
id.$get_params;
3584 } elseif ($option ==
'compta') {
3585 $url = DOL_URL_ROOT.
'/comm/propal/card.php?id='.$this->
id.$get_params;
3586 } elseif ($option ==
'expedition') {
3587 $url = DOL_URL_ROOT.
'/expedition/propal.php?id='.$this->
id.$get_params;
3588 } elseif ($option ==
'document') {
3589 $url = DOL_URL_ROOT.
'/comm/propal/document.php?id='.$this->
id.$get_params;
3592 if ($option !=
'nolink')
3595 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
3596 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
3597 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
3602 if (empty($notooltip) && $user->rights->propal->lire)
3604 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
3606 $label = $langs->trans(
"Proposal");
3607 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
3609 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
3610 $linkclose .=
' class="classfortooltip"';
3613 $linkstart =
'<a href="'.$url.
'"';
3614 $linkstart .= $linkclose.
'>';
3617 $result .= $linkstart;
3618 if ($withpicto) $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
3619 if ($withpicto != 2) $result .= $this->ref;
3620 $result .= $linkend;
3622 if ($addlinktonotes >= 0) {
3625 if ($addlinktonotes == 0) {
3626 if (!empty($this->note_private) || !empty($this->note_public)) {
3627 $txttoshow = $langs->trans(
'ViewPrivateNote');
3629 } elseif ($addlinktonotes == 1) {
3630 if (!empty($this->note_private)) {
3633 } elseif ($addlinktonotes == 2) {
3634 if (!empty($this->note_public)) {
3637 } elseif ($addlinktonotes == 3) {
3638 if ($user->socid > 0) {
3639 if (!empty($this->note_public)) {
3643 if (!empty($this->note_public)) {
3646 if (!empty($this->note_private)) {
3647 if (!empty($txttoshow)) $txttoshow .=
'<br><br>';
3654 $result .=
' <span class="note inline-block">';
3655 $result .=
'<a href="'.DOL_URL_ROOT.
'/comm/propal/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($txttoshow).
'">';
3658 $result .=
'</span>';
3686 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
3688 global $conf, $langs;
3690 $langs->load(
"propale");
3691 $outputlangs->load(
"products");
3696 if ($this->model_pdf) {
3697 $modele = $this->model_pdf;
3698 } elseif (!empty($conf->global->PROPALE_ADDON_PDF)) {
3699 $modele = $conf->global->PROPALE_ADDON_PDF;
3703 $modelpath =
"core/modules/propale/doc/";
3705 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
3735 public $element =
'propaldet';
3740 public $table_element =
'propaldet';
3746 public $fk_parent_line;
3764 public $vat_src_code;
3767 public $remise_percent;
3768 public $fk_remise_except;
3772 public $fk_fournprice;
3777 public $special_code;
3782 public $info_bits = 0;
3811 public $product_ref;
3826 public $product_label;
3831 public $product_desc;
3837 public $product_tobatch;
3843 public $product_barcode;
3845 public $localtax1_tx;
3846 public $localtax2_tx;
3847 public $localtax1_type;
3848 public $localtax2_type;
3849 public $total_localtax1;
3850 public $total_localtax2;
3855 public $skip_update_total;
3858 public $fk_multicurrency;
3859 public $multicurrency_code;
3860 public $multicurrency_subprice;
3861 public $multicurrency_total_ht;
3862 public $multicurrency_total_tva;
3863 public $multicurrency_total_ttc;
3883 $sql =
'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,';
3884 $sql .=
' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
3885 $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,';
3886 $sql .=
' pd.fk_unit,';
3887 $sql .=
' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,';
3888 $sql .=
' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc,';
3889 $sql .=
' p.ref as product_ref, p.label as product_label, p.description as product_desc,';
3890 $sql .=
' pd.date_start, pd.date_end, pd.product_type';
3891 $sql .=
' FROM '.MAIN_DB_PREFIX.
'propaldet as pd';
3892 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON pd.fk_product = p.rowid';
3893 $sql .=
' WHERE pd.rowid = '.$rowid;
3895 $result = $this->
db->query($sql);
3898 $objp = $this->
db->fetch_object($result);
3902 $this->
id = $objp->rowid;
3903 $this->
rowid = $objp->rowid;
3904 $this->fk_propal = $objp->fk_propal;
3905 $this->fk_parent_line = $objp->fk_parent_line;
3906 $this->label = $objp->custom_label;
3907 $this->desc = $objp->description;
3908 $this->qty = $objp->qty;
3909 $this->
price = $objp->price;
3910 $this->subprice = $objp->subprice;
3911 $this->vat_src_code = $objp->vat_src_code;
3912 $this->tva_tx = $objp->tva_tx;
3913 $this->remise = $objp->remise;
3914 $this->remise_percent = $objp->remise_percent;
3915 $this->fk_remise_except = $objp->fk_remise_except;
3916 $this->fk_product = $objp->fk_product;
3917 $this->info_bits = $objp->info_bits;
3919 $this->total_ht = $objp->total_ht;
3920 $this->total_tva = $objp->total_tva;
3921 $this->total_ttc = $objp->total_ttc;
3923 $this->fk_fournprice = $objp->fk_fournprice;
3925 $marginInfos =
getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
3926 $this->pa_ht = $marginInfos[0];
3927 $this->marge_tx = $marginInfos[1];
3928 $this->marque_tx = $marginInfos[2];
3930 $this->special_code = $objp->special_code;
3931 $this->product_type = $objp->product_type;
3932 $this->rang = $objp->rang;
3934 $this->ref = $objp->product_ref;
3935 $this->product_ref = $objp->product_ref;
3936 $this->libelle = $objp->product_label;
3937 $this->product_label = $objp->product_label;
3938 $this->product_desc = $objp->product_desc;
3939 $this->fk_unit = $objp->fk_unit;
3941 $this->date_start = $this->
db->jdate($objp->date_start);
3942 $this->date_end = $this->
db->jdate($objp->date_end);
3945 $this->fk_multicurrency = $objp->fk_multicurrency;
3946 $this->multicurrency_code = $objp->multicurrency_code;
3947 $this->multicurrency_subprice = $objp->multicurrency_subprice;
3948 $this->multicurrency_total_ht = $objp->multicurrency_total_ht;
3949 $this->multicurrency_total_tva = $objp->multicurrency_total_tva;
3950 $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
3954 $this->
db->free($result);
3973 global $conf, $user;
3977 dol_syslog(get_class($this).
"::insert rang=".$this->rang);
3979 $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht ==
'');
3982 if (empty($this->tva_tx)) $this->tva_tx = 0;
3983 if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
3984 if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
3985 if (empty($this->localtax1_type)) $this->localtax1_type = 0;
3986 if (empty($this->localtax2_type)) $this->localtax2_type = 0;
3987 if (empty($this->total_localtax1)) $this->total_localtax1 = 0;
3988 if (empty($this->total_localtax2)) $this->total_localtax2 = 0;
3989 if (empty($this->rang)) $this->rang = 0;
3990 if (empty($this->remise)) $this->remise = 0;
3991 if (empty($this->remise_percent) || !is_numeric($this->remise_percent)) $this->remise_percent = 0;
3992 if (empty($this->info_bits)) $this->info_bits = 0;
3993 if (empty($this->special_code)) $this->special_code = 0;
3994 if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
3995 if (empty($this->fk_fournprice)) $this->fk_fournprice = 0;
3996 if (!is_numeric($this->qty)) $this->qty = 0;
3997 if (empty($this->pa_ht)) $this->pa_ht = 0;
3998 if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0;
3999 if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0;
4000 if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0;
4001 if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0;
4004 if ($this->pa_ht == 0 && $pa_ht_isemptystring)
4006 if (($result = $this->
defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
4010 $this->pa_ht = $result;
4015 if ($this->product_type < 0)
return -1;
4020 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'propaldet';
4021 $sql .=
' (fk_propal, fk_parent_line, label, description, fk_product, product_type,';
4022 $sql .=
' fk_remise_except, qty, vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
4023 $sql .=
' subprice, remise_percent, ';
4024 $sql .=
' info_bits, ';
4025 $sql .=
' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,';
4026 $sql .=
' fk_unit,';
4027 $sql .=
' date_start, date_end';
4028 $sql .=
', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc)';
4029 $sql .=
" VALUES (".$this->fk_propal.
",";
4030 $sql .=
" ".($this->fk_parent_line > 0 ?
"'".$this->db->escape($this->fk_parent_line).
"'" :
"null").
",";
4031 $sql .=
" ".(!empty($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
4032 $sql .=
" '".$this->db->escape($this->desc).
"',";
4033 $sql .=
" ".($this->fk_product ?
"'".$this->db->escape($this->fk_product).
"'" :
"null").
",";
4034 $sql .=
" '".$this->db->escape($this->product_type).
"',";
4035 $sql .=
" ".($this->fk_remise_except ?
"'".$this->db->escape($this->fk_remise_except).
"'" :
"null").
",";
4036 $sql .=
" ".price2num($this->qty).
",";
4037 $sql .=
" ".(empty($this->vat_src_code) ?
"''" :
"'".$this->db->escape($this->vat_src_code).
"'").
",";
4038 $sql .=
" ".price2num($this->tva_tx).
",";
4039 $sql .=
" ".price2num($this->localtax1_tx).
",";
4040 $sql .=
" ".price2num($this->localtax2_tx).
",";
4041 $sql .=
" '".$this->db->escape($this->localtax1_type).
"',";
4042 $sql .=
" '".$this->db->escape($this->localtax2_type).
"',";
4043 $sql .=
" ".(price2num($this->subprice) !==
'' ?
price2num($this->subprice) :
"null").
",";
4044 $sql .=
" ".price2num($this->remise_percent).
",";
4045 $sql .=
" ".(isset($this->info_bits) ?
"'".$this->db->escape($this->info_bits).
"'" :
"null").
",";
4046 $sql .=
" ".price2num($this->total_ht).
",";
4047 $sql .=
" ".price2num($this->total_tva).
",";
4048 $sql .=
" ".price2num($this->total_localtax1).
",";
4049 $sql .=
" ".price2num($this->total_localtax2).
",";
4050 $sql .=
" ".price2num($this->total_ttc).
",";
4051 $sql .=
" ".(!empty($this->fk_fournprice) ?
"'".$this->db->escape($this->fk_fournprice).
"'" :
"null").
",";
4052 $sql .=
" ".(isset($this->pa_ht) ?
"'".price2num($this->pa_ht).
"'" :
"null").
",";
4053 $sql .=
' '.$this->special_code.
',';
4054 $sql .=
' '.$this->rang.
',';
4055 $sql .=
' '.(!$this->fk_unit ?
'NULL' : $this->fk_unit).
',';
4056 $sql .=
" ".(!empty($this->date_start) ?
"'".$this->db->idate($this->date_start).
"'" :
"null").
',';
4057 $sql .=
" ".(!empty($this->date_end) ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
4058 $sql .=
", ".($this->fk_multicurrency > 0 ? $this->fk_multicurrency :
'null');
4059 $sql .=
", '".$this->db->escape($this->multicurrency_code).
"'";
4060 $sql .=
", ".$this->multicurrency_subprice;
4061 $sql .=
", ".$this->multicurrency_total_ht;
4062 $sql .=
", ".$this->multicurrency_total_tva;
4063 $sql .=
", ".$this->multicurrency_total_ttc;
4066 dol_syslog(get_class($this).
'::insert', LOG_DEBUG);
4070 $this->
rowid = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'propaldet');
4074 $this->
id = $this->rowid;
4082 if (!$error && !$notrigger)
4085 $result = $this->
call_trigger(
'LINEPROPAL_INSERT', $user);
4088 $this->
db->rollback();
4094 $this->
db->commit();
4097 $this->error = $this->
db->error().
" sql=".$sql;
4098 $this->
db->rollback();
4110 public function delete(
User $user, $notrigger = 0)
4117 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"propaldet WHERE rowid = ".$this->rowid;
4118 dol_syslog(
"PropaleLigne::delete", LOG_DEBUG);
4119 if ($this->
db->query($sql))
4124 $this->
id = $this->rowid;
4129 dol_syslog(get_class($this).
"::delete error -4 ".$this->error, LOG_ERR);
4133 if (!$error && !$notrigger)
4136 $result = $this->
call_trigger(
'LINEPROPAL_DELETE', $user);
4139 $this->
db->rollback();
4145 $this->
db->commit();
4149 $this->error = $this->
db->error().
" sql=".$sql;
4150 $this->
db->rollback();
4163 global $conf, $user;
4167 $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht ==
'');
4169 if (empty($this->
id) && !empty($this->
rowid)) $this->
id = $this->
rowid;
4172 if (empty($this->tva_tx)) $this->tva_tx = 0;
4173 if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
4174 if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
4175 if (empty($this->total_localtax1)) $this->total_localtax1 = 0;
4176 if (empty($this->total_localtax2)) $this->total_localtax2 = 0;
4177 if (empty($this->localtax1_type)) $this->localtax1_type = 0;
4178 if (empty($this->localtax2_type)) $this->localtax2_type = 0;
4179 if (empty($this->marque_tx)) $this->marque_tx = 0;
4180 if (empty($this->marge_tx)) $this->marge_tx = 0;
4182 if (empty($this->remise)) $this->remise = 0;
4183 if (empty($this->remise_percent)) $this->remise_percent = 0;
4184 if (empty($this->info_bits)) $this->info_bits = 0;
4185 if (empty($this->special_code)) $this->special_code = 0;
4186 if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
4187 if (empty($this->fk_fournprice)) $this->fk_fournprice = 0;
4188 if (empty($this->subprice)) $this->subprice = 0;
4189 if (empty($this->pa_ht)) $this->pa_ht = 0;
4192 if ($this->pa_ht == 0 && $pa_ht_isemptystring)
4194 if (($result = $this->
defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
4198 $this->pa_ht = $result;
4205 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propaldet SET";
4206 $sql .=
" description='".$this->db->escape($this->desc).
"'";
4207 $sql .=
", label=".(!empty($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null");
4208 $sql .=
", product_type=".$this->product_type;
4209 $sql .=
", vat_src_code = '".(empty($this->vat_src_code) ?
'' : $this->vat_src_code).
"'";
4210 $sql .=
", tva_tx='".price2num($this->tva_tx).
"'";
4211 $sql .=
", localtax1_tx=".price2num($this->localtax1_tx);
4212 $sql .=
", localtax2_tx=".price2num($this->localtax2_tx);
4213 $sql .=
", localtax1_type='".$this->db->escape($this->localtax1_type).
"'";
4214 $sql .=
", localtax2_type='".$this->db->escape($this->localtax2_type).
"'";
4215 $sql .=
", qty='".price2num($this->qty).
"'";
4216 $sql .=
", subprice=".price2num($this->subprice).
"";
4217 $sql .=
", remise_percent=".price2num($this->remise_percent).
"";
4218 $sql .=
", price=".price2num($this->
price).
"";
4219 $sql .=
", remise=".price2num($this->remise).
"";
4220 $sql .=
", info_bits='".$this->db->escape($this->info_bits).
"'";
4221 if (empty($this->skip_update_total))
4223 $sql .=
", total_ht=".price2num($this->total_ht).
"";
4224 $sql .=
", total_tva=".price2num($this->total_tva).
"";
4225 $sql .=
", total_ttc=".price2num($this->total_ttc).
"";
4226 $sql .=
", total_localtax1=".price2num($this->total_localtax1).
"";
4227 $sql .=
", total_localtax2=".price2num($this->total_localtax2).
"";
4229 $sql .=
", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ?
"'".$this->db->escape($this->fk_fournprice).
"'" :
"null");
4230 $sql .=
", buy_price_ht=".price2num($this->pa_ht);
4231 if (strlen($this->special_code)) $sql .=
", special_code=".$this->special_code;
4232 $sql .=
", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line :
"null");
4233 if (!empty($this->rang)) $sql .=
", rang=".$this->rang;
4234 $sql .=
", date_start=".(!empty($this->date_start) ?
"'".$this->db->idate($this->date_start).
"'" :
"null");
4235 $sql .=
", date_end=".(!empty($this->date_end) ?
"'".$this->db->idate($this->date_end).
"'" :
"null");
4236 $sql .=
", fk_unit=".(!$this->fk_unit ?
'NULL' : $this->fk_unit);
4239 $sql .=
", multicurrency_subprice=".price2num($this->multicurrency_subprice).
"";
4240 $sql .=
", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).
"";
4241 $sql .=
", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).
"";
4242 $sql .=
", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).
"";
4244 $sql .=
" WHERE rowid = ".$this->id;
4246 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
4259 if (!$error && !$notrigger)
4262 $result = $this->
call_trigger(
'LINEPROPAL_UPDATE', $user);
4265 $this->
db->rollback();
4271 $this->
db->commit();
4274 $this->error = $this->
db->error();
4275 $this->
db->rollback();
4293 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"propaldet SET";
4294 $sql .=
" total_ht=".price2num($this->total_ht,
'MT').
"";
4295 $sql .=
",total_tva=".price2num($this->total_tva,
'MT').
"";
4296 $sql .=
",total_ttc=".price2num($this->total_ttc,
'MT').
"";
4297 $sql .=
" WHERE rowid = ".$this->rowid;
4299 dol_syslog(
"PropaleLigne::update_total", LOG_DEBUG);
4304 $this->
db->commit();
4307 $this->error = $this->
db->error();
4308 $this->
db->rollback();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
deleteline($lineid)
Delete detail line.
updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.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, $date_start= '', $date_end= '', $array_options=0, $fk_unit=null, $pu_ht_devise=0, $notrigger=0)
Update a proposal line.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
reopen($user, $statut, $note= '', $notrigger=0)
Reopen the commercial proposal.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
set_date_livraison($user, $delivery_date, $notrigger=0)
Set delivery date.
getInvoiceArrayList()
Returns an array with the numbers of related invoices.
set_ref_client($user, $ref_client, $notrigger=0)
Set customer reference number.
fetch($rowid)
Retrieve the propal line object.
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.
update($notrigger=0)
Update propal line object into DB.
setDraft($user, $notrigger=0)
Set draft status.
static getIdAndTxFromCode($db, $code, $date_document= '')
Get id and rate of currency from code.
InvoiceArrayList($id)
Returns an array with id and ref of related invoices.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
</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
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.
delete_linked_contact($source= '', $code= '')
Delete all links between an object $this and all its contacts.
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.
Class to manage Dolibarr database access.
set_echeance($user, $date_fin_validite, $notrigger=0)
Define end validity date.
set_availability($user, $id, $notrigger=0)
Set delivery.
liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield= 'p.datep', $sortorder= 'DESC')
Return list of proposal (eventually filtered on user) into an array.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
getLinesArray()
Retrieve an array of proposal lines.
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.
insert($notrigger=0)
Insert object line propal in database.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
update(User $user, $notrigger=0)
Update database.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
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.
valid($user, $notrigger=0)
Set status to validated.
$conf db
API class for accounts.
add_product($idproduct, $qty, $remise_percent=0)
Add line into array ->lines $this->thirdparty should be loaded.
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...
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type= 'HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label= '', $date_start= '', $date_end= '', $array_options=0, $fk_unit=null, $origin= '', $origin_id=0, $pu_ht_devise=0, $fk_remise_except=0)
Add a proposal line into database (linked to product/service or not) The parameters are already suppo...
insertExtraFields($trigger= '', $userused=null)
Add/Update all extra fields values for the current object.
create($user, $notrigger=0)
Create commercial proposal into database this->ref can be set or empty.
set_demand_reason($user, $id, $notrigger=0)
Set source of demand.
const STATUS_NOTSIGNED
Not signed quote.
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)
createFromClone(User $user, $socid=0, $forceentity=null)
Load an object from its id and create a new one in database.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
const STATUS_BILLED
Billed or processed quote.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
const STATUS_SIGNED
Signed quote.
deleteEcmFiles($mode=0)
Delete related files of object in database.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
static getIdFromCode($db, $code)
Get id of currency from code.
LibStatut($status, $mode=1)
Return label of a status (draft, validated, ...)
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
set_remise_percent($user, $remise, $notrigger=0)
Set an overall discount on the proposal.
load_state_board()
Charge indicateurs this->nb de tableau de bord.
demand_reason($demand_reason_id, $notrigger=0)
Change source demand.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
static replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
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) ...
fetchObjectLinked($sourceid=null, $sourcetype= '', $targetid=null, $targettype= '', $clause= 'OR', $alsosametype=1, $orderby= 'sourcetype', $loadalsoobjects=1)
Fetch array of objects linked to current object (object of enabled modules only). ...
Class to manage commercial proposal lines.
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.
set_remise_absolue($user, $remise, $notrigger=0)
Set an absolute overall discount on the proposal.
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_date($user, $date, $notrigger=0)
Define proposal date.
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.
defineBuyPrice($unitPrice=0.0, $discountPercent=0.0, $fk_product=0)
Get buy price to use for margin calculation.
fetch_lines($only_product=0, $loadalsotranslation=0)
Load array lines.
print $_SERVER["PHP_SELF"]
Edit parameters.
const STATUS_DRAFT
Draft status.
__construct($db, $socid=0, $propalid=0)
Constructor.
setDeliveryDate($user, $delivery_date, $notrigger=0)
Set delivery date.
trait CommonIncoterm
Superclass for incoterm classes.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
call_trigger($triggerName, $user)
Call trigger based on this instance.
fetch($rowid, $ref= '', $ref_ext= '')
Load a proposal from database.
__construct($db)
Class line Contructor.
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.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
const STATUS_VALIDATED
Validated status.
getNextNumRef($soc)
Returns the reference to the following non used Proposal used depending on the active numbering modul...
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
initAsSpecimen()
Initialise an instance with random values.
insert_discount($idremise)
Adding line of fixed discount in the proposal in DB.
add_object_linked($origin=null, $origin_id=null)
Add objects linked in llx_element_element.
getLibStatut($mode=0)
Return label of status of proposal (draft, validated, ...)
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)...
update_total()
Update DB line fields total_xxx Used by migration.
availability($availability_id, $notrigger=0)
Change the delivery time.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
classifyBilled(User $user, $notrigger=0)
Class invoiced the Propal.
info($id)
Object Proposal Information.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
if(!empty($search_group)) natural_search(array("g.nom"g note
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
Class to manage proposals.
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...
getNomUrl($withpicto=0, $option= '', $get_params= '', $notooltip=0, $save_lastsearch_value=-1, $addlinktonotes=-1)
Return clicable link of object (with eventually picto)
cloture($user, $status, $note="", $notrigger=0)
Close the commercial proposal.