From 95e1b97f42350375af61e1d9c45fe9714f163c88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2022 13:09:21 +0200 Subject: [PATCH 01/25] Fix missing inventory code in reception --- htdocs/fourn/class/fournisseur.commande.class.php | 4 +++- htdocs/fourn/commande/dispatch.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f350c4f3640..08126bf5974 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2006,6 +2006,8 @@ class CommandeFournisseur extends CommonOrder $now = dol_now(); + $inventorycode = $langs->trans("Reception").' '.$this->ref; + if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) { $this->db->begin(); @@ -2039,7 +2041,7 @@ class CommandeFournisseur extends CommonOrder // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; $mouv->setOrigin($this->element, $this->id); - $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); + $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch, $inventorycode); if ($result < 0) { $this->error = $mouv->error; $this->errors = $mouv->errors; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a1ddef959a0..acb9766a318 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -221,6 +221,7 @@ if ($action == 'denydispatchline' && $permissiontocontrol) { if ($action == 'dispatch' && $permissiontoreceive) { $error = 0; + $notrigger = 0; $db->begin(); From f48752fc1693c792951a5fd2d194f4ccf9ea1315 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2022 13:25:07 +0200 Subject: [PATCH 02/25] FIX inventory code must be different at each transation --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/mrp/mo_production.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 08126bf5974..ad666573b18 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2006,7 +2006,7 @@ class CommandeFournisseur extends CommonOrder $now = dol_now(); - $inventorycode = $langs->trans("Reception").' '.$this->ref; + $inventorycode = dol_print_date(dol_now(), 'dayhourlog'); if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) { $this->db->begin(); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 1c6f3f7ec39..34b9191db94 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -660,8 +660,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { $defaultstockmovementlabel = GETPOST('inventorylabel', 'alphanohtml') ? GETPOST('inventorylabel', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref); - //$defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog'); - $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref); + $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : dol_print_date(dol_now(), 'dayhourlog'); print '
'; print '
'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; From a35d7f8a4b1199add41780d23765ad4e857c996b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2022 14:17:14 +0200 Subject: [PATCH 03/25] Fix must not overwrite the var that is an object of cache --- htdocs/fourn/commande/dispatch.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index acb9766a318..ccf95de4232 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1202,10 +1202,6 @@ if ($id > 0 || !empty($ref)) { while ($i < $num) { $objp = $db->fetch_object($resql); - $tmpproduct->id = $objp->fk_product; - $tmpproduct->ref = $objp->ref; - $tmpproduct->label = $objp->label; - if ($action == 'editline' && $lineid == $objp->dispatchlineid) { print '
From 3c5f3f7b858d57a82be46c08b4999a96cd4ba7a7 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Mon, 12 Sep 2022 16:28:06 +0200 Subject: [PATCH 04/25] fix --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 4af49c7a3d5..181ae20589d 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -988,7 +988,7 @@ while ($i < min($num, $limit)) { // Description if (!empty($arrayfields['t.description']['checked'])) { print ''; - print dol_escape_htmltag($object->description); + print $object->description; print ''; if (!$i) { $totalarray['nbfield']++; From 527cfadf0f168e61918c1e1a8aa3215cc4236934 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Mon, 12 Sep 2022 16:31:00 +0200 Subject: [PATCH 05/25] nl2br like on the card --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 181ae20589d..65ceda08242 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -988,7 +988,7 @@ while ($i < min($num, $limit)) { // Description if (!empty($arrayfields['t.description']['checked'])) { print ''; - print $object->description; + print nl2br($object->description); print ''; if (!$i) { $totalarray['nbfield']++; From 77ec9ee669275b8125b49057f8d45a249736409c Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Tue, 13 Sep 2022 11:26:37 +0200 Subject: [PATCH 06/25] FIX : ToOfferALinkForOnlinePayment not translated ToOfferALinkForOnlinePayment is defined on stripe.lang --- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 72eb041f873..c47e9fc7c60 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1265,7 +1265,7 @@ class pdf_sponge extends ModelePDFFactures require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; global $langs; - $langs->loadLangs(array('payment', 'paybox')); + $langs->loadLangs(array('payment', 'paybox', 'stripe')); $servicename = $langs->transnoentities('Online'); $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', ''); $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").''; From 4f9c273c644f2ccc157674144ec9a87cd9102db4 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Tue, 13 Sep 2022 14:19:28 +0200 Subject: [PATCH 07/25] retours --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 65ceda08242..4f7c4bf7a42 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -988,7 +988,7 @@ while ($i < min($num, $limit)) { // Description if (!empty($arrayfields['t.description']['checked'])) { print ''; - print nl2br($object->description); + print dolGetFirstLineOfText($object->description, 5); print ''; if (!$i) { $totalarray['nbfield']++; From 7d4c7e0f6b7090a98838366da9df4049efb27f88 Mon Sep 17 00:00:00 2001 From: Atm-Gregr Date: Tue, 13 Sep 2022 14:28:57 +0200 Subject: [PATCH 08/25] stickler --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 4f7c4bf7a42..d74b84dd7ba 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -988,7 +988,7 @@ while ($i < min($num, $limit)) { // Description if (!empty($arrayfields['t.description']['checked'])) { print ''; - print dolGetFirstLineOfText($object->description, 5); + print dolGetFirstLineOfText($object->description, 5); print ''; if (!$i) { $totalarray['nbfield']++; From 0fe65591e80bfcc498a7be55bf9f73275e901ff6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 14:01:41 +0200 Subject: [PATCH 09/25] Fix message avec import simulation Fix suggested name of import profile avec a save. Fix trans --- htdocs/core/modules/modSociete.class.php | 2 +- htdocs/imports/import.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 327262ce39f..7f7624b167f 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -747,7 +747,7 @@ class modSociete extends DolibarrModules 's.fk_departement' => "StateCode", 's.fk_pays' => "CountryCode", 's.birthday' => "DateOfBirth", - 's.poste' => "Role", + 's.poste' => "PostOrFunction", 's.phone' => "Phone", 's.phone_perso' => "PhonePerso", 's.phone_mobile' => "PhoneMobile", diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index a66814ce1b1..8916041520d 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -235,6 +235,7 @@ if ($action == 'add_import_model') { $result = $objimport->create($user); if ($result >= 0) { setEventMessages($langs->trans("ImportModelSaved", $objimport->model_name), null, 'mesgs'); + $import_name = ''; } else { $langs->load("errors"); if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -1286,7 +1287,7 @@ if ($step == 4 && $datatoimport) { print ''; // Lines for remark - print ''.$langs->trans("Remark").''; + print ''.$langs->trans("Note").''; print '
'; print ''; @@ -1470,8 +1471,8 @@ if ($step == 4 && $datatoimport) { print ''; $nameofimportprofile = str_replace(' ', '-', $langs->trans("ImportProfile").' '.$titleofmodule.' '.dol_print_date(dol_now('gmt'), 'dayxcard')); - if (is_object($objimport) && !empty($objimport->model_name)) { - $nameofimportprofile = $objimport->model_name; + if (GETPOST('import_name')) { // If we have submited a form, we take value used fot the update try + $nameofimportprofile = $import_name; } print ''; @@ -1966,9 +1967,9 @@ if ($step == 5 && $datatoimport) { print '
'; print ''.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'
'; - if (empty($nboferrors)) { + /*if (empty($nboferrors)) { print $langs->trans("DataLoadedWithId", $importid).'
'; - } + }*/ print '
'; print '
'; From 34da698537c5360164ca14acc0a0e4640ee5441b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 16:01:45 +0200 Subject: [PATCH 10/25] FIX Import in upgrade when using a socialnetwork field. --- htdocs/core/db/Database.interface.php | 9 +++++++++ htdocs/core/db/mysqli.class.php | 12 ++++++++++++ htdocs/core/db/pgsql.class.php | 14 +++++++++++++- htdocs/core/db/sqlite3.class.php | 14 +++++++++++++- htdocs/core/lib/website.lib.php | 6 +++--- htdocs/core/modules/import/import_csv.modules.php | 12 ++++++++---- htdocs/core/modules/import/import_xlsx.modules.php | 8 ++++++-- htdocs/debugbar/class/TraceableDB.php | 12 ++++++++++++ 8 files changed, 76 insertions(+), 11 deletions(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 1d24b058614..faff7ff5172 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -182,9 +182,18 @@ interface Database * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode); + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode); + /** * Sanitize a string for SQL forging * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 29c2d30df2f..f2c5f9f3a03 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -479,12 +479,24 @@ class DoliDBMysqli extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { return str_replace('_', '\_', (string) $stringtoencode); } + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + } + /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index fe3269867a9..e259933cd07 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -726,10 +726,22 @@ class DoliDBPgsql extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { - return str_replace('_', '\_', $stringtoencode); + return str_replace('_', '\_', (string) $stringtoencode); + } + + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); } /** diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 8d0141e8ca6..e31eeffe457 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -654,10 +654,22 @@ class DoliDBSqlite3 extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { - return str_replace('_', '\_', $stringtoencode); + return str_replace('_', '\_', (string) $stringtoencode); + } + + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); } /** diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e9de957e4a8..e9ea4dbcf09 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -947,11 +947,11 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so $sql .= " AND ("; $searchalgo = ''; if (preg_match('/meta/', $algo)) { - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%'"; - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeunderscore($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeunderscore($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeforlike($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeforlike($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeforlike($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords } if (preg_match('/content/', $algo)) { - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'"; } $sql .= $searchalgo; if (is_array($otherfilters) && !empty($otherfilters['category'])) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 32284a2cbd1..0bea7d1d739 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -835,8 +835,8 @@ class ImportCsv extends ModeleImports $sqlSelect = "SELECT ".$fname." FROM ".$tablename; $data = array_combine($listfields, $listvalues); - $where = array(); - $filters = array(); + $where = array(); // filters to forge SQL request + $filters = array(); // filters to forge output error message foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; $key = preg_replace('/^.*\./i', '', $key); @@ -846,8 +846,12 @@ class ImportCsv extends ModeleImports $socialnetwork = $tmp[1]; $jsondata = $data[$key]; $json = json_decode($jsondata); - $where[] = $key." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; - $filters[] = $col." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; + $stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork); + //var_dump($stringtosearch); + //var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like) + $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + //var_dump($where[1]); // This provide a value for sql string inside a like } else { $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index d8a9d77a98e..8652f106ca2 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -891,8 +891,12 @@ class ImportXlsx extends ModeleImports $socialnetwork = $tmp[1]; $jsondata = $data[$key]; $json = json_decode($jsondata); - $where[] = $key." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; - $filters[] = $col." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; + $stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork); + //var_dump($stringtosearch); + //var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like) + $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + //var_dump($where[1]); // This provide a value for sql string inside a like } else { $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 082e45e4f43..785af37fc94 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -255,12 +255,24 @@ class TraceableDB extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { return $this->db->escapeunderscore($stringtoencode); } + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT From 5f27435ffcf7f61c14d9982c6eb3ab44b17bac42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 16:06:42 +0200 Subject: [PATCH 11/25] Fix position of import --- htdocs/core/modules/modAccounting.class.php | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 5e30978693e..737d2831db6 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -272,6 +272,24 @@ class modAccounting extends DolibarrModules //-------- $r = 0; + // Chart of accounts + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Chartofaccounts"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account'); + $this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation"); + $this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); + $this->import_convertvalue_array[$r] = array( + 'aa.account_number'=>array('rule'=>'accountingaccount'), + 'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'), + 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'), + ); + $this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28"); + $this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting'); + // General ledger $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; @@ -393,23 +411,5 @@ class modAccounting extends DolibarrModules 'b.multicurrency_amount'=>"90 (Necessary if devise is different than EUR)", 'b.multicurrency_code'=>"US (Necessary if devise is different than EUR)", ); - - // Chart of accounts - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Chartofaccounts"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account'); - $this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation"); - $this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); - $this->import_convertvalue_array[$r] = array( - 'aa.account_number'=>array('rule'=>'accountingaccount'), - 'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'), - 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'), - ); - $this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28"); - $this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting'); } } From 337cc7553ddef8137e9ed7d3ff1c0b217d8e858b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 17:44:47 +0200 Subject: [PATCH 12/25] Fix rounding --- htdocs/core/lib/price.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 6b85e837b07..f85e78865ed 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -372,16 +372,16 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // If rounding is not using base 10 (rare) if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) { if ($price_base_type == 'HT') { - $result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[0] = price2num(round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); + $result[1] = price2num(round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); + $result[9] = price2num(round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); + $result[10] = price2num(round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); $result[2] = price2num($result[0] + $result[1] + $result[9] + $result[10], 'MT'); } else { - $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; - $result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[1] = price2num(round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); + $result[2] = price2num(round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); + $result[9] = price2num(round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); + $result[10] = price2num(round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT'); $result[0] = price2num($result[2] - $result[1] - $result[9] - $result[10], 'MT'); } } From 3a078ec77dd2c8872b12c043c784fd0ced0ee011 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 18:12:05 +0200 Subject: [PATCH 13/25] Fix type of var --- htdocs/core/class/commonobject.class.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7b78d9bbcb9..02c38e9a89e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3553,8 +3553,8 @@ abstract class CommonObject } $forcedroundingmode = $roundingadjust; - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) { - $forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; + if ($forcedroundingmode == 'auto' && getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND')) { + $forcedroundingmode = getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND'); } elseif ($forcedroundingmode == 'auto') { $forcedroundingmode = '0'; } @@ -3679,14 +3679,17 @@ abstract class CommonObject } $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid); dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); - $resqlfix = $this->db->query($sqlfix); + + $resqlfix = $this->db->query($sqlfix); + if (!$resqlfix) { dol_print_error($this->db, 'Failed to update line'); } - $this->total_tva -= $diff; - $this->total_ttc -= $diff; - $total_tva_by_vats[$obj->vatrate] -= $diff; - $total_ttc_by_vats[$obj->vatrate] -= $diff; + + $this->total_tva = (float) price2num($this->total_tva - $diff); + $this->total_ttc = (float) price2num($this->total_ttc - $diff); + $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff); + $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff); } } From 8f7f104806cef5197260b35c21bd638ac8780dad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 18:34:13 +0200 Subject: [PATCH 14/25] Fix test on MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND --- htdocs/core/class/commonobject.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 02c38e9a89e..94d6e039477 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3553,7 +3553,7 @@ abstract class CommonObject } $forcedroundingmode = $roundingadjust; - if ($forcedroundingmode == 'auto' && getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND')) { + if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) { $forcedroundingmode = getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND'); } elseif ($forcedroundingmode == 'auto') { $forcedroundingmode = '0'; @@ -3686,10 +3686,10 @@ abstract class CommonObject dol_print_error($this->db, 'Failed to update line'); } - $this->total_tva = (float) price2num($this->total_tva - $diff); - $this->total_ttc = (float) price2num($this->total_ttc - $diff); - $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff); - $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff); + $this->total_tva = (float) price2num($this->total_tva - $diff, '', 1); + $this->total_ttc = (float) price2num($this->total_ttc - $diff, '', 1); + $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff, '', 1); + $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff, '', 1); } } From 90dbb933883aa1306946f19123236913ae1d5d0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 18:51:07 +0200 Subject: [PATCH 15/25] Try fix rounding --- htdocs/core/class/commonobject.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 94d6e039477..fd71e78afc6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3716,6 +3716,13 @@ abstract class CommonObject } } + // Clean total + $this->total_ht = (float) price2num($this->total_ht); + $this->total_tva = (float) price2num($this->total_tva); + $this->total_localtax1 = (float) price2num($this->total_localtax1); + $this->total_localtax2 = (float) price2num($this->total_localtax2); + $this->total_ttc = (float) price2num($this->total_ttc); + $this->db->free($resql); // Now update global field total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_* @@ -3749,11 +3756,11 @@ abstract class CommonObject if (empty($nodatabaseupdate)) { $sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET'; - $sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).","; - $sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).","; - $sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).","; - $sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2)).","; - $sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc)); + $sql .= " ".$fieldht." = ".((float) price2num($this->total_ht, 'MT', 1)).","; + $sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva, 'MT', 1)).","; + $sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1, 'MT', 1)).","; + $sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2, 'MT', 1)).","; + $sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc, 'MT', 1)); $sql .= ", multicurrency_total_ht = ".((float) price2num($this->multicurrency_total_ht, 'MT', 1)); $sql .= ", multicurrency_total_tva = ".((float) price2num($this->multicurrency_total_tva, 'MT', 1)); $sql .= ", multicurrency_total_ttc = ".((float) price2num($this->multicurrency_total_ttc, 'MT', 1)); From 094c2c3027e6e769996fb58f621aedb93ae316b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 01:02:49 +0200 Subject: [PATCH 16/25] Fix condition on a field --- htdocs/projet/class/project.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7ee71bc1569..849c1c53398 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -345,6 +345,7 @@ class Project extends CommonObject $this->fields['accept_booth_suggestions']['enabled'] = 0; $this->fields['price_registration']['enabled'] = 0; $this->fields['price_booth']['enabled'] = 0; + $this->fields['max_attendees']['enabled'] = 0; } } From 9881e7753d0fa9d638e8c9326968e4529cfd4ac0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 01:35:54 +0200 Subject: [PATCH 17/25] Fix regression --- .../societe/mod_codeclient_elephant.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 820dfafdc7e..100799dff95 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -172,27 +172,32 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode "ErrorBadMaskBadRazMonth", "ErrorCantUseRazWithYearOnOneDigit", ); + + $cssforerror = (getDolGlobalString('SOCIETE_CODECLIENT_ADDON') == 'mod_codeclient_elephant' ? 'error' : 'opacitymedium'); + if ($type != 1) { $examplecust = $this->getNextValue($objsoc, 0); - if (!$examplecust) { - $examplecust = '
'.$langs->trans('NotConfigured').'
'; + if (!$examplecust && ($cssforerror == 'error' || $this->error != 'NotConfigured')) { + $langs->load("errors"); + $examplecust = ''.$langs->trans('ErrorBadMask').''; $error = 1; } if (in_array($examplecust, $errmsg)) { $langs->load("errors"); - $examplecust = '
'.$langs->trans($examplecust).'
'; + $examplecust = ''.$langs->trans($examplecust).''; $error = 1; } } if ($type != 0) { $examplesup = $this->getNextValue($objsoc, 1); - if (!$examplesup) { - $examplesup = '
'.$langs->trans('NotConfigured').'
'; + if (!$examplesup && ($cssforerror == 'error' || $this->error != 'NotConfigured')) { + $langs->load("errors"); + $examplesup = ''.$langs->trans('ErrorBadMask').''; $error = 1; } if (in_array($examplesup, $errmsg)) { $langs->load("errors"); - $examplesup = '
'.$langs->trans($examplesup).'
'; + $examplesup = ''.$langs->trans($examplesup).''; $error = 1; } } @@ -202,11 +207,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } elseif ($type == 1) { return $examplesup; } else { - if ($error == 1) { - return $examplecust.' '.$examplesup; - } else { - return $examplecust.'
'.$examplesup; - } + return $examplecust.'
'.$examplesup; } } From 2ac4103af8ea42b422a572b87afad10025a5aa7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 10:20:31 +0200 Subject: [PATCH 18/25] Fix css --- htdocs/compta/sociales/list.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 365cdf93a2f..4772b9c45bd 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -451,7 +451,8 @@ if (!empty($arrayfields['p.ref']['checked'])) { if (!empty($arrayfields['cs.fk_user']['checked'])) { // Employee print ''; - print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true); + print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth150', 0, 0, true); + print ''; } // Filter: Type @@ -592,7 +593,7 @@ while ($i < min($num, $limit)) { if (isModEnabled('accounting')) { $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code; } - print ''.dol_escape_htmltag($typelabeltoshow).''; + print ''.dol_escape_htmltag($typelabeltoshow).''; if (!$i) { $totalarray['nbfield']++; } @@ -600,7 +601,7 @@ while ($i < min($num, $limit)) { // Date if (!empty($arrayfields['cs.date_ech']['checked'])) { - print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; + print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; if (!$i) { $totalarray['nbfield']++; } @@ -608,7 +609,7 @@ while ($i < min($num, $limit)) { // Date end period if (!empty($arrayfields['cs.periode']['checked'])) { - print ''.dol_print_date($db->jdate($obj->periode), 'day').''; + print ''.dol_print_date($db->jdate($obj->periode), 'day').''; if (!$i) { $totalarray['nbfield']++; } @@ -616,7 +617,7 @@ while ($i < min($num, $limit)) { // Project ref if (!empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; if ($obj->project_id > 0) { print $projectstatic->getNomUrl(1); } @@ -628,7 +629,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['cs.fk_user']['checked'])) { // Employee - print ""; + print ''; if (!empty($obj->fk_user)) { if (!empty($TLoadedUsers[$obj->fk_user])) { $ustatic = $TLoadedUsers[$obj->fk_user]; @@ -647,7 +648,7 @@ while ($i < min($num, $limit)) { // Type if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { - print ''; + print 'payment_code)).'">'; if (!empty($obj->payment_code)) { print $langs->trans("PaymentTypeShort".$obj->payment_code); } @@ -659,7 +660,7 @@ while ($i < min($num, $limit)) { // Account if (!empty($arrayfields['cs.fk_account']['checked'])) { - print ''; + print ''; if ($obj->fk_account > 0) { $bankstatic->id = $obj->fk_account; $bankstatic->ref = $obj->bref; @@ -682,7 +683,7 @@ while ($i < min($num, $limit)) { // Amount if (!empty($arrayfields['cs.amount']['checked'])) { - print ''.price($obj->amount).''; + print ''.price($obj->amount).''; if (!$i) { $totalarray['nbfield']++; } @@ -694,7 +695,7 @@ while ($i < min($num, $limit)) { // Status if (!empty($arrayfields['cs.paye']['checked'])) { - print ''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).''; + print ''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).''; if (!$i) { $totalarray['nbfield']++; } From e0f76fd8f93a37559e67af32b1a485b73be751c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 11:53:52 +0200 Subject: [PATCH 19/25] Fix modify cursor on submit after a confirmation. --- htdocs/core/class/html.form.class.php | 19 ++++++++++++++----- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0107dd8641d..5729b87cc6f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5152,7 +5152,8 @@ class Form var options = "&token='.urlencode(newToken()).'"; var inputok = '.json_encode($inputok).'; /* List of fields into form */ var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'"; - if (inputok.length>0) { + + if (inputok.length > 0) { $.each(inputok, function(i, inputname) { var more = ""; var inputvalue; @@ -5168,14 +5169,19 @@ class Form }); } var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options; - if (pageyes.length > 0) { location.href = urljump; } - $(this).dialog("close"); + if (pageyes.length > 0) { + // The call to urljump can be slow, so we set the wait cursor + jQuery("html,body,#id-container").addClass("cursorwait"); + location.href = urljump; + console.log("after location.href"); + } + $(this).dialog("close"); }, "'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() { var options = "&token='.urlencode(newToken()).'"; var inputko = '.json_encode($inputko).'; /* List of fields into form */ var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'"; - if (inputko.length>0) { + if (inputko.length > 0) { $.each(inputko, function(i, inputname) { var more = ""; if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; } @@ -5186,7 +5192,10 @@ class Form } var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options; //alert(urljump); - if (pageno.length > 0) { location.href = urljump; } + if (pageno.length > 0) { + location.href = urljump; + console.log("after location.href"); + } $(this).dialog("close"); } } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 90cc6b420f8..fc4fafc60af 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -887,6 +887,9 @@ textarea.centpercent { .cursornotallowed { cursor: not-allowed; } +.cursorwait { + cursor: wait; +} .backgroundblank { background-color: #fff; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f1c314426a2..7521172121f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1032,6 +1032,9 @@ textarea.centpercent { .cursormove { cursor: move; } +.cursorwait { + cursor: wait; +} .cursornotallowed { cursor: not-allowed; } From 3abff910357a033f28e14475488b4681a7c01eca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 12:01:15 +0200 Subject: [PATCH 20/25] Fix alternative name not visible in tooltip --- htdocs/societe/list.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 137ddd1c7cb..18999ed9a1f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1445,24 +1445,19 @@ while ($i < min($num, $limit)) { } } if (!empty($arrayfields['s.nom']['checked'])) { - $savalias = $obj->name_alias; - if (!empty($arrayfields['s.name_alias']['checked'])) { - $companystatic->name_alias = ''; - } print 'global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">'; if ($contextpage == 'poslist') { - print $obj->name; + print dol_escape_htmltag($obj->name); } else { - print $companystatic->getNomUrl(1, '', 100, 0, 1); + print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); } print "\n"; - $companystatic->name_alias = $savalias; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; + print ''; print dol_escape_htmltag($companystatic->name_alias); print "\n"; if (!$i) { @@ -1471,7 +1466,7 @@ while ($i < min($num, $limit)) { } // Barcode if (!empty($arrayfields['s.barcode']['checked'])) { - print ''.dol_escape_htmltag($obj->barcode).''; + print ''.dol_escape_htmltag($obj->barcode).''; if (!$i) { $totalarray['nbfield']++; } From 08be53494f58c33d29c3ac690710d8978db20168 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Sep 2022 17:43:34 +0200 Subject: [PATCH 21/25] trans --- htdocs/admin/system/perf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index f43bc3bf49a..fba5f9efb75 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install", "other", "admin")); +$langs->loadLangs(array("install", "other", "admin", "products")); if (!$user->admin) { accessforbidden(); From 76e8d6d36deda4b7b6d5a73b5c5ecc039948755b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Sep 2022 00:50:02 +0200 Subject: [PATCH 22/25] Avoid fatal error when multicompany not correctly installed --- htdocs/core/login/functions_ldap.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 022186b8de1..e9785ce82a8 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -233,12 +233,14 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) $usertmp = new User($db); $usertmp->fetch('', $login); - $ret = $mc->checkRight($usertmp->id, $entitytotest); - if ($ret < 0) { - dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user id '".$usertmp->id."'", LOG_NOTICE); - $login = ''; // force authentication failure + if (is_object($mc)) { + $ret = $mc->checkRight($usertmp->id, $entitytotest); + if ($ret < 0) { + dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user id '".$usertmp->id."'", LOG_NOTICE); + $login = ''; // force authentication failure + } + unset($usertmp); } - unset($usertmp); } } if ($result == 1) { From 662384ad7de705df21d9f7067297728e16eae5b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Sep 2022 01:16:59 +0200 Subject: [PATCH 23/25] Fix error message in LDAP test --- htdocs/admin/ldap_contacts.php | 2 +- htdocs/admin/ldap_groups.php | 2 +- htdocs/admin/ldap_members.php | 2 +- htdocs/admin/ldap_members_types.php | 2 +- htdocs/admin/ldap_users.php | 2 +- htdocs/core/class/ldap.class.php | 7 ++++--- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index fef3882d2ff..4e7f148672b 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -142,7 +142,7 @@ if (!function_exists("ldap_connect")) { print dol_get_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1); -print $langs->trans("LDAPDescContact").'
'; +print ''.$langs->trans("LDAPDescContact").'
'; print '
'; print ''; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 5723183735e..595afe29042 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -116,7 +116,7 @@ if (!function_exists("ldap_connect")) { print dol_get_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1); -print $langs->trans("LDAPDescGroups").'
'; +print ''.$langs->trans("LDAPDescGroups").'
'; print '
'; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 876c31d79b1..4bdec17867e 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -190,7 +190,7 @@ print ''; print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); -print $langs->trans("LDAPDescMembers").'
'; +print ''.$langs->trans("LDAPDescMembers").'
'; print '
'; print ''; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 7933b59d5e0..3c6ef9f5aa9 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -108,7 +108,7 @@ if (!function_exists("ldap_connect")) { print dol_get_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1); -print $langs->trans("LDAPDescMembersTypes").'
'; +print ''.$langs->trans("LDAPDescMembersTypes").'
'; print '
'; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index f395eb88fb4..53e142cf900 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -179,7 +179,7 @@ print ''; print dol_get_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1); -print $langs->trans("LDAPDescUsers").'
'; +print ''.$langs->trans("LDAPDescUsers").'
'; print '
'; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 6f54229c993..689fbe6845e 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -263,6 +263,7 @@ class Ldap if ($this->result) { $this->bind = $this->result; $connected = 2; + $this->connectedServer = $host; break; } else { $this->error = ldap_errno($this->connection).' '.ldap_error($this->connection); @@ -275,6 +276,7 @@ class Ldap if ($this->result) { $this->bind = $this->result; $connected = 2; + $this->connectedServer = $host; break; } else { $this->error = ldap_errno($this->connection).' '.ldap_error($this->connection); @@ -287,6 +289,7 @@ class Ldap if ($result) { $this->bind = $this->result; $connected = 1; + $this->connectedServer = $host; break; } else { $this->error = ldap_errno($this->connection).' '.ldap_error($this->connection); @@ -297,10 +300,8 @@ class Ldap if (!$connected) { $this->unbind(); - } else { - $this->connectedServer = $host; } - } + } // End loop on each server } if ($connected) { From 3c4106f6988c9170cbf0b0f8df98ce74af1a9968 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Sep 2022 03:24:36 +0200 Subject: [PATCH 24/25] Fix look and feel v16 --- htdocs/ticket/agenda.php | 18 +++++++++++------- htdocs/ticket/messaging.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index e0d06759d77..fd82269a08f 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -81,14 +81,14 @@ if (!$action) { // Security check $id = GETPOST("id", 'int'); if ($user->socid > 0) $socid = $user->socid; -$result = restrictedArea($user, 'ticket', $id, ''); +$result = restrictedArea($user, 'ticket', $object->id, ''); // restrict access for externals users if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { accessforbidden(); } // or for unauthorized internals users -if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { +if (!$user->socid && (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { accessforbidden(); } @@ -144,7 +144,7 @@ if ($socid > 0) { print dol_get_fiche_end(); } -if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { +if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) { $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; } elseif ($user->socid > 0) { $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; @@ -162,11 +162,15 @@ if ($object->fk_user_create > 0) { $langs->load("users"); $fuser = new User($db); $fuser->fetch($object->fk_user_create); - $morehtmlref .= $fuser->getNomUrl(0); -} -if (!empty($object->origin_email)) { + $morehtmlref .= $fuser->getNomUrl(-1); +} elseif (!empty($object->email_msgid)) { $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; + $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); + $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')'; +} elseif (!empty($object->origin_email)) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); + $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("CreatedByPublicPortal").')'; } // Thirdparty diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index 0abbf568c26..91904a97dab 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -50,7 +50,7 @@ if (!$sortfield) { $sortfield = "a.datep,a.id"; } if (!$sortorder) { - $sortorder = "desc"; + $sortorder = "DESC"; } $offset = $limit * $page; $pageprev = $page - 1; From c6499c52193acdfa674178c885fc47d960f0ebe6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Sep 2022 13:00:25 +0200 Subject: [PATCH 25/25] Fix cursor to wait --- htdocs/core/class/html.form.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5729b87cc6f..f0fceb521da 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5141,6 +5141,12 @@ class Form },'; } + $jsforcursor = ''; + if (empty($useajax)) { + $jsforcursor = '// The call to urljump can be slow, so we set the wait cursor'."\n"; + $jsforcursor .= 'jQuery("html,body,#id-container").addClass("cursorwait");'."\n"; + } + $formconfirm .= ' resizable: false, height: "'.$height.'", @@ -5170,8 +5176,7 @@ class Form } var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options; if (pageyes.length > 0) { - // The call to urljump can be slow, so we set the wait cursor - jQuery("html,body,#id-container").addClass("cursorwait"); + '.$jsforcursor.' location.href = urljump; console.log("after location.href"); }