diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9ab28f6b2c0..dae9827e0e4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -46,47 +46,58 @@ abstract class CommonObject * @var DoliDb Database handler (result of a new DoliDB) */ public $db; + /** * @var int The object identifier */ public $id; + /** * @var string Error string * @see errors */ public $error; + /** * @var string[] Array of error strings */ public $errors=array(); + /** * @var string */ public $element; + /** * @var string */ public $table_element; + /** * @var */ public $table_element_line; + /** * @var string Key value used to track if data is coming from import wizard */ public $import_key; + /** * @var mixed Contains data to manage extrafields */ public $array_options=array(); + /** * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked */ public $linkedObjectsIds; + /** * @var mixed Array of linked objects. Loaded by ->fetchObjectLinked */ public $linkedObjects; + /** * @var Object To store a cloned copy of object before to edit it and keep track of old properties */ @@ -116,11 +127,13 @@ abstract class CommonObject * @see fetch_projet() */ public $project; + /** * @var int The related project ID * @see setProject(), project */ public $fk_project; + /** * @deprecated * @see project @@ -132,6 +145,7 @@ abstract class CommonObject * @see fetch_contact() */ public $contact; + /** * @var int The related contact ID * @see fetch_contact() @@ -165,14 +179,17 @@ abstract class CommonObject * @var string The object's reference */ public $ref; + /** * @var string The object's previous reference */ public $ref_previous; + /** * @var string The object's next reference */ public $ref_next; + /** * @var string An external reference for the object */ @@ -189,36 +206,43 @@ abstract class CommonObject * @see getFullAddress() */ public $country; + /** * @var int * @see getFullAddress(), country */ public $country_id; + /** * @var string * @see getFullAddress(), isInEEC(), country */ public $country_code; + /** * @var string * @see getFullAddress() */ public $state; + /** * @var int * @see getFullAddress(), state */ public $state_id; + /** * @var string * @see getFullAddress(), state */ public $state_code; + /** * @var string * @see getFullAddress(), region */ public $region; + /** * @var string * @see getFullAddress(), region @@ -230,16 +254,19 @@ abstract class CommonObject * @see fetch_barcode() */ public $barcode_type; + /** * @var string * @see fetch_barcode(), barcode_type */ public $barcode_type_code; + /** * @var string * @see fetch_barcode(), barcode_type */ public $barcode_type_label; + /** * @var string * @see fetch_barcode(), barcode_type @@ -257,6 +284,7 @@ abstract class CommonObject * @see setPaymentTerms() */ public $cond_reglement_id; + /** * @var int Payment terms ID * @deprecated Kept for compatibility @@ -294,11 +322,13 @@ abstract class CommonObject * @see update_note() */ public $note_public; + /** * @var string Private note * @see update_note() */ public $note_private; + /** * @deprecated * @see note_public @@ -310,21 +340,25 @@ abstract class CommonObject * @see update_price() */ public $total_ht; + /** * @var float Total VAT amount * @see update_price() */ public $total_tva; + /** * @var float Total local tax 1 amount * @see update_price() */ public $total_localtax1; + /** * @var float Total local tax 2 amount * @see update_price() */ public $total_localtax2; + /** * @var float Total amount with taxes * @see update_price() @@ -347,11 +381,13 @@ abstract class CommonObject * @see setIncoterms() */ public $fk_incoterms; + /** * @var string * @see SetIncoterms() */ public $libelle_incoterms; + /** * @var string * @see display_incoterms() @@ -3721,7 +3757,7 @@ abstract class CommonObject $num = count($this->lines); - //Line extrafield + // Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafieldsline = new ExtraFields($this->db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); @@ -3730,6 +3766,7 @@ abstract class CommonObject $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + // Title line print "\n"; print ''; @@ -3821,7 +3858,6 @@ abstract class CommonObject //Line extrafield $line->fetch_optionals(); - //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) if (is_object($hookmanager)) // Old code is commented on preceding line. { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8ce8b796892..040bbb49bfa 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -100,7 +100,7 @@ class FactureFournisseur extends CommonInvoice public $total_localtax1=0; public $total_localtax2=0; public $total_ttc=0; - /** + /** * @deprecated * @see note_private, note_public */ @@ -663,7 +663,9 @@ class FactureFournisseur extends CommonInvoice */ 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'; @@ -673,7 +675,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) @@ -691,6 +692,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; @@ -1724,7 +1728,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); @@ -1804,6 +1808,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; @@ -2633,6 +2640,9 @@ class SupplierInvoiceLine extends CommonObjectLine */ public $description; + public $date_start; + public $date_end; + public $skip_update_total; // Skip update price total for special lines /** @@ -2690,7 +2700,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'; @@ -2717,6 +2727,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; @@ -2848,6 +2860,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); @@ -3022,12 +3036,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 {