Implemented constants in Commande, Facture and Propal

This commit is contained in:
Marcos García de La Fuente 2015-03-15 11:48:57 +01:00
parent 0170d409d3
commit 094538c07b
14 changed files with 199 additions and 133 deletions

View File

@ -146,7 +146,7 @@ if (empty($reshook))
// Reopen a closed order // Reopen a closed order
else if ($action == 'reopen' && $user->rights->commande->creer) else if ($action == 'reopen' && $user->rights->commande->creer)
{ {
if ($object->statut == 3) if ($object->statut == Commande::STATUS_CLOSED)
{ {
$result = $object->set_reopen($user); $result = $object->set_reopen($user);
if ($result > 0) if ($result > 0)
@ -1793,7 +1793,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$absolute_discount = price2num($absolute_discount, 'MT'); $absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT');
if ($absolute_discount) { if ($absolute_discount) {
if ($object->statut > 0) { if ($object->statut > Commande::STATUS_DRAFT) {
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
} else { } else {
// Remise dispo de type remise fixe (not credit note) // Remise dispo de type remise fixe (not credit note)
@ -2065,7 +2065,7 @@ if ($action == 'create' && $user->rights->commande->creer)
<input type="hidden" name="id" value="' . $object->id . '"> <input type="hidden" name="id" value="' . $object->id . '">
'; ';
if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { if (! empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
} }
@ -2080,7 +2080,7 @@ if ($action == 'create' && $user->rights->commande->creer)
/* /*
* Form to add new line * Form to add new line
*/ */
if ($object->statut == 0 && $user->rights->commande->creer) if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer)
{ {
if ($action != 'editline') if ($action != 'editline')
{ {
@ -2110,7 +2110,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// modified by hook // modified by hook
if (empty($reshook)) { if (empty($reshook)) {
// Valid // Valid
if ($object->statut == 0 && $object->total_ttc >= 0 && $numlines > 0 && if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
) )
@ -2118,7 +2118,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
} }
// Edit // Edit
if ($object->statut == 1 && $user->rights->commande->creer) { if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
} }
// Create event // Create event
@ -2129,7 +2129,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>'; print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>';
} }
// Send // Send
if ($object->statut > 0) { if ($object->statut > Commande::STATUS_DRAFT) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=presend&amp;mode=init">' . $langs->trans('SendByMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=presend&amp;mode=init">' . $langs->trans('SendByMail') . '</a></div>';
} else } else
@ -2141,7 +2141,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
$numshipping = $object->nb_expedition(); $numshipping = $object->nb_expedition();
if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfProductsLines() > 0) { if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfProductsLines() > 0) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) {
if ($user->rights->expedition->creer) { if ($user->rights->expedition->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('ShipProduct') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('ShipProduct') . '</a></div>';
@ -2159,7 +2159,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if ($conf->ficheinter->enabled) { if ($conf->ficheinter->enabled) {
$langs->load("interventions"); $langs->load("interventions");
if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfServicesLines() > 0) { if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
if ($user->rights->ficheinter->creer) { if ($user->rights->ficheinter->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans('AddIntervention') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans('AddIntervention') . '</a></div>';
} else { } else {
@ -2169,12 +2169,12 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
// Reopen a closed order // Reopen a closed order
if ($object->statut == 3 && $user->rights->commande->creer) { if ($object->statut == Commande::STATUS_CLOSED && $user->rights->commande->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=reopen">' . $langs->trans('ReOpen') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
} }
// Create contract // Create contract
if ($conf->contrat->enabled && ($object->statut == 1 || $object->statut == 2)) { if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED)) {
$langs->load("contracts"); $langs->load("contracts");
if ($user->rights->contrat->creer) { if ($user->rights->contrat->creer) {
@ -2184,17 +2184,17 @@ if ($action == 'create' && $user->rights->commande->creer)
// Create bill and Classify billed // Create bill and Classify billed
// Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed"
if ($object->statut > 0 && ! $object->billed) { if ($object->statut > Commande::STATUS_DRAFT && ! $object->billed) {
if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>';
} }
if ($user->rights->commande->creer && $object->statut > 2 && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { if ($user->rights->commande->creer && $object->statut > Commande::STATUS_ACCEPTED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>';
} }
} }
// Set to shipped // Set to shipped
if (($object->statut == 1 || $object->statut == 2) && $user->rights->commande->cloturer) { if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED) && $user->rights->commande->cloturer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>';
} }
@ -2204,7 +2204,7 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
// Cancel order // Cancel order
if ($object->statut == 1 && $user->rights->commande->annuler) { if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->annuler) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';
} }

View File

@ -60,10 +60,39 @@ class Commande extends CommonOrder
var $ref_int; var $ref_int;
var $contactid; var $contactid;
var $fk_project; var $fk_project;
var $statut; // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) /**
* Status of the commande. Check the following constants:
* - STATUS_CANCELED
* - STATUS_DRAFT
* - STATUS_ACCEPTED
* - STATUS_CLOSED
* @var int
*/
var $statut;
var $facturee; // deprecated var $facturee; // deprecated
var $billed; // billed or not var $billed; // billed or not
/**
* Canceled status
*/
const STATUS_CANCELED = -1;
/**
* Draft status
*/
const STATUS_DRAFT = 0;
/**
* Validated status
*/
const STATUS_VALIDATED = 1;
/**
* Accepted/On process not managed for customer orders
*/
const STATUS_ACCEPTED = 2;
/**
* Closed (Sent/Received, billed or not)
*/
const STATUS_CLOSED = 3;
var $brouillon; var $brouillon;
var $cond_reglement_id; var $cond_reglement_id;
var $cond_reglement_code; var $cond_reglement_code;
@ -194,7 +223,7 @@ class Commande extends CommonOrder
$error=0; $error=0;
// Protection // Protection
if ($this->statut == 1) if ($this->statut == self::STATUS_VALIDATED)
{ {
dol_syslog(get_class($this)."::valid no draft status", LOG_WARNING); dol_syslog(get_class($this)."::valid no draft status", LOG_WARNING);
return 0; return 0;
@ -233,7 +262,7 @@ class Commande extends CommonOrder
// Validate // Validate
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET ref = '".$num."',"; $sql.= " SET ref = '".$num."',";
$sql.= " fk_statut = 1,"; $sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
$sql.= " date_valid='".$this->db->idate($now)."',"; $sql.= " date_valid='".$this->db->idate($now)."',";
$sql.= " fk_user_valid = ".$user->id; $sql.= " fk_user_valid = ".$user->id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
@ -323,7 +352,7 @@ class Commande extends CommonOrder
if (! $error) if (! $error)
{ {
$this->ref = $num; $this->ref = $num;
$this->statut = 1; $this->statut = self::STATUS_VALIDATED;
} }
if (! $error) if (! $error)
@ -352,7 +381,7 @@ class Commande extends CommonOrder
$error=0; $error=0;
// Protection // Protection
if ($this->statut <= 0) if ($this->statut <= self::STATUS_DRAFT)
{ {
return 0; return 0;
} }
@ -367,7 +396,7 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET fk_statut = 0"; $sql.= " SET fk_statut = ".self::STATUS_DRAFT;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); dol_syslog(get_class($this)."::set_draft", LOG_DEBUG);
@ -393,7 +422,7 @@ class Commande extends CommonOrder
if (!$error) if (!$error)
{ {
$this->statut=0; $this->statut=self::STATUS_DRAFT;
$this->db->commit(); $this->db->commit();
return $result; return $result;
} }
@ -405,7 +434,7 @@ class Commande extends CommonOrder
} }
} }
$this->statut=0; $this->statut=self::STATUS_DRAFT;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -430,7 +459,7 @@ class Commande extends CommonOrder
global $conf,$langs; global $conf,$langs;
$error=0; $error=0;
if ($this->statut != 3) if ($this->statut != self::STATUS_CLOSED)
{ {
dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING); dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING);
return 0; return 0;
@ -439,7 +468,7 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET fk_statut=1, facture=0'; $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG); dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
@ -460,7 +489,7 @@ class Commande extends CommonOrder
if (! $error) if (! $error)
{ {
$this->statut = 1; $this->statut = self::STATUS_VALIDATED;
$this->billed = 0; $this->billed = 0;
$this->facturee = 0; // deprecated $this->facturee = 0; // deprecated
@ -499,10 +528,10 @@ class Commande extends CommonOrder
$now=dol_now(); $now=dol_now();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET fk_statut = 3,'; $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.',';
$sql.= ' fk_user_cloture = '.$user->id.','; $sql.= ' fk_user_cloture = '.$user->id.',';
$sql.= " date_cloture = '".$this->db->idate($now)."'"; $sql.= " date_cloture = '".$this->db->idate($now)."'";
$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 ($this->db->query($sql))
{ {
@ -513,7 +542,7 @@ class Commande extends CommonOrder
if (! $error) if (! $error)
{ {
$this->statut=3; $this->statut=self::STATUS_CLOSED;
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -550,9 +579,9 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET fk_statut = -1"; $sql.= " SET fk_statut = ".self::STATUS_CANCELED;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND fk_statut = 1"; $sql.= " AND fk_statut = ".self::STATUS_VALIDATED;
dol_syslog(get_class($this)."::cancel", LOG_DEBUG); dol_syslog(get_class($this)."::cancel", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -591,7 +620,7 @@ class Commande extends CommonOrder
if (! $error) if (! $error)
{ {
$this->statut=-1; $this->statut=self::STATUS_CANCELED;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -906,7 +935,7 @@ class Commande extends CommonOrder
} }
$this->id=0; $this->id=0;
$this->statut=0; $this->statut=self::STATUS_DRAFT;
// Clear fields // Clear fields
$this->user_author_id = $user->id; $this->user_author_id = $user->id;
@ -1151,7 +1180,7 @@ class Commande extends CommonOrder
// Check parameters // Check parameters
if ($type < 0) return -1; if ($type < 0) return -1;
if ($this->statut == 0) if ($this->statut == self::STATUS_DRAFT)
{ {
$this->db->begin(); $this->db->begin();
@ -1457,7 +1486,7 @@ class Commande extends CommonOrder
$this->lines = array(); $this->lines = array();
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for invoice // Retreive all extrafield for invoice
// fetch optionals attributes and labels // fetch optionals attributes and labels
@ -1769,7 +1798,7 @@ class Commande extends CommonOrder
* *
* TODO deprecated, move to Shipping class * TODO deprecated, move to Shipping class
*/ */
function livraison_array($filtre_statut=-1) function livraison_array($filtre_statut=self::STATUS_CANCELED)
{ {
$delivery = new Livraison($this->db); $delivery = new Livraison($this->db);
$deliveryArray = $delivery->livraison_array($filtre_statut); $deliveryArray = $delivery->livraison_array($filtre_statut);
@ -1784,7 +1813,7 @@ class Commande extends CommonOrder
* *
* TODO FONCTION NON FINIE A FINIR * TODO FONCTION NON FINIE A FINIR
*/ */
function stock_array($filtre_statut=-1) function stock_array($filtre_statut=self::STATUS_CANCELED)
{ {
$this->stocks = array(); $this->stocks = array();
@ -1826,7 +1855,7 @@ class Commande extends CommonOrder
{ {
global $user; global $user;
if ($this->statut == 0) if ($this->statut == self::STATUS_DRAFT)
{ {
$this->db->begin(); $this->db->begin();
@ -1909,7 +1938,7 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET remise_percent = '.$remise; $sql.= ' SET remise_percent = '.$remise;
$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 ($this->db->query($sql))
{ {
@ -1943,7 +1972,7 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET remise_absolue = '.$remise; $sql.= ' SET remise_absolue = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG); dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG);
@ -1975,7 +2004,7 @@ class Commande extends CommonOrder
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null'); $sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null');
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(get_class($this)."::set_date",LOG_DEBUG); dol_syslog(get_class($this)."::set_date",LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -2119,7 +2148,7 @@ class Commande extends CommonOrder
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
} }
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($draft) $sql.= " AND c.fk_statut = 0"; if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT;
if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id; if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id;
$sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->order($sortfield,$sortorder);
$sql.= $this->db->plimit($limit,$offset); $sql.= $this->db->plimit($limit,$offset);
@ -2170,7 +2199,7 @@ class Commande extends CommonOrder
function availability($availability_id) function availability($availability_id)
{ {
dol_syslog('Commande::availability('.$availability_id.')'); dol_syslog('Commande::availability('.$availability_id.')');
if ($this->statut >= 0) if ($this->statut >= self::STATUS_DRAFT)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_availability = '.$availability_id; $sql .= ' SET fk_availability = '.$availability_id;
@ -2204,7 +2233,7 @@ class Commande extends CommonOrder
function demand_reason($demand_reason_id) function demand_reason($demand_reason_id)
{ {
dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
if ($this->statut >= 0) if ($this->statut >= self::STATUS_DRAFT)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' SET fk_input_reason = '.$demand_reason_id;
@ -2275,7 +2304,7 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1';
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG); dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -2753,7 +2782,7 @@ class Commande extends CommonOrder
} }
$sql.= $clause." c.entity = ".$conf->entity; $sql.= $clause." c.entity = ".$conf->entity;
//$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0"; //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
$sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 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_ACCEPTED.")) 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; if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -2827,57 +2856,57 @@ class Commande extends CommonOrder
//print 'x'.$statut.'-'.$billed; //print 'x'.$statut.'-'.$billed;
if ($mode == 0) if ($mode == 0)
{ {
if ($statut==-1) return $langs->trans('StatusOrderCanceled'); if ($statut==self::STATUS_CANCELED-1) return $langs->trans('StatusOrderCanceled');
if ($statut==0) return $langs->trans('StatusOrderDraft'); if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
if ($statut==1) return $langs->trans('StatusOrderValidated'); if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated');
if ($statut==2) return $langs->trans('StatusOrderSentShort'); if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort');
if ($statut==3 && (! $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('StatusOrderToBill');
if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed');
} }
elseif ($mode == 1) elseif ($mode == 1)
{ {
if ($statut==-1) return $langs->trans('StatusOrderCanceledShort'); if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
if ($statut==0) return $langs->trans('StatusOrderDraftShort'); if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
if ($statut==1) return $langs->trans('StatusOrderValidatedShort'); if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort');
if ($statut==2) return $langs->trans('StatusOrderSentShort'); if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort');
if ($statut==3 && (! $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('StatusOrderToBillShort');
if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed');
} }
elseif ($mode == 2) elseif ($mode == 2)
{ {
if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort'); if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort'); if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort'); if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort');
if ($statut==2) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort'); if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort');
if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort');
if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort'); if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort');
} }
elseif ($mode == 3) elseif ($mode == 3)
{ {
if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1');
if ($statut==2) return img_picto($langs->trans('StatusOrderSentShort'),'statut3'); if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort'),'statut3');
if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7');
if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6'); if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6');
} }
elseif ($mode == 4) elseif ($mode == 4)
{ {
if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled'); if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft'); if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidated'); if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidated');
if ($statut==2) return img_picto($langs->trans('StatusOrderSentShort'),'statut3').' '.$langs->trans('StatusOrderSent'); if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort'),'statut3').' '.$langs->trans('StatusOrderSent');
if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill');
if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed'); if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed');
} }
elseif ($mode == 5) elseif ($mode == 5)
{ {
if ($statut==-1) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderCanceledShort').' </span>'.img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($statut==self::STATUS_CANCELED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderCanceledShort').' </span>'.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDraftShort').' </span>'.img_picto($langs->trans('StatusOrderDraft'),'statut0'); if ($statut==self::STATUS_DRAFT) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDraftShort').' </span>'.img_picto($langs->trans('StatusOrderDraft'),'statut0');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderValidatedShort').' </span>'.img_picto($langs->trans('StatusOrderValidated'),'statut1'); if ($statut==self::STATUS_VALIDATED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderValidatedShort').' </span>'.img_picto($langs->trans('StatusOrderValidated'),'statut1');
if ($statut==2) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSentShort').' </span>'.img_picto($langs->trans('StatusOrderSent'),'statut3'); if ($statut==self::STATUS_ACCEPTED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSentShort').' </span>'.img_picto($langs->trans('StatusOrderSent'),'statut3');
if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderToBillShort').' </span>'.img_picto($langs->trans('StatusOrderToBill'),'statut7'); 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'),'statut7');
if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderProcessedShort').' </span>'.img_picto($langs->trans('StatusOrderProcessed'),'statut6'); if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderProcessedShort').' </span>'.img_picto($langs->trans('StatusOrderProcessed'),'statut6');
} }
} }

View File

@ -147,16 +147,16 @@ if ($id > 0 || ! empty($ref))
if ($absolute_discount > 0) if ($absolute_discount > 0)
{ {
print '. '; print '. ';
if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) if ($object->statut > Facture::STATUS_DRAFT || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
{ {
if ($object->statut == 0) if ($object->statut == Facture::STATUS_DRAFT)
{ {
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
print '. '; print '. ';
} }
else else
{ {
if ($object->statut < 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) if ($object->statut < Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
{ {
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
print '<br>'.$text.'.<br>'; print '<br>'.$text.'.<br>';
@ -181,7 +181,7 @@ if ($id > 0 || ! empty($ref))
{ {
if ($absolute_creditnote > 0) // If not linked will be added later if ($absolute_creditnote > 0) // If not linked will be added later
{ {
if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'<br>'; if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'<br>';
else print '.'; else print '.';
} }
else print '. '; else print '. ';
@ -189,9 +189,9 @@ if ($id > 0 || ! empty($ref))
if ($absolute_creditnote > 0) if ($absolute_creditnote > 0)
{ {
// If validated, we show link "add credit note to payment" // If validated, we show link "add credit note to payment"
if ($object->statut != 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
{ {
if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_DEPOSIT)
{ {
$text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)); $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse")); print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
@ -212,7 +212,7 @@ if ($id > 0 || ! empty($ref))
if (! $absolute_discount && ! $absolute_creditnote) if (! $absolute_discount && ! $absolute_creditnote)
{ {
print $langs->trans("CompanyHasNoAbsoluteDiscount"); print $langs->trans("CompanyHasNoAbsoluteDiscount");
if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'<br>'; if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'<br>';
else print '. '; else print '. ';
} }
/*if ($object->statut == 0 && $object->type != 2 && $object->type != 3) /*if ($object->statut == 0 && $object->type != 2 && $object->type != 3)

View File

@ -260,7 +260,7 @@ class FactureRec extends Facture
$this->rang = $obj->rang; $this->rang = $obj->rang;
$this->special_code = $obj->special_code; $this->special_code = $obj->special_code;
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
/* /*
* Lines * Lines

View File

@ -95,10 +95,15 @@ class Facture extends CommonInvoice
var $note; var $note;
var $note_private; var $note_private;
var $note_public; var $note_public;
//! 0=draft,
//! 1=validated (need to be paid), /**
//! 2=classified paid partially (close_code='discount_vat','badcustomer') or completely (close_code=null), * Check constants for more info:
//! 3=classified abandoned and no payment done (close_code='badcustomer','abandon' or 'replaced') * - STATUS_DRAFT
* - STATUS_VALIDATED
* - STATUS_PAID
* - STATUS_ABANDONED
* @var int
*/
var $statut; var $statut;
//! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon
//! Fermeture alors que aucun paiement: replaced (si remplace), abandon //! Fermeture alors que aucun paiement: replaced (si remplace), abandon
@ -177,6 +182,39 @@ class Facture extends CommonInvoice
*/ */
const TYPE_SITUATION = 5; const TYPE_SITUATION = 5;
/**
* Draft
*/
const STATUS_DRAFT = 0;
/**
* Validated (need to be paid)
*/
const STATUS_VALIDATED = 1;
/**
* Classified paid.
* If paid partially, $this->close_code can be:
* - CLOSECODE_DISCOUNTVAT
* - CLOSECODE_BADDEBT
* If paid completelly, this->close_code will be null
*/
const STATUS_CLOSED = 2;
/**
* Classified abandoned and no payment done.
* $this->close_code can be:
* - CLOSECODE_BADDEBT
* - CLOSECODE_ABANDONED
* - CLOSECODE_REPLACED
*/
const STATUS_ABANDONED = 3;
const CLOSECODE_DISCOUNTVAT = 'discount_vat';
const CLOSECODE_BADDEBT = 'badcustomer';
const CLOSECODE_ABANDONED = 'abandon';
const CLOSECODE_REPLACED = 'replaced';
/** /**
* Constructor * Constructor
* *
@ -670,7 +708,7 @@ class Facture extends CommonInvoice
} }
$this->id=0; $this->id=0;
$this->statut=0; $this->statut= self::STATUS_DRAFT;
// Clear fields // Clear fields
$this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box
@ -987,7 +1025,7 @@ class Facture extends CommonInvoice
$this->situation_final = $obj->situation_final; $this->situation_final = $obj->situation_final;
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for invoice // Retreive all extrafield for invoice
// fetch optionals attributes and labels // fetch optionals attributes and labels
@ -1524,7 +1562,7 @@ class Facture extends CommonInvoice
dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
$sql.= ' fk_statut=2'; $sql.= ' fk_statut='.self::STATUS_CLOSED;
if (! $close_code) $sql.= ', paye=1'; if (! $close_code) $sql.= ', paye=1';
if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'";
if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
@ -1579,7 +1617,7 @@ class Facture extends CommonInvoice
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null';
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG);
@ -1632,7 +1670,7 @@ class Facture extends CommonInvoice
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
$sql.= ' fk_statut=3'; $sql.= ' fk_statut='.self::STATUS_ABANDONED;
if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'";
if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
@ -1783,7 +1821,7 @@ class Facture extends CommonInvoice
// Validate // Validate
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= " SET facnumber='".$num."', fk_statut = 1, fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'";
if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date
{ {
$sql.= ", datef='".$this->db->idate($this->date)."'"; $sql.= ", datef='".$this->db->idate($this->date)."'";
@ -1884,7 +1922,7 @@ class Facture extends CommonInvoice
{ {
$this->ref = $num; $this->ref = $num;
$this->facnumber=$num; $this->facnumber=$num;
$this->statut=1; $this->statut= self::STATUS_VALIDATED;
$this->brouillon=0; $this->brouillon=0;
$this->date_validation=$now; $this->date_validation=$now;
$i = 0; $i = 0;
@ -1928,7 +1966,7 @@ class Facture extends CommonInvoice
$error=0; $error=0;
if ($this->statut == 0) if ($this->statut == self::STATUS_DRAFT)
{ {
dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING); dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING);
return 0; return 0;
@ -1937,7 +1975,7 @@ class Facture extends CommonInvoice
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."facture"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
$sql.= " SET fk_statut = 0"; $sql.= " SET fk_statut = ".self::STATUS_DRAFT;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); dol_syslog(get_class($this)."::set_draft", LOG_DEBUG);
@ -1968,7 +2006,7 @@ class Facture extends CommonInvoice
{ {
$old_statut=$this->statut; $old_statut=$this->statut;
$this->brouillon = 1; $this->brouillon = 1;
$this->statut = 0; $this->statut = self::STATUS_DRAFT;
// Call trigger // Call trigger
$result=$this->call_trigger('BILL_UNVALIDATE',$user); $result=$this->call_trigger('BILL_UNVALIDATE',$user);
if ($result < 0) if ($result < 0)
@ -2460,7 +2498,7 @@ class Facture extends CommonInvoice
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_percent = '.$remise; $sql.= ' SET remise_percent = '.$remise;
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
$sql.= ' AND fk_statut = 0'; $sql.= ' AND fk_statut = '.self::STATUS_DRAFT;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -2495,7 +2533,7 @@ class Facture extends CommonInvoice
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_absolue = '.$remise; $sql.= ' SET remise_absolue = '.$remise;
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
$sql.= ' AND fk_statut = 0'; $sql.= ' AND fk_statut = '.self::STATUS_DRAFT;
dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG); dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG);
@ -2795,7 +2833,7 @@ class Facture extends CommonInvoice
return $last; return $last;
} }
} }
else if ($this->statut == 0 && $facref == 'PROV') // Si facture brouillon et provisoire else if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // Si facture brouillon et provisoire
{ {
return 1; return 1;
} }
@ -2835,7 +2873,7 @@ class Facture extends CommonInvoice
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
} }
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($draft) $sql.= " AND f.fk_statut = 0"; if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT;
if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id;
$sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->order($sortfield,$sortorder);
$sql.= $this->db->plimit($limit,$offset); $sql.= $this->db->plimit($limit,$offset);
@ -2896,7 +2934,7 @@ class Facture extends CommonInvoice
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
$sql.= " WHERE (f.fk_statut = 1 OR (f.fk_statut = 3 AND f.close_code = 'abandon'))"; $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.paye = 0"; // Pas classee payee completement $sql.= " AND f.paye = 0"; // Pas classee payee completement
$sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
@ -2944,7 +2982,7 @@ class Facture extends CommonInvoice
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")";
$sql.= " WHERE f.entity = ".$conf->entity; $sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut in (1,2)"; $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")";
// $sql.= " WHERE f.fk_statut >= 1"; // $sql.= " WHERE f.fk_statut >= 1";
// $sql.= " AND (f.paye = 1"; // Classee payee completement // $sql.= " AND (f.paye = 1"; // Classee payee completement
// $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement
@ -2960,8 +2998,8 @@ class Facture extends CommonInvoice
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$qualified=0; $qualified=0;
if ($obj->fk_statut == 1) $qualified=1; if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1;
if ($obj->fk_statut == 2) $qualified=1; if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1;
if ($qualified) if ($qualified)
{ {
//$ref=$obj->facnumber; //$ref=$obj->facnumber;
@ -2992,7 +3030,7 @@ class Facture extends CommonInvoice
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
if ($this->statut > 0 && $this->paye == 0) if ($this->statut > self::STATUS_DRAFT && $this->paye == 0)
{ {
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$bac = new CompanyBankAccount($this->db); $bac = new CompanyBankAccount($this->db);
@ -3125,7 +3163,7 @@ class Facture extends CommonInvoice
} }
$sql.= $clause." f.paye=0"; $sql.= $clause." f.paye=0";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut = 1"; $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED;
if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);

View File

@ -523,12 +523,12 @@ else
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($object->statut == 0 && $user->rights->facture->creer) if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer)
{ {
echo '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;socid='.$object->thirdparty->id.'&amp;fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>'; echo '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;socid='.$object->thirdparty->id.'&amp;fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
} }
if ($object->statut == 0 && $user->rights->facture->supprimer) if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
} }

View File

@ -95,7 +95,7 @@ if ($action == 'presend' && GETPOST('sendmail'))
if ($result > 0) // Invoice was found if ($result > 0) // Invoice was found
{ {
if ($object->statut != 1) if ($object->statut != Facture::STATUS_VALIDATED)
{ {
continue; // Payment done or started or canceled continue; // Payment done or started or canceled
} }

View File

@ -229,15 +229,15 @@ if ($object->id > 0)
print '. '; print '. ';
if ($absolute_discount > 0) if ($absolute_discount > 0)
{ {
if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) if ($object->statut > Facture::STATUS_DRAFT || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
{ {
if ($object->statut == 0) if ($object->statut == Facture::STATUS_DRAFT)
{ {
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. '; print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. ';
} }
else else
{ {
if ($object->statut < 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) if ($object->statut < Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT)
{ {
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
print '<br>'.$text.'.<br>'; print '<br>'.$text.'.<br>';
@ -261,9 +261,9 @@ if ($object->id > 0)
if ($absolute_creditnote > 0) if ($absolute_creditnote > 0)
{ {
// If validated, we show link "add credit note to payment" // If validated, we show link "add credit note to payment"
if ($object->statut != 1 || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_CREDIT_NOTE) if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_CREDIT_NOTE)
{ {
if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_DEPOSIT)
{ {
$text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)); $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency));
print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse")); print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse"));
@ -350,7 +350,7 @@ if ($object->id > 0)
else else
{ {
print dol_print_date($object->date_lim_reglement,'daytext'); print dol_print_date($object->date_lim_reglement,'daytext');
if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am)) print img_warning($langs->trans('Late')); if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == Facture::STATUS_VALIDATED && ! isset($object->am)) print img_warning($langs->trans('Late'));
} }
} }
else else
@ -473,7 +473,7 @@ if ($object->id > 0)
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
// Add a withdraw request // Add a withdraw request
if ($object->statut > 0 && $object->paye == 0 && $num == 0) if ($object->statut > Facture::STATUS_DRAFT && $object->paye == 0 && $num == 0)
{ {
if ($user->rights->prelevement->bons->creer) if ($user->rights->prelevement->bons->creer)
{ {
@ -488,7 +488,7 @@ if ($object->id > 0)
{ {
if ($num == 0) if ($num == 0)
{ {
if ($object->statut > 0) print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPayed")).'">'.$langs->trans("MakeWithdrawRequest").'</a>'; if ($object->statut > Facture::STATUS_DRAFT) print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPayed")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("Draft")).'">'.$langs->trans("MakeWithdrawRequest").'</a>'; else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("Draft")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
} }
else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("RequestAlreadyDone")).'">'.$langs->trans("MakeWithdrawRequest").'</a>'; else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("RequestAlreadyDone")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';

View File

@ -142,7 +142,7 @@ if ($socid > 0)
print '<td aling="left">'.$fac->getLibStatut(2,$totalpaye).'</td>'; print '<td aling="left">'.$fac->getLibStatut(2,$totalpaye).'</td>';
print '<td align="right">'.price($fac->total_ttc)."</td>\n"; print '<td align="right">'.price($fac->total_ttc)."</td>\n";
if (($fac->statut == 3 ) || ($fac->statut == 2 && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye; if (($fac->statut == Facture::STATUS_ABANDONED ) || ($fac->statut == Facture::STATUS_CLOSED && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye;
else $solde = $solde + $fac->total_ttc; else $solde = $solde + $fac->total_ttc;
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';

View File

@ -1193,7 +1193,7 @@ class pdf_crabe extends ModelePDFFactures
} }
// Escompte // Escompte
if ($object->close_code == 'discount_vat') if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
{ {
$index++; $index++;
$pdf->SetFillColor(255,255,255); $pdf->SetFillColor(255,255,255);

View File

@ -216,7 +216,7 @@ if ($id > 0 || ! empty($ref))
$absolute_creditnote=price2num($absolute_creditnote,'MT'); $absolute_creditnote=price2num($absolute_creditnote,'MT');
if ($absolute_discount) if ($absolute_discount)
{ {
if ($commande->statut > 0) if ($commande->statut > Commande::STATUS_DRAFT)
{ {
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
} }
@ -606,7 +606,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Bouton expedier sans gestion des stocks // Bouton expedier sans gestion des stocks
if (empty($conf->stock->enabled) && ($commande->statut > 0 && $commande->statut < 3)) if (empty($conf->stock->enabled) && ($commande->statut > Commande::STATUS_DRAFT && $commande->statut < Commande::STATUS_CLOSED))
{ {
if ($user->rights->expedition->creer) if ($user->rights->expedition->creer)
{ {
@ -626,7 +626,7 @@ if ($id > 0 || ! empty($ref))
// Bouton expedier avec gestion des stocks // Bouton expedier avec gestion des stocks
if (! empty($conf->stock->enabled) && ($commande->statut > 0 && $commande->statut < 3)) if (! empty($conf->stock->enabled) && ($commande->statut > Commande::STATUS_DRAFT && $commande->statut < Commande::STATUS_CLOSED))
{ {
if ($user->rights->expedition->creer) if ($user->rights->expedition->creer)
{ {

View File

@ -241,7 +241,6 @@ class Societe extends CommonObject
var $specimen; var $specimen;
/** /**
* 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect
* @var int * @var int

View File

@ -522,7 +522,7 @@ function createInvoice($authentication,$invoice)
$newobject->date=dol_stringtotime($invoice['date'],'dayrfc'); $newobject->date=dol_stringtotime($invoice['date'],'dayrfc');
$newobject->note_private=$invoice['note_private']; $newobject->note_private=$invoice['note_private'];
$newobject->note_public=$invoice['note_public']; $newobject->note_public=$invoice['note_public'];
$newobject->statut=0; // We start with status draft $newobject->statut= Facture::STATUS_DRAFT; // We start with status draft
$newobject->fk_project=$invoice['project_id']; $newobject->fk_project=$invoice['project_id'];
$newobject->date_creation=$now; $newobject->date_creation=$now;

View File

@ -687,7 +687,7 @@ function createOrder($authentication,$order)
$newobject->date_lim_reglement=dol_stringtotime($order['date_due'],'dayrfc'); $newobject->date_lim_reglement=dol_stringtotime($order['date_due'],'dayrfc');
$newobject->note_private=$order['note_private']; $newobject->note_private=$order['note_private'];
$newobject->note_public=$order['note_public']; $newobject->note_public=$order['note_public'];
$newobject->statut=0; // We start with status draft $newobject->statut=Commande::STATUS_DRAFT; // We start with status draft
$newobject->billed=$order['billed']; $newobject->billed=$order['billed'];
$newobject->fk_project=$order['project_id']; $newobject->fk_project=$order['project_id'];
$newobject->fk_delivery_address=$order['fk_delivery_address']; $newobject->fk_delivery_address=$order['fk_delivery_address'];