Clean constructors

This commit is contained in:
Laurent Destailleur 2018-04-21 16:01:05 +02:00
parent 912d5c53f2
commit 06e51703b1

View File

@ -184,23 +184,9 @@ class CommandeFournisseur extends CommonOrder
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf;
$this->db = $db; $this->db = $db;
$this->products = array();
// TODO Move in LibStatut $this->products = array();
$this->statuts[0] = 'StatusOrderDraft';
$this->statuts[1] = 'StatusOrderValidated';
$this->statuts[2] = 'StatusOrderApproved';
if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess';
else $this->statuts[3] = 'StatusOrderOnProcessWithValidation';
$this->statuts[4] = 'StatusOrderReceivedPartially';
$this->statuts[5] = 'StatusOrderReceivedAll';
$this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled
$this->statuts[7] = 'StatusOrderCanceled'; // Process running->canceled
//$this->statuts[8] = 'StatusOrderBilled'; // Everything is finished, order received totally and bill received
$this->statuts[9] = 'StatusOrderRefused';
} }
@ -586,13 +572,23 @@ class CommandeFournisseur extends CommonOrder
* @return string Label of status * @return string Label of status
*/ */
function LibStatut($statut,$mode=0,$billed=0) function LibStatut($statut,$mode=0,$billed=0)
{
if (empty($this->statuts) || empty($statutshort))
{ {
global $langs; global $langs;
$langs->load('orders'); $langs->load('orders');
$billedtext=''; $this->statuts[0] = 'StatusOrderDraft';
//if ($statut==5 && $this->billed == 1) $statut = 8; $this->statuts[1] = 'StatusOrderValidated';
if ($billed == 1) $billedtext=$langs->trans("Billed"); $this->statuts[2] = 'StatusOrderApproved';
if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess';
else $this->statuts[3] = 'StatusOrderOnProcessWithValidation';
$this->statuts[4] = 'StatusOrderReceivedPartially';
$this->statuts[5] = 'StatusOrderReceivedAll';
$this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled
$this->statuts[7] = 'StatusOrderCanceled'; // Process running->canceled
//$this->statuts[8] = 'StatusOrderBilled'; // Everything is finished, order received totally and bill received
$this->statuts[9] = 'StatusOrderRefused';
// List of language codes for status // List of language codes for status
$statutshort[0] = 'StatusOrderDraftShort'; $statutshort[0] = 'StatusOrderDraftShort';
@ -604,6 +600,13 @@ class CommandeFournisseur extends CommonOrder
$statutshort[6] = 'StatusOrderCanceledShort'; $statutshort[6] = 'StatusOrderCanceledShort';
$statutshort[7] = 'StatusOrderCanceledShort'; $statutshort[7] = 'StatusOrderCanceledShort';
$statutshort[9] = 'StatusOrderRefusedShort'; $statutshort[9] = 'StatusOrderRefusedShort';
}
$langs->load('orders');
$billedtext='';
//if ($statut==5 && $this->billed == 1) $statut = 8;
if ($billed == 1) $billedtext=$langs->trans("Billed");
if ($mode == 0) if ($mode == 0)
{ {