From 8e57d04f94ac82825175296c668ea70623c48ec4 Mon Sep 17 00:00:00 2001 From: GregM Date: Mon, 11 Jul 2022 16:18:56 +0200 Subject: [PATCH 01/22] FIX dol_compress_dir names files on archives --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index f774982b240..21c290b595d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2193,7 +2193,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = if (!$file->isDir()) { // Get real and relative path for current file $filePath = $file->getRealPath(); - $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1); + $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen(realpath($inputdir)) + 1); if (empty($excludefiles) || !preg_match($excludefiles, $filePath)) { // Add current file to archive From 54b90abd87b50cd8cf1ed7d318f3fccf8376a844 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 26 Jul 2022 13:50:53 +0200 Subject: [PATCH 02/22] 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 af4d8ef53e75833b9c3f06551c53d9ad94c4be60 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 30 Jul 2022 15:32:18 +0200 Subject: [PATCH 03/22] FIX validation paymentok.php if advance rights --- htdocs/public/payment/paymentok.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c9b8f13c877..e04f00d7459 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -364,13 +364,14 @@ if ($ispaymentok) { } if (empty($user->rights->facture)) { $user->rights->facture = new stdClass(); + $user->rights->facture->invoice_advance = new stdClass(); } 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; + $user->rights->facture->invoice_advance->validate = 1; $user->rights->adherent->cotisation->creer = 1; if (array_key_exists('MEM', $tmptag) && $tmptag['MEM'] > 0) { From cec9725ced00a63289748d3062a4ad89428ac407 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 1 Aug 2022 16:28:44 +0200 Subject: [PATCH 04/22] 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 05/22] 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 06/22] 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 07/22] 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 9db6c779f0fc251853e4e6e5274136200c811baf Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Fri, 5 Aug 2022 04:16:23 +0200 Subject: [PATCH 08/22] Fix layout of Incomes-Expenses + Claims-Debts accounting tables --- htdocs/compta/resultat/clientfourn.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 30d4f4ce825..ab2a339cc40 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -249,7 +249,10 @@ if ($date_endyear) { } print ''; -print ''; +print ''; +if ($modecompta != 'CREANCES-DETTES') { + print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is +} if ($modecompta == 'BOOKKEEPING') { print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 '); } else { @@ -1525,18 +1528,24 @@ print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { print ''; +} else { + print(''); } print ''; print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { print ''; +} else { + print(''); } print ''; print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { print ''; +} else { + print(''); } print ''; print ''; From 3a83676202d7374c669fd83e8aaf11f843384dda Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 5 Aug 2022 02:22:32 +0000 Subject: [PATCH 09/22] Fixing style errors. --- htdocs/compta/resultat/clientfourn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index ab2a339cc40..7cac2e25e31 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -249,7 +249,7 @@ if ($date_endyear) { } print '
'.$langs->trans("Income").''.price(price2num($total_ht_income, 'MT')).''.price(price2num($total_ttc_income, 'MT')).'
'.$langs->trans("Outcome").''.price(price2num(-$total_ht_outcome, 'MT')).''.price(price2num(-$total_ttc_outcome, 'MT')).'
'.$langs->trans("Profit").''.price(price2num($total_ht, 'MT')).''.price(price2num($total_ttc, 'MT')).'
'; -print ''; +print ''; if ($modecompta != 'CREANCES-DETTES') { print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is } From bbe74c5d77a20e2e64494a48fb08c251796a7140 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 6 Aug 2022 13:44:56 +0200 Subject: [PATCH 10/22] 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 11/22] 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 12/22] 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 '"; 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 13/22] 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 ''; } From 4c649a227a8169b4aa2a64626ae2f27e5e51738e Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 10 Aug 2022 12:54:14 +0200 Subject: [PATCH 14/22] More developer-friendly print of titles --- htdocs/compta/resultat/clientfourn.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 7cac2e25e31..e30e01c5916 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -250,9 +250,7 @@ if ($date_endyear) { 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 "
'.$langs->trans("PublicUrl").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); - print ''; + print ''; print '
'; print ''; -if ($modecompta != 'CREANCES-DETTES') { - print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is -} + if ($modecompta == 'BOOKKEEPING') { print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 '); } else { @@ -265,6 +263,9 @@ if ($modecompta == 'BOOKKEEPING') { if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder); } + else { + print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is + } print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder); } print "\n"; From ead7bd91fe72146f24d2d16aaa92a4bee85e86ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Aug 2022 01:36:31 +0200 Subject: [PATCH 15/22] Update clientfourn.php --- htdocs/compta/resultat/clientfourn.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index e30e01c5916..0ad8b9f3e49 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -262,8 +262,7 @@ if ($modecompta == 'BOOKKEEPING') { } else { if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder); - } - else { + } else { print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is } print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder); From c089fe124c6de8f593c1e9940dc0757d98d7015f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Aug 2022 01:37:53 +0200 Subject: [PATCH 16/22] Update clientfourn.php --- htdocs/compta/resultat/clientfourn.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 0ad8b9f3e49..2be668fac5c 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -1529,7 +1529,7 @@ print ''; } else { - print(''); + print ''; } print ''; print ''; @@ -1537,7 +1537,7 @@ print ''; } else { - print(''); + print ''; } print ''; print ''; @@ -1545,7 +1545,7 @@ print ''; } else { - print(''); + print ''; } print ''; print ''; From 326686794a439d3c6268336014083f23712a5116 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Aug 2022 17:09:14 +0200 Subject: [PATCH 17/22] Fix when log handler has been removed --- htdocs/core/class/conf.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 2b19e0db134..97edefd01e1 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1013,7 +1013,9 @@ class Conf } if (empty($handler_file_found)) { - throw new Exception('Missing log handler file '.$handler.'.php'); + // If log handler has been removed of is badly setup, we must be able to continue code. + //throw new Exception('Missing log handler file '.$handler.'.php'); + continue; } require_once $handler_file_found; From a0d56b6db764736c1e6b1bc0cc2b799f1ffc7654 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Aug 2022 19:14:20 +0200 Subject: [PATCH 18/22] FIX the online signature feature --- htdocs/core/lib/signature.lib.php | 2 +- htdocs/public/onlinesign/newonlinesign.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 6a8d824872d..33b0a1e8e5e 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -91,7 +91,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1) if ($mode == 1) { $out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)"; } else { - $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.$object->entity, '0'); + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref, '0'); } /* if ($mode == 1) { diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 9ebea80aeb3..87aef8163e1 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -139,7 +139,7 @@ if ($source == 'proposal') { $securekeyseed = $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN; } -if (!dol_verifyHash($securekeyseed.$type.$ref.$object->entity, $SECUREKEY, '0')) { +if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) { http_response_code(403); print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref); exit(-1); From 61739cc3383b6e7d52b377c92c30f8edffa30d97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Aug 2022 20:03:13 +0200 Subject: [PATCH 19/22] FIX online signature, better error management. --- htdocs/core/ajax/onlineSign.php | 48 ++++++++++++++-------- htdocs/core/class/commonobject.class.php | 3 +- htdocs/public/onlinesign/newonlinesign.php | 7 ++++ 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 994ba5c42f3..a67f89cc6ef 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -122,28 +122,44 @@ if ($action == "importSignature") { } if (!$error) { - $newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf"; + // Defined modele of doc + $directdownloadlink = $object->getLastMainDocLink('proposal'); - $pdf = pdf_getInstance(); - $pdf->Open(); - $pdf->AddPage(); - $pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF + if (preg_match('/\.pdf/i', $directdownloadlink)) { + $newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf"; + $sourcefile = $upload_dir.$ref.".pdf"; - for ($i=1;$i<($pagecount+1);$i++) { - if ($i>1) $pdf->AddPage(); - $tppl=$pdf->importPage($i); - $pdf->useTemplate($tppl); + if (dol_is_file($sourcefile)) { + $pdf = pdf_getInstance(); + $pdf->Open(); + $pdf->AddPage(); + $pagecount = $pdf->setSourceFile($sourcefile); // original PDF + + for ($i=1; $i<($pagecount+1); $i++) { + if ($i>1) $pdf->AddPage(); + $tppl=$pdf->importPage($i); + $pdf->useTemplate($tppl); + } + + $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset. + $pdf->Close(); + $pdf->Output($newpdffilename, "F"); + + // Index the new file and update the last_main_doc property of object. + $object->indexFile($newpdffilename, 1); + } + } elseif (preg_match('/\.odt/i', $directdownloadlink)) { + // Adding signature on .ODT not yet supported + // TODO + } else { + // Document format not supported to insert online signature. + // We should just create an image file with the signature. } + } - $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset. - $pdf->Close(); - $pdf->Output($newpdffilename, "F"); - + if (!$error) { $db->begin(); - // Index the new file and update the last_main_doc property of object. - $object->indexFile($newpdffilename, 1); - $online_sign_ip = getUserRemoteIP(); $online_sign_name = ''; // TODO Ask name on form to sign diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bd8ab4c22f4..513717b56de 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -941,7 +941,8 @@ abstract class CommonObject // Add entry into index if ($initsharekey) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - // TODO We can't, we dont' have full path of file, only last_main_doc adn ->element, so we must rebuild full path first + + // TODO We can't, we dont' have full path of file, only last_main_doc and ->element, so we must first rebuild full path $destfull /* $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 87aef8163e1..b09006787c4 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -321,6 +321,13 @@ if ($source == 'proposal') { print ''."\n"; - - // TODO Add link to download PDF (similar code than for invoice) } From 3d73f210fb8c1e691b68e74afbb8877c1930b7b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Aug 2022 21:31:53 +0200 Subject: [PATCH 21/22] Debug feature for signature --- htdocs/core/ajax/onlineSign.php | 45 +++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 3fb8671cd39..56cc79662ae 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -70,7 +70,7 @@ $type = $mode; // Check securitykey $securekeyseed = ''; if ($type == 'proposal') { - $securekeyseed = $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN; + $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN'); } if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) { @@ -133,19 +133,44 @@ if ($action == "importSignature") { $sourcefile = $upload_dir.$ref.".pdf"; if (dol_is_file($sourcefile)) { + // We build the new PDF $pdf = pdf_getInstance(); - $pdf->Open(); - $pdf->AddPage(); - $pagecount = $pdf->setSourceFile($sourcefile); // original PDF + if (class_exists('TCPDF')) { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($langs)); - for ($i=1; $i<($pagecount+1); $i++) { - if ($i>1) $pdf->AddPage(); - $tppl=$pdf->importPage($i); - $pdf->useTemplate($tppl); + if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { + $pdf->SetCompression(false); } - $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset. - $pdf->Close(); + + //$pdf->Open(); + $pagecount = $pdf->setSourceFile($sourcefile); // original PDF + + $s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297); + for ($i=1; $i<($pagecount+1); $i++) { + try { + $tppl = $pdf->importPage($i); + $s = $pdf->getTemplatesize($tppl); + $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); + $pdf->useTemplate($tppl); + } catch (Exception $e) { + dol_syslog("Error when manipulating some PDF by onlineSign: ".$e->getMessage(), LOG_ERR); + $response = $e->getMessage(); + $error++; + } + } + + // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF + // TODO Get position of box from PDF template + $xforimgstart = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15); + $yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 60); + $wforimg = $s['w'] - 20 - $xforimgstart; + + $pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4)); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset. + //$pdf->Close(); $pdf->Output($newpdffilename, "F"); // Index the new file and update the last_main_doc property of object. From 545db83ecd4db0a28865bc7256a50116d23f211f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 16 Aug 2022 20:17:44 +0200 Subject: [PATCH 22/22] remove duplicate --- htdocs/admin/oauthlogintokens.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 8697b400a2b..574d4d96353 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -190,7 +190,6 @@ if ($mode == 'setup' && $user->admin) { $tokenobj = null; // Token require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; // Dolibarr storage $storage = new DoliStorage($db, $conf); try {
'.$langs->trans("Inc if ($modecompta == 'CREANCES-DETTES') { print ''.price(price2num($total_ht_income, 'MT')).''.price(price2num($total_ttc_income, 'MT')).'
'.$langs->trans("Out if ($modecompta == 'CREANCES-DETTES') { print ''.price(price2num(-$total_ht_outcome, 'MT')).''.price(price2num(-$total_ttc_outcome, 'MT')).'
'.$langs->trans("Pro if ($modecompta == 'CREANCES-DETTES') { print ''.price(price2num($total_ht, 'MT')).''.price(price2num($total_ttc, 'MT')).'
'.$langs->trans("Designation"); print ''.$text; if ($object->status == $object::STATUS_VALIDATED) { + if (empty($object->last_main_doc) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) { + // It seems document has never been generated, or was generated and the deleted. + // So we try to regenerate it with its default template. + $defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used. + $object->generateDocument($defaulttemplate, $langs); + } + $directdownloadlink = $object->getLastMainDocLink('proposal'); if ($directdownloadlink) { print '
'; From 57fea5151d3d25c21111da838ca9a9ef0d437083 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Aug 2022 20:45:04 +0200 Subject: [PATCH 20/22] Fix regression in online signature Conflicts: htdocs/core/ajax/onlineSign.php htdocs/public/onlinesign/newonlinesign.php --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/core/ajax/onlineSign.php | 9 ++++++--- htdocs/public/onlinesign/newonlinesign.php | 19 +++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5b91caa2673..1002a14aef3 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3721,7 +3721,7 @@ class Propal extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index a67f89cc6ef..3fb8671cd39 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -53,6 +53,7 @@ if (is_numeric($entity)) { define("DOLENTITY", $entity); } include '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $action = GETPOST('action', 'aZ09'); @@ -123,9 +124,11 @@ if ($action == "importSignature") { if (!$error) { // Defined modele of doc - $directdownloadlink = $object->getLastMainDocLink('proposal'); + $last_main_doc_file = $object->last_main_doc; + $directdownloadlink = $object->getLastMainDocLink('proposal'); // url to download the $object->last_main_doc - if (preg_match('/\.pdf/i', $directdownloadlink)) { + if (preg_match('/\.pdf/i', $last_main_doc_file)) { + // TODO Use the $last_main_doc_file to defined the $newpdffilename and $sourcefile $newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf"; $sourcefile = $upload_dir.$ref.".pdf"; @@ -148,7 +151,7 @@ if ($action == "importSignature") { // Index the new file and update the last_main_doc property of object. $object->indexFile($newpdffilename, 1); } - } elseif (preg_match('/\.odt/i', $directdownloadlink)) { + } elseif (preg_match('/\.odt/i', $last_main_doc_file)) { // Adding signature on .ODT not yet supported // TODO } else { diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index b09006787c4..5dca1604f58 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -39,7 +39,7 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +// Because 2 entities can have the same ref. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); @@ -51,7 +51,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; // Load translation files $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "members", "paybox", "propal")); @@ -125,6 +124,7 @@ $creditor = $mysoc->name; $type = $source; if ($source == 'proposal') { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object = new Propal($db); $object->fetch(0, $ref, '', $entity); } else { @@ -318,11 +318,14 @@ if ($source == 'proposal') { // Object $text = ''.$langs->trans("SignatureProposalRef", $object->ref).''; - print '
'.$langs->trans("Designation"); + print '
'.$langs->trans("Designation"); print ''.$text; + + $last_main_doc_file = $object->last_main_doc; + if ($object->status == $object::STATUS_VALIDATED) { - if (empty($object->last_main_doc) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) { - // It seems document has never been generated, or was generated and the deleted. + if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) { + // It seems document has never been generated, or was generated and then deleted. // So we try to regenerate it with its default template. $defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used. $object->generateDocument($defaulttemplate, $langs); @@ -335,13 +338,11 @@ if ($source == 'proposal') { print $langs->trans("DownloadDocument").''; } } else { - $last_main_doc_file = $object->last_main_doc; - if ($object->status == $object::STATUS_NOTSIGNED) { $directdownloadlink = $object->getLastMainDocLink('proposal'); if ($directdownloadlink) { print '
'; - print img_mime($object->last_main_doc, ''); + print img_mime($last_main_doc_file, ''); print $langs->trans("DownloadDocument").''; } } elseif ($object->status == $object::STATUS_SIGNED || $object->status == $object::STATUS_BILLED) { @@ -366,8 +367,6 @@ if ($source == 'proposal') { print ''; print ''; print '