mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Clean code. Use constant for status of supplier order process.
This commit is contained in:
parent
41716281ed
commit
74deb05527
|
|
@ -18,6 +18,8 @@ Following changes may create regressions for some external modules, but were nec
|
|||
* Some REST API to access the dictionary (country, town, ...) were moved into a common API.
|
||||
* Page bank/index.php and bank/bankentries.php were renamed into bank/list.php and bank/bankentries_list.php to
|
||||
follow page naming conventions (so default filter/sort order features can also work).
|
||||
* The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed ORDER_SUPPLIER_STATUS_ORDERED
|
||||
* The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.1 compared to 6.0.* *****
|
||||
|
|
|
|||
|
|
@ -169,15 +169,11 @@ class Commande extends CommonOrder
|
|||
*/
|
||||
const STATUS_VALIDATED = 1;
|
||||
/**
|
||||
* Accepted (supplier orders)
|
||||
*/
|
||||
const STATUS_ACCEPTED = 2;
|
||||
/**
|
||||
* Shipment on process (customer orders)
|
||||
* Shipment on process
|
||||
*/
|
||||
const STATUS_SHIPMENTONPROCESS = 2;
|
||||
/**
|
||||
* Closed (Sent/Received, billed or not)
|
||||
* Closed (Sent, billed or not)
|
||||
*/
|
||||
const STATUS_CLOSED = 3;
|
||||
|
||||
|
|
@ -3225,7 +3221,7 @@ class Commande extends CommonOrder
|
|||
}
|
||||
$sql.= $clause." c.entity IN (".getEntity('commande').")";
|
||||
//$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
|
||||
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
|
||||
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
|
||||
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
|
@ -3310,7 +3306,7 @@ class Commande extends CommonOrder
|
|||
if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled');
|
||||
if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
|
||||
if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
|
||||
|
|
@ -3320,7 +3316,7 @@ class Commande extends CommonOrder
|
|||
if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
|
||||
if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
|
||||
if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
|
||||
|
|
@ -3330,7 +3326,7 @@ class Commande extends CommonOrder
|
|||
if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
|
||||
if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
|
||||
if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBillShort');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort');
|
||||
|
|
@ -3340,7 +3336,7 @@ class Commande extends CommonOrder
|
|||
if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
|
||||
if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
|
||||
if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
|
||||
if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6');
|
||||
|
|
@ -3350,7 +3346,7 @@ class Commande extends CommonOrder
|
|||
if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
|
||||
if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
|
||||
if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext;
|
||||
if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBill');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered');
|
||||
|
|
@ -3360,7 +3356,7 @@ class Commande extends CommonOrder
|
|||
if ($statut==self::STATUS_CANCELED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderCanceledShort').' </span>'.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
|
||||
if ($statut==self::STATUS_DRAFT) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDraftShort').' </span>'.img_picto($langs->trans('StatusOrderDraft'),'statut0');
|
||||
if ($statut==self::STATUS_VALIDATED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderValidatedShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
|
||||
if ($statut==self::STATUS_ACCEPTED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSentShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_SHIPMENTONPROCESS) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSentShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
|
||||
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderToBillShort').' </span>'.img_picto($langs->trans('StatusOrderToBill'),'statut4');
|
||||
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderProcessedShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
|
||||
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDeliveredShort').' </span>'.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
|
||||
|
|
|
|||
|
|
@ -294,6 +294,8 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
|
|||
{
|
||||
global $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
$alreadygrabbed=array();
|
||||
|
||||
if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
|
||||
|
|
@ -344,7 +346,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
|
|||
fputs($fp, $tmpgeturl['content']);
|
||||
fclose($fp);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +404,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
|
|||
fputs($fp, $tmpgeturl['content']);
|
||||
fclose($fp);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
@chmod($filetosave, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
|
|
@ -60,9 +60,9 @@ class CommandeFournisseur extends CommonOrder
|
|||
public $ref;
|
||||
public $ref_supplier;
|
||||
public $brouillon;
|
||||
public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
|
||||
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
|
||||
// -> 6=Canceled -> (reopen) 2=Approved
|
||||
public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Ordered/Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
|
||||
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
|
||||
// -> 6=Canceled -> (reopen) 2=Approved
|
||||
// -> 9=Refused -> (reopen) 1=Validated
|
||||
// Note: billed or not is on another field "billed"
|
||||
public $statuts; // List of status
|
||||
|
|
@ -128,10 +128,43 @@ class CommandeFournisseur extends CommonOrder
|
|||
public $multicurrency_total_tva;
|
||||
public $multicurrency_total_ttc;
|
||||
|
||||
/**
|
||||
* Draft status
|
||||
*/
|
||||
const STATUS_DRAFT = 0;
|
||||
/**
|
||||
* Draft status
|
||||
*/
|
||||
const STATUS_DRAFT = 0;
|
||||
/**
|
||||
* Validated status
|
||||
*/
|
||||
const STATUS_VALIDATED = 1;
|
||||
/**
|
||||
* Accepted
|
||||
*/
|
||||
const STATUS_ACCEPTED = 2;
|
||||
/**
|
||||
* Order sent, shipment on process
|
||||
*/
|
||||
const STATUS_ORDERSENT = 3;
|
||||
/**
|
||||
* Received partially
|
||||
*/
|
||||
const STATUS_RECEIVED_PARTIALLY = 4;
|
||||
/**
|
||||
* Received completely
|
||||
*/
|
||||
const STATUS_RECEIVED_COMPLETELY = 5;
|
||||
/**
|
||||
* Order canceled
|
||||
*/
|
||||
const STATUS_CANCELED = 6;
|
||||
/**
|
||||
* Order canceled/never received
|
||||
*/
|
||||
const STATUS_CANCELED_AFTER_ORDER = 7;
|
||||
/**
|
||||
* Refused
|
||||
*/
|
||||
const STATUS_REFUSED = 9;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -418,11 +451,11 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur";
|
||||
$sql.= " SET ref='".$this->db->escape($num)."',";
|
||||
$sql.= " fk_statut = 1,";
|
||||
$sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
|
||||
$sql.= " date_valid='".$this->db->idate(dol_now())."',";
|
||||
$sql.= " fk_user_valid = ".$user->id;
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND fk_statut = 0";
|
||||
$sql.= " AND fk_statut = ".self::STATUS_DRAFT;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
|
|
@ -477,7 +510,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
if (! $error)
|
||||
{
|
||||
$result = 1;
|
||||
$this->statut = 1;
|
||||
$this->statut = self::STATUS_VALIDATED;
|
||||
$this->ref = $num;
|
||||
}
|
||||
|
||||
|
|
@ -537,7 +570,6 @@ class CommandeFournisseur extends CommonOrder
|
|||
$statutshort[5] = 'StatusOrderReceivedAllShort';
|
||||
$statutshort[6] = 'StatusOrderCanceledShort';
|
||||
$statutshort[7] = 'StatusOrderCanceledShort';
|
||||
//$statutshort[8] = 'StatusOrderBilledShort';
|
||||
$statutshort[9] = 'StatusOrderRefusedShort';
|
||||
|
||||
if ($mode == 0)
|
||||
|
|
@ -561,7 +593,6 @@ class CommandeFournisseur extends CommonOrder
|
|||
if ($statut==4) return img_picto($langs->trans($this->statuts[$statut]),'statut3');
|
||||
if ($statut==5) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
|
||||
if ($statut==6 || $statut==7) return img_picto($langs->trans($this->statuts[$statut]),'statut5');
|
||||
if ($statut==8) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
|
||||
if ($statut==9) return img_picto($langs->trans($this->statuts[$statut]),'statut5');
|
||||
}
|
||||
if ($mode == 4)
|
||||
|
|
@ -573,7 +604,6 @@ class CommandeFournisseur extends CommonOrder
|
|||
if ($statut==4) return img_picto($langs->trans($this->statuts[$statut]),'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:'');
|
||||
if ($statut==5) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:'');
|
||||
if ($statut==6 || $statut==7) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:'');
|
||||
if ($statut==8) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:'');
|
||||
if ($statut==9) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:'');
|
||||
}
|
||||
if ($mode == 5)
|
||||
|
|
@ -585,7 +615,6 @@ class CommandeFournisseur extends CommonOrder
|
|||
if ($statut==4) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
|
||||
if ($statut==5) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut6');
|
||||
if ($statut==6 || $statut==7) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
|
||||
if ($statut==8) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut6');
|
||||
if ($statut==9) return '<span class="hideonsmartphone">'.$langs->trans($statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
|
||||
}
|
||||
}
|
||||
|
|
@ -718,7 +747,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$this->db->begin();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if (! $error)
|
||||
|
|
@ -816,10 +845,10 @@ class CommandeFournisseur extends CommonOrder
|
|||
$comment=' (second level)';
|
||||
}
|
||||
// If double approval is required and first approval, we keep status to 1 = validated
|
||||
if ($movetoapprovestatus) $sql.= ", fk_statut = 2";
|
||||
else $sql.= ", fk_statut = 1";
|
||||
if ($movetoapprovestatus) $sql.= ", fk_statut = ".self::STATUS_ACCEPTED;
|
||||
else $sql.= ", fk_statut = ".self::STATUS_VALIDATED;
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND fk_statut = 1";
|
||||
$sql.= " AND fk_statut = ".self::STATUS_VALIDATED;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
|
|
@ -869,8 +898,8 @@ class CommandeFournisseur extends CommonOrder
|
|||
{
|
||||
$this->ref = $this->newref;
|
||||
|
||||
if ($movetoapprovestatus) $this->statut = 2;
|
||||
else $this->statut = 1;
|
||||
if ($movetoapprovestatus) $this->statut = self::STATUS_ACCEPTED;
|
||||
else $this->statut = self::STATUS_VALIDATED;
|
||||
if (empty($secondlevel)) // standard or first level approval
|
||||
{
|
||||
$this->date_approve = $now;
|
||||
|
|
@ -923,7 +952,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
{
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 9";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".self::STATUS_REFUSED;
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
|
|
@ -977,7 +1006,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$result = 0;
|
||||
if ($user->rights->fournisseur->commande->commander)
|
||||
{
|
||||
$statut = 6;
|
||||
$statut = self::STATUS_CANCELED;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
|
@ -1038,13 +1067,13 @@ class CommandeFournisseur extends CommonOrder
|
|||
{
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 3, fk_input_method=".$methode.", date_commande='".$this->db->idate($date)."'";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".self::STATUS_ORDERSENT.", fk_input_method=".$methode.", date_commande='".$this->db->idate($date)."'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::commande", LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->statut = 3;
|
||||
$this->statut = self::STATUS_ORDERSENT;
|
||||
$this->methode_commande_id = $methode;
|
||||
$this->date_commande = $date;
|
||||
|
||||
|
|
@ -1145,7 +1174,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$sql.= ", '".$this->db->idate($now)."'";
|
||||
$sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
|
||||
$sql.= ", ".$user->id;
|
||||
$sql.= ", 0";
|
||||
$sql.= ", ".self::STATUS_DRAFT;
|
||||
$sql.= ", ".$this->db->escape($this->source);
|
||||
$sql.= ", '".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."'";
|
||||
$sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null');
|
||||
|
|
@ -1280,7 +1309,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$objFrom = clone $this;
|
||||
|
||||
$this->id=0;
|
||||
$this->statut=0;
|
||||
$this->statut=self::STATUS_DRAFT;
|
||||
|
||||
// Clear fields
|
||||
$this->user_author_id = $user->id;
|
||||
|
|
@ -1629,7 +1658,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
$now=dol_now();
|
||||
|
||||
if (($this->statut == 3 || $this->statut == 4 || $this->statut == 5))
|
||||
if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY))
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
|
|
@ -1952,10 +1981,10 @@ class CommandeFournisseur extends CommonOrder
|
|||
|
||||
if ($user->rights->fournisseur->commande->receptionner)
|
||||
{
|
||||
if ($type == 'par') $statut = 4;
|
||||
if ($type == 'tot') $statut = 5;
|
||||
if ($type == 'nev') $statut = 7;
|
||||
if ($type == 'can') $statut = 7;
|
||||
if ($type == 'par') $statut = self::STATUS_RECEIVED_PARTIALLY;
|
||||
if ($type == 'tot') $statut = self::STATUS_RECEIVED_COMPLETELY;
|
||||
if ($type == 'nev') $statut = self::STATUS_CANCELED_AFTER_ORDER;
|
||||
if ($type == 'can') $statut = self::STATUS_CANCELED_AFTER_ORDER;
|
||||
|
||||
// Some checks to accept the record
|
||||
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS))
|
||||
|
|
@ -1989,7 +2018,8 @@ class CommandeFournisseur extends CommonOrder
|
|||
// TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty).
|
||||
|
||||
|
||||
if (! $error && ! ($statut == 4 or $statut == 5 or $statut == 7))
|
||||
// $statut is the new statut after reception
|
||||
if (! $error && ! ($statut == self::STATUS_RECEIVED_PARTIALLY || $statut == self::STATUS_RECEIVED_COMPLETELY || $statut == self::STATUS_CANCELED_AFTER_ORDER))
|
||||
{
|
||||
$error++;
|
||||
dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR);
|
||||
|
|
@ -2003,7 +2033,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||
$sql.= " SET fk_statut = ".$statut;
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND fk_statut IN (3,4)"; // Process running or Partially received
|
||||
$sql.= " AND fk_statut IN (".self::STATUS_ORDERSENT.",".self::STATUS_RECEIVED_PARTIALLY.")"; // Process running or Partially received
|
||||
|
||||
dol_syslog(get_class($this)."::Livraison", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
|
|
@ -2226,7 +2256,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
* @param int $status New status
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setStatus($user,$status)
|
||||
public function setStatus($user, $status)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$error=0;
|
||||
|
|
@ -2245,12 +2275,11 @@ class CommandeFournisseur extends CommonOrder
|
|||
$trigger_name[0] = 'DRAFT';
|
||||
$trigger_name[1] = 'VALIDATED';
|
||||
$trigger_name[2] = 'APPROVED';
|
||||
$trigger_name[3] = 'ONPROCESS';
|
||||
$trigger_name[3] = 'ORDERED'; // Ordered
|
||||
$trigger_name[4] = 'RECEIVED_PARTIALLY';
|
||||
$trigger_name[5] = 'RECEIVED_ALL';
|
||||
$trigger_name[5] = 'RECEIVED_COMPLETELY';
|
||||
$trigger_name[6] = 'CANCELED';
|
||||
$trigger_name[7] = 'CANCELED';
|
||||
$trigger_name[8] = 'BILLED';
|
||||
$trigger_name[9] = 'REFUSED';
|
||||
|
||||
// Call trigger
|
||||
|
|
@ -2615,7 +2644,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
*/
|
||||
function load_board($user)
|
||||
{
|
||||
|
|
@ -2632,7 +2661,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$clause = " AND";
|
||||
}
|
||||
$sql.= $clause." c.entity = ".$conf->entity;
|
||||
$sql.= " AND (c.fk_statut BETWEEN 1 AND 2)";
|
||||
$sql.= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")";
|
||||
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user