diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 02e39149364..f1c65395d79 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -817,34 +817,7 @@ class BOM extends CommonObject $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); - } + return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', 'status'.$status, $mode); } /** diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f26f44f4837..a9b77b38ff2 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -664,34 +664,7 @@ class MyObject extends CommonObject $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } + return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', 'status'.$status, $mode); } /** diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 6c1841a4a85..06c8f583f44 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -125,7 +125,7 @@ class modMyModule extends DolibarrModules $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mymodule@mymodule"); $this->phpmin = array(5,5); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module + $this->need_dolibarr_version = array(11,-3); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 384893269ce..03085c89d3e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -553,34 +553,7 @@ class Mo extends CommonObject $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); - } + return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', 'status'.$status, $mode); } /** diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index e9284781a5d..775ffcf3e5c 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -57,7 +57,7 @@ class Inventory extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_RECORDED = 2; - const STATUS_CANCELED = 9; + const STATUS_CANCELED = -1; /** * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') @@ -396,49 +396,16 @@ class Inventory extends CommonObject // phpcs:enable global $langs; - if ($mode == 0) + if (empty($this->labelstatus)) { - $prefix=''; - if ($status == 0) return $langs->trans('Draft'); - elseif ($status == 1) return $langs->trans('Enabled'); - elseif ($status == -1) return $langs->trans('Canceled'); - } - elseif ($mode == 1) - { - if ($status == 0) return $langs->trans('Draft'); - elseif ($status == 1) return $langs->trans('Enabled'); - elseif ($status == -1) return $langs->trans('Canceled'); - } - elseif ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - elseif ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == -1) return img_picto($langs->trans('Canceled'), 'statut6').' '.$langs->trans('Canceled'); - } - elseif ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == -1) return img_picto($langs->trans('Canceled'), 'statut6'); - } - elseif ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - elseif ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == -1) return img_picto($langs->trans('Canceled'), 'statut6').' '.$langs->trans('Canceled'); - } - elseif ($mode == 5) - { - if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'), 'statut6'); - } - elseif ($mode == 6) - { - if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'), 'statut6'); + global $langs; + //$langs->load("mrp"); + $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); } + + return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', 'status'.$status, $mode); } /** diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bee290878c1..e4e0eb0b11c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2188,44 +2188,39 @@ class SupplierProposal extends CommonObject /** * Return label of a status (draft, validated, ...) * - * @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 = 1) + public function LibStatut($status, $mode = 1) { // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); - } - $statuttrans=''; - if ($statut==0) $statuttrans='statut0'; - elseif ($statut==1) $statuttrans='statut1'; - elseif ($statut==2) $statuttrans='statut3'; - elseif ($statut==3) $statuttrans='statut5'; - elseif ($statut==4) $statuttrans='statut6'; + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelstatut[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelstatut[self::STATUS_VALIDATED]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelstatut[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelstatut[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelstatut[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelstatut_short[self::STATUS_DRAFT]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelstatut_short[self::STATUS_VALIDATED]=$langs->trans("Opened"); + $this->labelstatut_short[self::STATUS_SIGNED]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelstatut_short[self::STATUS_NOTSIGNED]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelstatut_short[self::STATUS_CLOSE]=$langs->trans("SupplierProposalStatusClosedShort"); + } - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + $statusnew=''; + if ($status==self::STATUS_DRAFT) $statusnew='status0'; + elseif ($status==self::STATUS_VALIDATED) $statusnew='status1'; + elseif ($status==self::STATUS_SIGNED) $statusnew='status3'; + elseif ($status==self::STATUS_NOTSIGNED) $statusnew='status5'; + elseif ($status==self::STATUS_CLOSE) $statusnew='status6'; + + return dolGetStatus($this->labelstatut[$status], $this->labelstatut_short[$status], '', $statusnew, $mode); }