diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 2ba78b32945..bf2b3a0e410 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -4380,10 +4380,10 @@ class Product extends CommonObject
/**
* Return label of a given status
*
- * @param int $status 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 $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
- * @return string Label of status
+ * @param int $status Statut
+ * @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
+ * @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
+ * @return string Label of status
*/
public function LibStatut($status, $mode = 0, $type = 0)
{
@@ -4420,42 +4420,41 @@ class Product extends CommonObject
$statuttrans=empty($status)?'status5':'status4';
- if($status == 0){
+ if ($status == 0) {
// $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
- if($type==0){
+ if($type==0) {
$labelstatut = $langs->trans('ProductStatusNotOnSellShort');
$labelstatutShort = $langs->trans('ProductStatusNotOnSell');
}
- elseif($type == 1){
+ elseif($type == 1) {
$labelstatut = $langs->trans('ProductStatusNotOnBuyShort');
$labelstatutShort = $langs->trans('ProductStatusNotOnBuy');
}
- elseif($type == 2){
+ elseif($type == 2) {
$labelstatut = $langs->trans('ProductStatusNotOnBatch');
$labelstatutShort = $langs->trans('ProductStatusNotOnBatchShort');
}
}
- elseif($status == 1){
+ elseif ($status == 1) {
// $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch"
- if($type==0){
+ if ($type==0) {
$labelstatut = $langs->trans('ProductStatusOnSellShort');
$labelstatutShort = $langs->trans('ProductStatusOnSell');
}
- elseif($type == 1){
+ elseif ($type == 1) {
$labelstatut = $langs->trans('ProductStatusOnBuyShort');
$labelstatutShort = $langs->trans('ProductStatusOnBuy');
}
- elseif($type == 2){
+ elseif ($type == 2) {
$labelstatut = $langs->trans('ProductStatusOnBatch');
$labelstatutShort = $langs->trans('ProductStatusOnBatchShort');
}
}
- if($mode>6){
+ if ($mode > 6) {
return dolGetStatus($langs->trans('Unknown'), '', '', 'status0', 0);
- }
- else{
+ } else {
return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode);
}
}
diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index a92d2cd071a..477dcc20b0c 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -360,10 +360,10 @@ if ($result)
print '';
}
print '
';
- print $product_static->LibStatut($objp->tosell, 3, 0);
+ print $product_static->LibStatut($objp->tosell, 5, 0);
print " | ";
print '';
- print $product_static->LibStatut($objp->tobuy, 3, 1);
+ print $product_static->LibStatut($objp->tobuy, 5, 1);
print " | ";
print "\n";
$i++;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index b20f80f5439..fe8c78c7aa2 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2258,8 +2258,8 @@ class Societe extends CommonObject
/**
* Return label of status (activity, closed)
*
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @return string Libelle
+ * @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 of status
*/
public function getLibStatut($mode = 0)
{
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 5bd493fdeba..b2962478b17 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -316,7 +316,7 @@ if ($result)
print dol_print_date($thirdparty_static->datem, 'day');
print "";
print '';
- print $thirdparty_static->getLibStatut(3);
+ print $thirdparty_static->getLibStatut(5);
print " | ";
print "\n";
$i++;
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index db919c9bf0a..6e7d2540d32 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -201,6 +201,12 @@ class User extends CommonObject
'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name','enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
);
+
+ const STATUS_DISABLED = 0;
+ const STATUS_ENABLED = 1;
+
+
+
/**
* Constructor of the class
*
@@ -2478,48 +2484,31 @@ class User extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoi le libelle d'un statut donne
+ * Return label of a status of user (active, inactive)
*
- * @param int $statut Id statut
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + 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 of status
*/
- public function LibStatut($statut, $mode = 0)
+ public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
- $langs->load('users');
- if ($mode == 0)
+ if (empty($this->labelstatus) || empty($this->labelstatusshort))
{
- if ($statut == 1) return $langs->trans('Enabled');
- elseif ($statut == 0) return $langs->trans('Disabled');
- }
- elseif ($mode == 1)
- {
- if ($statut == 1) return $langs->trans('Enabled');
- elseif ($statut == 0) return $langs->trans('Disabled');
- }
- elseif ($mode == 2)
- {
- if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
- elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
- }
- elseif ($mode == 3)
- {
- if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
- elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
- }
- elseif ($mode == 4)
- {
- if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
- elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
- }
- elseif ($mode == 5)
- {
- if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
- elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
+ global $langs;
+ //$langs->load("mymodule");
+ $this->labelstatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
+ $this->labelstatus[self::STATUS_DISABLED] = $langs->trans('Disabled');
+ $this->labelstatusshort[self::STATUS_ENABLED] = $langs->trans('Enabled');
+ $this->labelstatusshort[self::STATUS_DISABLED] = $langs->trans('Disabled');
}
+
+ $statusType = 'status5';
+ if ($status == self::STATUS_ENABLED) $statusType = 'status4';
+
+ return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
}
diff --git a/htdocs/user/list.php b/htdocs/user/list.php
index 3b334871c06..668f05fa6c2 100644
--- a/htdocs/user/list.php
+++ b/htdocs/user/list.php
@@ -677,7 +677,7 @@ while ($i < min($num, $limit))
if (! empty($arrayfields['u.statut']['checked']))
{
$userstatic->statut=$obj->statut;
- print ''.$userstatic->getLibStatut(3).' | ';
+ print ''.$userstatic->getLibStatut(5).' | ';
if (! $i) $totalarray['nbfield']++;
}
// Action column