From 68cd3d657ffedfc96d9835f9c5242368e45ae2fc Mon Sep 17 00:00:00 2001 From: le-reparateur <162715304+le-reparateur@users.noreply.github.com> Date: Thu, 21 Mar 2024 17:08:14 +0100 Subject: [PATCH 01/24] Update filefunc.inc.php Fix #28993 --- htdocs/filefunc.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 0c6698c736c..b6b2e7565e7 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -143,7 +143,8 @@ $result = @include_once $conffile; // Keep @ because with some error reporting m $listofwrappers = stream_get_wrappers(); // We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar by default. // phar stream does not auto unserialize content (possible code execution) since PHP 8.1 -$arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zip', 'zlib'); +// zip stream is necessary in import module +$arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zlib'); if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) { $arrayofstreamtodisable = $dolibarr_main_stream_to_disable; } From 55b86350ae474b8c4afbbf7cb60e35361c90389a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 21 Mar 2024 18:35:12 +0100 Subject: [PATCH 02/24] fix phpstan --- htdocs/core/boxes/box_members_by_tags.php | 7 +++---- htdocs/core/boxes/box_members_by_type.php | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 99c71e59063..e9f4d1c0c6a 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2023 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2021-2023 Waël Almoman * * This program is free software; you can redistribute it and/or modify @@ -140,12 +140,11 @@ class box_members_by_tags extends ModeleBoxes $line++; $AdherentTag = array(); foreach ($sumMembers as $key => $data) { - $adhtag = new Categorie($this->db); - $adhtag->id = $key; - if ($key == 'total') { break; } + $adhtag = new Categorie($this->db); + $adhtag->id = (int) $key; $adhtag->label = $data['label']; $AdherentTag[$key] = $adhtag; diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 05f886e2858..d3b065cc7ec 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2023 Frederic France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2021-2023 Waël Almoman * * This program is free software; you can redistribute it and/or modify @@ -140,12 +140,11 @@ class box_members_by_type extends ModeleBoxes $line++; $AdherentType = array(); foreach ($sumMembers as $key => $data) { - $adhtype = new AdherentType($this->db); - $adhtype->id = $key; - if ($key == 'total') { break; } + $adhtype = new AdherentType($this->db); + $adhtype->id = (int) $key; $adhtype->label = $data['label']; $AdherentType[$key] = $adhtype; From 34028bac6efc0042cb89029b7bb37cb224fbe292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 21 Mar 2024 18:39:30 +0100 Subject: [PATCH 03/24] fix phpstan --- htdocs/core/boxes/box_members_by_tags.php | 10 +++++----- htdocs/core/boxes/box_members_by_type.php | 10 +++++----- htdocs/core/boxes/box_members_last_modified.php | 4 ++-- htdocs/core/boxes/box_members_last_subscriptions.php | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index e9f4d1c0c6a..20ef8187840 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2024 Frédéric France - * Copyright (C) 2021-2023 Waël Almoman +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2024 Frédéric France + * Copyright (C) 2021-2023 Waël Almoman * * 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 diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index d3b065cc7ec..63479a55212 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2024 Frédéric France - * Copyright (C) 2021-2023 Waël Almoman +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2024 Frédéric France + * Copyright (C) 2021-2023 Waël Almoman * * 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 diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index 2ef36c822dd..a33b2b7577c 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2015-2024 Frédéric France * * 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 @@ -110,7 +110,7 @@ class box_members_last_modified extends ModeleBoxes $memberstatic->email = $objp->email; $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; - $memberstatic->statut = $objp->status; + $memberstatic->status = $objp->status; $memberstatic->date_creation = $datec; $memberstatic->date_modification = $datem; $memberstatic->need_subscription = $objp->subscription; diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 92d0413c5e7..8dbb96df25f 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2024 Frédéric France * * 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 @@ -110,7 +110,7 @@ class box_members_last_subscriptions extends ModeleBoxes $staticmember->email = $obj->email; $staticmember->photo = $obj->photo; $staticmember->morphy = $obj->morphy; - $staticmember->statut = $obj->status; + $staticmember->status = $obj->status; $staticmember->need_subscription = $obj->need_subscription; $staticmember->datefin = $this->db->jdate($obj->date_end_subscription); if (!empty($obj->fk_soc)) { From 2c1e8ff7c359236bd219405a09b40fda49cfd0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 21 Mar 2024 19:10:42 +0100 Subject: [PATCH 04/24] fix phpstan --- htdocs/core/boxes/box_graph_invoices_permonth.php | 3 ++- htdocs/core/boxes/box_graph_invoices_peryear.php | 3 ++- htdocs/core/boxes/box_graph_invoices_supplier_permonth.php | 3 ++- htdocs/core/boxes/box_graph_orders_permonth.php | 3 ++- htdocs/core/boxes/box_graph_orders_supplier_permonth.php | 3 ++- htdocs/core/boxes/box_graph_propales_permonth.php | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 74b31a3daaf..f38604467e4 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -68,7 +69,7 @@ class box_graph_invoices_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index f6decd57660..be20f7ff3c0 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -65,7 +66,7 @@ class box_graph_invoices_peryear extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 818398324c8..30cc4616d59 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -66,7 +67,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index ce11fe9e93d..182b2f5fb72 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -67,7 +68,7 @@ class box_graph_orders_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //$commandestatic=new Commande($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 9b7e40ab20f..6924bb9d9e8 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -66,7 +67,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 0192ecf2b12..5699d71e678 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -67,7 +68,7 @@ class box_graph_propales_permonth extends ModeleBoxes //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //$propalstatic=new Propal($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); if (!getDolGlobalString('GRAPH_USE_FISCAL_YEAR')) { $startmonth = 1; } From a2974f7778edf443d1ce67ccdc74649f32a96f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 21 Mar 2024 19:13:33 +0100 Subject: [PATCH 05/24] fix phpstan --- htdocs/core/boxes/box_task.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 170dd59e4b1..89f09bf5389 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2021 Frederic France + * Copyright (C) 2015-2024 Frédéric France * * 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 @@ -174,7 +174,7 @@ class box_task extends ModeleBoxes $taskstatic->ref = $objp->ref; $taskstatic->label = $objp->label; $taskstatic->progress = $objp->progress; - $taskstatic->fk_statut = $objp->fk_statut; + $taskstatic->status = $objp->fk_statut; $taskstatic->date_end = $this->db->jdate($objp->datee); $taskstatic->planned_workload = $objp->planned_workload; $taskstatic->duration_effective = $objp->duration_effective; From b4f04dbaee5e122281e54f651b03aa2df643e331 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 21 Mar 2024 20:58:59 +0100 Subject: [PATCH 06/24] new: upgrade minimum version of dolibarr for module builder --- .../modulebuilder/template/core/modules/modMyModule.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index eb3c4d656a0..4e552c0275b 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -150,7 +150,7 @@ class modMyModule extends DolibarrModules // Prerequisites $this->phpmin = array(7, 1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(17, -3); // Minimum version of Dolibarr required by module $this->need_javascript_ajax = 0; // Messages at activation From ce38158c356655af531122636ec21f1bceed86b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 21 Mar 2024 21:50:42 +0100 Subject: [PATCH 07/24] fix warnings with syslog checkconfiguration --- htdocs/admin/syslog.php | 12 +++++++++--- htdocs/core/modules/syslog/logHandler.php | 7 +++++++ htdocs/core/modules/syslog/mod_syslog_file.php | 11 +++++------ htdocs/core/modules/syslog/mod_syslog_syslog.php | 13 +++++++------ 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71dc5df45f6..5475e20d0d1 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2024 Frédéric France * * 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 @@ -112,11 +113,16 @@ if ($action == 'set') { dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure there is not a setup into another entity dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); - + $error = 0; + $errors = []; // Check configuration foreach ($activeModules as $modulename) { $module = new $modulename(); - $error = $module->checkConfiguration(); + $res = $module->checkConfiguration(); + if (!$res) { + $error++; + $errors = array_merge($errors, $module->errors); + } } @@ -125,7 +131,7 @@ if ($action == 'set') { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages('', $errors, 'errors'); } } diff --git a/htdocs/core/modules/syslog/logHandler.php b/htdocs/core/modules/syslog/logHandler.php index 0af3f304331..1672a683cb1 100644 --- a/htdocs/core/modules/syslog/logHandler.php +++ b/htdocs/core/modules/syslog/logHandler.php @@ -1,4 +1,6 @@ + */ /* * 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 @@ -24,6 +26,11 @@ class LogHandler { protected $ident = 0; + /** + * @var string[] Array of errors messages + */ + public $errors = []; + /** * Content of the info tooltip. diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 3442877dca3..5468923120e 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France */ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; @@ -78,23 +79,21 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface /** * Return if configuration is valid * - * @return array Array of errors. Empty array if ok. + * @return bool true if ok */ public function checkConfiguration() { global $langs; - $errors = array(); - $filename = $this->getFilename(); if (file_exists($filename) && is_writable($filename)) { dol_syslog('admin/syslog: file '.$filename); + return true; } else { - $errors[] = $langs->trans("ErrorFailedToOpenFile", $filename); + $this->errors[] = $langs->trans("ErrorFailedToOpenFile", $filename); + return false; } - - return $errors; } /** diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index d3931cf09eb..b2ccf4f997e 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -1,4 +1,6 @@ + */ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; @@ -77,15 +79,14 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface /** * Return if configuration is valid * - * @return array Array of errors. Empty array if ok. + * @return bool True if ok. */ public function checkConfiguration() { global $conf, $langs; - $errors = array(); + $facility = constant(getDolGlobalString('SYSLOG_FACILITY')); - $facility = constant($conf->global->SYSLOG_FACILITY); if ($facility) { // Only LOG_USER supported on Windows if (!empty($_SERVER["WINDIR"])) { @@ -93,11 +94,11 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface } dol_syslog("admin/syslog: facility ".$facility); + return true; } else { - $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); + $this->errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); + return false; } - - return $errors; } /** From c76ab41c91926ee168fd27a3e33a84e11ef03e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 21 Mar 2024 21:52:02 +0100 Subject: [PATCH 08/24] fix warnings with syslog checkconfiguration --- htdocs/core/modules/syslog/logHandler.php | 4 ++-- htdocs/core/modules/syslog/logHandlerInterface.php | 4 +++- htdocs/core/modules/syslog/mod_syslog_syslog.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/syslog/logHandler.php b/htdocs/core/modules/syslog/logHandler.php index 1672a683cb1..e7ec4dbc567 100644 --- a/htdocs/core/modules/syslog/logHandler.php +++ b/htdocs/core/modules/syslog/logHandler.php @@ -87,11 +87,11 @@ class LogHandler * It will be called after setting the configuration. * The function returns an array with error messages * - * @return array + * @return bool */ public function checkConfiguration() { - return array(); + return true; } /** diff --git a/htdocs/core/modules/syslog/logHandlerInterface.php b/htdocs/core/modules/syslog/logHandlerInterface.php index 15ab436f4fa..2613d50f755 100644 --- a/htdocs/core/modules/syslog/logHandlerInterface.php +++ b/htdocs/core/modules/syslog/logHandlerInterface.php @@ -1,4 +1,6 @@ + */ /* * 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 @@ -79,7 +81,7 @@ interface LogHandlerInterface /** * Output log content * - * @param string $content Content to log + * @param array $content Content to log * @return void */ public function export($content); diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index b2ccf4f997e..8d1457fa2ec 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -83,7 +83,7 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface */ public function checkConfiguration() { - global $conf, $langs; + global $langs; $facility = constant(getDolGlobalString('SYSLOG_FACILITY')); From 1fa7013313dcebe6845d1fbe91ad90bf9b5acbb7 Mon Sep 17 00:00:00 2001 From: brad Date: Fri, 22 Mar 2024 15:11:52 +1100 Subject: [PATCH 09/24] FIX Add state/province filter to email adv select --- htdocs/comm/mailing/advtargetemailing.php | 2 +- htdocs/core/tpl/advtarget.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index e0098643747..e135b8ab378 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -1,4 +1,4 @@ - * Copyright (C) 2016 Laurent Destailleur * diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 42aba1b10ba..efd80c5141d 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -1,4 +1,4 @@ - * Copyright (C) 2024 Frédéric France */ From d351005cb1a893b102feaa360d7b5ac43d847297 Mon Sep 17 00:00:00 2001 From: brad Date: Fri, 22 Mar 2024 15:19:18 +1100 Subject: [PATCH 10/24] FIX Add state/province filter to email adv select --- htdocs/comm/mailing/advtargetemailing.php | 2 +- .../mailing/class/advtargetemailing.class.php | 9 +++ .../html.formadvtargetemailing.class.php | 62 +++++++++++++++++++ htdocs/core/tpl/advtarget.tpl.php | 16 ++++- 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index e0098643747..e135b8ab378 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -1,4 +1,4 @@ - * Copyright (C) 2016 Laurent Destailleur * diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index e97f3d6df66..28bdb0b02d8 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -584,6 +584,9 @@ class AdvanceTargetingMailing extends CommonObject if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman']) > 0) { $sqlwhere[] = " (saleman.fk_user IN (".$this->db->sanitize(implode(',', $arrayquery['cust_saleman']))."))"; } + if (!empty($arrayquery['cust_state']) && count($arrayquery['cust_state']) > 0) { + $sqlwhere[] = " (t.fk_departement IN (".$this->db->sanitize(implode(',', $arrayquery['cust_state']))."))"; + } if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country']) > 0) { $sqlwhere[] = " (t.fk_pays IN (".$this->db->sanitize(implode(',', $arrayquery['cust_country']))."))"; } @@ -825,6 +828,12 @@ class AdvanceTargetingMailing extends CommonObject if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman']) > 0) { $sqlwhere[] = " (saleman.fk_user IN (".$this->db->sanitize(implode(',', $arrayquery['cust_saleman']))."))"; } + //if (!empty($arrayquery['cust_state'])) { + // $sqlwhere[] = $this->transformToSQL('tsd.nom', $arrayquery['cust_state']); + //} + if (!empty($arrayquery['cust_state']) && count($arrayquery['cust_state']) > 0) { + $sqlwhere[] = " (t.fk_departement IN (".$this->db->sanitize(implode(',', $arrayquery['cust_state']))."))"; + } if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country']) > 0) { $sqlwhere[] = " (ts.fk_pays IN (".$this->db->sanitize(implode(',', $arrayquery['cust_country']))."))"; } diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 70f7c9ba975..5ec9be92dbc 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -87,6 +87,68 @@ class FormAdvTargetEmailing extends Form return $this->advMultiselectarray($htmlname, $options_array, $selected_array); } + /** + * Return combo list of activated countries, into language of user + * + * @param string $htmlname of html select object + * @param array $selected_array or Code or Label of preselected country + * @return string HTML string with select + */ + public function multiselectState($htmlname = 'state_id', $selected_array = array()) + { + global $conf, $langs; + + $langs->load("dict"); + $maxlength = 0; + + $out = ''; + $countryArray = array(); + $label = array(); + + $options_array = array(); + + $sql = "SELECT d.rowid as rowid, d.code_departement as code_iso, d.nom as department, r.nom as region"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions r on d.fk_region=r.code_region"; + $sql .= " WHERE d.active = 1 AND d.code_departement<>''"; + //$sql .= " ORDER BY r.nom ASC, d.nom ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + if ($num) { + $foundselected = false; + + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + $stateArray [$i] ['rowid'] = $obj->rowid; + $stateArray [$i] ['code_iso'] = $obj->code_iso; + $stateArray [$i] ['label'] = $obj->region.'/'.$obj->department; + //($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); + $label[$i] = $stateArray[$i]['label']; + $i++; + } + + $array1_sort_order = SORT_ASC; + array_multisort($label, $array1_sort_order, $stateArray); + + foreach ($stateArray as $row) { + $label = dol_trunc($row['label'], $maxlength, 'middle'); + if ($row['code_iso']) { + $label .= ' ('.$row['code_iso'].')'; + } + + $options_array[$row['rowid']] = $label; + } + } + } else { + dol_print_error($this->db); + } + + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); + } + /** * Return combo list of activated countries, into language of user * diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 42aba1b10ba..0741286c1c8 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -1,4 +1,4 @@ - * Copyright (C) 2024 Frédéric France */ @@ -110,9 +110,9 @@ if (!empty($array_query['cust_code'])) { print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); $cust_code_str = (string) $array_query['cust_code']; } else { - $cust_code_str = "null"; + $cust_code_str = null; } -print ''."\n"; +print ''."\n"; print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); print ''."\n"; @@ -143,6 +143,16 @@ print ''."\n"; +// State Client +print ''.$langs->trans('State'); +if (!empty($array_query['cust_state'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''."\n"; +print $formadvtargetemaling->multiselectState('cust_state', $array_query['cust_state']); +print ''."\n"; +print ''."\n"; + // Customer Country print ''.$langs->trans("Country"); if (!empty($array_query['cust_country'])) { From ca36c740e519d424354cda614c31afd0b36867ea Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 21 Mar 2024 17:15:19 +0100 Subject: [PATCH 11/24] "Qual: Add dependencies between workflows # Qual: Add dependencies between workflows Run costly workflows only after a few workflows succeed (pre-commit, phan). --- .github/workflows/README.md | 16 ++++++ .github/workflows/ci.yml | 40 +++++++++++++++ .github/workflows/gh-travis.yml | 49 +++++++++++++++++++ .github/workflows/phan.yml | 21 +++++--- .github/workflows/phpstan.yml | 42 ++++++++++------ .github/workflows/pre-commit.yml | 21 +++++--- .../{windows-ci.yaml => windows-ci.yml} | 15 ++++-- 7 files changed, 172 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/gh-travis.yml rename .github/workflows/{windows-ci.yaml => windows-ci.yml} (94%) diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000000..fbe406e6c46 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,16 @@ +# Workflow run order + +To reduce run minutes, the following order is put in place: + +On PR & Merge, always run: + +- pre-commit; +- phan. + +When both succeed, start: + +- phpstan; +- Windows-ci; +- travis. + +See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..39edbc3496b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: "CI" + +on: [push, pull_request] +jobs: + pre-commit: + uses: ./.github/workflows/pre-commit.yml + secrets: inherit + with: + gh_event: ${{ github.event_name }} + phan: + uses: ./.github/workflows/phan.yml + secrets: inherit + with: + gh_event: ${{ github.event_name }} + phpstan: + uses: ./.github/workflows/phpstan.yml + secrets: inherit + needs: [pre-commit, phan] + with: + gh_event: ${{ github.event_name }} + windows-ci: + needs: [pre-commit, phan] + secrets: inherit + uses: ./.github/workflows/windows-ci.yml + with: + gh_event: ${{ github.event_name }} + gh-travis: # Runs travis script on github runner (not on travis) + if: false + # needs: [pre-commit, phan] + # needs: [windows-ci] + secrets: inherit + uses: ./.github/workflows/gh-travis.yml + with: + gh_event: ${{ github.event_name }} + + +# Note (not tested, from https://github.com/orgs/community/discussions/38361) +# To cancel jobs if one failes, the following action may help +# - if: "failure()" +# uses: "andymckay/cancel-action@0.3" diff --git a/.github/workflows/gh-travis.yml b/.github/workflows/gh-travis.yml new file mode 100644 index 00000000000..30c10765f07 --- /dev/null +++ b/.github/workflows/gh-travis.yml @@ -0,0 +1,49 @@ +--- +# This runs a travis script inside a github runner +name: Travis +# Controls when the workflow will run +on: + # push: + # pull_request: + workflow_call: + inputs: + gh_event: + required: true + type: string + workflow_dispatch: + +concurrency: + group: travis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + }} + cancel-in-progress: true +env: + gh_event: ${{ inputs.gh_event || github.event_name }} + GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job + gh-travis: + # The type of runner that the job will run on + runs-on: ubuntu-latest + strategy: + fail-fast: false + # matrix: + # php-version: + # # PHPStan requires PHP >= 7.2. + # #- "7.2" + # - "8.2" + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout travis file + uses: actions/checkout@v4 + - name: Run .travis.yml build script + uses: ktomk/run-travis-yml@v1 + with: + # run-job: travis # name of a job in travis file + allow-failure: false + # file: .travis.yml + # steps: | # Default: setup, before_install, install, before_script, script, after_script, before_deploy + # install + # script + # env: + # TRAVIS_PHP_VERSION: ${{ matrix.php-version }} diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml index 67bec077a13..f233c24907c 100644 --- a/.github/workflows/phan.yml +++ b/.github/workflows/phan.yml @@ -1,16 +1,22 @@ --- on: - pull_request: - push: - schedule: - # execute once a day, the 1st - - cron: 10 9 * * * + # pull_request: + # push: + # schedule: + # # execute once a day, the 1st + # - cron: 10 9 * * * + workflow_call: + inputs: + gh_event: + required: true + type: string workflow_dispatch: + concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: phan-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: - # Do pull analysis on schedule or manual dispatch + gh_event: ${{ inputs.gh_event || github.event_name }} PHAN_CONFIG: > ${{ ( github.event.schedule || github.event_name == 'workflow_dispatch' ) @@ -21,6 +27,7 @@ env: PHAN_MIN_PHP: 7.0 PHAN_QUICK: ${{ github.event.schedule && '' || '--quick' }} GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action + name: phan jobs: phan: diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index cbe0f4b2732..c638ee83e50 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,16 +1,25 @@ +--- # This is a basic workflow to check code with PHPSTAN tool - -name: "PHPStan" - +name: PHPStan # Controls when the workflow will run -on: [push, pull_request] -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true +on: + # push: + # pull_request: + workflow_call: + inputs: + gh_event: + required: true + type: string + workflow_dispatch: +concurrency: + group: stan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + }} + cancel-in-progress: true env: - CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} - GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action + gh_event: ${{ inputs.gh_event || github.event_name }} + CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || github.event_name == 'pull_request' ) && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} + GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job @@ -23,7 +32,7 @@ jobs: php-version: # PHPStan requires PHP >= 7.2. #- "7.2" - - "8.2" + - '8.2' # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -34,9 +43,10 @@ jobs: id: setup-php uses: shivammathur/setup-php@v2 with: - php-version: "${{ matrix.php-version }}" + php-version: ${{ matrix.php-version }} tools: phpstan, cs2pr - extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, mysql, pgsql, sqlite3, ldap, xml, mcrypt + extensions: calendar, json, imagick, gd, zip, mbstring, intl, opcache, imap, + mysql, pgsql, sqlite3, ldap, xml, mcrypt # Restore old cache - name: Restore phpstan cache @@ -44,7 +54,8 @@ jobs: uses: actions/cache/restore@v4 with: path: ./.github/tmp - key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }} + key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ + github.run_id }} restore-keys: | phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}- phpstan-cache-${{ matrix.php-version }}-${{ github.head_ref }}- @@ -61,12 +72,13 @@ jobs: # continue-on-error: true # Save cache - - name: "Save phpstan cache" + - name: Save phpstan cache uses: actions/cache/save@v4 if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }} with: path: ./.github/tmp - key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }} + key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ + github.run_id }} - name: Provide phpstan log as artifact uses: actions/upload-artifact@v4 if: ${{ always() }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 671a266c767..f113a8a7a36 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,8 +1,17 @@ --- name: pre-commit on: - pull_request: - push: + # pull_request: + # push: + workflow_call: + inputs: + gh_event: + required: true + type: string + workflow_dispatch: + +env: + gh_event: ${{ inputs.gh_event || github.event_name }} jobs: pre-commit: runs-on: ubuntu-latest @@ -20,7 +29,7 @@ jobs: - name: Get all changed php files (if PR) id: changed-php uses: tj-actions/changed-files@v43 - if: github.event_name == 'pull_request' + if: env.gh_event == 'pull_request' with: files: | **.php @@ -58,7 +67,7 @@ jobs: # - name: Get all changed php files (if PR) # id: changed-php # uses: tj-actions/changed-files@v43 - # if: github.event_name == 'pull_request' + # if: env.gh_event == 'pull_request' # with: # files: | # **.php @@ -72,7 +81,7 @@ jobs: steps.changed-php.outputs.any_changed == 'true' || ( - github.event_name == 'push' + env.gh_event == 'push' && ( github.event.ref == 'refs/heads/develop' || endsWith(github.event.ref, '.0') @@ -94,7 +103,7 @@ jobs: - name: Run some pre-commit hooks on all files on push to "main" branches if: | - github.event_name == 'push' + env.gh_event == 'push' && ( github.event.ref == 'refs/heads/develop' || endsWith(github.event.ref, '.0') diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yml similarity index 94% rename from .github/workflows/windows-ci.yaml rename to .github/workflows/windows-ci.yml index cb467055156..f85ad2535be 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yml @@ -2,19 +2,26 @@ name: Win CI # yamllint disable-line rule:truthy on: - push: - pull_request: + # push: + # pull_request: + workflow_call: + inputs: + gh_event: + required: true + type: string workflow_dispatch: + concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + group: win-ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: + gh_event: ${{ inputs.gh_event || github.event_name }} PHPUNIT_LOG: phpunit_tests.log DOLIBARR_LOG: documents/dolibarr.log PHPSERVER_LOG: phpserver.log PHPSERVER_DOMAIN_PORT: 127.0.0.1:8000 # could be 127.0.0.1:8000 if config modified - CACHE_KEY_PART: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} + CACHE_KEY_PART: ${{ ( inputs.gh_event == 'pull_request' || github.event_name == 'pull_request' ) && format('{0}-{1}', github.base_ref, github.head_ref) || github.ref_name }} PHP_INI_SCAN_DIR: C:\myphpini CKEY: win-ci-2 GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action From df13bc5ab4b15b5530cb4d4bde95007094293fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 22 Mar 2024 12:24:52 +0100 Subject: [PATCH 12/24] fetch last_main_doc in invoice supplier --- htdocs/fourn/class/fournisseur.facture.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 845053a4d89..0acfd1a66d7 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -887,6 +887,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " t.note_private,"; $sql .= " t.note_public,"; $sql .= " t.model_pdf,"; + $sql .= " t.last_main_doc,"; $sql .= " t.import_key,"; $sql .= " t.extraparams,"; $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_label, cr.libelle_facture as cond_reglement_doc,"; @@ -967,6 +968,7 @@ class FactureFournisseur extends CommonInvoice $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; $this->import_key = $obj->import_key; //Incoterms From b78766b904b3e8b49bcfd4b934433c82f50779b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 22 Mar 2024 12:28:56 +0100 Subject: [PATCH 13/24] fetch last_main_doc in invoice supplier --- .../core/modules/supplier_invoice/doc/pdf_canelle.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3327e63506d..9e71c73b268 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -125,7 +125,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /* if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $this->posxtva = $this->posxup; } */ - $this->posxpicture = $this->posxtva - (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxpicture = $this->posxtva - (getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20)); // width of images if ($this->page_largeur < 210) { // To work with US executive format $this->posxpicture -= 20; $this->posxtva -= 20; From 828cf2cbce4098c067eb92f09fef36703bb50d71 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 22 Mar 2024 14:20:03 +0100 Subject: [PATCH 14/24] NEW now button when editing an event --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 9b688ac3d3e..cae65bdc3f5 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1916,9 +1916,9 @@ if ($id > 0) { */ print ''; $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); print '     -     '; - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); print ''; print ' '; From 4d6bd2a8e004df59c1c43ba04692229acea040a2 Mon Sep 17 00:00:00 2001 From: Can Arslan <138895927+mc2rcanarslan@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:17:39 -0600 Subject: [PATCH 15/24] FIX: PHP Warning: Undefined properties --- htdocs/comm/action/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index a7118ccffcf..dbc0b02d8bf 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -267,7 +267,7 @@ if (empty($reshook)) { $objectlabel = 'Events'; $uploaddir = true; // Only users that can delete any event can remove records. - $permissiontodelete = $user->rights->agenda->allactions->delete; + $permissiontodelete = $user->hasRight('agenda', 'allactions', 'delete'); $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create'); include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -708,7 +708,7 @@ $url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); -$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')); +$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')); $param .= '&mode='.$mode; From 1282e6840e95710804458bafded99238cb7fefc5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Mar 2024 11:58:55 +0100 Subject: [PATCH 16/24] FIX navigation after filter in subaccount --- htdocs/accountancy/admin/subaccount.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index fb9a61e36d0..38e672e132d 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -128,6 +128,7 @@ $form = new Form($db); // Page Header $help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); + llxHeader('', $title, $help_url); @@ -300,14 +301,17 @@ if ($resql) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } if ($search_subaccount) { $param .= '&search_subaccount='.urlencode($search_subaccount); } if ($search_label) { $param .= '&search_label='.urlencode($search_label); } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); + if ($search_type) { + $param .= '&search_type='.urlencode($search_type); } // List of mass actions available @@ -373,7 +377,7 @@ if ($resql) { print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch '); } if (!empty($arrayfields['subaccount']['checked'])) { print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder); @@ -391,7 +395,7 @@ if ($resql) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch '); } print "\n"; From 8d1e21150021dc0ee48f93c984dc3086ceed8e68 Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 23 Mar 2024 16:50:34 +0100 Subject: [PATCH 17/24] Fix access to db results (fix PhanNonClassMethodCall) Fixed the access to db results - may need to be backported --- htdocs/accountancy/bookkeeping/balance.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 0b5b0005694..697962ef486 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -473,9 +473,12 @@ if ($action != 'export_csv') { $resql = $db->query($sql); $nrows = $resql->num_rows; $opening_balances = array(); - for ($i = 0; $i < $nrows; $i++) { - $arr = $resql->fetch_array(); - $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; + if ($resql) { + $nrows = $db->num_rows($resql); + for ($i = 0; $i < $nrows; $i++) { + $arr = $db->fetch_array($resql); + $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; + } } } From ce274c403efc0459cabcea891cfa5e7dad649467 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Mar 2024 19:06:54 +0100 Subject: [PATCH 18/24] Depreciate a method usage --- htdocs/core/db/Database.interface.php | 25 +++++++++++++------------ htdocs/core/db/mysqli.class.php | 1 - 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 9613688e753..1cedec5b34f 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -40,8 +40,9 @@ interface Database /** * Return datas as an array * - * @param resource $resultset Resultset of request - * @return array Array + * @param resource $resultset Resultset of request + * @return array Array + * @deprecated Use fetch_object() so you can access a field with its name instead of using an index of position of field. */ public function fetch_row($resultset); // phpcs:enable @@ -441,6 +442,16 @@ interface Database ); // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * List information of columns into a table. + * + * @param string $table Name of table + * @return array Array with information on table + */ + public function DDLInfoTable($table); + // phpcs:enable + /** * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) * 19700101020000 -> 3600 with TZ+1 and gmt=0 @@ -470,16 +481,6 @@ interface Database */ public function commit($log = ''); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * List information of columns into a table. - * - * @param string $table Name of table - * @return array Array with information on table - */ - public function DDLInfoTable($table); - // phpcs:enable - /** * Free last resultset used. * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 7fc92bf23ff..485477d052d 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -481,7 +481,6 @@ class DoliDBMysqli extends DoliDB return $this->db->affected_rows; } - /** * Libere le dernier resultset utilise sur cette connection * From 27ad9573f64a57a85a8eeea579d238f3670f41c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Mar 2024 19:32:08 +0100 Subject: [PATCH 19/24] Debug v20 --- htdocs/blockedlog/admin/blockedlog_list.php | 2 +- htdocs/compta/accounting-files.php | 6 +++--- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index fb8f92d9e12..2604e35f362 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -379,7 +379,7 @@ if (GETPOST('withtab', 'alpha')) { // Add $param from extra fields //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -print '
'; +print ''; print ''; print '
'; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 05351d41713..36b12bf6b36 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -72,7 +72,7 @@ $date_stopMonth = GETPOSTINT('date_stopmonth'); $date_stopYear = GETPOSTINT('date_stopyear'); $date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel'); $action = GETPOST('action', 'aZ09'); -$projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : 0); +$projectid = GETPOSTINT('projectid'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('comptafileslist', 'globallist')); @@ -667,7 +667,7 @@ foreach ($listofchoices as $choice => $val) { $disabled = ' disabled'; } $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); - print '