Fix date_start and date_end not saved on supplier invoice

Conflicts:
	htdocs/core/class/commonobject.class.php
	htdocs/fourn/class/fournisseur.facture.class.php
	htdocs/fourn/facture/card.php
This commit is contained in:
Laurent Destailleur 2018-08-29 17:03:18 +02:00
parent 74b3e3e814
commit 7bf48b8d77
2 changed files with 58 additions and 9 deletions

View File

@ -46,47 +46,58 @@ abstract class CommonObject
* @var DoliDb Database handler (result of a new DoliDB) * @var DoliDb Database handler (result of a new DoliDB)
*/ */
public $db; public $db;
/** /**
* @var int The object identifier * @var int The object identifier
*/ */
public $id; public $id;
/** /**
* @var string Error string * @var string Error string
* @see errors * @see errors
*/ */
public $error; public $error;
/** /**
* @var string[] Array of error strings * @var string[] Array of error strings
*/ */
public $errors=array(); public $errors=array();
/** /**
* @var string * @var string
*/ */
public $element; public $element;
/** /**
* @var string * @var string
*/ */
public $table_element; public $table_element;
/** /**
* @var * @var
*/ */
public $table_element_line; public $table_element_line;
/** /**
* @var string Key value used to track if data is coming from import wizard * @var string Key value used to track if data is coming from import wizard
*/ */
public $import_key; public $import_key;
/** /**
* @var mixed Contains data to manage extrafields * @var mixed Contains data to manage extrafields
*/ */
public $array_options=array(); public $array_options=array();
/** /**
* @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked
*/ */
public $linkedObjectsIds; public $linkedObjectsIds;
/** /**
* @var mixed Array of linked objects. Loaded by ->fetchObjectLinked * @var mixed Array of linked objects. Loaded by ->fetchObjectLinked
*/ */
public $linkedObjects; public $linkedObjects;
/** /**
* @var Object To store a cloned copy of object before to edit it and keep track of old properties * @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() * @see fetch_projet()
*/ */
public $project; public $project;
/** /**
* @var int The related project ID * @var int The related project ID
* @see setProject(), project * @see setProject(), project
*/ */
public $fk_project; public $fk_project;
/** /**
* @deprecated * @deprecated
* @see project * @see project
@ -132,6 +145,7 @@ abstract class CommonObject
* @see fetch_contact() * @see fetch_contact()
*/ */
public $contact; public $contact;
/** /**
* @var int The related contact ID * @var int The related contact ID
* @see fetch_contact() * @see fetch_contact()
@ -165,14 +179,17 @@ abstract class CommonObject
* @var string The object's reference * @var string The object's reference
*/ */
public $ref; public $ref;
/** /**
* @var string The object's previous reference * @var string The object's previous reference
*/ */
public $ref_previous; public $ref_previous;
/** /**
* @var string The object's next reference * @var string The object's next reference
*/ */
public $ref_next; public $ref_next;
/** /**
* @var string An external reference for the object * @var string An external reference for the object
*/ */
@ -189,36 +206,43 @@ abstract class CommonObject
* @see getFullAddress() * @see getFullAddress()
*/ */
public $country; public $country;
/** /**
* @var int * @var int
* @see getFullAddress(), country * @see getFullAddress(), country
*/ */
public $country_id; public $country_id;
/** /**
* @var string * @var string
* @see getFullAddress(), isInEEC(), country * @see getFullAddress(), isInEEC(), country
*/ */
public $country_code; public $country_code;
/** /**
* @var string * @var string
* @see getFullAddress() * @see getFullAddress()
*/ */
public $state; public $state;
/** /**
* @var int * @var int
* @see getFullAddress(), state * @see getFullAddress(), state
*/ */
public $state_id; public $state_id;
/** /**
* @var string * @var string
* @see getFullAddress(), state * @see getFullAddress(), state
*/ */
public $state_code; public $state_code;
/** /**
* @var string * @var string
* @see getFullAddress(), region * @see getFullAddress(), region
*/ */
public $region; public $region;
/** /**
* @var string * @var string
* @see getFullAddress(), region * @see getFullAddress(), region
@ -230,16 +254,19 @@ abstract class CommonObject
* @see fetch_barcode() * @see fetch_barcode()
*/ */
public $barcode_type; public $barcode_type;
/** /**
* @var string * @var string
* @see fetch_barcode(), barcode_type * @see fetch_barcode(), barcode_type
*/ */
public $barcode_type_code; public $barcode_type_code;
/** /**
* @var string * @var string
* @see fetch_barcode(), barcode_type * @see fetch_barcode(), barcode_type
*/ */
public $barcode_type_label; public $barcode_type_label;
/** /**
* @var string * @var string
* @see fetch_barcode(), barcode_type * @see fetch_barcode(), barcode_type
@ -257,6 +284,7 @@ abstract class CommonObject
* @see setPaymentTerms() * @see setPaymentTerms()
*/ */
public $cond_reglement_id; public $cond_reglement_id;
/** /**
* @var int Payment terms ID * @var int Payment terms ID
* @deprecated Kept for compatibility * @deprecated Kept for compatibility
@ -294,11 +322,13 @@ abstract class CommonObject
* @see update_note() * @see update_note()
*/ */
public $note_public; public $note_public;
/** /**
* @var string Private note * @var string Private note
* @see update_note() * @see update_note()
*/ */
public $note_private; public $note_private;
/** /**
* @deprecated * @deprecated
* @see note_public * @see note_public
@ -310,21 +340,25 @@ abstract class CommonObject
* @see update_price() * @see update_price()
*/ */
public $total_ht; public $total_ht;
/** /**
* @var float Total VAT amount * @var float Total VAT amount
* @see update_price() * @see update_price()
*/ */
public $total_tva; public $total_tva;
/** /**
* @var float Total local tax 1 amount * @var float Total local tax 1 amount
* @see update_price() * @see update_price()
*/ */
public $total_localtax1; public $total_localtax1;
/** /**
* @var float Total local tax 2 amount * @var float Total local tax 2 amount
* @see update_price() * @see update_price()
*/ */
public $total_localtax2; public $total_localtax2;
/** /**
* @var float Total amount with taxes * @var float Total amount with taxes
* @see update_price() * @see update_price()
@ -347,11 +381,13 @@ abstract class CommonObject
* @see setIncoterms() * @see setIncoterms()
*/ */
public $fk_incoterms; public $fk_incoterms;
/** /**
* @var string * @var string
* @see SetIncoterms() * @see SetIncoterms()
*/ */
public $libelle_incoterms; public $libelle_incoterms;
/** /**
* @var string * @var string
* @see display_incoterms() * @see display_incoterms()
@ -3721,7 +3757,7 @@ abstract class CommonObject
$num = count($this->lines); $num = count($this->lines);
//Line extrafield // Line extrafield
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline = new ExtraFields($this->db); $extrafieldsline = new ExtraFields($this->db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); $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 $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) if (empty($reshook))
{ {
// Title line
print "<thead>\n"; print "<thead>\n";
print '<tr class="liste_titre nodrag nodrop">'; print '<tr class="liste_titre nodrag nodrop">';
@ -3821,7 +3858,6 @@ abstract class CommonObject
//Line extrafield //Line extrafield
$line->fetch_optionals(); $line->fetch_optionals();
//if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) //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. if (is_object($hookmanager)) // Old code is commented on preceding line.
{ {

View File

@ -100,7 +100,7 @@ class FactureFournisseur extends CommonInvoice
public $total_localtax1=0; public $total_localtax1=0;
public $total_localtax2=0; public $total_localtax2=0;
public $total_ttc=0; public $total_ttc=0;
/** /**
* @deprecated * @deprecated
* @see note_private, note_public * @see note_private, note_public
*/ */
@ -663,7 +663,9 @@ class FactureFournisseur extends CommonInvoice
*/ */
function fetch_lines() 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.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.= ', 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'; $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.= ' WHERE fk_facture_fourn='.$this->id;
$sql.= ' ORDER BY f.rang, f.rowid'; $sql.= ' ORDER BY f.rang, f.rowid';
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$resql_rows = $this->db->query($sql); $resql_rows = $this->db->query($sql);
if ($resql_rows) if ($resql_rows)
@ -691,6 +692,9 @@ class FactureFournisseur extends CommonInvoice
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->rowid = $obj->rowid; $line->rowid = $obj->rowid;
$line->description = $obj->description; $line->description = $obj->description;
$line->date_start = $obj->date_start;
$line->date_end = $obj->date_end;
$line->product_ref = $obj->product_ref; $line->product_ref = $obj->product_ref;
$line->ref = $obj->product_ref; $line->ref = $obj->product_ref;
$line->ref_supplier = $obj->ref_supplier; $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='') 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; 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'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$pu = price2num($pu); $pu = price2num($pu);
@ -1804,6 +1808,9 @@ class FactureFournisseur extends CommonInvoice
$line->remise_percent = $remise_percent; $line->remise_percent = $remise_percent;
$line->ref_supplier = $ref_supplier; $line->ref_supplier = $ref_supplier;
$line->date_start = $date_start;
$line->date_end = $date_end;
$line->vat_src_code=$vat_src_code; $line->vat_src_code=$vat_src_code;
$line->tva_tx = $vatrate; $line->tva_tx = $vatrate;
$line->localtax1_tx = $txlocaltax1; $line->localtax1_tx = $txlocaltax1;
@ -2633,6 +2640,9 @@ class SupplierInvoiceLine extends CommonObjectLine
*/ */
public $description; public $description;
public $date_start;
public $date_end;
public $skip_update_total; // Skip update price total for special lines public $skip_update_total; // Skip update price total for special lines
/** /**
@ -2690,7 +2700,7 @@ class SupplierInvoiceLine extends CommonObjectLine
*/ */
public function fetch($rowid) 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.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.= ', 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'; $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->rowid = $obj->rowid;
$this->fk_facture_fourn = $obj->fk_facture_fourn; $this->fk_facture_fourn = $obj->fk_facture_fourn;
$this->description = $obj->description; $this->description = $obj->description;
$this->date_start = $obj->date_start;
$this->date_end = $obj->date_end;
$this->product_ref = $obj->product_ref; $this->product_ref = $obj->product_ref;
$this->ref_supplier = $obj->ref_supplier; $this->ref_supplier = $obj->ref_supplier;
$this->libelle = $obj->label; $this->libelle = $obj->label;
@ -2848,6 +2860,8 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " description ='".$this->db->escape($this->description)."'"; $sql.= " description ='".$this->db->escape($this->description)."'";
$sql.= ", ref ='".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'"; $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_ht = ".price2num($this->pu_ht);
$sql.= ", pu_ttc = ".price2num($this->pu_ttc); $sql.= ", pu_ttc = ".price2num($this->pu_ttc);
$sql.= ", qty = ".price2num($this->qty); $sql.= ", qty = ".price2num($this->qty);
@ -3022,12 +3036,11 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql.= ", ".price2num($this->multicurrency_total_ttc); $sql.= ", ".price2num($this->multicurrency_total_ttc);
$sql.= ')'; $sql.= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $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 if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {