Clean code, remove use of $statuts and $statuts_short

This commit is contained in:
Laurent Destailleur 2023-09-01 00:02:16 +02:00
parent 7ecf52f6a5
commit f9f5affbd2
2 changed files with 33 additions and 23 deletions

View File

@ -103,10 +103,6 @@ class Deplacement extends CommonObject
public $statut;
public $extraparams = array();
public $statuts = array();
public $statuts_short = array();
public $statuts_logo = array();
/**
* Draft status
@ -131,10 +127,6 @@ class Deplacement extends CommonObject
public function __construct(DoliDB $db)
{
$this->db = $db;
$this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded');
$this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded');
$this->statuts_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5');
}
/**
@ -222,8 +214,6 @@ class Deplacement extends CommonObject
*/
public function update($user)
{
global $langs;
// Clean parameters
$this->km = price2num($this->km);
@ -366,12 +356,21 @@ class Deplacement extends CommonObject
// phpcs:enable
global $langs;
$labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]);
$labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]);
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule@mymodule");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
$this->labelStatus[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
$this->labelStatusShort[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded');
}
$statusType = $this->statuts_logo[$status];
$status_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5');
$statusType = $status_logo[$status];
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
/**

View File

@ -659,10 +659,30 @@ abstract class CommonObject
*/
public $alreadypaid;
/**
* @var array Array with label of status
*/
public $labelStatus;
/**
* @var array array of status string
* @deprecated Use instead labelStatus
*/
public $statuts = array();
/**
* @var array Array with short label of status
*/
protected $labelStatusShort;
/**
* @var array array of short status string
* @deprecated Use instead labelStatusShort
*/
public $statuts_short = array();
/**
* @var int show photo on popup
*/
@ -673,15 +693,6 @@ abstract class CommonObject
*/
public $nb = array();
/**
* @var array array of status string
*/
public $statuts = array();
/**
* @var array array of short status string
*/
public $statuts_short = array();
/**
* @var string output