From ff178667a3ee966b865c6693e961866bdd043893 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Tue, 11 May 2021 12:33:35 +0200 Subject: [PATCH 001/114] add thirdparty customer code to substitutionarray --- htdocs/comm/mailing/card.php | 7 +++++++ htdocs/core/class/html.formmail.class.php | 2 ++ htdocs/langs/fr_FR/mails.lang | 2 ++ 3 files changed, 11 insertions(+) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 5148956163e..4bf304bc519 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -201,6 +201,13 @@ if (empty($reshook)) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; + if ($obj->source_type == "thirdparty") { + $thirdpartystatic = new Societe($db); + $thirdpartystatic->fetch($obj->source_id); + + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); + } $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; $substitutionarray['__FIRSTNAME__'] = $obj->firstname; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c4723eacc57..5947ad8d810 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1502,6 +1502,8 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 3788acb53c4..9adfc684b8d 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -116,6 +116,8 @@ ToAddRecipientsChooseHere=Pour ajouter des destinataires, choisir dans les liste NbOfEMailingsReceived=Emailings de masse reçus NbOfEMailingsSend=Emailings de masse envoyés IdRecord=ID enregistrement +CustomerCode = Code client +CustomerCodeWithoutPrefix = Code client sans préfix DeliveryReceipt=Accusé de réception YouCanUseCommaSeparatorForSeveralRecipients=Vous pouvez utiliser le caractère de séparation virgule pour spécifier plusieurs destinataires. TagCheckMail=Suivre l'ouverture de l'email From 4ce81ee53591f9b98088c2bada735c1c1c113204 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Tue, 11 May 2021 20:30:57 +0200 Subject: [PATCH 002/114] set new outside the loop, add fetch result check --- htdocs/comm/mailing/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 4bf304bc519..2aae9ef1d73 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -171,6 +171,7 @@ if (empty($reshook)) dol_print_error($db); } + $thirdpartystatic = new Societe($db); // Loop on each email and send it $i = 0; @@ -202,11 +203,12 @@ if (empty($reshook)) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; if ($obj->source_type == "thirdparty") { - $thirdpartystatic = new Societe($db); - $thirdpartystatic->fetch($obj->source_id); + $result = $thirdpartystatic->fetch($obj->source_id); - $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; - $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); + if ($result > 0) { + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); + } } $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; From 09a694628106d1be9caae44a3f270571b0ed0588 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:34:58 +0200 Subject: [PATCH 003/114] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 5947ad8d810..a784521fcf9 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1503,7 +1503,7 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; - $tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; + //$tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; // Not yet working $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; From 40106ff7670afb1de4d887ee2f8cea08433278bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:35:29 +0200 Subject: [PATCH 004/114] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a784521fcf9..99b25d27fc4 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1503,7 +1503,6 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; - //$tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; // Not yet working $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; From a4f4cca895b7fcb3a4f1fd6c56f3f355d676fd45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:36:49 +0200 Subject: [PATCH 005/114] Prefix length may have different length and be at a different place so i remove this tag. Must be replaced by a generic method to substring a substitution variable. --- htdocs/comm/mailing/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 2aae9ef1d73..f2b93ddbb80 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -207,7 +207,6 @@ if (empty($reshook)) if ($result > 0) { $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; - $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); } } $substitutionarray['__EMAIL__'] = $obj->email; From aa9642b86fd58299131565fe58a276f9280e0146 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:38:38 +0200 Subject: [PATCH 006/114] Update mails.lang --- htdocs/langs/fr_FR/mails.lang | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 9adfc684b8d..3788acb53c4 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -116,8 +116,6 @@ ToAddRecipientsChooseHere=Pour ajouter des destinataires, choisir dans les liste NbOfEMailingsReceived=Emailings de masse reçus NbOfEMailingsSend=Emailings de masse envoyés IdRecord=ID enregistrement -CustomerCode = Code client -CustomerCodeWithoutPrefix = Code client sans préfix DeliveryReceipt=Accusé de réception YouCanUseCommaSeparatorForSeveralRecipients=Vous pouvez utiliser le caractère de séparation virgule pour spécifier plusieurs destinataires. TagCheckMail=Suivre l'ouverture de l'email From 23249751d57ab712642544027d72908cd6d61080 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 17 Nov 2021 12:10:12 +0100 Subject: [PATCH 007/114] FIX : reorder all lines when delete document line everywhere --- htdocs/commande/card.php | 2 ++ htdocs/compta/facture/card.php | 2 ++ htdocs/fourn/commande/card.php | 2 ++ htdocs/fourn/facture/card.php | 2 ++ 4 files changed, 8 insertions(+) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b9900459006..21b8897a3e3 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -216,6 +216,8 @@ if (empty($reshook)) $result = $object->deleteline($user, $lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 86d3abedd2b..5a500eafe12 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -243,6 +243,8 @@ if (empty($reshook)) $result = $object->deleteline(GETPOST('lineid')); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f79f37d16e5..c85d1f56c29 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -805,6 +805,8 @@ if (empty($reshook)) $result = $object->deleteline($lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 985c9a4cc62..d912f6917f7 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -253,6 +253,8 @@ if (empty($reshook)) $result = $object->deleteline($lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language /*$outputlangs = $langs; $newlang = ''; From 8f91086e83a93e6f8fc217efb0c337a6fb25ea43 Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Mon, 6 Dec 2021 15:33:51 +0200 Subject: [PATCH 008/114] Add some missing characters --- htdocs/core/lib/functions.lib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 94148722862..3dda3373cc4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1174,18 +1174,23 @@ function dol_string_unaccent($str) $string = rawurlencode($str); $replacements = array( '%C3%80' => 'A', '%C3%81' => 'A', '%C3%82' => 'A', '%C3%83' => 'A', '%C3%84' => 'A', '%C3%85' => 'A', + '%C3%87' => 'C', '%C3%88' => 'E', '%C3%89' => 'E', '%C3%8A' => 'E', '%C3%8B' => 'E', '%C3%8C' => 'I', '%C3%8D' => 'I', '%C3%8E' => 'I', '%C3%8F' => 'I', + '%C3%91' => 'N', '%C3%92' => 'O', '%C3%93' => 'O', '%C3%94' => 'O', '%C3%95' => 'O', '%C3%96' => 'O', + '%C5%A0' => 'S', '%C3%99' => 'U', '%C3%9A' => 'U', '%C3%9B' => 'U', '%C3%9C' => 'U', + '%C3%9D' => 'Y', '%C5%B8' => 'y', '%C3%A0' => 'a', '%C3%A1' => 'a', '%C3%A2' => 'a', '%C3%A3' => 'a', '%C3%A4' => 'a', '%C3%A5' => 'a', '%C3%A7' => 'c', '%C3%A8' => 'e', '%C3%A9' => 'e', '%C3%AA' => 'e', '%C3%AB' => 'e', '%C3%AC' => 'i', '%C3%AD' => 'i', '%C3%AE' => 'i', '%C3%AF' => 'i', '%C3%B1' => 'n', '%C3%B2' => 'o', '%C3%B3' => 'o', '%C3%B4' => 'o', '%C3%B5' => 'o', '%C3%B6' => 'o', + '%C5%A1' => 's', '%C3%B9' => 'u', '%C3%BA' => 'u', '%C3%BB' => 'u', '%C3%BC' => 'u', - '%C3%BF' => 'y' + '%C3%BD' => 'y', '%C3%BF' => 'y' ); $string = strtr($string, $replacements); return rawurldecode($string); From 04d4c06a43dd261866e409361743935f53286cdd Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Mon, 6 Dec 2021 15:34:20 +0200 Subject: [PATCH 009/114] Use intl extension when available --- htdocs/core/lib/functions.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3dda3373cc4..dd05038f968 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1170,6 +1170,10 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) function dol_string_unaccent($str) { if (utf8_check($str)) { + if (extension_loaded('intl')) { + $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); + return $transliterator->transliterate($str); + } // See http://www.utf8-chartable.de/ $string = rawurlencode($str); $replacements = array( From 8ff0d1f366c15c56b6aab6fb74b7108ebc0cf35e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:49:52 +0100 Subject: [PATCH 010/114] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dd05038f968..4d9c5f49440 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1169,8 +1169,10 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) */ function dol_string_unaccent($str) { + global $conf; + if (utf8_check($str)) { - if (extension_loaded('intl')) { + if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); return $transliterator->transliterate($str); } From 646ba34f89a320c9d613a601bf9724dc3ec48984 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 19:15:35 +0100 Subject: [PATCH 011/114] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4d9c5f49440..9202cc89466 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1170,7 +1170,7 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) function dol_string_unaccent($str) { global $conf; - + if (utf8_check($str)) { if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); From fca26827ecd7fa1a9c576a8a9275658f90621f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Wed, 15 Dec 2021 10:47:30 +0100 Subject: [PATCH 012/114] Add constant TAKEPOS_CHANGE_PRICE_HT --- htdocs/takepos/invoice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2a951a505ae..61f955636f5 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -680,6 +680,8 @@ if ($action == "updateprice") { } else { if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } elseif ($conf->global->TAKEPOS_CHANGE_PRICE_HT == 1) { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } From 0a72aed3d7b1af170901a08fda85e10d648d43f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Dec 2021 13:35:38 +0100 Subject: [PATCH 013/114] Fix missing space before union --- htdocs/expensereport/class/expensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b9e60ed50d5..14d3c8fc178 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2123,7 +2123,7 @@ class ExpenseReport extends CommonObject $sql = "SELECT DISTINCT ur.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; - $sql.= "UNION"; + $sql.= " UNION"; $sql.= " SELECT DISTINCT ugu.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; From 81bee064afba78ba9c53d7b6260d9a04799efbd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 28 Dec 2021 11:28:58 +0100 Subject: [PATCH 014/114] add getDolGlobalInt --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 61f955636f5..5e41a3538e3 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -680,7 +680,7 @@ if ($action == "updateprice") { } else { if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } elseif ($conf->global->TAKEPOS_CHANGE_PRICE_HT == 1) { + } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); From ff2388ceaf197e7eba0eb8f195d3df96eff1c6e8 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 3 Jan 2022 13:08:20 +0100 Subject: [PATCH 015/114] Fix: correctly display the products of a warehouse in the pdf --- .../stock/doc/pdf_standard.modules.php | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 55923d68a79..0b0fbf623c0 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -289,7 +290,7 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 80 + $top_shift; + $tab_top = 65 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); $tab_height = 130; @@ -323,7 +324,7 @@ class pdf_standard extends ModelePDFStock $i = 0; $nblines = $num; - $this->tabTitleHeight = 0; + $this->tabTitleHeight = 10; $nexY = $tab_top + $this->tabTitleHeight; for ($i = 0; $i < $nblines; $i++) @@ -362,7 +363,8 @@ class pdf_standard extends ModelePDFStock $showpricebeforepagebreak = 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 3, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -370,7 +372,8 @@ class pdf_standard extends ModelePDFStock $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 4, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text @@ -418,8 +421,8 @@ class pdf_standard extends ModelePDFStock $productstatic->status_batch = $objp->tobatch; // Ref. - $pdf->SetXY($this->posxdesc, $curY); - $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); + //$pdf->SetXY($this->posxdesc, $curY); + //$pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); // Label $pdf->SetXY($this->posxlabel + 0.8, $curY); @@ -506,7 +509,7 @@ class pdf_standard extends ModelePDFStock /** * Footer table */ - $nexY = $pdf->GetY(); + //$nexY = $pdf->GetY(); $nexY += 2; $curY = $nexY; @@ -572,11 +575,11 @@ class pdf_standard extends ModelePDFStock $height_note = 0; } - $iniY = $tab_top + 7; + /*$iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $tab_top = $tab_top_newpage + 25 + $top_shift; + $tab_top = $tab_top_newpage + 25 + $top_shift;*/ // Show square if ($pagenb == 1) @@ -732,10 +735,12 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R'); } - $pdf->SetDrawColor(200, 200, 200); - $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200))); - $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11); - $pdf->SetLineStyle(array('dash'=>0)); + if (empty($hidetop)) { + $pdf->SetDrawColor(200, 200, 200); + $pdf->SetLineStyle(array('dash' => '0', 'color' => array(200, 200, 200))); + $pdf->line($this->marge_gauche, $tab_top + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10); + $pdf->SetLineStyle(array('dash' => 0)); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From 1f6e9a1a9e0d8889166c61a6ffe897a166cbc638 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 Jan 2022 18:46:29 +0100 Subject: [PATCH 016/114] Fix install - Belgium provinces incorrect mapping --- htdocs/install/mysql/data/llx_20_c_departements.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 7e9417b487b..4aece5f21a3 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -158,10 +158,10 @@ insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,no insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (201,'05','',1,'FLANDRE-OCCIDENTALE','Flandre-Occidentale'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (201,'06','',1,'FLANDRE-ORIENTALE','Flandre-Orientale'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (202,'07','',2,'HAINAUT','Hainaut'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (201,'08','',2,'LIEGE','Liège'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (202,'08','',2,'LIEGE','Liège'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (202,'09','',1,'LIMBOURG','Limbourg'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (202,'10','',2,'LUXEMBOURG','Luxembourg'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (201,'11','',2,'NAMUR','Namur'); +insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (202,'11','',2,'NAMUR','Namur'); -- Provinces Italy (id=3) insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom) values ('AG',315,NULL,NULL,NULL,'AGRIGENTO'); From 97d9b4571a90e9b5bcf83c64dfc1e0ba6ae9c0d3 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 6 Jan 2022 11:21:46 +0100 Subject: [PATCH 017/114] FIX : late warning calculation on action comm list --- htdocs/comm/action/list.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2db2d988add..6891b696be4 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -657,6 +657,8 @@ if ($resql) $actionstatic->label = $obj->label; $actionstatic->location = $obj->location; $actionstatic->note_private = dol_htmlentitiesbr($obj->note); + $actionstatic->datep = $db->jdate($obj->dp); + $actionstatic->percentage = $obj->percent; $actionstatic->fetchResources(); @@ -738,10 +740,7 @@ if ($resql) print ''; print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); $late = 0; - if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; - if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; - if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1; - if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if($actioncomm->hasDelay() && $actioncomm->percentage >= 0 && $actioncomm->percentage < 100 ) $late = 1; if ($late) print img_warning($langs->trans("Late")).' '; print ''; } From ec11be2480c99ee556c02568abbfe3661c86381f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 6 Jan 2022 10:31:50 +0000 Subject: [PATCH 018/114] Fixing style errors. --- htdocs/comm/action/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 6891b696be4..91c77895540 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -740,7 +740,7 @@ if ($resql) print ''; print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); $late = 0; - if($actioncomm->hasDelay() && $actioncomm->percentage >= 0 && $actioncomm->percentage < 100 ) $late = 1; + if ($actioncomm->hasDelay() && $actioncomm->percentage >= 0 && $actioncomm->percentage < 100 ) $late = 1; if ($late) print img_warning($langs->trans("Late")).' '; print ''; } From f157a22cd0ca39d1e825c56d6aa9d07a787cc117 Mon Sep 17 00:00:00 2001 From: oscim Date: Thu, 6 Jan 2022 16:55:24 +0100 Subject: [PATCH 019/114] Update paiementfourn.class.php For stock in fetch object payment id type --- htdocs/fourn/class/paiementfourn.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index fa58139b7e7..de9aa4eade9 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -93,7 +93,7 @@ class PaiementFourn extends Paiement $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank, p.multicurrency_amount,'; $sql .= ' c.code as payment_code, c.libelle as payment_type,'; - $sql .= ' p.num_paiement as num_payment, p.note, b.fk_account'; + $sql .= ' p.num_paiement as num_payment, p.note, b.fk_account, p.fk_paiement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; @@ -130,6 +130,7 @@ class PaiementFourn extends Paiement $this->note_private = $obj->note; $this->type_code = $obj->payment_code; $this->type_label = $obj->payment_type; + $this->fk_paiement = $obj->fk_paiement; $this->statut = $obj->statut; $error = 1; From a0fb0b8741a408c4249fe26629a8fdf6738ce892 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 6 Jan 2022 21:48:12 +0100 Subject: [PATCH 020/114] NEW: add ref product into BOM tooltips --- htdocs/bom/class/bom.class.php | 10 ++++++++++ htdocs/product/stats/bom.php | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index fd8d4a19a75..ecec1a56709 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -789,6 +789,16 @@ class BOM extends CommonObject if (isset($this->label)) { $label .= '
'.$langs->trans('Label').': '.$this->label; } + if (!empty($this->fk_product)) { + $product = new Product($db); + $resultFetch = $product->fetch($this->fk_product); + if ($resultFetch < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } else { + $label .= "
".$langs->trans("Product").': '.$product->getNomUrl(0,'',0,-1,1); + } + } + $url = DOL_URL_ROOT.'/bom/bom_card.php?id='.$this->id; diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index ef4923e89be..5e4829083f3 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) { //Qauntity to produce - $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid,"; + $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid, b.fk_product,"; $sql .= " b.qty as qty_toproduce"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b"; $sql .= " WHERE "; @@ -166,6 +166,7 @@ if ($id > 0 || !empty($ref)) { $objp = $db->fetch_object($result); $bomtmp->id = $objp->rowid; $bomtmp->ref = $objp->ref; + $bomtmp->fk_product = $objp->fk_product; $bom_data_result[$objp->rowid]['link'] = $bomtmp->getNomUrl(1, 'production'); $bom_data_result[$objp->rowid]['qty_toproduce'] += ($objp->qty_toproduce > 0 ? $objp->qty_toproduce : 0); $bom_data_result[$objp->rowid]['qty_toconsume'] = 0; @@ -180,7 +181,7 @@ if ($id > 0 || !empty($ref)) { $db->free($result); //Qauntity to consume - $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid,"; + $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid, b.fk_product,"; $sql .= " SUM(bl.qty) as qty_toconsume"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid"; @@ -214,6 +215,7 @@ if ($id > 0 || !empty($ref)) { $objp = $db->fetch_object($result); $bomtmp->id = $objp->rowid; $bomtmp->ref = $objp->ref; + $bomtmp->fk_product = $objp->fk_product; if (!array_key_exists($objp->rowid, $bom_data_result)) { $bom_data_result[$objp->rowid]['link'] = $bomtmp->getNomUrl(1, 'production'); From f71092e05cd3373c8deae6b7b62af712e04912ab Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 6 Jan 2022 20:56:51 +0000 Subject: [PATCH 021/114] Fixing style errors. --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ecec1a56709..6b53e3e3405 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -795,7 +795,7 @@ class BOM extends CommonObject if ($resultFetch < 0) { setEventMessages($product->error, $product->errors, 'errors'); } else { - $label .= "
".$langs->trans("Product").': '.$product->getNomUrl(0,'',0,-1,1); + $label .= "
".$langs->trans("Product").': '.$product->getNomUrl(0, '', 0, -1, 1); } } From 59b1feaf2eae9424d52510bfcd88c094866757f4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 08:27:49 +0100 Subject: [PATCH 022/114] fix include --- htdocs/bom/class/bom.class.php | 1 + htdocs/mrp/index.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ecec1a56709..2dcaa0c0c6b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -790,6 +790,7 @@ class BOM extends CommonObject $label .= '
'.$langs->trans('Label').': '.$this->label; } if (!empty($this->fk_product)) { + dol_include_once('/product/class/product.class.php'); $product = new Product($db); $resultFetch = $product->fetch($this->fk_product); if ($resultFetch < 0) { diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index c4480f76ed0..d9ee0e39cc6 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -155,7 +155,7 @@ print '
'; $max = 5; -$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a"; $sql .= " WHERE a.entity IN (".getEntity('bom').")"; $sql .= $db->order("a.tms", "DESC"); @@ -176,6 +176,7 @@ if ($resql) { $staticbom->id = $obj->rowid; $staticbom->ref = $obj->ref; + $staticbom->fk_product = $obj->fk_product; $staticbom->date_modification = $obj->datem; $staticbom->status = $obj->status; From 6cecc3c2aa805d89c3b05eeaf557e019e63942f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 10:25:58 +0100 Subject: [PATCH 023/114] Fix clean data after update --- htdocs/fourn/facture/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 4c634e1c1db..e969ae01412 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1325,6 +1325,8 @@ if (empty($reshook)) { unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); + unset($_POST['price_ttc']); + unset($_POST['price_ht']); $db->commit(); } else { From 61fc81732c02bffd5cd18063dcbf667acb9a7e14 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 11:29:43 +0100 Subject: [PATCH 024/114] fix: #19749 --- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/class/task.class.php | 10 ++++++++++ htdocs/projet/tasks/task.php | 1 + 3 files changed, 12 insertions(+) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index c19f32a0396..9d3a83c7a61 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -284,3 +284,4 @@ PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with al SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them ProjectTasksWithoutTimeSpent=Project tasks without time spent FormForNewLeadDesc=Thanks to fill the following form to contact us. You can also send us an email directly to %s. +StartDateCannotBeAfterEndDate=End date cannot be before start date diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index dac2afa4834..d0b27caf326 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -165,6 +165,11 @@ class Task extends CommonObject $this->label = trim($this->label); $this->description = trim($this->description); + if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { + $this->errors[] = $langs->trans('StartDateCannotBeAfterEndDate'); + return -1; + } + // Check parameters // Put here code to add control on parameters values @@ -384,6 +389,11 @@ class Task extends CommonObject $this->budget_amount = trim($this->budget_amount); } + if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { + $this->errors[] = $langs->trans('StartDateCannotBeAfterEndDate'); + return -1; + } + // Check parameters // Put here code to add control on parameters values diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8feb682f023..8e773f92788 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -117,6 +117,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; } } } else { From 6aeae8fe7fea6384a973e43d1799ec3fb79f4f8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 12:22:48 +0100 Subject: [PATCH 025/114] Debug v15 --- htdocs/core/lib/payments.lib.php | 4 ++- htdocs/public/onlinesign/newonlinesign.php | 38 +++++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 05993368802..2911564adef 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -461,9 +461,11 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } + print ''."\n"; + print '
'; - print '
'."\n"; + print '
'."\n"; if ($addformmessage) { print ''; print '
'; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index cb2458de4ff..3aaa3676663 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -62,6 +62,8 @@ $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", // Get parameters $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + $refusepropal = GETPOST('refusepropal', 'alpha'); $message = GETPOST('message', 'aZ09'); @@ -148,7 +150,7 @@ if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) { * Actions */ -if ($action == 'confirm_refusepropal') { +if ($action == 'confirm_refusepropal' && $confirm == 'yes') { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; @@ -213,6 +215,7 @@ print ''."\n print ''."\n"; print ''."\n"; print ''; +print ''; print "\n"; print ''."\n"; @@ -336,18 +339,28 @@ if ($source == 'proposal') { } } else { $last_main_doc_file = $proposal->last_main_doc; - if (preg_match('/_signed-(\d+)/', $last_main_doc_file)) { // If the last main doc has been signed - $last_main_doc_file_not_signed = preg_replace('/_signed-(\d+)/', '', $last_main_doc_file); - $datefilesigned = dol_filemtime($last_main_doc_file); - $datefilenotsigned = dol_filemtime($last_main_doc_file_not_signed); + if ($proposal->status == $proposal::STATUS_NOTSIGNED) { + $directdownloadlink = $proposal->getLastMainDocLink('proposal'); + if ($directdownloadlink) { + print '
'; + print img_mime($proposal->last_main_doc, ''); + print $langs->trans("DownloadDocument").''; + } + } elseif ($proposal->status == $proposal::STATUS_SIGNED || $proposal->status == $proposal::STATUS_BILLED) { + if (preg_match('/_signed-(\d+)/', $last_main_doc_file)) { // If the last main doc has been signed + $last_main_doc_file_not_signed = preg_replace('/_signed-(\d+)/', '', $last_main_doc_file); - if (empty($datefilenotsigned) || $datefilesigned > $datefilenotsigned) { - $directdownloadlink = $proposal->getLastMainDocLink('proposal'); - if ($directdownloadlink) { - print '
'; - print img_mime($proposal->last_main_doc, ''); - print $langs->trans("DownloadDocument").''; + $datefilesigned = dol_filemtime($last_main_doc_file); + $datefilenotsigned = dol_filemtime($last_main_doc_file_not_signed); + + if (empty($datefilenotsigned) || $datefilesigned > $datefilenotsigned) { + $directdownloadlink = $proposal->getLastMainDocLink('proposal'); + if ($directdownloadlink) { + print '
'; + print img_mime($proposal->last_main_doc, ''); + print $langs->trans("DownloadDocument").''; + } } } } @@ -392,6 +405,7 @@ if ($action == "dosign" && empty($cancel)) { print ''; print '
'; print '
'; + // Do not use class="reposition" here: It breaks the submit and there is a message on top to say it's ok, so going back top is better. print ''; print ''; @@ -459,7 +473,7 @@ if ($action == "dosign" && empty($cancel)) { } } else { print ''; - print ''; + print ''; } } } From 500b0e0218e7cb39a84c0f582e1f9b052bbf4b65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 12:43:41 +0100 Subject: [PATCH 026/114] FIX Sepa payment with company name with accent --- .../prelevement/class/bonprelevement.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index c786c007988..e16e651bf18 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1483,7 +1483,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1599,7 +1599,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1849,7 +1849,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); @@ -1900,7 +1900,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); @@ -2072,7 +2072,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); @@ -2096,7 +2096,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; @@ -2138,7 +2138,7 @@ class BonPrelevement extends CommonObject */ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); @@ -2162,7 +2162,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; From 51a36040f171db0bb512048a9432799130e990bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 13:03:03 +0100 Subject: [PATCH 027/114] Fix special char in sepa file on address --- .../class/bonprelevement.class.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index e16e651bf18..93279218218 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1855,10 +1855,10 @@ class BonPrelevement extends CommonObject $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1906,10 +1906,10 @@ class BonPrelevement extends CommonObject $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; @@ -2078,10 +2078,10 @@ class BonPrelevement extends CommonObject $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2099,8 +2099,8 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS.'').$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV @@ -2144,10 +2144,10 @@ class BonPrelevement extends CommonObject $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2165,8 +2165,8 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV From bdac615cba28efdfdf32da05957e1bbbe135c38f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 14:01:15 +0100 Subject: [PATCH 028/114] Fix empty column --- htdocs/compta/bank/bankentries_list.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index d428426107d..3800edb42ae 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1102,8 +1102,7 @@ if ($resql) { print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1); print ''; } - print ''; - print ''; + // Actions and select print ''; $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; @@ -1160,7 +1159,7 @@ if ($resql) { $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch '); + // Actions and select print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -1279,7 +1278,7 @@ if ($resql) { '; print ''; } - print ''; + print ''; print ' '; print ''; print ''; @@ -1664,7 +1663,7 @@ if ($resql) { } } - // Action edit/delete + // Action edit/delete and select print ''; // Transaction reconciliated or edit link if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) { // If line not conciliated and account can be conciliated @@ -1692,19 +1691,14 @@ if ($resql) { print ''; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } // Action column - print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->rowid, $arrayofselected)) { $selected = 1; } - print ''; + print ''; } print ''; if (!$i) { From 144a8af438dc1c02fd9056d72ccf16280147f724 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 14:28:58 +0100 Subject: [PATCH 029/114] Debug v15 --- htdocs/compta/bank/card.php | 8 ++++---- htdocs/fourn/paiement/list.php | 25 +++++++++++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 9f000786b7f..5d2bb71109b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1060,19 +1060,19 @@ if ($action == 'create') { // IBAN print ''.$langs->trans($ibankey).''; - print ''; + print ''; print ''.$langs->trans($bickey).''; - print ''; + print ''; if ($conf->prelevement->enabled) { print ''.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')'; - print ''; + print ''; } if ($conf->paymentbybanktransfer->enabled) { print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')'; - print ''; + print ''; } print ''.$langs->trans("BankAccountDomiciliation").''; diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index f9df30c2f54..45ed0c4776f 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -35,8 +35,10 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'banks', 'compta')); @@ -170,13 +172,14 @@ llxHeader('', $langs->trans('ListPayment')); $form = new Form($db); $formother = new FormOther($db); +$accountstatic = new Account($db); $companystatic = new Societe($db); $paymentfournstatic = new PaiementFourn($db); $sql = 'SELECT p.rowid, p.ref, p.datep, p.amount as pamount, p.num_paiement'; $sql .= ', s.rowid as socid, s.nom as name, s.email'; $sql .= ', c.code as paiement_type, c.libelle as paiement_libelle'; -$sql .= ', ba.rowid as bid, ba.label'; +$sql .= ', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal'; if (empty($user->rights->societe->client->voir)) { $sql .= ', sc.fk_soc, sc.fk_user'; } @@ -232,7 +235,8 @@ if ($search_all) { // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, s.email, c.code, c.libelle, ba.rowid, ba.label'; +$sql .= ' GROUP BY p.rowid, p.ref, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, s.email, c.code, c.libelle,'; +$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal'; if (empty($user->rights->societe->client->voir)) { $sql .= ', sc.fk_soc, sc.fk_user'; } @@ -533,11 +537,24 @@ while ($i < min($num, $limit)) { } } - // Account + // Bank account if (!empty($arrayfields['ba.label']['checked'])) { print ''; if ($objp->bid) { - print ''.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).''; + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->iban = $objp->iban_prefix; + $accountstatic->bic = $objp->bic; + $accountstatic->currency_code = $objp->currency_code; + $accountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->code; + + print $accountstatic->getNomUrl(1); } else { print ' '; } From 10e32c056ec3d7c5b35bd75c3405edcfa46a798b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jan 2022 15:35:33 +0100 Subject: [PATCH 030/114] FIX avoid infinite loop on dump with popen --- htdocs/core/class/utils.class.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 37ccea748f1..58c1179e1c0 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -291,18 +291,20 @@ class Utils $ok=0; dol_syslog("Run command ".$fullcommandcrypted); $handlein = popen($fullcommandclear, 'r'); - $i=0; - while (!feof($handlein)) - { - $i++; // output line number - $read = fgets($handlein); - // Exclude warning line we don't want - if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; - fwrite($handle,$read); - if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1; - elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1; + if ($handlein) { + $i=0; + while (!feof($handlein)) + { + $i++; // output line number + $read = fgets($handlein); + // Exclude warning line we don't want + if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; + fwrite($handle,$read); + if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1; + elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1; + } + pclose($handlein); } - pclose($handlein); if ($compression == 'none') fclose($handle); if ($compression == 'gz') gzclose($handle); From d8ae40c647f155fe84c88c0978aca0667076a167 Mon Sep 17 00:00:00 2001 From: Randall Mora <50120822+randallmoraes@users.noreply.github.com> Date: Fri, 7 Jan 2022 12:30:56 -0600 Subject: [PATCH 031/114] add support for sharedmailbox in office365 with 4 code lines enable support when a mailbox is shared... --- htdocs/emailcollector/class/emailcollector.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 729762be327..d6204fa632f 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -762,7 +762,12 @@ class EmailCollector extends CommonObject if ($norsh || !empty($conf->global->IMAP_FORCE_NORSH)) { $flags .= '/norsh'; } - + //Used in shared mailbox from Office365 + if (strpos($this->login,'/') != false) { + $partofauth = explode ('/',$this->login); + $flags .= '/authuser='.$partofauth[0].'/user='.$partofauth[1]; + } + $connectstringserver = '{'.$this->host.':993'.$flags.'}'; return $connectstringserver; From 912f0a8b95aee54c4ad7ef1a12645ae960296fa3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 7 Jan 2022 18:34:00 +0000 Subject: [PATCH 032/114] Fixing style errors. --- htdocs/emailcollector/class/emailcollector.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index d6204fa632f..7a4330aa161 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -763,11 +763,11 @@ class EmailCollector extends CommonObject $flags .= '/norsh'; } //Used in shared mailbox from Office365 - if (strpos($this->login,'/') != false) { - $partofauth = explode ('/',$this->login); + if (strpos($this->login, '/') != false) { + $partofauth = explode('/', $this->login); $flags .= '/authuser='.$partofauth[0].'/user='.$partofauth[1]; } - + $connectstringserver = '{'.$this->host.':993'.$flags.'}'; return $connectstringserver; From 2db35c4acc6fb68bc81a036bed514d99ac9ddc60 Mon Sep 17 00:00:00 2001 From: Randall Mora <50120822+randallmoraes@users.noreply.github.com> Date: Fri, 7 Jan 2022 15:19:18 -0600 Subject: [PATCH 033/114] Enable attachements in hook Enable to send attachments to the hook for custom data processing... --- htdocs/emailcollector/class/emailcollector.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 729762be327..71d1768fedc 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2381,6 +2381,7 @@ class EmailCollector extends CommonObject 'messagetext'=>$messagetext, 'subject'=>$subject, 'header'=>$header, + 'attachments'=>$attachments, ); $res = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); From 3a6b5199ec5f46b58606df63466d1c6680df0867 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Jan 2022 01:19:04 +0100 Subject: [PATCH 034/114] Debug module intracomm --- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 2 ++ htdocs/intracommreport/list.php | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index dcdbca568c5..58d39fe8aa4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1488,7 +1488,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Intracomm report if (!empty($conf->intracommreport->enabled)) { - $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); + $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 60, '', '', '', img_picto('', 'intracommreport', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { // DEB / DES $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1); diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index cd24a252a04..d33701c6ad6 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -480,3 +480,5 @@ ALTER TABLE llx_session MODIFY COLUMN user_agent VARCHAR(255) NULL; ALTER TABLE llx_inventorydet ADD COLUMN fk_movement integer NULL; ALTER TABLE llx_stock_mouvement MODIFY COLUMN origintype varchar(64); + +ALTER TABLE llx_intracommreport CHANGE COLUMN period periods varchar(32); diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index a4fed4def2d..6d1952b8786 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -251,7 +251,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= " GROUP BY i.rowid"; +$sql .= " GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity"; /* // Add fields from extrafields @@ -348,7 +348,7 @@ if ($resql) { print ''; } - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'intracommreport', 0, $newcardbutton, '', $limit); $topicmail = "Information"; $modelmail = "product"; From c3a42162d98805ac3f2fa57419c1c706fac35dc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Jan 2022 14:16:34 +0100 Subject: [PATCH 035/114] FIX The vat code was not correctly managed on PDF templates --- .../commande/doc/pdf_einstein.modules.php | 22 ++++++-- .../commande/doc/pdf_eratosthene.modules.php | 51 +++++++++++++++++-- .../delivery/doc/pdf_storm.modules.php | 3 ++ .../delivery/doc/pdf_typhon.modules.php | 3 ++ .../doc/pdf_standard.modules.php | 2 + .../modules/facture/doc/pdf_crabe.modules.php | 22 +++++--- .../facture/doc/pdf_sponge.modules.php | 26 +++++++--- .../core/modules/facture/modules_facture.php | 6 ++- .../modules/propale/doc/pdf_azur.modules.php | 24 +++++++-- .../modules/propale/doc/pdf_cyan.modules.php | 10 +++- .../stock/doc/pdf_standard.modules.php | 1 + .../doc/pdf_canelle.modules.php | 1 + .../supplier_order/doc/pdf_cornas.modules.php | 5 ++ .../doc/pdf_muscadet.modules.php | 5 ++ .../doc/pdf_standard.modules.php | 1 + .../doc/pdf_aurore.modules.php | 5 ++ 16 files changed, 157 insertions(+), 30 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 913438b4600..0ed0134a944 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -201,6 +201,7 @@ class pdf_einstein extends ModelePDFCommandes } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -567,10 +568,14 @@ class pdf_einstein extends ModelePDFCommandes if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { @@ -882,16 +887,16 @@ class pdf_einstein extends ModelePDFCommandes * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position pour suite */ - protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { // phpcs:enable global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -994,8 +999,9 @@ class pdf_einstein extends ModelePDFCommandes } } //} + // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1009,11 +1015,17 @@ class pdf_einstein extends ModelePDFCommandes } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= $tvaval['vatcode'].$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index e6ed244fc8f..a901a23cc69 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -185,6 +185,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Use new system for position of columns, view $this->defineColumnField() $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -792,10 +793,14 @@ class pdf_eratosthene extends ModelePDFCommandes if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { @@ -1098,15 +1103,15 @@ class pdf_eratosthene extends ModelePDFCommandes * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position pour suite */ - protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -1207,8 +1212,9 @@ class pdf_eratosthene extends ModelePDFCommandes } } //} + // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1222,11 +1228,46 @@ class pdf_eratosthene extends ModelePDFCommandes } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= $tvaval['vatcode'].$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); + } + } + + // VAT + foreach ($this->tva_array as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 903c8a233cd..742d06e2e34 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -156,6 +156,9 @@ class pdf_storm extends ModelePDFDeliveryOrder } $this->tva = array(); + $this->tva_array = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 865bef37fbb..5875814b546 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -173,6 +173,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder } $this->tva = array(); + $this->tva_array = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 6fdc14ec1ad..a4e3ab491a5 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -197,9 +197,11 @@ class pdf_standard extends ModeleExpenseReport } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 426976a0a90..be42ab002d5 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -210,6 +210,7 @@ class pdf_crabe extends ModelePDFFactures } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -743,10 +744,14 @@ class pdf_crabe extends ModelePDFFactures if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; @@ -1349,8 +1354,6 @@ class pdf_crabe extends ModelePDFFactures if ($tvakey != 0) { // On affiche pas taux 0 //$this->atleastoneratenotnull++; - - $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1373,7 +1376,7 @@ class pdf_crabe extends ModelePDFFactures //} // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1385,12 +1388,19 @@ class pdf_crabe extends ModelePDFFactures $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= $tvaval['vatcode'].$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval, 'MT'), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index e9481ea371c..2def31cbf30 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -187,6 +187,7 @@ class pdf_sponge extends ModelePDFFactures // Use new system for position of columns, view $this->defineColumnField() $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -881,10 +882,14 @@ class pdf_sponge extends ModelePDFFactures if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); $nexY = max($nexY, $posYAfterImage); @@ -1593,9 +1598,8 @@ class pdf_sponge extends ModelePDFFactures } //} - // VAT - // Situations totals migth be wrong on huge amounts - if ($object->situation_cycle_ref && $object->situation_counter > 1) { + // Situations totals migth be wrong on huge amounts with old mode 1 + if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) { $sum_pdf_tva = 0; foreach ($this->tva as $tvakey => $tvaval) { $sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object @@ -1612,10 +1616,14 @@ class pdf_sponge extends ModelePDFFactures foreach ($this->tva as $tvakey => $tvaval) { $this->tva[$tvakey] = $tvaval * $coef_fix_tva; } + foreach ($this->tva_array as $tvakey => $tvaval) { + $this->tva_array[$tvakey]['amount'] = $tvaval['amount'] * $coef_fix_tva; + } } } - foreach ($this->tva as $tvakey => $tvaval) { + // VAT + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1629,11 +1637,17 @@ class pdf_sponge extends ModelePDFFactures } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index b5f8b62d419..e188f66b1ad 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -42,10 +42,14 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ public $error = ''; + public $tva; + public $tva_array; + public $localtax1; + public $localtax2; + public $atleastonediscount = 0; public $atleastoneratenotnull = 0; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index e97eb0ff81d..ea2ea8add99 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -197,6 +197,7 @@ class pdf_azur extends ModelePDFPropales } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -677,10 +678,14 @@ class pdf_azur extends ModelePDFPropales if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; @@ -1059,9 +1064,10 @@ class pdf_azur extends ModelePDFPropales * @param int $deja_regle Amount already paid * @param int $posy Start position * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position for continuation */ - protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { // phpcs:enable global $conf, $mysoc; @@ -1164,8 +1170,9 @@ class pdf_azur extends ModelePDFPropales } } //} + // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1177,12 +1184,19 @@ class pdf_azur extends ModelePDFPropales $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index bb688c137a6..9963ecd9527 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -179,6 +179,7 @@ class pdf_cyan extends ModelePDFPropales // Use new system for position of columns, view $this->defineColumnField() $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -802,10 +803,14 @@ class pdf_cyan extends ModelePDFPropales if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = max($nexY, $posYAfterImage); @@ -1178,15 +1183,15 @@ class pdf_cyan extends ModelePDFPropales * @param int $deja_regle Amount already paid (in the currency of invoice) * @param int $posy Position depart * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position pour suite */ - protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -1293,6 +1298,7 @@ class pdf_cyan extends ModelePDFPropales } } //} + // VAT foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 226a62e50d2..1597ee32c18 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -174,6 +174,7 @@ class pdf_standard extends ModelePDFStock $this->postotalht -= 20; } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 08ccf213b18..23a38b961ec 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -181,6 +181,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 7738f1ec404..c30a2512083 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -169,6 +169,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -738,10 +739,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 76d264f2444..bb3d4f073fe 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -197,6 +197,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -617,10 +618,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 24ae9a71781..608d765b1c5 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -168,6 +168,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index c2ab5c99ea6..0417d06e44d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -194,6 +194,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -611,10 +612,14 @@ class pdf_aurore extends ModelePDFSupplierProposal if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; From eddc2a1a262909ab16524517fdc39929b8d97bfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Jan 2022 19:50:55 +0100 Subject: [PATCH 036/114] FIX #yogosha8272 --- htdocs/product/ajax/products.php | 4 ++-- htdocs/societe/ajax/company.php | 4 ++-- test/phpunit/CodingPhpTest.php | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index e230d148026..c6ce5fb5873 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -47,7 +47,7 @@ if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) { require '../../main.inc.php'; -$htmlname = GETPOST('htmlname', 'alpha'); +$htmlname = GETPOST('htmlname', 'aZ09'); $socid = GETPOST('socid', 'int'); $type = GETPOST('type', 'int'); $mode = GETPOST('mode', 'int'); @@ -242,7 +242,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // Filter on the product to search can be: // Into an array with key $htmlname123 (we take first one found). Which page use this ? // Into a var with name $htmlname can be 'prodid', 'productid', ... - $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.preg_quote($htmlname, '/').'[0-9]+)/', array_keys($_GET)); sort($match); $idprod = (empty($match[0]) ? '' : $match[0]); // Take first key found into GET array with matching $htmlname123 diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 7edd00db4d5..9dfe3909393 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -44,7 +44,7 @@ if (!defined('NOCSRFCHECK')) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -$htmlname = GETPOST('htmlname', 'alpha'); +$htmlname = GETPOST('htmlname', 'aZ09'); $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); $action = GETPOST('action', 'aZ09'); @@ -102,7 +102,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // Filter on the company to search can be: // Into an array with key $htmlname123 (we take first one found). Which page use this ? // Into a var with name $htmlname can be 'prodid', 'productid', ... - $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.preg_quote($htmlname, '/').'[0-9]+)/', array_keys($_GET)); sort($match); $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 7f894fe8b29..b173779538b 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -473,6 +473,19 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found a forbidden string sequence into '.$file['relativename'].' : name="token" value="\'.$_SESSION[..., you must use a newToken() instead of $_SESSION[\'newtoken\'].'); + // Test we don't have @var array( + $ok=true; + $matches=array(); + preg_match_all('/preg_grep\(.*\$/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) { + if (strpos($val[0], 'preg_quote') === false) { + $ok=false; + break; + } + } + $this->assertTrue($ok, 'Found a preg_grep with a param that is a $var but without preg_quote in file '.$file['relativename'].'.'); + + // Test we don't have @var array( $ok=true; $matches=array(); From bb1ec5940d39c70f597efe022eab88d92b7b6069 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 9 Jan 2022 10:24:28 +0100 Subject: [PATCH 037/114] Fix setup class --- htdocs/core/class/html.formsetup.class.php | 33 ++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 25ab99bfe01..4f5557279f4 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -215,7 +215,7 @@ class FormSetup $out = ''; $out .= ''; $out .= ''; - $out .= ' '; + $out .= ' '; $out .= ' '; $out .= ''; $out .= ''; @@ -353,7 +353,8 @@ class FormSetup */ $item = new FormSetupItem($confKey); - $item->setTypeFromTypeString($params['type']); + // need to be ignored from scrutinizer setTypeFromTypeString was created as deprecated to incite developper to use object oriented usage + /** @scrutinizer ignore-deprecated */ $item->setTypeFromTypeString($params['type']); if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; @@ -560,13 +561,16 @@ class FormSetupItem /** @var string $helpText */ public $helpText = ''; - /** @var string $value */ + /** @var string $fieldValue */ public $fieldValue; + /** @var array $fieldAttr fields attribute only for compatible fields like input text */ + public $fieldAttr; + /** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */ public $fieldOverride = false; - /** @var bool|string set this var to override field output */ + /** @var bool|string set this var to override field input */ public $fieldInputOverride = false; /** @var bool|string set this var to override field output */ @@ -583,6 +587,7 @@ class FormSetupItem /** * TODO each type must have setAs{type} method to help configuration * And set var as protected when its done configuration must be done by method + * this is important for retrocompatibility of futures versions * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' */ protected $type = 'string'; @@ -594,13 +599,19 @@ class FormSetupItem /** * Constructor * - * @param $confKey the conf key used in database + * @param string $confKey the conf key used in database */ public function __construct($confKey) { - global $langs, $db, $conf; + global $langs, $db, $conf, $form; $this->db = $db; - $this->form = new Form($this->db); + + if (!empty($form) && is_object($form) && get_class($form) == 'Form') { // the form class has a cache inside so I am using it to optimize + $this->form = $form; + } else { + $this->form = new Form($this->db); + } + $this->langs = $langs; $this->entity = $conf->entity; @@ -700,6 +711,10 @@ class FormSetupItem return $this->fieldInputOverride; } + $this->fieldAttr['name'] = $this->confKey; + $this->fieldAttr['id'] = 'setup-'.$this->confKey; + $this->fieldAttr['value'] = $this->fieldValue; + $out = ''; if ($this->type == 'title') { @@ -726,7 +741,9 @@ class FormSetupItem $out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1); } } else { - $out.= ''; + if (empty($this->fieldAttr)) { $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass); } + + $out.= 'fieldAttr).' />'; } return $out; From fcfb6a55f4138d396c8f1c5b60d4259cbca6c7ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jan 2022 13:50:10 +0100 Subject: [PATCH 038/114] Fix error management --- htdocs/fourn/facture/card.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e969ae01412..e675ca2a4af 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2395,18 +2395,23 @@ if ($action == 'create') { $productstatic = new Product($db); - $object->fetch($id, $ref); - $result = $object->fetch_thirdparty(); - if ($result < 0) { - dol_print_error($db); + $result = $object->fetch($id, $ref); + if ($result <= 0) { + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); + llxFooter(); + $db->close(); + exit; } - $societe = new Fournisseur($db); - $result = $societe->fetch($object->socid); + $result = $object->fetch_thirdparty(); if ($result < 0) { - dol_print_error($db); + dol_print_error($db, $object->error, $object->errors); + exit; } + $societe = $object->thirdparty; + $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); From 4ce77e62c6633909d44eea337b4fdc499b74710e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jan 2022 14:19:55 +0100 Subject: [PATCH 039/114] Debug v15 --- htdocs/admin/limits.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/societe/card.php | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 74c46112241..c16cde9bb09 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -49,7 +49,7 @@ $mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(!empty($currencycode) ? '_'.$cu $valmainmaxdecimalsunit = GETPOST($mainmaxdecimalsunit, 'int'); $valmainmaxdecimalstot = GETPOST($mainmaxdecimalstot, 'int'); $valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int'); -$valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alpha')); +$valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alphanohtml'), '', 2); if ($action == 'update') { $error = 0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ed871204cae..051ee4022b0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5318,7 +5318,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * 'CT'=Round to Max for totals with Tax of foreign currency accuracy * Numeric = Nb of digits for rounding (For example 2 for a percentage) * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) - * Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator). + * Put 2 if you know that number is a user input (so we know we have to fix decimal separator). * @return string Amount with universal numeric format (Example: '99.99999'). * If conversion fails to return a numeric, it returns: * - text unchanged or partial if ($rounding = ''): price2num('W9ç', '', 0) => '9ç', price2num('W9ç', '', 1) => 'W9ç', price2num('W9ç', '', 2) => '9ç' diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d75d9256b34..b6c483fc026 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1765,10 +1765,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('name')) { // We overwrite with values if posted $object->name = GETPOST('name', 'alphanohtml'); - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->name_alias = GETPOST('name_alias', 'alphanohtml'); + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); $object->client = GETPOST('client', 'int'); - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur', 'int'); + $object->code_client = GETPOST('customer_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur', 'int'); $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); From cc72418ab99a4eb433195f9bcd6d43c53fc56f41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jan 2022 14:22:42 +0100 Subject: [PATCH 040/114] Fix example --- htdocs/admin/limits.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index c16cde9bb09..1209f41c48e 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -211,7 +211,7 @@ if (empty($mysoc->country_code)) { print ''.$langs->trans("Format").': '.price(price2num(1234.56789, 'MT'), 0, $langs, 1, -1, -1, $currencycode)."
\n"; // Always show vat rates with vat 0 - $s = 2 / 7; $qty = 1; $vat = 0; + $s = 2 / 3; $qty = 1; $vat = 0; $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; From eb529a660d1c0d1d1097e622df8fad42b1391abf Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 9 Jan 2022 17:14:59 +0100 Subject: [PATCH 041/114] NEW add API REST for recruitment module --- .../class/api_recruitment.class.php | 647 ++++++++++++++++++ 1 file changed, 647 insertions(+) create mode 100644 htdocs/recruitment/class/api_recruitment.class.php diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php new file mode 100644 index 00000000000..d8790c62aeb --- /dev/null +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -0,0 +1,647 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Luracast\Restler\RestException; + +dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); +dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); + + + +/** + * \file recruitment/class/api_recruitment.class.php + * \ingroup recruitment + * \brief File for API management of recruitment. + */ + +/** + * API class for recruitment + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Recruitment extends DolibarrApi +{ + /** + * @var jobposition $jobposition {@type jobposition} + */ + public $jobposition; + public $candidature; + + /** + * Constructor + * + * @url GET / + * + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->jobposition = new RecruitmentJobPosition($this->db); + $this->candidature = new RecruitmentCandidature($this->db); + } + + /** + * Get properties of a jobposition object + * + * Return an array with jobposition informations + * + * @param int $id ID of jobposition + * @return array|mixed data without useless information + * + * @url GET jobposition/{id} + * + * @throws RestException 401 Not allowed + * @throws RestException 404 Not found + */ + public function getJobPosition($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $result = $this->jobposition->fetch($id); + if (!$result) { + throw new RestException(404, 'JobPosition not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) { + throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->jobposition); + } + + /** + * Get properties of a candidature object + * + * Return an array with candidature informations + * + * @param int $id ID of candidature + * @return array|mixed data without useless information + * + * @url GET candidature/{id} + * + * @throws RestException 401 Not allowed + * @throws RestException 404 Not found + */ + public function getCandidature($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $result = $this->candidature->fetch($id); + if (!$result) { + throw new RestException(404, 'Candidature not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) { + throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->candidature); + } + + + /** + * List jobpositions + * + * Get a list of jobpositions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /jobposition/ + */ + public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + $tmpobject = new RecruitmentJobPosition($this->db); + + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + + $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } + + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } + $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; + + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } + $sql .= " WHERE 1 = 1"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".((int) $socid); + } + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".((int) $search_sale); + } + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit + 1, $offset); + } + + $result = $this->db->query($sql); + $i = 0; + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $tmp_object = new RecruitmentJobPosition($this->db); + if ($tmp_object->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($tmp_object); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No jobposition found'); + } + return $obj_ret; + } + + /** + * List candatures + * + * Get a list of candidatures + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /candidature/ + */ + public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + $tmpobject = new RecruitmentCandidature($this->db); + + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + + $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } + + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } + $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; + + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } + $sql .= " WHERE 1 = 1"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".((int) $socid); + } + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".((int) $search_sale); + } + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit + 1, $offset); + } + + $result = $this->db->query($sql); + $i = 0; + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $tmp_object = new RecruitmentCandidature($this->db); + if ($tmp_object->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($tmp_object); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No candidature found'); + } + return $obj_ret; + } + + /** + * Create jobposition object + * + * @param array $request_data Request datas + * @return int ID of jobposition + * + * @throws RestException + * + * @url POST jobposition/ + */ + public function postJobPosition($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach ($request_data as $field => $value) { + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->jobposition->create(DolibarrApiAccess::$user)<0) { + throw new RestException(500, "Error creating jobposition", array_merge(array($this->jobposition->error), $this->jobposition->errors)); + } + return $this->jobposition->id; + } + + /** + * Create candidature object + * + * @param array $request_data Request datas + * @return int ID of candidature + * + * @throws RestException + * + * @url POST candidature/ + */ + public function postCandidature($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach ($request_data as $field => $value) { + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->candidature->create(DolibarrApiAccess::$user)<0) { + throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors)); + } + return $this->candidature->id; + } + + /** + * Update jobposition + * + * @param int $id Id of jobposition to update + * @param array $request_data Datas + * @return int + * + * @throws RestException + * + * @url PUT jobposition/{id} + */ + public function putJobPosition($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + $result = $this->jobposition->fetch($id); + if (!$result) { + throw new RestException(404, 'jobposition not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) { + throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->jobposition->update(DolibarrApiAccess::$user, false) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->jobposition->error); + } + } + + /** + * Update candidature + * + * @param int $id Id of candidature to update + * @param array $request_data Datas + * @return int + * + * @throws RestException + * + * @url PUT candidature/{id} + */ + public function putCandidature($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + $result = $this->candidature->fetch($id); + if (!$result) { + throw new RestException(404, 'candidature not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) { + throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->candidature->$field = $this->_checkValForAPI($field, $value, $this->candidature); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->candidature->update(DolibarrApiAccess::$user, false) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->candidature->error); + } + } + + + /** + * Delete jobposition + * + * @param int $id jobposition ID + * @return array + * + * @throws RestException + * + * @url DELETE jobposition/{id} + */ + public function deleteJobPosition($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->delete) { + throw new RestException(401); + } + $result = $this->jobposition->fetch($id); + if (!$result) { + throw new RestException(404, 'jobposition not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) { + throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (!$this->jobposition->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting jobposition : '.$this->jobposition->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'jobposition deleted' + ) + ); + } + + /** + * Delete candidature + * + * @param int $id candidature ID + * @return array + * + * @throws RestException + * + * @url DELETE candidature/{id} + */ + public function deleteCandidature($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->delete) { + throw new RestException(401); + } + $result = $this->candidature->fetch($id); + if (!$result) { + throw new RestException(404, 'candidature not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) { + throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (!$this->candidature->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting candidature : '.$this->candidature->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'candidature deleted' + ) + ); + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); + + unset($object->rowid); + unset($object->canvas); + + /*unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->statut); + unset($object->state); + unset($object->state_id); + unset($object->state_code); + unset($object->region); + unset($object->region_code); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_account); + unset($object->comments); + unset($object->note); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->shipping_method_id); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + */ + + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) { + $this->_cleanObjectDatas($object->lines[$i]); + + unset($object->lines[$i]->lines); + unset($object->lines[$i]->note); + } + } + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Array of data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $jobposition = array(); + foreach ($this->jobposition->fields as $field => $propfield) { + if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) { + continue; // Not a mandatory field + } + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $jobposition[$field] = $data[$field]; + } + return $jobposition; + } +} From f4f7a360a1853ba54b44cbe9266cf329b2a938b0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 9 Jan 2022 16:17:22 +0000 Subject: [PATCH 042/114] Fixing style errors. --- .../class/api_recruitment.class.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php index d8790c62aeb..e0c2cb5da11 100644 --- a/htdocs/recruitment/class/api_recruitment.class.php +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -377,27 +377,27 @@ class Recruitment extends DolibarrApi * * @url POST candidature/ */ - public function postCandidature($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { - throw new RestException(401); - } + public function postCandidature($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); - } + foreach ($request_data as $field => $value) { + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } - // Clean data - // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); - if ($this->candidature->create(DolibarrApiAccess::$user)<0) { - throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors)); - } - return $this->candidature->id; - } + if ($this->candidature->create(DolibarrApiAccess::$user)<0) { + throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors)); + } + return $this->candidature->id; + } /** * Update jobposition From 423a4ea104da0dd24fc229bfff576fbf8e029b11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jan 2022 19:48:38 +0100 Subject: [PATCH 043/114] Debug v15 --- htdocs/compta/facture/class/facture.class.php | 5 +- .../class/bonprelevement.class.php | 74 +++++++++++++++++++ .../class/fournisseur.commande.class.php | 9 ++- .../fourn/class/fournisseur.facture.class.php | 19 +++-- htdocs/index.php | 46 ++++++++---- 5 files changed, 126 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4f72b5a14a3..ea3b7fb6d01 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4263,10 +4263,10 @@ class Facture extends CommonInvoice $clause = " WHERE"; - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total_ht"; + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin, f.fk_statut, f.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; + $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; } @@ -4304,6 +4304,7 @@ class Facture extends CommonInvoice } } + $this->db->free($resql); return $response; } else { dol_print_error($this->db); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 93279218218..e5697ab3cb3 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -2300,4 +2300,78 @@ class BonPrelevement extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param string $mode Mode 'direct_debit' or 'credit_transfer' + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + public function load_board($user, $mode) + { + // phpcs:enable + global $conf, $langs; + + if ($user->socid) { + return -1; // protection pour eviter appel par utilisateur externe + } + + /* + if ($mode == 'direct_debit') { + $sql = "SELECT b.rowid, f.datedue as datefin"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.entity IN (".getEntity('facture').")"; + $sql .= " AND f.total_ttc > 0"; + } else { + $sql = "SELECT b.rowid, f.datedue as datefin"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " WHERE f.entity IN (".getEntity('facture_fourn').")"; + $sql .= " AND f.total_ttc > 0"; + } + + $resql = $this->db->query($sql); + if ($resql) { + $langs->load("banks"); + $now = dol_now(); + + $response = new WorkboardResponse(); + if ($mode == 'direct_debit') { + $response->warning_delay = $conf->prelevement->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("PendingDirectDebitToComplete"); + $response->labelShort = $langs->trans("PendingDirectDebitToCompleteShort"); + $response->url = DOL_URL_ROOT.'/compta/prelevement/index.php?leftmenu=checks&mainmenu=bank'; + } else { + $response->warning_delay = $conf->paymentbybanktransfer->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("PendingCreditTransferToComplete"); + $response->labelShort = $langs->trans("PendingCreditTransferToCompleteShort"); + $response->url = DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php?leftmenu=checks&mainmenu=bank'; + } + $response->img = img_object('', "payment"); + + while ($obj = $this->db->fetch_object($resql)) { + $response->nbtodo++; + + if ($this->db->jdate($obj->datefin) < ($now - $conf->withdraw->warning_delay)) { + $response->nbtodolate++; + } + } + + $response->nbtodo = 0; + $response->nbtodolate = 0; + // Return workboard only if quantity is not 0 + if ($response->nbtodo) { + return $response; + } else { + return 0; + } + } else { + dol_print_error($this->db); + $this->error = $this->db->error(); + return -1; + } + */ + return 0; + } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9b68ef199db..83b737a050e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3008,10 +3008,10 @@ class CommandeFournisseur extends CommonOrder $clause = " WHERE"; - $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date"; + $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date, c.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; + $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; } @@ -3043,12 +3043,13 @@ class CommandeFournisseur extends CommonOrder } while ($obj = $this->db->fetch_object($resql)) { - $response->nbtodo++; - $commandestatic->delivery_date = $this->db->jdate($obj->delivery_date); $commandestatic->date_commande = $this->db->jdate($obj->date_commande); $commandestatic->statut = $obj->fk_statut; + $response->nbtodo++; + $response->total += $obj->total_ht; + if ($commandestatic->hasDelay()) { $response->nbtodolate++; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a202e459e6d..d08031b5b69 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2418,20 +2418,21 @@ class FactureFournisseur extends CommonInvoice // phpcs:enable global $conf, $langs; - $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut'; + $clause = " WHERE"; + + $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut, ff.total_ht'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ff.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".((int) $user->id); + $clause = " AND"; } - $sql .= ' WHERE ff.paye=0'; + $sql .= $clause.' ff.paye=0'; $sql .= ' AND ff.fk_statut = '.self::STATUS_VALIDATED; $sql .= " AND ff.entity = ".$conf->entity; if ($user->socid) { $sql .= ' AND ff.fk_soc = '.((int) $user->socid); } - if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } $resql = $this->db->query($sql); if ($resql) { @@ -2449,16 +2450,18 @@ class FactureFournisseur extends CommonInvoice $facturestatic = new FactureFournisseur($this->db); while ($obj = $this->db->fetch_object($resql)) { - $response->nbtodo++; - $facturestatic->date_echeance = $this->db->jdate($obj->datefin); $facturestatic->statut = $obj->fk_statut; + $response->nbtodo++; + $response->total += $obj->total_ht; + if ($facturestatic->hasDelay()) { $response->nbtodolate++; $response->url_late = DOL_URL_ROOT.'/fourn/facture/list.php?search_option=late&mainmenu=billing&leftmenu=suppliers_bills'; } } + $this->db->free($resql); return $response; } else { diff --git a/htdocs/index.php b/htdocs/index.php index be439300291..5593eaffacf 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -252,11 +252,24 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } } + // Number of cheque to send - if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_DISABLE_BLOCK_BANK) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $board = new RemiseCheque($db); - $dashboardlines[$board->element] = $board->load_board($user); + if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_DISABLE_BLOCK_BANK) && $user->rights->banque->lire && !$user->socid) { + if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; + $board = new RemiseCheque($db); + $dashboardlines[$board->element] = $board->load_board($user); + } + if (!empty($conf->prelevement->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; + $board = new BonPrelevement($db); + $dashboardlines[$board->element.'_direct_debit'] = $board->load_board($user, 'direct_debit'); + } + if (!empty($conf->paymentbybanktransfer->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; + $board = new BonPrelevement($db); + $dashboardlines[$board->element.'_credit_transfer'] = $board->load_board($user, 'credit_transfer'); + } } // Number of foundation members @@ -375,7 +388,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { array( 'groupName' => 'BankAccount', 'stats' => - array('bank_account', 'chequereceipt'), + array('bank_account', 'chequereceipt', 'widthdraw_direct_debit', 'widthdraw_credit_transfer'), ), 'member' => array( @@ -414,7 +427,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $totallate = $totaltodo = 0; //Remove any invalid response - //load_board can return an integer if failed or WorkboardResponse if OK + //load_board can return an integer if failed, or WorkboardResponse if OK $valid_dashboardlines = array(); foreach ($dashboardlines as $workboardid => $tmp) { if ($tmp instanceof WorkboardResponse) { @@ -477,6 +490,8 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { foreach ($dashboardgroup as $groupKey => $groupElement) { $boards = array(); + + // Scan $groupElement and save the one with 'stats' that lust be used for Open object dashboard if (empty($conf->global->MAIN_DISABLE_NEW_OPENED_DASH_BOARD)) { foreach ($groupElement['stats'] as $infoKey) { if (!empty($valid_dashboardlines[$infoKey])) { @@ -492,7 +507,6 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } $groupName = $langs->trans($groupElement['groupName']); $groupKeyLowerCase = strtolower($groupKey); - $nbTotalForGroup = 0; // global stats $globalStatsKey = false; @@ -513,7 +527,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')'; $groupElement['globalStats']['total'] = $nbTotal; - $groupElement['globalStats']['link'] = $links[$keyIndex]; + //$groupElement['globalStats']['link'] = $links[$keyIndex]; } } } @@ -565,7 +579,17 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $nbtodClass = 'opacitymedium'; } - $openedDashBoard .= ''.$infoName.''.$board->nbtodo.''; + // Forge the line to show into the open object box + $labeltoshow = $board->label.' ('.$board->nbtodo.')'; + if ($board->total > 0) { + $labeltoshow .= ' - '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency); + } + $openedDashBoard .= ''.$infoName.''; + $openedDashBoard .= $board->nbtodo; + if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) { + $openedDashBoard .= ' : '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency); + } + $openedDashBoard .= ''; if ($textLate) { if ($board->url_late) { $openedDashBoard .= ''; @@ -576,10 +600,6 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $openedDashBoard .= $textLate; } $openedDashBoard .= ''."\n"; - - if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) { - $openedDashBoard .= ''.$langs->trans('Total').' '.price($board->total).''; - } $openedDashBoard .= ''."\n"; } From 4af80507cb45ed35e4e25bfcc19058afccb2acd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jan 2022 20:25:10 +0100 Subject: [PATCH 044/114] Fix #yogosha8282 --- htdocs/core/class/translate.class.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index c092690a505..f881447cd67 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -555,9 +555,9 @@ class Translate * Return translated value of key for special keys ("Currency...", "Civility...", ...). * Search in lang file, then into database. Key must be any complete entry into lang file: CurrencyEUR, ... * If not found, return key. - * The string return is not formated (translated with transnoentitiesnoconv) - * NOTE: To avoid infinite loop (getLabelFromKey->transnoentities->getTradFromKey), if you modify this function, - * check that getLabelFromKey is not called with same value than input. + * The string return is not formated (translated with transnoentitiesnoconv). + * NOTE: To avoid infinite loop (getLabelFromKey->transnoentities->getTradFromKey->getLabelFromKey), if you modify this function, + * check that getLabelFromKey is never called with the same value than $key. * * @param string $key Key to translate * @return string Translated string (translated with transnoentitiesnoconv) @@ -585,7 +585,7 @@ class Translate $newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label'); } elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg)) { // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method - //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); + //$newstr=$this->getLabelFromKey($db,$reg[1],'llx_c_input_reason','code','label'); } /* Disabled. There is too many cases where translation of $newstr is not defined is normal (like when output with setEventMessage an already translated string) @@ -945,9 +945,9 @@ class Translate * * @param DoliDB $db Database handler * @param string $key Translation key to get label (key in language file) - * @param string $tablename Table name without prefix - * @param string $fieldkey Field for key - * @param string $fieldlabel Field for label + * @param string $tablename Table name without prefix. This value must always be a hardcoded string and not a value coming from user input. + * @param string $fieldkey Field for key. This value must always be a hardcoded string and not a value coming from user input. + * @param string $fieldlabel Field for label. This value must always be a hardcoded string and not a value coming from user input. * @param string $keyforselect Use another value than the translation key for the where into select * @param int $filteronentity Use a filter on entity * @return string Label in UTF8 (but without entities) @@ -959,10 +959,15 @@ class Translate if ($key == '') { return ''; } + // Test should be useless because the 3 variables are never set from user input but we keep it in case of. + if (preg_match('/[^0-9A-Z_]/i', $tablename) || preg_match('/[^0-9A-Z_]/i', $fieldkey) || preg_match('/[^0-9A-Z_]/i', $fieldlabel)) { + $this->error = 'Bad value for parameter tablename, fieldkey or fieldlabel'; + return -1; + } //print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit; - // Check if a translation is available (this can call getTradFromKey) + // Check if a translation is available (Note: this can call getTradFromKey that can call getLabelFromKey) $tmp = $this->transnoentitiesnoconv($key); if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString') { return $tmp; // Found in language array @@ -973,6 +978,7 @@ class Translate return $this->cache_labels[$tablename][$key]; // Found in cache } + // Not found in loaded language file nor in cache. So we will take the label into database. $sql = "SELECT ".$fieldlabel." as label"; $sql .= " FROM ".MAIN_DB_PREFIX.$tablename; $sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'"; From 2a2a8b47d8d77f1b9980d763e1052213afea05be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jan 2022 20:43:26 +0100 Subject: [PATCH 045/114] Fix link to vcard on contact --- htdocs/adherents/card.php | 2 +- htdocs/contact/card.php | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d7d72f70540..a2e3779d52b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -949,7 +949,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print load_fiche_titre($langs->trans("NewMember"), '', $object->picto); if ($conf->use_javascript_ajax) { - print "\n".'
' . $this->langs->trans("Parameter") . '' . $this->langs->trans("Parameter") . '' . $this->langs->trans("Value") . '