From 5c52f244c4f47ee37e0a58d289789a95f46f4ffb Mon Sep 17 00:00:00 2001 From: Irvine Fleith Date: Thu, 29 Aug 2024 15:03:26 +0200 Subject: [PATCH 1/2] Added extrafields when inserting a line of facturerec --- .../facture/class/facture-rec.class.php | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index ec73b91231b9f..c5e1828b4c23b 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1019,16 +1019,28 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt $sql .= ", ".price2num($multicurrency_total_ttc, 'CT'); $sql .= ")"; - dol_syslog(get_class($this)."::addline", LOG_DEBUG); - if ($this->db->query($sql)) { - $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec"); - $this->id = $facid; - $this->update_price(1); - return $lineId; - } else { - $this->error = $this->db->lasterror(); - return -1; - } + dol_syslog(get_class($this) . "::addline", LOG_DEBUG); + if ($this->db->query($sql)) { + $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX . "facturedet_rec"); + $this->id = $facid; + $this->update_price(1); + + /** + * Backported from contract + */ + $factureRecLine = new FactureLigneRec($this->db); + $factureRecLine->array_options = $array_options; + $factureRecLine->id = $lineId; + $result = $factureRecLine->insertExtraFields(); + if ($result < 0) { + $this->error[] = $factureRecLine->error; + } + + return $lineId; + } else { + $this->error = $this->db->lasterror(); + return -1; + } } } From 84f7e20e753775ba88c302039df04e71f891c701 Mon Sep 17 00:00:00 2001 From: Irvine Fleith Date: Thu, 29 Aug 2024 15:05:46 +0200 Subject: [PATCH 2/2] Oui --- htdocs/compta/facture/class/facture-rec.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c5e1828b4c23b..a0dc51a2ef7f8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -858,9 +858,10 @@ public function delete(User $user, $notrigger = 0, $idwarehouse = -1) * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' + * @param array $array_options Extrafields array * @return int <0 if KO, Id of line if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = []) { global $mysoc;