From de8e7107ee42659c0f46fba61048058c5e36e89e Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Fri, 6 Nov 2015 01:53:20 +0100 Subject: [PATCH 1/2] Maintain origin_id and origin for copy document Fix any errors. --- htdocs/comm/propal/class/propal.class.php | 21 ++++++++++++++----- htdocs/commande/class/commande.class.php | 8 +++++-- htdocs/compta/facture/class/facture.class.php | 8 ++++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 390e05363bb..f7a55bf6e02 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -375,13 +375,15 @@ class Propal extends CommonObject * @param int $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param string $origin 'order', ... + * @param int $origin_id Id of origin object * @return int >0 if OK, <0 if KO * * @see add_product */ - 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) + 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) { - global $mysoc; + global $mysoc, $conf, $langs; 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"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -499,6 +501,9 @@ class Propal extends CommonObject $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + $this->line->origin_id = $origin_id; + $this->line->origin = $origin; + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -570,7 +575,8 @@ class Propal extends CommonObject { global $mysoc; - dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, 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=$a_ht, type=$type, date_start=$date_start, date_end=$date_end"); + dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, + 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"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -894,7 +900,9 @@ class Propal extends CommonObject $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->array_options, - $this->lines[$i]->fk_unit + $this->lines[$i]->fk_unit, + $this->element, + $this->lines[$i]->id ); if ($result < 0) @@ -1384,7 +1392,10 @@ class Propal extends CommonObject */ function update_extrafields($user) { + global $conf, $hookmanager; + $action='update'; + $error = 0; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -2717,7 +2728,7 @@ class Propal extends CommonObject */ function getNomUrl($withpicto=0,$option='', $get_params='') { - global $langs; + global $langs, $conf; $result=''; $label = '' . $langs->trans("ShowPropal") . ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 29be83ea3e2..1de3b25e5d2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -777,7 +777,9 @@ class Commande extends CommonOrder $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, - $this->lines[$i]->fk_unit + $this->lines[$i]->fk_unit, + $this->element, + $this->lines[$i]->id ); if ($result < 0) { @@ -2321,6 +2323,7 @@ class Commande extends CommonOrder function classifyBilled() { global $conf, $user, $langs; + $error = 0; $this->db->begin(); @@ -2635,6 +2638,7 @@ class Commande extends CommonOrder global $hookmanager, $conf; $action='create'; + $error = 0; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -2871,7 +2875,7 @@ class Commande extends CommonOrder */ function LibStatut($statut,$billed,$mode) { - global $langs; + global $langs, $conf; //print 'x'.$statut.'-'.$billed; if ($mode == 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1462bf43a9b..8f8c9ae5d47 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -385,6 +385,8 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; + $newinvoiceline->origin = $this->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 { // Reset fk_parent_line for no child products and special product @@ -441,8 +443,8 @@ class Facture extends CommonInvoice $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, - '', - 0, + $this->element, + $this->lines[$i]->id, $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, @@ -873,7 +875,7 @@ class Facture extends CommonInvoice */ function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='') { - global $langs; + global $langs, $conf; $result=''; From 6bf8b7f328f7c9fb8cecb32b38708d40f3764a96 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Fri, 6 Nov 2015 02:25:51 +0100 Subject: [PATCH 2/2] Default value origin_id and origin --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f7a55bf6e02..fcac4ba9de1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -381,7 +381,7 @@ class Propal extends CommonObject * * @see add_product */ - 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) + 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) { global $mysoc, $conf, $langs;