dolibarr 21.0.0-alpha
fournisseur.facture.ligne.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
5 * Copyright (C) 2005 Marc Barilley <marc@ocebo.com>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2013-2019 Philippe Grand <philippe.grand@atoo-net.com>
9 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
10 * Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
11 * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
12 * Copyright (C) 2015-2022 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2016-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
14 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
15 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
16 * Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
17 * Copyright (C) 2023 Nick Fragoulis
18 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
19 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
20 *
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <https://www.gnu.org/licenses/>.
33 */
34
41require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
42require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
43require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
44
45if (isModEnabled('accounting')) {
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
47 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
48}
49
54{
58 public $element = 'facture_fourn_det';
59
63 public $table_element = 'facture_fourn_det';
64
68 public $parent_element = 'facture_fourn';
69
73 public $fk_parent_attribute = 'fk_facture_fourn';
74
78 public $oldline;
79
85 public $ref;
86
91 public $product_ref;
92
98 public $ref_supplier;
99
104 public $product_desc;
105
112 public $pu_ht;
113
118 public $subprice;
119
124 public $pu_ttc;
125
126
131 public $fk_facture_fourn;
132
138 public $label;
139
145 public $description;
146
150 public $date_start;
154 public $date_end;
155
159 public $fk_code_ventilation;
160
164 public $skip_update_total; // Skip update price total for special lines
165
169 public $situation_percent;
170
174 public $fk_prev_id;
175
180 public $vat_src_code;
181
186 public $tva_tx;
187
192 public $localtax1_tx;
193
198 public $localtax2_tx;
199
204 public $qty;
205
210 public $remise_percent;
211
216 public $pa_ht;
217
222 public $total_ht;
223
228 public $total_ttc;
229
234 public $total_tva;
235
240 public $total_localtax1;
241
246 public $total_localtax2;
247
251 public $fk_product;
252
257 public $product_type;
258
263 public $product_label;
264
271 public $info_bits;
272
277 public $fk_remise_except;
278
282 public $fk_parent_line;
283
287 public $special_code;
288
292 public $rang;
293
298 public $localtax1_type;
299
304 public $localtax2_type;
305
306
312 public function __construct($db)
313 {
314 $this->db = $db;
315 }
316
323 public function fetch($rowid)
324 {
325 $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description as line_desc, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
326 $sql .= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_remise_except';
327 $sql .= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
328 $sql .= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc';
329 $sql .= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
330 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
331 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
332 $sql .= ' WHERE f.rowid = '.((int) $rowid);
333 $sql .= ' ORDER BY f.rang, f.rowid';
334
335 $query = $this->db->query($sql);
336
337 if (!$query) {
338 $this->errors[] = $this->db->error();
339 return -1;
340 }
341
342 if (!$this->db->num_rows($query)) {
343 return 0;
344 }
345
346 $obj = $this->db->fetch_object($query);
347
348 $this->id = $obj->rowid;
349 $this->rowid = $obj->rowid;
350 $this->fk_facture_fourn = $obj->fk_facture_fourn;
351 $this->description = $obj->line_desc;
352 $this->desc = $obj->line_desc;
353 $this->date_start = $obj->date_start;
354 $this->date_end = $obj->date_end;
355 $this->product_ref = $obj->product_ref;
356 $this->ref_supplier = $obj->ref_supplier;
357 $this->product_desc = $obj->product_desc;
358
359 $this->subprice = $obj->pu_ht;
360 $this->pu_ht = $this->subprice;
361 $this->pu_ttc = $obj->pu_ttc;
362 $this->tva_tx = $obj->tva_tx;
363 $this->localtax1_tx = $obj->localtax1_tx;
364 $this->localtax2_tx = $obj->localtax2_tx;
365 $this->localtax1_type = $obj->localtax1_type;
366 $this->localtax2_type = $obj->localtax2_type;
367
368 $this->qty = $obj->qty;
369 $this->remise_percent = $obj->remise_percent;
370 $this->fk_remise_except = $obj->fk_remise_except;
371 //$this->tva = $obj->total_tva; // deprecated
372 $this->total_ht = $obj->total_ht;
373 $this->total_tva = $obj->total_tva;
374 $this->total_localtax1 = $obj->total_localtax1;
375 $this->total_localtax2 = $obj->total_localtax2;
376 $this->total_ttc = $obj->total_ttc;
377 $this->fk_product = $obj->fk_product;
378 $this->product_type = $obj->product_type;
379 $this->product_label = $obj->product_label;
380 $this->label = $obj->product_label;
381 $this->info_bits = $obj->info_bits;
382 $this->fk_parent_line = $obj->fk_parent_line;
383 $this->special_code = $obj->special_code;
384 $this->rang = $obj->rang;
385 $this->fk_unit = $obj->fk_unit;
386
387 $this->multicurrency_subprice = $obj->multicurrency_subprice;
388 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
389 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
390 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
391
392 $this->fetch_optionals();
393
394 return 1;
395 }
396
403 public function delete($notrigger = 0)
404 {
405 global $user;
406
407 dol_syslog(get_class($this)."::deleteline rowid=".((int) $this->id), LOG_DEBUG);
408
409 $error = 0;
410
411 $this->db->begin();
412
413 if (!$notrigger) {
414 if ($this->call_trigger('LINEBILL_SUPPLIER_DELETE', $user) < 0) {
415 $error++;
416 }
417 }
418
419 $this->deleteObjectLinked();
420
421 // Remove extrafields
422 if (!$error) {
423 $result = $this->deleteExtraFields();
424 if ($result < 0) {
425 $error++;
426 dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
427 }
428 }
429
430 if (!$error) {
431 // Supprime ligne
432 $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
433 $sql .= " WHERE rowid = ".((int) $this->id);
434 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
435 $resql = $this->db->query($sql);
436 if (!$resql) {
437 $error++;
438 $this->error = $this->db->lasterror();
439 }
440 }
441
442 if (!$error) {
443 $this->db->commit();
444 return 1;
445 } else {
446 $this->db->rollback();
447 return -1;
448 }
449 }
450
457 public function update($notrigger = 0)
458 {
459 global $conf;
460
461 $pu = price2num($this->subprice);
462 $qty = price2num($this->qty);
463
464 // Check parameters
465 if (empty($this->qty)) {
466 $this->qty = 0;
467 }
468
469 if ($this->product_type < 0) {
470 return -1;
471 }
472
473 // Clean parameters
474 if (empty($this->remise_percent)) {
475 $this->remise_percent = 0;
476 }
477 if (empty($this->tva_tx)) {
478 $this->tva_tx = 0;
479 }
480 if (empty($this->localtax1_tx)) {
481 $this->localtax1_tx = 0;
482 }
483 if (empty($this->localtax2_tx)) {
484 $this->localtax2_tx = 0;
485 }
486
487 if (empty($this->pa_ht)) {
488 $this->pa_ht = 0;
489 }
490 if (empty($this->multicurrency_subprice)) {
491 $this->multicurrency_subprice = 0;
492 }
493 if (empty($this->multicurrency_total_ht)) {
494 $this->multicurrency_total_ht = 0;
495 }
496 if (empty($this->multicurrency_total_tva)) {
497 $this->multicurrency_total_tva = 0;
498 }
499 if (empty($this->multicurrency_total_ttc)) {
500 $this->multicurrency_total_ttc = 0;
501 }
502
503 $fk_product = (int) $this->fk_product;
504 $fk_unit = (int) $this->fk_unit;
505
506 $this->db->begin();
507
508 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
509 $sql .= " description = '".$this->db->escape(empty($this->description) ? $this->desc : $this->description)."'";
510 $sql .= ", ref = '".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'";
511 $sql .= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
512 $sql .= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
513 $sql .= ", pu_ht = ".price2num($this->subprice);
514 $sql .= ", pu_ttc = ".price2num($this->pu_ttc);
515 $sql .= ", qty = ".price2num($this->qty);
516 $sql .= ", remise_percent = ".price2num($this->remise_percent);
517 if ($this->fk_remise_except > 0) {
518 $sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
519 } else {
520 $sql .= ", fk_remise_except=null";
521 }
522 $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'";
523 $sql .= ", tva_tx = ".price2num($this->tva_tx);
524 $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx);
525 $sql .= ", localtax2_tx = ".price2num($this->localtax2_tx);
526 $sql .= ", localtax1_type = '".$this->db->escape($this->localtax1_type)."'";
527 $sql .= ", localtax2_type = '".$this->db->escape($this->localtax2_type)."'";
528 $sql .= ", total_ht = ".price2num($this->total_ht);
529 $sql .= ", tva= ".price2num($this->total_tva);
530 $sql .= ", total_localtax1= ".price2num($this->total_localtax1);
531 $sql .= ", total_localtax2= ".price2num($this->total_localtax2);
532 $sql .= ", total_ttc = ".price2num($this->total_ttc);
533 $sql .= ", fk_product = ".($fk_product > 0 ? (int) $fk_product : 'null');
534 $sql .= ", product_type = ".((int) $this->product_type);
535 $sql .= ", info_bits = ".((int) $this->info_bits);
536 $sql .= ", fk_unit = ".($fk_unit > 0 ? (int) $fk_unit : 'null');
537
538 if (!empty($this->rang)) {
539 $sql .= ", rang=".((int) $this->rang);
540 }
541
542 // Multicurrency
543 $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice);
544 $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht);
545 $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva);
546 $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
547
548 $sql .= " WHERE rowid = ".((int) $this->id);
549
550 dol_syslog(get_class($this)."::update", LOG_DEBUG);
551 $resql = $this->db->query($sql);
552
553 if (!$resql) {
554 $this->db->rollback();
555 $this->error = $this->db->lasterror();
556 return -1;
557 }
558
559 $this->rowid = $this->id;
560 $error = 0;
561
562 if (!$error) {
563 $result = $this->insertExtraFields();
564 if ($result < 0) {
565 $error++;
566 }
567 }
568
569 if (!$error && !$notrigger) {
570 global $langs, $user;
571
572 // Call trigger
573 if ($this->call_trigger('LINEBILL_SUPPLIER_MODIFY', $user) < 0) {
574 $this->db->rollback();
575 return -1;
576 }
577 // End call triggers
578 }
579
580 if ($error) {
581 $this->db->rollback();
582 return -1;
583 }
584
585 $this->db->commit();
586 return 1;
587 }
588
596 public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0)
597 {
598 global $user, $langs;
599
600 $error = 0;
601
602 dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
603
604 // Clean parameters
605 $this->desc = trim($this->desc);
606 if (empty($this->tva_tx)) {
607 $this->tva_tx = 0;
608 }
609 if (empty($this->localtax1_tx)) {
610 $this->localtax1_tx = 0;
611 }
612 if (empty($this->localtax2_tx)) {
613 $this->localtax2_tx = 0;
614 }
615 if (empty($this->localtax1_type)) {
616 $this->localtax1_type = 0.0;
617 }
618 if (empty($this->localtax2_type)) {
619 $this->localtax2_type = 0.0;
620 }
621 if (empty($this->total_tva)) {
622 $this->total_tva = 0;
623 }
624 if (empty($this->total_localtax1)) {
625 $this->total_localtax1 = 0;
626 }
627 if (empty($this->total_localtax2)) {
628 $this->total_localtax2 = 0;
629 }
630 if (empty($this->rang)) {
631 $this->rang = 0;
632 }
633 if (empty($this->remise_percent)) {
634 $this->remise_percent = 0;
635 }
636 if (empty($this->info_bits)) {
637 $this->info_bits = 0;
638 }
639 if (empty($this->subprice)) {
640 $this->subprice = 0;
641 }
642 if (empty($this->special_code)) {
643 $this->special_code = 0;
644 }
645 if (empty($this->fk_parent_line)) {
646 $this->fk_parent_line = 0;
647 }
648 if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') {
649 $this->situation_percent = 100;
650 }
651
652 if (empty($this->pa_ht)) {
653 $this->pa_ht = 0;
654 }
655 if (empty($this->multicurrency_subprice)) {
656 $this->multicurrency_subprice = 0;
657 }
658 if (empty($this->multicurrency_total_ht)) {
659 $this->multicurrency_total_ht = 0;
660 }
661 if (empty($this->multicurrency_total_tva)) {
662 $this->multicurrency_total_tva = 0;
663 }
664 if (empty($this->multicurrency_total_ttc)) {
665 $this->multicurrency_total_ttc = 0;
666 }
667
668
669 // Check parameters
670 if ($this->product_type < 0) {
671 $this->error = 'ErrorProductTypeMustBe0orMore';
672 return -1;
673 }
674 if (!empty($this->fk_product) && $this->fk_product > 0) {
675 // Check product exists
676 $result = Product::isExistingObject('product', $this->fk_product);
677 if ($result <= 0) {
678 $this->error = 'ErrorProductIdDoesNotExists';
679 return -1;
680 }
681 }
682
683 $this->db->begin();
684
685 // Insertion dans base de la ligne
686 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
687 $sql .= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
688 $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
689 $sql .= ' fk_product, product_type, remise_percent, fk_remise_except, pu_ht, pu_ttc,';
690 $sql .= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
691 $sql .= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
692 $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
693 $sql .= ')';
694 $sql .= " VALUES (".$this->fk_facture_fourn.",";
695 $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape($this->fk_parent_line)."'" : "null").",";
696 $product_label
697 = !empty($this->product_label)
698 ? $this->product_label :
699 (!empty($this->label) ? $this->label : null);
700 $sql .= " ".(!empty($product_label) ? "'".$this->db->escape($product_label)."'" : "null").",";
701 $sql .= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',";
702 $sql .= " '".$this->db->escape($this->ref_supplier)."',";
703 $sql .= " ".price2num($this->qty).",";
704
705 $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").",";
706 $sql .= " ".price2num($this->tva_tx).",";
707 $sql .= " ".price2num($this->localtax1_tx).",";
708 $sql .= " ".price2num($this->localtax2_tx).",";
709 $sql .= " '".$this->db->escape($this->localtax1_type)."',";
710 $sql .= " '".$this->db->escape($this->localtax2_type)."',";
711 $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
712 $sql .= " ".((int) $this->product_type).",";
713 $sql .= " ".price2num($this->remise_percent).",";
714 $sql .= ' '.(!empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").',';
715 $sql .= " ".price2num($this->subprice).",";
716 $sql .= " ".(!empty($this->qty) ? price2num($this->total_ttc / $this->qty) : price2num($this->total_ttc)).",";
717 $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").",";
718 $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
719 $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).',';
720 $sql .= ' '.((int) $this->rang).',';
721 $sql .= ' '.((int) $this->special_code).',';
722 $sql .= " ".((int) $this->info_bits).",";
723 $sql .= " ".price2num($this->total_ht).",";
724 $sql .= " ".price2num($this->total_tva).",";
725 $sql .= " ".price2num($this->total_ttc).",";
726 $sql .= " ".price2num($this->total_localtax1).",";
727 $sql .= " ".price2num($this->total_localtax2);
728 $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
729 $sql .= ", ".(int) $this->fk_multicurrency;
730 $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
731 $sql .= ", ".price2num($this->multicurrency_subprice);
732 $sql .= ", ".price2num($this->multicurrency_total_ht);
733 $sql .= ", ".price2num($this->multicurrency_total_tva);
734 $sql .= ", ".price2num($this->multicurrency_total_ttc);
735 $sql .= ')';
736
737 $resql = $this->db->query($sql);
738 if ($resql) {
739 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
740 $this->rowid = $this->id; // backward compatibility
741
742 if (!$error) {
743 $result = $this->insertExtraFields();
744 if ($result < 0) {
745 $error++;
746 }
747 }
748
749 // Si fk_remise_except defini, on lie la remise a la facture
750 // ce qui la flague comme "consommee".
751 if ($this->fk_remise_except) {
752 $discount = new DiscountAbsolute($this->db);
753 $result = $discount->fetch($this->fk_remise_except);
754 if ($result >= 0) {
755 // Check if discount was found
756 if ($result > 0) {
757 // Check if discount not already affected to another invoice
758 if ($discount->fk_facture_line > 0) {
759 if (empty($noerrorifdiscountalreadylinked)) {
760 $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
761 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
762 $this->db->rollback();
763 return -3;
764 }
765 } else {
766 $result = $discount->link_to_invoice($this->id, 0);
767 if ($result < 0) {
768 $this->error = $discount->error;
769 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
770 $this->db->rollback();
771 return -3;
772 }
773 }
774 } else {
775 $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
776 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
777 $this->db->rollback();
778 return -3;
779 }
780 } else {
781 $this->error = $discount->error;
782 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
783 $this->db->rollback();
784 return -3;
785 }
786 }
787
788 if (!$error && !$notrigger) {
789 // Call trigger
790 $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user);
791 if ($result < 0) {
792 $this->db->rollback();
793 return -2;
794 }
795 // End call triggers
796 }
797
798 $this->db->commit();
799 return $this->id;
800 } else {
801 $this->error = $this->db->error();
802 $this->db->rollback();
803 return -2;
804 }
805 }
806
807 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
813 public function update_total()
814 {
815 // phpcs:enable
816 $this->db->begin();
817
818 // Mise a jour ligne en base
819 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
820 $sql .= " total_ht = ".price2num($this->total_ht);
821 $sql .= ", tva= ".price2num($this->total_tva);
822 $sql .= ", total_localtax1 = ".price2num($this->total_localtax1);
823 $sql .= ", total_localtax2 = ".price2num($this->total_localtax2);
824 $sql .= ", total_ttc = ".price2num($this->total_ttc);
825 $sql .= " WHERE rowid = ".((int) $this->id);
826
827 dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG);
828
829 $resql = $this->db->query($sql);
830 if ($resql) {
831 $this->db->commit();
832 return 1;
833 } else {
834 $this->error = $this->db->error();
835 $this->db->rollback();
836 return -2;
837 }
838 }
839}
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=0, $f_user=null, $notrigger=0)
Delete all links between an object $this.
static isExistingObject($element, $id, $ref='', $ref_ext='')
Check if an object id or ref exists If you don't need or want to instantiate the object and just need...
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage absolute discounts.
Class to manage line invoices.
fetch($rowid)
Retrieves a supplier invoice line.
update($notrigger=0)
Update a supplier invoice line.
insert($notrigger=0, $noerrorifdiscountalreadylinked=0)
Insert line into database.
update_total()
Mise a jour de l'objet ligne de commande en base.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.