From edc4dc3727dd0fed9e04e17287fe54ca6bae67e1 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:20:07 +0200 Subject: [PATCH 1/7] Fix project libStatus to use new dolGetStatus --- htdocs/projet/class/project.class.php | 51 ++++++++------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 027fe6503b2..2382f93c17a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -942,48 +942,27 @@ class Project extends CommonObject /** * Renvoi status label for a status * - * @param int $statut id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $status id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; - if ($mode == 0) { - return $langs->trans($this->statuts_long[$statut]); - } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); - } elseif ($mode == 2) { - if ($statut == 0) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); - elseif ($statut == 1) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); - elseif ($statut == 2) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); - } elseif ($mode == 3) { - if ($statut == 0) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); - elseif ($statut == 1) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); - elseif ($statut == 2) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); - } elseif ($mode == 4) { - if ($statut == 0) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); - elseif ($statut == 1) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); - if ($statut == 2) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); - } elseif ($mode == 5) { - if ($statut == 0) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); - elseif ($statut == 1) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); - elseif ($statut == 2) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); + $statustrans = array( + 0 => 'status0', + 1 => 'status4', + 2 => 'status6', + ); + + $statusClass = 'status0'; + if(!empty($statustrans[$status])){ + $statusClass = $statustrans[$status]; } + + return dolGetStatus($this->statuts_long[$status], $this->statuts_short[$status], '', $statusClass, $mode); + } /** From 77f666a23695c441d79334e6e3678c851089693d Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:28:11 +0200 Subject: [PATCH 2/7] Fix dolGetStatus param --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aa594a694cd..7b617471fca 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8164,13 +8164,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel; if ($displayMode == 3) { - $return = dolGetBadge($statusLabel, '', $statusType, 'dot'); + $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url); } elseif ($displayMode === 5) { - $return = dolGetBadge($statusLabelShort, $html, $statusType); + $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url); } else { - $return = dolGetBadge($statusLabel, $html, $statusType); + $return = dolGetBadge($statusLabel, $html, $statusType, '', $url); } } From 027c8224b0f6003ff4a5e12a5293149145449888 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:34:01 +0200 Subject: [PATCH 3/7] Fix dolGetStatus unused --- htdocs/core/lib/functions.lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b617471fca..dab617f5e19 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8109,6 +8109,11 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $return = ''; + $dolGetBadgeParams = array(); + if(!empty($params['badgeParams'])){ + $dolGetBadgeParams = $params['badgeParams']; + } + // image's filename are still in French $statusImg=array( 'status0' => 'statut0' @@ -8164,13 +8169,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel; if ($displayMode == 3) { - $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url); + $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url, $dolGetBadgeParams); } elseif ($displayMode === 5) { - $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url); + $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url, $dolGetBadgeParams); } else { - $return = dolGetBadge($statusLabel, $html, $statusType, '', $url); + $return = dolGetBadge($statusLabel, $html, $statusType, '', $url, $dolGetBadgeParams); } } From 35c6008e1afbe5d7f79a61add30e4792dbedd9f2 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:58:23 +0200 Subject: [PATCH 4/7] Fix supplier order libStatus to use new dolGetStatus --- .../class/fournisseur.commande.class.php | 77 +++++++------------ 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d8f760330b8..0b2d9022b58 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -625,18 +625,17 @@ class CommandeFournisseur extends CommonOrder /** * Return label of a status * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @param int $billed 1=Billed * @return string Label of status */ - public function LibStatut($statut, $mode = 0, $billed = 0) + public function LibStatut($status, $mode = 0, $billed = 0) { // phpcs:enable global $conf, $langs; - if (empty($this->statuts) || empty($this->statutshort)) - { + if (empty($this->statuts) || empty($this->statutshort)){ $langs->load('orders'); $this->statuts[0] = 'StatusSupplierOrderDraft'; @@ -662,55 +661,33 @@ class CommandeFournisseur extends CommonOrder $this->statutshort[9] = 'StatusSupplierOrderRefusedShort'; } - $billedtext=''; - //if ($statut==5 && $this->billed == 1) $statut = 8; - if ($billed == 1) $billedtext=$langs->trans("Billed"); + $statustrans = array( + 0 => 'status0', + 1 => 'status1', + 2 => 'status3', + 3 => 'status3', + 4 => 'status3', + 5 => 'status6', + 6 => 'status5', + 7 => 'status5', - if ($mode == 0) - { - return $langs->trans($this->statuts[$statut]); + 9 => 'status5', + ); + + $statusClass = 'status0'; + if(!empty($statustrans[$status])){ + $statusClass = $statustrans[$status]; } - elseif ($mode == 1) - { - return $langs->trans($this->statutshort[$statut]); - } - elseif ($mode == 2) - { - return $langs->trans($this->statuts[$statut]); - } - elseif ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==4) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==5) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - elseif ($statut==6 || $statut==7) return img_picto($langs->trans($this->statuts[$statut]), 'statut5'); - elseif ($statut==9) return img_picto($langs->trans($this->statuts[$statut]), 'statut5'); - } - elseif ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==4) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==5) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==6 || $statut==7) return img_picto($langs->trans($this->statuts[$statut]), 'statut5').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==9) return img_picto($langs->trans($this->statuts[$statut]), 'statut5').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - } - elseif ($mode == 5) - { - if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==3) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==4) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==5) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - elseif ($statut==6 || $statut==7) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut5'); - elseif ($statut==9) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut5'); + + $billedtext = ''; + if($mode == 4 && $billed){ + $billedtext = ' - '.$langs->trans("Billed"); } + + $statusLong = $langs->trans($this->statuts_long[$status]).$billedtext; + $statusShort = $langs->trans($this->statutshort[$status]); + + return dolGetStatus($statusLong, $statusShort, '', $statusClass, $mode); } From 5932f0e6b18e32bad9612c712c67178a8d1959ca Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Oct 2019 20:03:23 +0000 Subject: [PATCH 5/7] Fixing style errors. --- htdocs/projet/class/project.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2382f93c17a..4f38fdbe49c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -962,7 +962,6 @@ class Project extends CommonObject } return dolGetStatus($this->statuts_long[$status], $this->statuts_short[$status], '', $statusClass, $mode); - } /** From 13e456d992e278c743d419cad7f7d4ccf747d02b Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 22:05:48 +0200 Subject: [PATCH 6/7] Fix Project LibStatus langs --- htdocs/projet/class/project.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2382f93c17a..d24cbb144fb 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -949,6 +949,7 @@ class Project extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable + global $langs; $statustrans = array( 0 => 'status0', @@ -961,7 +962,7 @@ class Project extends CommonObject $statusClass = $statustrans[$status]; } - return dolGetStatus($this->statuts_long[$status], $this->statuts_short[$status], '', $statusClass, $mode); + return dolGetStatus($langs->trans($this->statuts_long[$status]), $langs->trans($this->statuts_short[$status]), '', $statusClass, $mode); } From cb34c7e29970c43355ae7e7c90d37858b49344f7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Oct 2019 20:08:42 +0000 Subject: [PATCH 7/7] Fixing style errors. --- htdocs/projet/class/project.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d24cbb144fb..e14cd53c3c3 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -963,7 +963,6 @@ class Project extends CommonObject } return dolGetStatus($langs->trans($this->statuts_long[$status]), $langs->trans($this->statuts_short[$status]), '', $statusClass, $mode); - } /**