Merge pull request #2537 from marcosgdf/cq

Created Propal, FactureFourniseur, and Commande constants for status
This commit is contained in:
Laurent Destailleur 2015-04-06 12:37:52 +02:00
commit e2508287bd
8 changed files with 247 additions and 116 deletions

View File

@ -302,7 +302,7 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->statut = 0;
$object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -549,7 +549,7 @@ if (empty($reshook))
// Reopen proposal
else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
// prevent browser refresh from reopening proposal several times
if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) {
if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) {
$object->reopen($user, 1);
}
}
@ -561,7 +561,7 @@ if (empty($reshook))
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
if ($object->statut == 1) {
if ($object->statut == Propal::STATUS_VALIDATED) {
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
}
@ -575,7 +575,7 @@ if (empty($reshook))
// Reopen proposal
else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
// prevent browser refresh from reopening proposal several times
if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) {
if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) {
$object->reopen($user, 1);
}
}
@ -587,7 +587,7 @@ if (empty($reshook))
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
if ($object->statut == 1) {
if ($object->statut == Propal::STATUS_VALIDATED) {
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
}
@ -1735,7 +1735,7 @@ if ($action == 'create')
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
if ($absolute_discount) {
if ($object->statut > 0) {
if ($object->statut > Propal::STATUS_DRAFT) {
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount, 0, $langs, 0, 0, -1, $conf->currency));
} else {
// Remise dispo de type non avoir
@ -1797,7 +1797,7 @@ if ($action == 'create')
} else {
if (! empty($object->fin_validite)) {
print dol_print_date($object->fin_validite, 'daytext');
if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay))
if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay))
print img_warning($langs->trans("Late"));
} else {
print '&nbsp;';
@ -2081,7 +2081,7 @@ if ($action == 'create')
<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 == Propal::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
@ -2091,7 +2091,7 @@ if ($action == 'create')
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
// Form to add new line
if ($object->statut == 0 && $user->rights->propal->creer)
if ($object->statut == Propal::STATUS_DRAFT && $user->rights->propal->creer)
{
if ($action != 'editline')
{
@ -2154,7 +2154,7 @@ if ($action == 'create')
if ($action != 'statut' && $action != 'editline')
{
// Validate
if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 &&
if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
) {
@ -2168,18 +2168,18 @@ if ($action == 'create')
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>';
}
// Edit
if ($object->statut == 1 && $user->rights->propal->creer) {
if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
}
// ReOpen
if (($object->statut == 2 || $object->statut == 3 || $object->statut == 4) && $user->rights->propal->cloturer) {
if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $user->rights->propal->cloturer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=reopen' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen') . '"';
print '>' . $langs->trans('ReOpen') . '</a></div>';
}
// Send
if ($object->statut == 1 || $object->statut == 2) {
if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED) {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_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>';
} else
@ -2187,14 +2187,14 @@ if ($action == 'create')
}
// Create an order
if (! empty($conf->commande->enabled) && $object->statut == 2) {
if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($user->rights->commande->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/commande/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddOrder") . '</a></div>';
}
}
// Create contract
if ($conf->contrat->enabled && $object->statut == 2) {
if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) {
$langs->load("contracts");
if ($user->rights->contrat->creer) {
@ -2203,7 +2203,7 @@ if ($action == 'create')
}
// Create an invoice and classify billed
if ($object->statut == 2) {
if ($object->statut == Propal::STATUS_SIGNED) {
if (! empty($conf->facture->enabled) && $user->rights->facture->creer)
{
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("AddBill") . '</a></div>';
@ -2217,7 +2217,7 @@ if ($action == 'create')
}
// Close
if ($object->statut == 1 && $user->rights->propal->cloturer) {
if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->cloturer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=statut' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close') . '"';
print '>' . $langs->trans('Close') . '</a></div>';
}

View File

@ -54,19 +54,56 @@ class Propal extends CommonObject
var $id;
var $socid; // Id client
var $client; // Objet societe client (a charger par fetch_client)
/**
* ID of the client
* @var int
*/
var $socid;
/**
* Client (loaded by fetch_client)
* @var Societe
*/
var $client;
var $contactid;
var $fk_project;
var $author;
var $ref;
var $ref_client;
var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed)
var $datec; // Date of creation
var $datev; // Date of validation
var $date; // Date of proposal
var $datep; // Same than date
/**
* Status of the quote
* Check the following constants:
* - STATUS_DRAFT
* - STATUS_VALIDATED
* - STATUS_SIGNED
* - STATUS_NOTSIGNED
* - STATUS_BILLED
* @var int
*/
var $statut;
/**
* Date of creation
* @var
*/
var $datec;
/**
* Date of validation
* @var
*/
var $datev;
/**
* Date of the quote
* @var
*/
var $date;
/**
* Same than date ¿?
* @var
*/
var $datep;
var $date_livraison;
var $fin_validite;
@ -79,9 +116,19 @@ class Propal extends CommonObject
var $total_localtax1; // Total Local Taxes 1
var $total_localtax2; // Total Local Taxes 2
var $total_ttc; // Total with tax
var $price; // deprecated (for compatibility)
var $tva; // deprecated (for compatibility)
var $total; // deprecated (for compatibility)
/**
* @deprecated
*/
var $price;
/**
* @deprecated
*/
var $tva;
/**
* @deprecated
*/
var $total;
var $cond_reglement_id;
var $cond_reglement_code;
@ -91,10 +138,16 @@ class Propal extends CommonObject
var $remise;
var $remise_percent;
var $remise_absolue;
var $note; // deprecated (for compatibility)
/**
* @deprecated
*/
var $note;
var $note_private;
var $note_public;
var $fk_delivery_address; // deprecated (for compatibility)
/**
* @deprecated
*/
var $fk_delivery_address;
var $fk_address;
var $address_type;
var $address;
@ -126,6 +179,26 @@ class Propal extends CommonObject
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/**
* Draft status
*/
const STATUS_DRAFT = 0;
/**
* Validated status
*/
const STATUS_VALIDATED = 1;
/**
* Signed quote
*/
const STATUS_SIGNED = 2;
/**
* Not signed quote
*/
const STATUS_NOTSIGNED = 3;
/**
* Billed quote
*/
const STATUS_BILLED = 4;
/**
* Constructor
@ -361,7 +434,7 @@ class Propal extends CommonObject
// Check parameters
if ($type < 0) return -1;
if ($this->statut == 0)
if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin();
@ -525,7 +598,7 @@ class Propal extends CommonObject
if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag
if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag
if ($this->statut == 0)
if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin();
@ -650,7 +723,7 @@ class Propal extends CommonObject
*/
function deleteline($lineid)
{
if ($this->statut == 0)
if ($this->statut == self::STATUS_DRAFT)
{
$line=new PropaleLigne($this->db);
@ -1007,7 +1080,7 @@ class Propal extends CommonObject
}
$this->id=0;
$this->statut=0;
$this->statut=self::STATUS_DRAFT;
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
{
@ -1192,7 +1265,7 @@ class Propal extends CommonObject
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
if ($obj->fk_statut == 0)
if ($obj->fk_statut == self::STATUS_DRAFT)
{
$this->brouillon = 1;
}
@ -1385,8 +1458,8 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET ref = '".$num."',";
$sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
$sql.= " fk_statut = ".self::STATUS_VALIDATED.", date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(get_class($this)."::valid", LOG_DEBUG);
$resql=$this->db->query($sql);
@ -1441,7 +1514,7 @@ class Propal extends CommonObject
$this->ref=$num;
$this->brouillon=0;
$this->statut = 1;
$this->statut = self::STATUS_VALIDATED;
$this->user_valid_id=$user->id;
$this->datev=$now;
@ -1476,7 +1549,7 @@ class Propal extends CommonObject
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
$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);
if ($this->db->query($sql) )
@ -1505,7 +1578,7 @@ class Propal extends CommonObject
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null');
$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) )
{
$this->fin_validite = $date_fin_validite;
@ -1655,7 +1728,7 @@ class Propal extends CommonObject
$remise = price2num($remise);
$sql = "UPDATE ".MAIN_DB_PREFIX."propal 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) )
{
@ -1689,7 +1762,7 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$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;
if ($this->db->query($sql) )
{
@ -1797,7 +1870,7 @@ class Propal extends CommonObject
$modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf;
$trigger_name='PROPAL_CLOSE_REFUSED';
if ($statut == 2)
if ($statut == self::STATUS_SIGNED)
{
$trigger_name='PROPAL_CLOSE_SIGNED';
$modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf;
@ -1814,7 +1887,7 @@ class Propal extends CommonObject
return -2;
}
}
if ($statut == 4)
if ($statut == self::STATUS_BILLED)
{
$trigger_name='PROPAL_CLASSIFY_BILLED';
}
@ -1864,11 +1937,11 @@ class Propal extends CommonObject
*/
function classifyBilled()
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;';
if ($this->db->query($sql) )
{
$this->statut=4;
$this->statut=self::STATUS_BILLED;
return 1;
}
else
@ -1896,12 +1969,12 @@ class Propal extends CommonObject
*/
function set_draft($user)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = ".self::STATUS_DRAFT;
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
$this->statut = 0;
$this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
return 1;
}
@ -1945,7 +2018,7 @@ class Propal extends CommonObject
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($draft) $sql.= " AND p.fk_statut = 0";
if ($draft) $sql.= " AND p.fk_statut = ".self::STATUS_DRAFT;
if ($notcurrentuser > 0) $sql.= " AND p.fk_user_author <> ".$user->id;
$sql.= $this->db->order($sortfield,$sortorder);
$sql.= $this->db->plimit($limit,$offset);
@ -2215,7 +2288,7 @@ class Propal extends CommonObject
function availability($availability_id)
{
dol_syslog('Propale::availability('.$availability_id.')');
if ($this->statut >= 0)
if ($this->statut >= self::STATUS_DRAFT)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_availability = '.$availability_id;
@ -2249,7 +2322,7 @@ class Propal extends CommonObject
function demand_reason($demand_reason_id)
{
dol_syslog('Propale::demand_reason('.$demand_reason_id.')');
if ($this->statut >= 0)
if ($this->statut >= self::STATUS_DRAFT)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_input_reason = '.$demand_reason_id;
@ -2356,11 +2429,11 @@ class Propal extends CommonObject
global $langs;
$langs->load("propal");
if ($statut==0) $statuttrans='statut0';
if ($statut==1) $statuttrans='statut1';
if ($statut==2) $statuttrans='statut3';
if ($statut==3) $statuttrans='statut5';
if ($statut==4) $statuttrans='statut6';
if ($statut==self::STATUS_DRAFT) $statuttrans='statut0';
if ($statut==self::STATUS_VALIDATED) $statuttrans='statut1';
if ($statut==self::STATUS_SIGNED) $statuttrans='statut3';
if ($statut==self::STATUS_NOTSIGNED) $statuttrans='statut5';
if ($statut==self::STATUS_BILLED) $statuttrans='statut6';
if ($mode == 0) return $this->labelstatut[$statut];
if ($mode == 1) return $this->labelstatut_short[$statut];
@ -2393,8 +2466,8 @@ class Propal extends CommonObject
$clause = " AND";
}
$sql.= $clause." p.entity = ".$conf->entity;
if ($mode == 'opened') $sql.= " AND p.fk_statut = 1";
if ($mode == 'signed') $sql.= " AND p.fk_statut = 2";
if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED;
if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED;
if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id;
$resql=$this->db->query($sql);
@ -2405,12 +2478,12 @@ class Propal extends CommonObject
if ($mode == 'opened') {
$delay_warning=$conf->propal->cloture->warning_delay;
$statut = 1;
$statut = self::STATUS_VALIDATED;
$label = $langs->trans("PropalsToClose");
}
if ($mode == 'signed') {
$delay_warning=$conf->propal->facturation->warning_delay;
$statut = 2;
$statut = self::STATUS_SIGNED;
$label = $langs->trans("PropalsToBill");
}
@ -2815,7 +2888,14 @@ class PropaleLigne extends CommonObject
var $fk_parent_line;
var $desc; // Description ligne
var $fk_product; // Id produit predefini
var $product_type = 0; // Type 0 = product, 1 = Service
/**
* Product type.
* Use the following constants:
* - Product::TYPE_PRODUCT
* - Product::TYPE_SERVICE
* @var int
*/
var $product_type = Product::TYPE_PRODUCT;
var $qty;
var $tva_tx;

View File

@ -126,7 +126,7 @@ if ($id > 0 || ! empty($ref))
if ($object->fin_validite)
{
print dol_print_date($object->fin_validite,'daytext');
if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{

View File

@ -51,8 +51,17 @@ class Commande extends CommonOrder
var $id;
var $socid; // Id client
var $client; // Objet societe client (a charger par fetch_client)
/**
* Client ID
* @var int
*/
var $socid;
/**
* Client (loaded by fetch_client)
* @var Societe
*/
var $client;
var $ref;
var $ref_client;
@ -69,31 +78,13 @@ class Commande extends CommonOrder
* - STATUS_CLOSED
* @var int
*/
var $statut; // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Delivered=Sent/Received, billed or not)
var $statut;
/**
* @deprecated
*/
var $facturee; // deprecated
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 $cond_reglement_id;
var $cond_reglement_code;
@ -153,6 +144,27 @@ class Commande extends CommonOrder
*/
const STOCK_NOT_ENOUGH_FOR_ORDER = -3;
/**
* 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;
/**
* Constructor

View File

@ -60,6 +60,34 @@ abstract class CommonInvoice extends CommonObject
*/
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;
/**
* Return amount of payments already done
*

View File

@ -52,7 +52,11 @@ class CommandeFournisseur extends CommonOrder
var $id;
var $ref; // TODO deprecated
/**
* TODO: Remove
* @deprecated
*/
var $ref;
var $product_ref;
var $ref_supplier;
var $brouillon;

View File

@ -55,10 +55,15 @@ class FactureFournisseur extends CommonInvoice
var $socid;
//Check constants for types
var $type = self::TYPE_STANDARD;
//! 0=draft,
//! 1=validated
//! 2=classified paid partially (close_code='discount_vat','badcustomer') or completely (close_code=null),
//! Also 2, should be 3=classified abandoned and no payment done (close_code='badcustomer','abandon' ou 'replaced')
/**
* Check constants for more info:
* - STATUS_DRAFT
* - STATUS_VALIDATED
* - STATUS_PAID
* - STATUS_ABANDONED
* @var int
*/
var $statut;
//! 1 si facture payee COMPLETEMENT, 0 sinon (ce champ ne devrait plus servir car insuffisant)
var $paye;
@ -438,7 +443,7 @@ class FactureFournisseur extends CommonInvoice
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
if ($this->statut == 0) $this->brouillon = 1;
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
$result=$this->fetch_lines();
if ($result < 0)
@ -886,7 +891,7 @@ class FactureFournisseur extends CommonInvoice
$error=0;
// Protection
if ($this->statut > 0) // This is to avoid to validate twice (avoid errors on logs and stock management)
if ($this->statut > self::STATUS_DRAFT) // This is to avoid to validate twice (avoid errors on logs and stock management)
{
dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING);
return 0;
@ -995,7 +1000,7 @@ class FactureFournisseur extends CommonInvoice
if (! $error)
{
$this->ref = $num;
$this->statut=1;
$this->statut=self::STATUS_VALIDATED;
//$this->date_validation=$now; this is stored into log table
}
@ -1032,7 +1037,7 @@ class FactureFournisseur extends CommonInvoice
$error=0;
if ($this->statut == 0)
if ($this->statut == self::STATUS_DRAFT)
{
dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING);
return 0;
@ -1746,7 +1751,7 @@ class FactureFournisseur extends CommonInvoice
// Load source object
$object->fetch($fromid);
$object->id=0;
$object->statut=0;
$object->statut=self::STATUS_DRAFT;
// Clear fields
$object->ref_supplier=$langs->trans("CopyOf").' '.$object->ref_supplier;

View File

@ -288,7 +288,7 @@ if (empty($reshook))
elseif ($action == 'deletepaiement' && $user->rights->fournisseur->facture->creer)
{
$object->fetch($id);
if ($object->statut == 1 && $object->paye == 0)
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0)
{
$paiementfourn = new PaiementFourn($db);
$result=$paiementfourn->fetch(GETPOST('paiement_id'));
@ -867,8 +867,8 @@ if (empty($reshook))
elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
{
$result = $object->fetch($id);
if ($object->statut == 2
|| ($object->statut == 3 && $object->close_code != 'replaced'))
if ($object->statut == FactureFournisseur::STATUS_CLOSED
|| ($object->statut == FactureFournisseur::STATUS_ABANDONED && $object->close_code != 'replaced'))
{
$result = $object->set_unpaid($user);
if ($result > 0)
@ -1739,8 +1739,8 @@ else
print "</tr>\n";
// Ref supplier
print '<tr><td>'.$form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="4">';
print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
print '<tr><td>'.$form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<FactureFournisseur::STATUS_CLOSED && $user->rights->fournisseur->facture->creer)).'</td><td colspan="4">';
print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<FactureFournisseur::STATUS_CLOSED && $user->rights->fournisseur->facture->creer));
print '</td></tr>';
// Third party
@ -1788,8 +1788,8 @@ else
print '</td></tr>';
// Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td>';
print '<td colspan="3">'.$form->editfieldval("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td>';
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<FactureFournisseur::STATUS_CLOSED && $user->rights->fournisseur->facture->creer)).'</td>';
print '<td colspan="3">'.$form->editfieldval("Label",'label',$object->label,$object,($object->statut<FactureFournisseur::STATUS_CLOSED && $user->rights->fournisseur->facture->creer)).'</td>';
/*
* List of payments
@ -1853,7 +1853,7 @@ else
}
print '<td align="right">'.price($objp->amount).'</td>';
print '<td align="center">';
if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
print img_delete();
@ -1891,15 +1891,17 @@ else
print '</tr>';
$form_permission = $object->statut<FactureFournisseur::STATUS_CLOSED && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0;
// Date
print '<tr><td>'.$form->editfieldkey("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
print $form->editfieldval("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
print '<tr><td>'.$form->editfieldkey("Date",'datef',$object->datep,$object,$form_permission,'datepicker').'</td><td colspan="3">';
print $form->editfieldval("Date",'datef',$object->datep,$object,$form_permission,'datepicker');
print '</td>';
// Due date
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
if ($action != 'editdate_lim_reglement' && $object->statut < 2 && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late'));
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,$form_permission,'datepicker').'</td><td colspan="3">';
print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,$form_permission,'datepicker');
if ($action != 'editdate_lim_reglement' && $object->statut < FactureFournisseur::STATUS_CLOSED && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late'));
print '</td>';
// Conditions de reglement par defaut
@ -2081,7 +2083,7 @@ else
<input type="hidden" name="socid" value="'.$societe->id.'">
';
if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
if (! empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
@ -2279,7 +2281,7 @@ else
}
*/
// Form to add new line
if ($object->statut == 0 && $user->rights->fournisseur->facture->creer)
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $user->rights->fournisseur->facture->creer)
{
if ($action != 'editline')
{
@ -2310,7 +2312,7 @@ else
print '<div class="tabsAction">';
// Modify a validated invoice with no payments
if ($object->statut == 1 && $action != 'edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
}
@ -2329,7 +2331,7 @@ else
}
// Send by mail
if (($object->statut == 1 || $object->statut == 2))
if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED))
{
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send)
{
@ -2340,13 +2342,13 @@ else
// Make payments
if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create &amp;accountid='.$object->fk_account.'">'.$langs->trans('DoPayment').'</a>'; // must use facid because id is for payment id not invoice
}
// Classify paid
if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"';
print '>'.$langs->trans('ClassifyPaid').'</a>';
@ -2355,7 +2357,7 @@ else
}
// Validate
if ($action != 'edit' && $object->statut == 0)
if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_DRAFT)
{
if (count($object->lines))
{