From ce37323f697be20d84d03173238b1e8dbdc680e1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 13 Oct 2021 14:14:30 +0200 Subject: [PATCH 01/10] FIX avoid non-numeric warning --- htdocs/core/lib/invoice.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 193c4c3acb7..7c0dbbd084c 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -518,8 +518,10 @@ function getNumberInvoicesPieChart($mode) $dataseries[$i]=array($langs->trans('NbOfOpenInvoices'), $obj->nblate30, $obj->nblate15 - $obj->nblate30, $obj->nblatenow - $obj->nblate15, $obj->nbnotlatenow - $obj->nbnotlate15, $obj->nbnotlate15 - $obj->nbnotlate30, $obj->nbnotlate30); $i++; } - foreach ($dataseries[0] as $key=>$value) { - $total += $value; + if (!empty($dataseries[0])) { + foreach ($dataseries[0] as $key=>$value) { + $total += $value; + } } $legend = array( $langs->trans('InvoiceLate30Days'), From f14de50bd787a932c9a15eced029467322395292 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 13 Oct 2021 14:26:43 +0200 Subject: [PATCH 02/10] FIX check if numeric value --- htdocs/core/lib/invoice.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 7c0dbbd084c..573f27c1eee 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -519,8 +519,10 @@ function getNumberInvoicesPieChart($mode) $i++; } if (!empty($dataseries[0])) { - foreach ($dataseries[0] as $key=>$value) { - $total += $value; + foreach ($dataseries[0] as $key => $value) { + if (is_numeric($value)) { + $total += $value; + } } } $legend = array( From b612815aed93e514bed30678e07aa82bc5d7451b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 13 Oct 2021 14:43:42 +0200 Subject: [PATCH 03/10] FIX wrong accented characters with DolGraph --- htdocs/contrat/class/contrat.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a7a42ca7350..a23a620359e 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2770,20 +2770,20 @@ class ContratLigne extends CommonObjectLine $langs->load("contracts"); if ($status == self::STATUS_INITIAL) { - $labelStatus = $langs->trans("ServiceStatusInitial"); - $labelStatusShort = $langs->trans("ServiceStatusInitial"); + $labelStatus = $langs->transnoentities("ServiceStatusInitial"); + $labelStatusShort = $langs->transnoentities("ServiceStatusInitial"); } elseif ($status == self::STATUS_OPEN && $expired == -1) { - $labelStatus = $langs->trans("ServiceStatusRunning"); - $labelStatusShort = $langs->trans("ServiceStatusRunning"); + $labelStatus = $langs->transnoentities("ServiceStatusRunning"); + $labelStatusShort = $langs->transnoentities("ServiceStatusRunning"); } elseif ($status == self::STATUS_OPEN && $expired == 0) { - $labelStatus = $langs->trans("ServiceStatusNotLate"); - $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); + $labelStatus = $langs->transnoentities("ServiceStatusNotLate"); + $labelStatusShort = $langs->transnoentities("ServiceStatusNotLateShort"); } elseif ($status == self::STATUS_OPEN && $expired == 1) { - $labelStatus = $langs->trans("ServiceStatusLate"); - $labelStatusShort = $langs->trans("ServiceStatusLateShort"); + $labelStatus = $langs->transnoentities("ServiceStatusLate"); + $labelStatusShort = $langs->transnoentities("ServiceStatusLateShort"); } elseif ($status == self::STATUS_CLOSED) { - $labelStatus = $langs->trans("ServiceStatusClosed"); - $labelStatusShort = $langs->trans("ServiceStatusClosed"); + $labelStatus = $langs->transnoentities("ServiceStatusClosed"); + $labelStatusShort = $langs->transnoentities("ServiceStatusClosed"); } $statusType = 'status'.$status; From 412746ec8fea883dc437e6f3135d33773bc02be9 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 15 Oct 2021 10:18:32 +0200 Subject: [PATCH 04/10] NEW : we need to be able to put more filters on deleteByParentField() function --- htdocs/core/class/commonobject.class.php | 24 ++++++++++++++++++++++-- htdocs/hrm/class/job.class.php | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 37083cdf5f8..2bf6d758435 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9056,10 +9056,13 @@ abstract class CommonObject $className = str_replace('@', '', $deleteFromObject[0]); $filePath = $deleteFromObject[1]; $columnName = $deleteFromObject[2]; + $TMoreSQL = array(); + $more_sql = $deleteFromObject[3]; + if(!empty($more_sql)) $TMoreSQL['customsql'] = $more_sql; if (dol_include_once($filePath)) { $childObject = new $className($this->db); if (method_exists($childObject, 'deleteByParentField')) { - $result = $childObject->deleteByParentField($this->id, $columnName); + $result = $childObject->deleteByParentField($this->id, $columnName, $TMoreSQL); if ($result < 0) { $error++; $this->errors[] = $childObject->error; @@ -9144,7 +9147,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @throws Exception */ - public function deleteByParentField($parentId = 0, $parentField = '') + public function deleteByParentField($parentId = 0, $parentField = '', $filter=array(), $filtermode="AND") { global $user; @@ -9157,6 +9160,23 @@ abstract class CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE ".$parentField." = ".(int) $parentId; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; + } + $resql = $this->db->query($sql); if (!$resql) { $this->errors[] = $this->db->lasterror(); diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 4ff5ccbe303..01cc9260c61 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -154,7 +154,7 @@ class Job extends CommonObject // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object // */ - // protected $childtablesoncascade = array('hrm_jobdet'); + protected $childtablesoncascade = array("@SkillRank:hrm/class/skillrank.class.php:fk_object:objecttype='job'"); // /** // * @var JobLine[] Array of subtable lines From 5ef681ef912f8e07a51fa14467037d78809c3628 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 15 Oct 2021 10:36:47 +0200 Subject: [PATCH 05/10] FIX : stickler --- htdocs/core/class/commonobject.class.php | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2bf6d758435..8689f7c26d1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9058,7 +9058,7 @@ abstract class CommonObject $columnName = $deleteFromObject[2]; $TMoreSQL = array(); $more_sql = $deleteFromObject[3]; - if(!empty($more_sql)) $TMoreSQL['customsql'] = $more_sql; + if (!empty($more_sql)) $TMoreSQL['customsql'] = $more_sql; if (dol_include_once($filePath)) { $childObject = new $className($this->db); if (method_exists($childObject, 'deleteByParentField')) { @@ -9144,10 +9144,12 @@ abstract class CommonObject * * @param int $parentId Parent Id * @param string $parentField Name of Foreign key parent column + * @param array $filter an array filter + * @param string $filtermode AND or OR * @return int <0 if KO, >0 if OK * @throws Exception */ - public function deleteByParentField($parentId = 0, $parentField = '', $filter=array(), $filtermode="AND") + public function deleteByParentField($parentId = 0, $parentField = '', $filter = array(), $filtermode = "AND") { global $user; @@ -9160,22 +9162,22 @@ abstract class CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE ".$parentField." = ".(int) $parentId; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { + // Manage filters + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { if ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; - } + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; + } $resql = $this->db->query($sql); if (!$resql) { From 26c50b9e2ca2c43ab20ce786e39310fd5d481875 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 15 Oct 2021 11:59:12 +0200 Subject: [PATCH 06/10] add setting to create PDF in PDF/A - 1b format #18990 --- htdocs/admin/pdf.php | 12 ++++++++++++ htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 13 insertions(+) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index be45a2101f5..a245c9338c9 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -165,6 +165,10 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('PDF_USE_1A')) { + dolibarr_set_const($db, "PDF_USE_1A", GETPOST('PDF_USE_1A', 'alpha'), 'chaine', 0, '', $conf->entity); + } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); @@ -534,6 +538,14 @@ if ($conf->use_javascript_ajax) { } print ''; +print ''.$langs->trans("PDF_USE_1A").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_USE_1A'); +} else { + print $form->selectyesno('PDF_USE_1A', (!empty($conf->global->PDF_USE_1A)) ? $conf->global->PDF_USE_1A : 0, 1); +} +print ''; + print ''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index def603e653e..81034e4aacd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2194,3 +2194,4 @@ LanguageAndPresentation=Language and presentation SkinAndColors=Skin and colors IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax +PDF_USE_1A=Generate PDF with PDF/A- 1b format From bbbc58ec024150a8727cb646191471b81968ddf5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Oct 2021 18:55:34 +0200 Subject: [PATCH 07/10] Update admin.lang --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 81034e4aacd..0cf17545b5f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2194,4 +2194,4 @@ LanguageAndPresentation=Language and presentation SkinAndColors=Skin and colors IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax -PDF_USE_1A=Generate PDF with PDF/A- 1b format +PDF_USE_1A=Generate PDF with PDF/A-1b format From 5dfbd3642fc299d781cb1a8bca7b9fe2a70bf4a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Oct 2021 19:03:20 +0200 Subject: [PATCH 08/10] Update pdf.php --- htdocs/admin/pdf.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index a245c9338c9..fdb0dae6ff0 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -165,8 +165,8 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity); } - if (GETPOSTISSET('PDF_USE_1A')) { - dolibarr_set_const($db, "PDF_USE_1A", GETPOST('PDF_USE_1A', 'alpha'), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('PDF_USE_A')) { + dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -538,11 +538,11 @@ if ($conf->use_javascript_ajax) { } print ''; -print ''.$langs->trans("PDF_USE_1A").''; +print ''.$langs->trans("PDF_USE_A").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PDF_USE_1A'); + print ajax_constantonoff('PDF_USE_A'); } else { - print $form->selectyesno('PDF_USE_1A', (!empty($conf->global->PDF_USE_1A)) ? $conf->global->PDF_USE_1A : 0, 1); + print $form->selectyesno('PDF_USE_A', (empty($conf->global->PDF_USE_1A) ? 0 : $conf->global->PDF_USE_A, 1); } print ''; From bbe867a7a97fb9c86191471a19577a21cbdd3281 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Oct 2021 19:06:50 +0200 Subject: [PATCH 09/10] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8689f7c26d1..ad99ef4fff3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9169,9 +9169,9 @@ abstract class CommonObject if ($key == 'customsql') { $sqlwhere[] = $value; } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; } } } From 9469c0dc2b922e66a82b36a294e3739b6a4f6f36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Oct 2021 19:10:50 +0200 Subject: [PATCH 10/10] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ad99ef4fff3..c9740951fc9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9058,7 +9058,9 @@ abstract class CommonObject $columnName = $deleteFromObject[2]; $TMoreSQL = array(); $more_sql = $deleteFromObject[3]; - if (!empty($more_sql)) $TMoreSQL['customsql'] = $more_sql; + if (!empty($more_sql)) { + $TMoreSQL['customsql'] = $more_sql; + } if (dol_include_once($filePath)) { $childObject = new $className($this->db); if (method_exists($childObject, 'deleteByParentField')) {