|
@@ -186,6 +186,8 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
public $fac_rec;
|
|
|
|
|
|
+ public $date_pointoftax;
|
|
|
+
|
|
|
// Multicurrency
|
|
|
/**
|
|
|
* @var int ID
|
|
@@ -645,7 +647,7 @@ class Facture extends CommonInvoice
|
|
|
$sql .= ", ".$this->cond_reglement_id;
|
|
|
$sql .= ", ".$this->mode_reglement_id;
|
|
|
$sql .= ", '".$this->db->idate($this->date_lim_reglement)."'";
|
|
|
- $sql .= ", ".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null");
|
|
|
+ $sql .= ", ".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null");
|
|
|
$sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null");
|
|
|
$sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null");
|
|
|
$sql .= ", ".($this->situation_final ? $this->situation_final : 0);
|
|
@@ -1080,6 +1082,8 @@ class Facture extends CommonInvoice
|
|
|
$facture->retained_warranty_fk_cond_reglement = $this->retained_warranty_fk_cond_reglement;
|
|
|
$facture->retained_warranty_date_limit = $this->retained_warranty_date_limit;
|
|
|
|
|
|
+ $facture->fk_user_author = $user->id;
|
|
|
+
|
|
|
|
|
|
// Loop on each line of new invoice
|
|
|
foreach ($facture->lines as $i => $tmpline)
|
|
@@ -1164,8 +1168,10 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
// Clear fields
|
|
|
$object->date = (empty($this->date) ? dol_now() : $this->date);
|
|
|
- $object->user_author = $user->id;
|
|
|
- $object->user_valid = '';
|
|
|
+ $object->user_author = $user->id; // deprecated
|
|
|
+ $object->user_valid = null; // deprecated
|
|
|
+ $object->fk_user_author = $user->id;
|
|
|
+ $object->fk_user_valid = null;
|
|
|
$object->fk_facture_source = 0;
|
|
|
$object->date_creation = '';
|
|
|
$object->date_modification = '';
|
|
@@ -1317,8 +1323,9 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
// get extrafields from original line
|
|
|
$object->lines[$i]->fetch_optionals();
|
|
|
- foreach ($object->lines[$i]->array_options as $options_key => $value)
|
|
|
+ foreach ($object->lines[$i]->array_options as $options_key => $value) {
|
|
|
$line->array_options[$options_key] = $value;
|
|
|
+ }
|
|
|
|
|
|
$this->lines[$i] = $line;
|
|
|
}
|
|
@@ -1348,6 +1355,8 @@ class Facture extends CommonInvoice
|
|
|
$this->origin = $object->element;
|
|
|
$this->origin_id = $object->id;
|
|
|
|
|
|
+ $this->fk_user_author = $user->id;
|
|
|
+
|
|
|
// get extrafields from original line
|
|
|
$object->fetch_optionals();
|
|
|
foreach ($object->array_options as $options_key => $value)
|
|
@@ -1362,8 +1371,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
$ret = $this->create($user);
|
|
|
|
|
|
- if ($ret > 0)
|
|
|
- {
|
|
|
+ if ($ret > 0) {
|
|
|
// Actions hooked (by external module)
|
|
|
$hookmanager->initHooks(array('invoicedao'));
|
|
|
|
|
@@ -1600,8 +1608,10 @@ class Facture extends CommonInvoice
|
|
|
$this->note = $obj->note_private; // deprecated
|
|
|
$this->note_private = $obj->note_private;
|
|
|
$this->note_public = $obj->note_public;
|
|
|
- $this->user_author = $obj->fk_user_author;
|
|
|
- $this->user_valid = $obj->fk_user_valid;
|
|
|
+ $this->user_author = $obj->fk_user_author; // deprecated
|
|
|
+ $this->user_valid = $obj->fk_user_valid; // deprecated
|
|
|
+ $this->fk_user_author = $obj->fk_user_author;
|
|
|
+ $this->fk_user_valid = $obj->fk_user_valid;
|
|
|
$this->model_pdf = $obj->model_pdf;
|
|
|
$this->modelpdf = $obj->model_pdf; // deprecated
|
|
|
$this->last_main_doc = $obj->last_main_doc;
|
|
@@ -1890,7 +1900,7 @@ class Facture extends CommonInvoice
|
|
|
$sql .= " date_lim_reglement=".(strval($this->date_lim_reglement) != '' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').",";
|
|
|
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
|
|
|
$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
|
|
|
- $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").",";
|
|
|
+ $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
|
|
|
$sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").",";
|
|
|
$sql .= " situation_cycle_ref=".(empty($this->situation_cycle_ref) ? "null" : $this->db->escape($this->situation_cycle_ref)).",";
|
|
|
$sql .= " situation_counter=".(empty($this->situation_counter) ? "null" : $this->db->escape($this->situation_counter)).",";
|
|
@@ -2113,7 +2123,7 @@ class Facture extends CommonInvoice
|
|
|
|
|
|
$rowid = $this->id;
|
|
|
|
|
|
- dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG);
|
|
|
+ dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".(empty($this->thirdparty) ? '' : $this->thirdparty->name), LOG_DEBUG);
|
|
|
|
|
|
// Test to avoid invoice deletion (allowed if draft)
|
|
|
$result = $this->is_erasable();
|
|
@@ -4118,7 +4128,7 @@ class Facture extends CommonInvoice
|
|
|
*/
|
|
|
public function initAsSpecimen($option = '')
|
|
|
{
|
|
|
- global $conf, $langs;
|
|
|
+ global $conf, $langs, $user;
|
|
|
|
|
|
$now = dol_now();
|
|
|
$arraynow = dol_getdate($now);
|
|
@@ -4167,6 +4177,8 @@ class Facture extends CommonInvoice
|
|
|
$this->note_private = 'This is a comment (private)';
|
|
|
$this->note = 'This is a comment (private)';
|
|
|
|
|
|
+ $this->fk_user_author = $user->id;
|
|
|
+
|
|
|
$this->multicurrency_tx = 1;
|
|
|
$this->multicurrency_code = $conf->currency;
|
|
|
|
|
@@ -4326,8 +4338,8 @@ class Facture extends CommonInvoice
|
|
|
/**
|
|
|
* Create a document onto disk according to template module.
|
|
|
*
|
|
|
- * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf','alpha') for example.
|
|
|
- * @param Translate $outputlangs objet lang a utiliser pour traduction
|
|
|
+ * @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example.
|
|
|
+ * @param Translate $outputlangs Object lang to use for translation
|
|
|
* @param int $hidedetails Hide details of lines
|
|
|
* @param int $hidedesc Hide description
|
|
|
* @param int $hideref Hide ref
|
|
@@ -4345,7 +4357,9 @@ class Facture extends CommonInvoice
|
|
|
$modele = 'crabe';
|
|
|
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type;
|
|
|
|
|
|
- if (!empty($this->modelpdf)) {
|
|
|
+ if (!empty($this->model_pdf)) {
|
|
|
+ $modele = $this->model_pdf;
|
|
|
+ } elseif (!empty($this->modelpdf)) { // deprecated
|
|
|
$modele = $this->modelpdf;
|
|
|
} elseif (!empty($conf->global->$thisTypeConfName)) {
|
|
|
$modele = $conf->global->$thisTypeConfName;
|