|
@@ -93,7 +93,7 @@ class Facture extends CommonInvoice
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
|
- protected $table_ref_field = 'facnumber';
|
|
|
+ protected $table_ref_field = 'ref';
|
|
|
|
|
|
public $socid;
|
|
|
|
|
@@ -450,7 +450,7 @@ class Facture extends CommonInvoice
|
|
|
$socid = $this->socid;
|
|
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture (";
|
|
|
- $sql.= " facnumber";
|
|
|
+ $sql.= " ref";
|
|
|
$sql.= ", entity";
|
|
|
$sql.= ", ref_ext";
|
|
|
$sql.= ", type";
|
|
@@ -514,7 +514,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
// Update ref with new one
|
|
|
$this->ref='(PROV'.$this->id.')';
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
|
|
|
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
|
|
|
|
|
|
$resql=$this->db->query($sql);
|
|
|
if (! $resql) $error++;
|
|
@@ -1310,7 +1310,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
|
|
|
|
|
|
- $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount';
|
|
|
+ $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount';
|
|
|
$sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp';
|
|
|
$sql.= ', f.remise_percent, f.remise_absolue, f.remise';
|
|
|
$sql.= ', f.datef as df, f.date_pointoftax';
|
|
@@ -1336,7 +1336,7 @@ class Facture extends CommonInvoice
|
|
|
if ($rowid) $sql.= " WHERE f.rowid=".$rowid;
|
|
|
else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid
|
|
|
|
|
|
- if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
|
|
|
+ if ($ref) $sql.= " AND f.ref='".$this->db->escape($ref)."'";
|
|
|
if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
|
|
|
if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'";
|
|
|
|
|
@@ -1351,7 +1351,7 @@ class Facture extends CommonInvoice
|
|
|
$this->id = $obj->rowid;
|
|
|
$this->entity = $obj->entity;
|
|
|
|
|
|
- $this->ref = $obj->facnumber;
|
|
|
+ $this->ref = $obj->ref;
|
|
|
$this->ref_client = $obj->ref_client;
|
|
|
$this->ref_ext = $obj->ref_ext;
|
|
|
$this->ref_int = $obj->ref_int;
|
|
@@ -1615,7 +1615,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
// Clean parameters
|
|
|
if (empty($this->type)) $this->type= self::TYPE_STANDARD;
|
|
|
- if (isset($this->facnumber)) $this->facnumber=trim($this->ref);
|
|
|
+ if (isset($this->ref)) $this->ref=trim($this->ref);
|
|
|
if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client);
|
|
|
if (isset($this->increment)) $this->increment=trim($this->increment);
|
|
|
if (isset($this->close_code)) $this->close_code=trim($this->close_code);
|
|
@@ -1631,7 +1631,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
// Update request
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET";
|
|
|
- $sql.= " facnumber=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
|
|
+ $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
|
|
$sql.= " type=".(isset($this->type)?$this->db->escape($this->type):"null").",";
|
|
|
$sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").",";
|
|
|
$sql.= " increment=".(isset($this->increment)?"'".$this->db->escape($this->increment)."'":"null").",";
|
|
@@ -2337,7 +2337,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
// Validate
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
|
|
- $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'";
|
|
|
+ $sql.= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'";
|
|
|
if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date
|
|
|
{
|
|
|
$sql.= ", datef='".$this->db->idate($this->date)."'";
|
|
@@ -2446,7 +2446,7 @@ class Facture extends CommonInvoice
|
|
|
if (! $error)
|
|
|
{
|
|
|
$this->ref = $num;
|
|
|
- $this->facnumber=$num;
|
|
|
+ $this->ref=$num;
|
|
|
$this->statut= self::STATUS_VALIDATED;
|
|
|
$this->brouillon=0;
|
|
|
$this->date_validation=$now;
|
|
@@ -3479,7 +3479,7 @@ class Facture extends CommonInvoice
|
|
|
$ga = array();
|
|
|
|
|
|
$sql = "SELECT s.rowid, s.nom as name, s.client,";
|
|
|
- $sql.= " f.rowid as fid, f.facnumber as ref, f.datef as df";
|
|
|
+ $sql.= " f.rowid as fid, f.ref as ref, f.datef as df";
|
|
|
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
|
|
|
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
@@ -3549,7 +3549,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
$return = array();
|
|
|
|
|
|
- $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,";
|
|
|
+ $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut,";
|
|
|
$sql.= " ff.rowid as rowidnext";
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
|
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
|
@@ -3560,7 +3560,7 @@ class Facture extends CommonInvoice
|
|
|
$sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
|
|
|
$sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
|
|
|
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
|
|
|
- $sql.= " ORDER BY f.facnumber";
|
|
|
+ $sql.= " ORDER BY f.ref";
|
|
|
|
|
|
dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG);
|
|
|
$resql=$this->db->query($sql);
|
|
@@ -3569,7 +3569,7 @@ class Facture extends CommonInvoice
|
|
|
while ($obj=$this->db->fetch_object($resql))
|
|
|
{
|
|
|
$return[$obj->rowid]=array( 'id' => $obj->rowid,
|
|
|
- 'ref' => $obj->facnumber,
|
|
|
+ 'ref' => $obj->ref,
|
|
|
'status' => $obj->fk_statut);
|
|
|
}
|
|
|
//print_r($return);
|
|
@@ -3600,7 +3600,7 @@ class Facture extends CommonInvoice
|
|
|
$return = array();
|
|
|
|
|
|
|
|
|
- $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement";
|
|
|
+ $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.paye, pf.fk_paiement";
|
|
|
$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."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")";
|
|
@@ -3629,7 +3629,7 @@ class Facture extends CommonInvoice
|
|
|
}
|
|
|
|
|
|
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
|
|
|
- $sql.= " ORDER BY f.facnumber";
|
|
|
+ $sql.= " ORDER BY f.ref";
|
|
|
|
|
|
dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG);
|
|
|
$resql=$this->db->query($sql);
|
|
@@ -3642,9 +3642,9 @@ class Facture extends CommonInvoice
|
|
|
if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1;
|
|
|
if ($qualified)
|
|
|
{
|
|
|
- //$ref=$obj->facnumber;
|
|
|
+ //$ref=$obj->ref;
|
|
|
$paymentornot=($obj->fk_paiement?1:0);
|
|
|
- $return[$obj->rowid]=array('ref'=>$obj->facnumber,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot);
|
|
|
+ $return[$obj->rowid]=array('ref'=>$obj->ref,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot);
|
|
|
}
|
|
|
}
|
|
|
|