From 0582653a679d0da3399f399ed39d634d46c99d57 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 10:55:03 +0100 Subject: [PATCH 1/7] FIX : get multicurrency infos of propal when create order from propal with "WORKFLOW_PROPAL_AUTOCREATE_ORDER" conf --- htdocs/commande/class/commande.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 54e50baa9f7..2e20567e4c5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1355,6 +1355,27 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($conf->multicurrency->enabled)) { + if (!empty($object->multicurrency_code)) { + $this->multicurrency_code = $object->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($object->multicurrency_tx)) { + $this->multicurrency_tx = $object->multicurrency_tx; + } + + 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_commande); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + } + // get extrafields from original line $object->fetch_optionals(); From 3b9d39c1d2fae893b272532167353a64ba866ba1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 21 Dec 2022 10:00:26 +0000 Subject: [PATCH 2/7] Fixing style errors. --- htdocs/commande/class/commande.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2e20567e4c5..12054c3ccb8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1355,7 +1355,7 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) if (!empty($conf->multicurrency->enabled)) { if (!empty($object->multicurrency_code)) { $this->multicurrency_code = $object->multicurrency_code; @@ -1364,16 +1364,16 @@ class Commande extends CommonOrder $this->multicurrency_tx = $object->multicurrency_tx; } - 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_commande); - } else { - $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); - } - if (empty($this->fk_multicurrency)) { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + 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_commande); + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } } // get extrafields from original line From a48d1ae8e392cc2b2ad9d9c324983d1e6193c1b1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 12:31:24 +0100 Subject: [PATCH 3/7] FIX : multicurrency_tx and not currency_tx --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c0d7cf53a5d..4f3d9230899 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2929,8 +2929,8 @@ if ($action == 'create') { $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); if (!empty($conf->multicurrency->enabled)) { - $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code)); - $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx)); + $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); + $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); } //Replicate extrafields From 69b0cf9bcfeeab25166131128b3f229477255771 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 14:05:54 +0100 Subject: [PATCH 4/7] FIX : include class multicurrency --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 12054c3ccb8..d56eeb2af0e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1281,6 +1281,7 @@ class Commande extends CommonOrder { global $conf, $hookmanager; + dol_include_once('/multicurrency/class/multicurrency.class.php'); dol_include_once('/core/class/extrafields.class.php'); $error = 0; From 2c7e0afabd7c04cbde50fcd9734edc75ac60cb35 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 21 Dec 2022 17:17:33 +0100 Subject: [PATCH 5/7] FIX : travis --- htdocs/commande/class/commande.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d56eeb2af0e..33de271b45d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1366,7 +1366,9 @@ class Commande extends CommonOrder } 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_commande); + $tmparray = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date_commande); + $this->fk_multicurrency = $tmparray[0]; + $this->multicurrency_tx = $tmparray[1]; } else { $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); } From 2aa271d96eea915d56f5230689b25b2a0ffe539c Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Wed, 28 Dec 2022 17:50:16 +0100 Subject: [PATCH 6/7] avoid editretainedwarranty if invoice is not draft --- htdocs/compta/facture/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c0d7cf53a5d..d682a17d91b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4517,13 +4517,13 @@ if ($action == 'create') { print ''; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { + if ($action != 'editretainedwarranty' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; print ''; - if ($action == 'editretainedwarranty') { + if ($action == 'editretainedwarranty' && $object->statut == Facture::STATUS_DRAFT) { print '
'; print ''; print ''; @@ -4540,7 +4540,7 @@ if ($action == 'create') { print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4551,7 +4551,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantypaymentterms') { + if ($action == 'editretainedwarrantypaymentterms' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -4575,7 +4575,7 @@ if ($action == 'create') { print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4586,7 +4586,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantydatelimit') { + if ($action == 'editretainedwarrantydatelimit' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; From 94fb344bd67c5910b8e681d74e7677e864270ea7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jan 2023 02:02:34 +0100 Subject: [PATCH 7/7] FIX #22271 --- htdocs/imports/import.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index dfe2d0b9d49..a6982bd0a4e 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -815,18 +815,22 @@ if ($step == 4 && $datatoimport) { $array_match_file_to_database = array(); } - // Load source fields in input file + // Load the source fields from input file into variable $arrayrecord $fieldssource = array(); $result = $obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport, $langs); if ($result >= 0) { // Read first line $arrayrecord = $obj->import_read_record(); - // Put into array fieldssource starting with 1. + + // Create array $fieldssource starting with 1 with values found of first line. $i = 1; foreach ($arrayrecord as $key => $val) { if ($val["type"] != -1) { $fieldssource[$i]['example1'] = dol_trunc($val['val'], 128); $i++; + } else { + $fieldssource[$i]['example1'] = $langs->trans('Empty'); + $i++; } } $obj->import_close_file();
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'