From 54b90abd87b50cd8cf1ed7d318f3fccf8376a844 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 26 Jul 2022 13:50:53 +0200 Subject: [PATCH 1/9] Delete Knowledge : categorie management --- .../class/knowledgerecord.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 8629ec7bbc6..a1d41c97a9f 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -467,6 +467,24 @@ class KnowledgeRecord extends CommonObject $this->error .= $this->db->lasterror(); $errorflag = -1; } + + // Delete all child tables + if (!$error) { + $elements = array('categorie_knowledgemanagement'); // product_batch is done before + foreach ($elements as $table) { + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; + $sql .= " WHERE fk_knowledgemanagement = ".(int) $this->id; + + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + } + } + return $this->deleteCommon($user, $notrigger); //return $this->deleteCommon($user, $notrigger, 1); } From cec9725ced00a63289748d3062a4ad89428ac407 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 1 Aug 2022 16:28:44 +0200 Subject: [PATCH 2/9] FIX : VAT rate recalculation set a checkbox on clone formquestion --- htdocs/compta/facture/card.php | 11 ++++++++--- htdocs/compta/facture/class/facture.class.php | 10 +++++++++- htdocs/langs/en_US/bills.lang | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index eb43da88a4b..268463f1e7d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -207,8 +207,12 @@ if (empty($reshook)) { $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + $objectutil->socid = $socid; - $result = $objectutil->createFromClone($user, $id); + + $targetThirdPartyVat = GETPOSTISSET('targetThirdPartyVat'); + $result = $objectutil->createFromClone($user, $id, $targetThirdPartyVat); + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); exit(); @@ -4174,9 +4178,10 @@ if ($action == 'create') { // Create an array for form $formquestion = array( array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)), - array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) + array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()), + array('type' => 'checkbox', 'name' => 'targetThirdPartyVat', 'label' => $langs->trans("targetThirdPartyVat"), 'value' => 0 ), ); - // Ask confirmatio to clone + // Ask confirmation to clone $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ec8e4a93b80..fb6a59ef3da 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1192,7 +1192,7 @@ class Facture extends CommonInvoice * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone(User $user, $fromid = 0) + public function createFromClone(User $user, $fromid = 0, $targetThirdPartyVat = false) { global $conf, $hookmanager; @@ -1277,6 +1277,14 @@ class Facture extends CommonInvoice $object->lines[$i]->ref_ext = ''; // Do not clone ref_ext } + // we have a different thirdparty selected and we checked $targetThirdPartyVat + if ($objFrom->socid != $object->socid && $targetThirdPartyVat) { + global $mysoc; + + foreach ($object->lines as $line) { + $line->tva_tx = get_default_tva($mysoc, $objsoc, $line->fk_product); + } + } // Create clone $object->context['createfromclone'] = 'createfromclone'; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index b9b4b111b43..4d32f48f862 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -609,4 +609,5 @@ NoPaymentAvailable=No payment available for %s PaymentRegisteredAndInvoiceSetToPaid=Payment registered and invoice %s set to paid SendEmailsRemindersOnInvoiceDueDate=Send reminder by email for unpaid invoices MakePaymentAndClassifyPayed=Record payment -BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status) \ No newline at end of file +BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status) +targetThirdPartyVat=Modify the VAT rate to use the default rate depending on the new thirdparty From d872b9c2c789def2f1e7d76a3cc652e4c272486e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 2 Aug 2022 21:05:33 +0200 Subject: [PATCH 3/9] Fix correct fix of paymentok.php this line was deleted by error --- htdocs/public/payment/paymentok.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index e04f00d7459..57e23350a2c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -368,6 +368,7 @@ if ($ispaymentok) { } if (empty($user->rights->adherent)) { $user->rights->adherent = new stdClass(); + $user->rights->adherent->cotisation = new stdClass(); } $user->rights->societe->creer = 1; $user->rights->facture->creer = 1; From c545756b6eb49ae53d6356169305453ab7624c01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Aug 2022 17:06:19 +0200 Subject: [PATCH 4/9] Revert "FIX : VAT rate recalculation" --- htdocs/compta/facture/card.php | 11 +++-------- htdocs/compta/facture/class/facture.class.php | 10 +--------- htdocs/langs/en_US/bills.lang | 3 +-- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 268463f1e7d..eb43da88a4b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -207,12 +207,8 @@ if (empty($reshook)) { $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - $objectutil->socid = $socid; - - $targetThirdPartyVat = GETPOSTISSET('targetThirdPartyVat'); - $result = $objectutil->createFromClone($user, $id, $targetThirdPartyVat); - + $result = $objectutil->createFromClone($user, $id); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); exit(); @@ -4178,10 +4174,9 @@ if ($action == 'create') { // Create an array for form $formquestion = array( array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)), - array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()), - array('type' => 'checkbox', 'name' => 'targetThirdPartyVat', 'label' => $langs->trans("targetThirdPartyVat"), 'value' => 0 ), + array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) ); - // Ask confirmation to clone + // Ask confirmatio to clone $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fb6a59ef3da..ec8e4a93b80 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1192,7 +1192,7 @@ class Facture extends CommonInvoice * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone(User $user, $fromid = 0, $targetThirdPartyVat = false) + public function createFromClone(User $user, $fromid = 0) { global $conf, $hookmanager; @@ -1277,14 +1277,6 @@ class Facture extends CommonInvoice $object->lines[$i]->ref_ext = ''; // Do not clone ref_ext } - // we have a different thirdparty selected and we checked $targetThirdPartyVat - if ($objFrom->socid != $object->socid && $targetThirdPartyVat) { - global $mysoc; - - foreach ($object->lines as $line) { - $line->tva_tx = get_default_tva($mysoc, $objsoc, $line->fk_product); - } - } // Create clone $object->context['createfromclone'] = 'createfromclone'; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 4d32f48f862..b9b4b111b43 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -609,5 +609,4 @@ NoPaymentAvailable=No payment available for %s PaymentRegisteredAndInvoiceSetToPaid=Payment registered and invoice %s set to paid SendEmailsRemindersOnInvoiceDueDate=Send reminder by email for unpaid invoices MakePaymentAndClassifyPayed=Record payment -BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status) -targetThirdPartyVat=Modify the VAT rate to use the default rate depending on the new thirdparty +BulkPaymentNotPossibleForInvoice=Bulk payment is not possible for invoice %s (bad type or status) \ No newline at end of file From 93b040250eaf112f716383ba47844ba6cf47781f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Aug 2022 18:25:32 +0200 Subject: [PATCH 5/9] Update knowledgerecord.class.php --- htdocs/knowledgemanagement/class/knowledgerecord.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index a1d41c97a9f..c78a88e07c7 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -470,7 +470,7 @@ class KnowledgeRecord extends CommonObject // Delete all child tables if (!$error) { - $elements = array('categorie_knowledgemanagement'); // product_batch is done before + $elements = array('categorie_knowledgemanagement'); foreach ($elements as $table) { if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; From bbe74c5d77a20e2e64494a48fb08c251796a7140 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 6 Aug 2022 13:44:56 +0200 Subject: [PATCH 6/9] FIX errors when search by code --- htdocs/admin/dict.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 621b2b783a7..22481296c68 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1169,14 +1169,16 @@ if ($id) { $sql .= natural_search("code_iso", $search_code); } elseif ($search_code != '' && $id == 28) { $sql .= natural_search("h.code", $search_code); - } elseif ($search_code != '' && $id == 32) { + } elseif ($search_code != '' && ($id == 7 || $id == 32)) { $sql .= natural_search("a.code", $search_code); } elseif ($search_code != '' && $id == 3) { $sql .= natural_search("r.code_region", $search_code); - } elseif ($search_code != '' && $id == 7) { - $sql .= natural_search("a.code", $search_code); - } elseif ($search_code != '' && $id == 10) { + } elseif ($search_code != '' && ($id == 8 || $id == 10)) { $sql .= natural_search("t.code", $search_code); + } elseif ($search_code != '' && $id == 1) { + $sql .= natural_search("f.code", $search_code); + } elseif ($search_code != '' && $id == 2) { + $sql .= natural_search("d.code_departement", $search_code); } elseif ($search_code != '' && $id != 9) { $sql .= natural_search("code", $search_code); } From 0f6effcdb05d54099a69d13bea265d73aaa5d1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Sun, 7 Aug 2022 14:43:26 +0200 Subject: [PATCH 7/9] Update import_xlsx.modules.php --- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 1c38f52cbfc..ae95b78ec8d 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -863,7 +863,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= "WHERE " . $keyfield . " = " .((int) $lastinsertid); + $sqlSelect .= " WHERE " . $keyfield . " = " .((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { From 96c17b485c2471bf5b9535ff731a013cc84572e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 8 Aug 2022 11:07:38 +0200 Subject: [PATCH 8/9] do not loose decription when changing country, reload cause description lost --- htdocs/product/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a1be8f35c29..b6180b2f77d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -16,7 +16,7 @@ * Copyright (C) 2016 Charlie Benke * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017 Josep Lluís Amador - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2022 Frédéric France * Copyright (C) 2019-2020 Thibault FOUCART * Copyright (C) 2020 Pierre Ardoin * @@ -1728,7 +1728,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("Description").''; // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. - $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); + $doleditor = new DolEditor('desc', GETPOSTISSET('desc') ? GETPOST('desc', 'restricthtml') : $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); print ""; From 5ef9d2d40d707b00a341cfd5eb7f2ad5b1b0d809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 8 Aug 2022 11:11:17 +0200 Subject: [PATCH 9/9] keep url --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b6180b2f77d..b8f4a8fa7f7 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1738,7 +1738,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) { print ''.$langs->trans("PublicUrl").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); - print ''; + print ''; print ''; }