From 0fe46b53d855ac0cfb56ab8c1fdff70195456ff2 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 13 Jul 2021 15:18:40 +0200 Subject: [PATCH 1/6] FIX : method_exists needs object at first param --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index bb648a71625..f0bf57485a9 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -262,7 +262,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) // Remove a line if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { - if (method_exists('deleteline', $object)) { + if (method_exists($object, 'deleteline')) { $result = $object->deleteline($user, $lineid); // For backward compatibility } else { $result = $object->deleteLine($user, $lineid); From cd5e1d603e8dc26e312dc1d186298749537a847f Mon Sep 17 00:00:00 2001 From: Alexis LAURIER Date: Wed, 14 Jul 2021 12:02:03 +0200 Subject: [PATCH 2/6] fix showInputField checkbox and radio type --- htdocs/core/class/commonobject.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9e6204bd364..a726987c607 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5898,7 +5898,10 @@ abstract class CommonObject $type = 'varchar'; } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { $param['options'] = $this->fields[$key]['arrayofkeyval']; - $type = 'select'; + $type = $this->fields[$key]['type']; + if(!in_array($type, array('select', 'checkbox', 'radio'))) { + $type = 'select'; + } } else { $param['options'] = array(); $type = $this->fields[$key]['type']; From b552c6b4fe012d64511875795c837e8e9eda707d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 14:32:05 +0200 Subject: [PATCH 3/6] Fix status color --- htdocs/compta/facture/list.php | 2 +- htdocs/holiday/class/holiday.class.php | 8 ++++++-- htdocs/holiday/list.php | 3 ++- htdocs/langs/en_US/main.lang | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index cc52984d6d4..f25b2b05975 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1043,7 +1043,7 @@ if ($resql) { $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= ''; } - // If the user can view prospects other than his' + // Filter on product tags if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 2b0641ff9ae..82229198185 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1251,6 +1251,8 @@ class Holiday extends CommonObject public function LibStatut($status, $mode = 0, $startdate = '') { // phpcs:enable + global $langs; + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); @@ -1266,9 +1268,11 @@ class Holiday extends CommonObject $this->labelStatusShort[self::STATUS_REFUSED] = $langs->trans('RefuseCP'); } + $params = array(); $statusType = 'status6'; - if (!empty($startdate) && $startdate > dol_now()) { + if (!empty($startdate) && $startdate >= dol_now()) { // If not yet passed, we use a green "in live" color $statusType = 'status4'; + $params = array('tooltip'=>$this->labelStatus[$status].' - '.$langs->trans("Forthcoming")); } if ($status == self::STATUS_DRAFT) { $statusType = 'status0'; @@ -1283,7 +1287,7 @@ class Holiday extends CommonObject $statusType = 'status5'; } - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode, '', $params); } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index ece1f9c9ec7..ab57a497e8e 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -730,6 +730,7 @@ if ($resql) { $holidaystatic->id = $obj->rowid; $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); $holidaystatic->statut = $obj->status; + $holidaystatic->date_debut = $db->jdate($obj->date_debut); // User $userstatic->id = $obj->fk_user; @@ -790,7 +791,7 @@ if ($resql) { } if (!empty($arrayfields['duration']['checked'])) { print ''; - $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates print $nbopenedday.' '.$langs->trans('DurationDays'); print ''; if (!$i) { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 863b94af564..94c851bf346 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1137,3 +1137,4 @@ CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. ConfirmCancel=Are you sure you want to cancel EmailMsgID=Email MsgID +Forthcoming=Forthcoming \ No newline at end of file From a773652c04e4158ab9661e48db7fac0b97106dcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 14:37:07 +0200 Subject: [PATCH 4/6] Fix phpcs --- 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 51254bede5d..d050af4883a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5918,8 +5918,10 @@ abstract class CommonObject } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { $param['options'] = $this->fields[$key]['arrayofkeyval']; $type = $this->fields[$key]['type']; - if(!in_array($type, array('select', 'checkbox', 'radio'))) { + if (!in_array($type, array('select', 'checkbox', 'radio'))) { $type = 'select'; + } else { + $type = $this->fields[$key]['type']; } } else { $param['options'] = array(); From 901a158238d9e7071f1981f3ea77596eaa743894 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 17:19:43 +0200 Subject: [PATCH 5/6] Fix backward compatibility --- htdocs/societe/class/societe.class.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index eff2ba39c21..422a3f118d8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1280,7 +1280,8 @@ class Societe extends CommonObject $this->get_codefournisseur($this, 1); } - $this->code_compta = trim($this->code_compta); + $this->code_compta_client = trim(empty($this->code_compta) ? $this->code_compta_client : $this->code_compta); + $this->code_compta = $this->code_compta_client; // for backward compatbility $this->code_compta_fournisseur = trim($this->code_compta_fournisseur); // Check parameters. More tests are done later in the ->verify() @@ -1292,8 +1293,8 @@ class Societe extends CommonObject $customer = false; if (!empty($allowmodcodeclient) && !empty($this->client)) { - // Attention get_codecompta peut modifier le code suivant le module utilise - if (empty($this->code_compta)) { + // If $allowmodcodeclient is set and value is not set, we generate it + if (empty($this->code_compta_client)) { $ret = $this->get_codecompta('customer'); if ($ret < 0) { return -1; @@ -1305,8 +1306,8 @@ class Societe extends CommonObject $supplier = false; if (!empty($allowmodcodefournisseur) && !empty($this->fournisseur)) { - // Attention get_codecompta peut modifier le code suivant le module utilise - if ($this->code_compta_fournisseur == "") { + // If $allowmodcodefournisseur is set and value is not set, we generate it + if (empty($this->code_compta_fournisseur)) { $ret = $this->get_codecompta('supplier'); if ($ret < 0) { return -1; @@ -1460,7 +1461,7 @@ class Societe extends CommonObject if ($customer) { $sql .= ", code_client = ".(!empty($this->code_client) ? "'".$this->db->escape($this->code_client)."'" : "null"); - $sql .= ", code_compta = ".(!empty($this->code_compta) ? "'".$this->db->escape($this->code_compta)."'" : "null"); + $sql .= ", code_compta = ".(!empty($this->code_compta_client) ? "'".$this->db->escape($this->code_compta_client)."'" : "null"); } if ($supplier) { @@ -3311,7 +3312,8 @@ class Societe extends CommonObject $result = $mod->get_code($this->db, $this, $type); if ($type == 'customer') { - $this->code_compta = $mod->code; + $this->code_compta_client = $mod->code; + $this->code_compta = $this->code_compta_client; // For backward compatibility } elseif ($type == 'supplier') { $this->code_compta_fournisseur = $mod->code; } @@ -3323,6 +3325,7 @@ class Societe extends CommonObject } } else { if ($type == 'customer') { + $this->code_compta_client = ''; $this->code_compta = ''; } elseif ($type == 'supplier') { $this->code_compta_fournisseur = ''; From 83d931f3c740f88b1e15e09f3ccb87b76959fb4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jul 2021 17:40:36 +0200 Subject: [PATCH 6/6] FIX #18143 --- htdocs/core/lib/functions.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a53162b7f2c..6e259e3c7fb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6828,6 +6828,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray = array_merge($substitutionarray, array( '__MYCOMPANY_NAME__' => $mysoc->name, '__MYCOMPANY_EMAIL__' => $mysoc->email, + '__MYCOMPANY_PHONE__' => $mysoc->phone, + '__MYCOMPANY_FAX__' => $mysoc->fax, '__MYCOMPANY_PROFID1__' => $mysoc->idprof1, '__MYCOMPANY_PROFID2__' => $mysoc->idprof2, '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,