|
@@ -45,22 +45,22 @@ class FactureFournisseur extends CommonInvoice
|
|
|
* @var string ID to identify managed object
|
|
|
*/
|
|
|
public $element='invoice_supplier';
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var string Name of table without prefix where object is stored
|
|
|
*/
|
|
|
public $table_element='facture_fourn';
|
|
|
-
|
|
|
+
|
|
|
public $table_element_line='facture_fourn_det';
|
|
|
public $fk_element='fk_facture_fourn';
|
|
|
public $picto='bill';
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
|
|
* @var int
|
|
|
*/
|
|
|
public $ismultientitymanaged = 1;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
|
|
|
* @var integer
|
|
@@ -110,13 +110,13 @@ class FactureFournisseur extends CommonInvoice
|
|
|
public $total_localtax1=0;
|
|
|
public $total_localtax2=0;
|
|
|
public $total_ttc=0;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @deprecated
|
|
|
* @see note_private, note_public
|
|
|
*/
|
|
|
public $note;
|
|
|
-
|
|
|
+
|
|
|
public $note_private;
|
|
|
public $note_public;
|
|
|
public $propalid;
|
|
@@ -676,7 +676,9 @@ class FactureFournisseur extends CommonInvoice
|
|
|
// phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
|
|
|
function fetch_lines()
|
|
|
{
|
|
|
- $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx';
|
|
|
+ $this->lines = array();
|
|
|
+
|
|
|
+ $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx';
|
|
|
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn ';
|
|
|
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
|
|
|
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
|
|
@@ -686,7 +688,6 @@ class FactureFournisseur extends CommonInvoice
|
|
|
$sql.= ' WHERE fk_facture_fourn='.$this->id;
|
|
|
$sql.= ' ORDER BY f.rang, f.rowid';
|
|
|
|
|
|
-
|
|
|
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
|
|
$resql_rows = $this->db->query($sql);
|
|
|
if ($resql_rows)
|
|
@@ -704,6 +705,9 @@ class FactureFournisseur extends CommonInvoice
|
|
|
$line->id = $obj->rowid;
|
|
|
$line->rowid = $obj->rowid;
|
|
|
$line->description = $obj->description;
|
|
|
+ $line->date_start = $obj->date_start;
|
|
|
+ $line->date_end = $obj->date_end;
|
|
|
+
|
|
|
$line->product_ref = $obj->product_ref;
|
|
|
$line->ref = $obj->product_ref;
|
|
|
$line->ref_supplier = $obj->ref_supplier;
|
|
@@ -1741,7 +1745,7 @@ class FactureFournisseur extends CommonInvoice
|
|
|
public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null, $pu_ht_devise=0, $ref_supplier='')
|
|
|
{
|
|
|
global $mysoc;
|
|
|
- dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit,$pu_ht_devise,$ref_supplier", LOG_DEBUG);
|
|
|
+ dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$notrigger,$date_start,$date_end,$fk_unit,$pu_ht_devise,$ref_supplier", LOG_DEBUG);
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
|
|
|
|
|
$pu = price2num($pu);
|
|
@@ -1821,6 +1825,9 @@ class FactureFournisseur extends CommonInvoice
|
|
|
$line->remise_percent = $remise_percent;
|
|
|
$line->ref_supplier = $ref_supplier;
|
|
|
|
|
|
+ $line->date_start = $date_start;
|
|
|
+ $line->date_end = $date_end;
|
|
|
+
|
|
|
$line->vat_src_code=$vat_src_code;
|
|
|
$line->tva_tx = $vatrate;
|
|
|
$line->localtax1_tx = $txlocaltax1;
|
|
@@ -2581,7 +2588,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
* @var string ID to identify managed object
|
|
|
*/
|
|
|
public $element='facture_fourn_det';
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var string Name of table without prefix where object is stored
|
|
|
*/
|
|
@@ -2594,7 +2601,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
* @see product_ref
|
|
|
*/
|
|
|
public $ref;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Internal ref
|
|
|
* @var string
|
|
@@ -2613,7 +2620,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
* @see label
|
|
|
*/
|
|
|
public $libelle;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Product description
|
|
|
* @var string
|
|
@@ -2627,7 +2634,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
* @see subprice
|
|
|
*/
|
|
|
public $pu_ht;
|
|
|
-
|
|
|
+
|
|
|
public $subprice;
|
|
|
|
|
|
/**
|
|
@@ -2643,7 +2650,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
* @see total_tva
|
|
|
*/
|
|
|
public $tva;
|
|
|
-
|
|
|
+
|
|
|
public $total_tva;
|
|
|
|
|
|
/**
|
|
@@ -2665,6 +2672,9 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
*/
|
|
|
public $description;
|
|
|
|
|
|
+ public $date_start;
|
|
|
+ public $date_end;
|
|
|
+
|
|
|
public $skip_update_total; // Skip update price total for special lines
|
|
|
|
|
|
/**
|
|
@@ -2722,7 +2732,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
*/
|
|
|
public function fetch($rowid)
|
|
|
{
|
|
|
- $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
|
|
|
+ $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
|
|
|
$sql.= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
|
|
|
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
|
|
|
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
|
|
@@ -2749,6 +2759,8 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
$this->rowid = $obj->rowid;
|
|
|
$this->fk_facture_fourn = $obj->fk_facture_fourn;
|
|
|
$this->description = $obj->description;
|
|
|
+ $this->date_start = $obj->date_start;
|
|
|
+ $this->date_end = $obj->date_end;
|
|
|
$this->product_ref = $obj->product_ref;
|
|
|
$this->ref_supplier = $obj->ref_supplier;
|
|
|
$this->libelle = $obj->label;
|
|
@@ -2880,6 +2892,8 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
|
|
|
$sql.= " description ='".$this->db->escape($this->description)."'";
|
|
|
$sql.= ", ref ='".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'";
|
|
|
+ $sql.= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
|
|
|
+ $sql.= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
|
|
|
$sql.= ", pu_ht = ".price2num($this->pu_ht);
|
|
|
$sql.= ", pu_ttc = ".price2num($this->pu_ttc);
|
|
|
$sql.= ", qty = ".price2num($this->qty);
|
|
@@ -3054,12 +3068,11 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|
|
$sql.= ", ".price2num($this->multicurrency_total_ttc);
|
|
|
$sql.= ')';
|
|
|
|
|
|
- dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
|
|
$resql=$this->db->query($sql);
|
|
|
if ($resql)
|
|
|
{
|
|
|
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
|
|
- $this->rowid=$this->id;
|
|
|
+ $this->rowid=$this->id; // backward compatibility
|
|
|
|
|
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
|
|
{
|