Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop
This commit is contained in:
Laurent Destailleur 2022-04-05 13:48:39 +02:00
parent d270a1a64b
commit 7c591d95d9

View File

@ -1759,14 +1759,15 @@ class FactureFournisseurRec extends CommonInvoice
return -2; return -2;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); $sql .= " SET frequency = ".($frequency ? ((int) $this->db->escape($frequency)) : "NULL");
if (!empty($unit)) { if (!empty($unit)) {
$sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; $sql .= ", unit_frequency = '".$this->db->escape($unit)."'";
} }
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this).'::setFrequencyAndUnit', LOG_DEBUG); dol_syslog(get_class($this).'::setFrequencyAndUnit', LOG_DEBUG);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$this->frequency = $frequency; $this->frequency = $frequency;
if (!empty($unit)) { if (!empty($unit)) {
@ -1774,7 +1775,7 @@ class FactureFournisseurRec extends CommonInvoice
} }
return 1; return 1;
} else { } else {
dol_print_error($this->db); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@ -1792,14 +1793,15 @@ class FactureFournisseurRec extends CommonInvoice
dol_syslog(get_class($this).'::setNextDate was called on objet with property table_element not defined', LOG_ERR); dol_syslog(get_class($this).'::setNextDate was called on objet with property table_element not defined', LOG_ERR);
return -1; return -1;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET date_when = ' .($date ? "'".$this->db->idate($date)."'" : 'null'); $sql .= " SET date_when = " .($date ? "'".$this->db->idate($date)."'" : "NULL");
if ($increment_nb_gen_done > 0) { if ($increment_nb_gen_done > 0) {
$sql .= ', nb_gen_done = nb_gen_done + 1'; $sql .= ", nb_gen_done = nb_gen_done + 1";
} }
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setNextDate', LOG_DEBUG); dol_syslog(get_class($this).'::setNextDate', LOG_DEBUG);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$this->date_when = $date; $this->date_when = $date;
if ($increment_nb_gen_done > 0) { if ($increment_nb_gen_done > 0) {
@ -1807,7 +1809,7 @@ class FactureFournisseurRec extends CommonInvoice
} }
return 1; return 1;
} else { } else {
dol_print_error($this->db); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@ -1829,11 +1831,12 @@ class FactureFournisseurRec extends CommonInvoice
$nb = 0; $nb = 0;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '. (int) $nb; $sql .= " SET nb_gen_max = ". (int) $nb;
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setMaxPeriod', LOG_DEBUG); dol_syslog(get_class($this).'::setMaxPeriod', LOG_DEBUG);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$this->nb_gen_max = $nb; $this->nb_gen_max = $nb;
return 1; return 1;
@ -1856,11 +1859,12 @@ class FactureFournisseurRec extends CommonInvoice
return -1; return -1;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET auto_validate = '.((int) $validate); $sql .= " SET auto_validate = ".((int) $validate);
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setAutoValidate', LOG_DEBUG); dol_syslog(get_class($this).'::setAutoValidate', LOG_DEBUG);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$this->auto_validate = $validate; $this->auto_validate = $validate;
return 1; return 1;
@ -1883,11 +1887,12 @@ class FactureFournisseurRec extends CommonInvoice
return -1; return -1;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET generate_pdf = '. (int) $validate; $sql .= " SET generate_pdf = ". (int) $validate;
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setGeneratePdf', LOG_DEBUG); dol_syslog(get_class($this).'::setGeneratePdf', LOG_DEBUG);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$this->generate_pdf = $validate; $this->generate_pdf = $validate;
return 1; return 1;
@ -1910,11 +1915,12 @@ class FactureFournisseurRec extends CommonInvoice
return -1; return -1;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET modelpdf = '".$this->db->escape($model)."'"; $sql .= " SET modelpdf = '".$this->db->escape($model)."'";
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setModelPdf', LOG_DEBUG); dol_syslog(get_class($this).'::setModelPdf', LOG_DEBUG);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$this->model_pdf = $model; $this->model_pdf = $model;
return 1; return 1;
@ -2137,8 +2143,8 @@ class FactureFournisseurLigneRec extends CommonObjectLine
$sql .= ' fk_facture_fourn = ' . (int) $this->fk_facture_fourn; $sql .= ' fk_facture_fourn = ' . (int) $this->fk_facture_fourn;
$sql .= ', fk_parent_line = ' . (int) $this->fk_parent; $sql .= ', fk_parent_line = ' . (int) $this->fk_parent;
$sql .= ', fk_product = ' . (int) $this->fk_product; $sql .= ', fk_product = ' . (int) $this->fk_product;
$sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'null'); $sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'NULL');
$sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'null'); $sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'NULL');
$sql .= ", description = '" . $this->db->escape($this->description) . "'"; $sql .= ", description = '" . $this->db->escape($this->description) . "'";
$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);
@ -2161,12 +2167,11 @@ class FactureFournisseurLigneRec extends CommonObjectLine
$sql .= ', product_type = ' . (int) $this->product_type; $sql .= ', product_type = ' . (int) $this->product_type;
$sql .= ', date_start = ' . (int) $this->date_start; $sql .= ', date_start = ' . (int) $this->date_start;
$sql .= ', date_end = ' . (int) $this->date_end; $sql .= ', date_end = ' . (int) $this->date_end;
$sql .= ", info_bits ='" . price2num($this->info_bits) . "'"; $sql .= ", info_bits = " . ((int) $this->info_bits);
$sql .= ', special_code =' . (int) $this->special_code; $sql .= ', special_code =' . (int) $this->special_code;
$sql .= ', rang = ' . (int) $this->rang; $sql .= ', rang = ' . (int) $this->rang;
$sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null'); $sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
$sql .= ', fk_user_modif = ' . (int) $user; $sql .= ', fk_user_modif = ' . (int) $user;
$sql .= ' WHERE rowid = ' . (int) $this->id; $sql .= ' WHERE rowid = ' . (int) $this->id;
$this->db->begin(); $this->db->begin();