FIX #yogosha5746 - next step (wip)

This commit is contained in:
Laurent Destailleur 2021-03-30 11:36:50 +02:00
parent 6c98276ead
commit 6e422d26f3
56 changed files with 140 additions and 175 deletions

View File

@ -149,7 +149,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
// Check that all fields are filled // Check that all fields are filled
$ok = 1; $ok = 1;
foreach ($listfield as $f => $value) { foreach ($listfield as $f => $value) {
if ($value == 'formula' && empty($_POST['formula'])) { if ($value == 'formula' && !GETPOST('formula')) {
continue; continue;
} }
if ($value == 'range_account' && empty($_POST['range_account'])) { if ($value == 'range_account' && empty($_POST['range_account'])) {

View File

@ -863,7 +863,7 @@ class AccountancyCategory // extends CommonObject
if (!empty($cat_id)) { if (!empty($cat_id)) {
$sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = ".$cat_id; $sql .= " WHERE t.fk_accounting_category = ".((int) $cat_id);
$sql .= " AND t.entity = ".$conf->entity; $sql .= " AND t.entity = ".$conf->entity;
$sql .= " ORDER BY t.account_number"; $sql .= " ORDER BY t.account_number";
} else { } else {

View File

@ -1644,7 +1644,7 @@ class AccountancyExport
// Get new customer invoice ref and company name // Get new customer invoice ref and company name
$sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
$sql .= ' WHERE f.rowid = ' . $line->fk_doc; $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($obj = $this->db->fetch_object($resql)) { if ($obj = $this->db->fetch_object($resql)) {
@ -1658,7 +1658,7 @@ class AccountancyExport
// Get new supplier invoice ref and company name // Get new supplier invoice ref and company name
$sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
$sql .= ' WHERE ff.rowid = ' . $line->fk_doc; $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($obj = $this->db->fetch_object($resql)) { if ($obj = $this->db->fetch_object($resql)) {

View File

@ -421,7 +421,7 @@ if ($result) {
//$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount;
$sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
$sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l';
$sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid; $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid);
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);

View File

@ -1367,7 +1367,7 @@ class ActionComm extends CommonObject
$sql .= ' fk_user_author,'; $sql .= ' fk_user_author,';
$sql .= ' fk_user_mod'; $sql .= ' fk_user_mod';
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
$sql .= ' WHERE a.id = '.$id; $sql .= ' WHERE a.id = '.((int) $id);
dol_syslog(get_class($this)."::info", LOG_DEBUG); dol_syslog(get_class($this)."::info", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -2997,7 +2997,7 @@ class Propal extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_availability = '.$availability_id; $sql .= ' SET fk_availability = '.((int) $availability_id);
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG); dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG);
@ -3061,7 +3061,7 @@ class Propal extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' SET fk_input_reason = '.((int) $demand_reason_id);
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
dol_syslog(__METHOD__.' demand_reason('.$demand_reason_id.')', LOG_DEBUG); dol_syslog(__METHOD__.' demand_reason('.$demand_reason_id.')', LOG_DEBUG);

View File

@ -100,18 +100,18 @@ class PropaleStats extends Stats
$this->where .= " AND p.fk_soc = ".$this->socid; $this->where .= " AND p.fk_soc = ".$this->socid;
} }
if ($this->userid > 0) { if ($this->userid > 0) {
$this->where .= ' AND fk_user_author = '.$this->userid; $this->where .= ' AND fk_user_author = '.((int) $this->userid);
} }
if ($typentid) { if ($typentid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
$this->where .= ' AND s.fk_typent = '.$typentid; $this->where .= ' AND s.fk_typent = '.((int) $typentid);
} }
if ($categid) { if ($categid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie';
$this->where .= ' AND c.rowid = '.$categid; $this->where .= ' AND c.rowid = '.((int) $categid);
} }
} }

View File

@ -2417,7 +2417,7 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET remise_percent = '.((float) $remise); $sql .= ' SET remise_percent = '.((float) $remise);
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -2743,7 +2743,7 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_availability = '.$availability_id; $sql .= ' SET fk_availability = '.((int) $availability_id);
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -2807,7 +2807,7 @@ class Commande extends CommonOrder
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' SET fk_input_reason = '.((int) $demand_reason_id);
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);

View File

@ -100,13 +100,13 @@ class CommandeStats extends Stats
if ($typentid) { if ($typentid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc';
$this->where .= ' AND s.fk_typent = '.$typentid; $this->where .= ' AND s.fk_typent = '.((int) $typentid);
} }
if ($categid) { if ($categid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie';
$this->where .= ' AND cat.rowid = '.$categid; $this->where .= ' AND cat.rowid = '.((int) $categid);
} }
} }

View File

@ -572,7 +572,7 @@ class PaymentVarious extends CommonObject
public function update_fk_bank($id_bank) public function update_fk_bank($id_bank)
{ {
// phpcs:enable // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.((int) $id_bank);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {

View File

@ -179,7 +179,8 @@ $sqlrequestforbankline = $sql;
if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) {
// TODO Add a test to check newbankreceipt does not exists yet // TODO Add a test to check newbankreceipt does not exists yet
$sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id; $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank';
$sqlupdate .= ' SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.((int) $id);
$result = $db->query($sqlupdate); $result = $db->query($sqlupdate);
if ($result < 0) { if ($result < 0) {
dol_print_error($db); dol_print_error($db);

View File

@ -213,7 +213,7 @@ class CashControl extends CommonObject
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."pos_cash_fence"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."pos_cash_fence");
$sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.((int) $this->id);
$this->db->query($sql); $this->db->query($sql);
} }

View File

@ -3091,7 +3091,7 @@ if ($action == 'create') {
$sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r';
$sql .= ' WHERE r.fk_soc = '.$invoice_predefined->socid; $sql .= ' WHERE r.fk_soc = '.((int) $invoice_predefined->socid);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {

View File

@ -1808,7 +1808,7 @@ class FactureRec extends CommonInvoice
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '.$nb; $sql .= ' SET nb_gen_max = '.((int) $nb);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG);
@ -1835,7 +1835,7 @@ class FactureRec extends CommonInvoice
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET auto_validate = '.$validate; $sql .= ' SET auto_validate = '.((int) $validate);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG);
@ -1862,7 +1862,7 @@ class FactureRec extends CommonInvoice
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET generate_pdf = '.$validate; $sql .= ' SET generate_pdf = '.((int) $validate);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG);

View File

@ -2282,9 +2282,9 @@ class Facture extends CommonInvoice
// Invoice line extrafileds // Invoice line extrafileds
$main = MAIN_DB_PREFIX.'facturedet'; $main = MAIN_DB_PREFIX.'facturedet';
$ef = $main."_extrafields"; $ef = $main."_extrafields";
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid);
// Delete invoice line // Delete invoice line
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.((int) $rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
@ -3585,8 +3585,7 @@ class Facture extends CommonInvoice
{ {
$sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd
INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid)
WHERE fd.fk_prev_id = '.$idline.' WHERE fd.fk_prev_id = '.((int) $idline).' AND f.fk_statut <> 0';
AND f.fk_statut <> 0';
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (!$result) { if (!$result) {
@ -3663,7 +3662,7 @@ class Facture extends CommonInvoice
// Libere remise liee a ligne de facture // Libere remise liee a ligne de facture
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' SET fk_facture_line = NULL'; $sql .= ' SET fk_facture_line = NULL';
$sql .= ' WHERE fk_facture_line = '.$rowid; $sql .= ' WHERE fk_facture_line = '.((int) $rowid);
dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); dol_syslog(get_class($this)."::deleteline", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -4610,7 +4609,7 @@ class Facture extends CommonInvoice
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.((int) $this->id);
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -105,13 +105,13 @@ class FactureStats extends Stats
if ($typentid) { if ($typentid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = f.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = f.fk_soc';
$this->where .= ' AND s.fk_typent = '.$typentid; $this->where .= ' AND s.fk_typent = '.((int) $typentid);
} }
if ($categid) { if ($categid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = f.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = f.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie';
$this->where .= ' AND c.rowid = '.$categid; $this->where .= ' AND c.rowid = '.((int) $categid);
} }
} }

View File

@ -559,8 +559,8 @@ class Localtax extends CommonObject
public function update_fk_bank($id) public function update_fk_bank($id)
{ {
// phpcs:enable // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.((int) $id);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.((int) $this->id);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
return 1; return 1;

View File

@ -187,7 +187,7 @@ class Cpaiement
$sql .= ' WHERE t.entity IN ('.getEntity('c_paiement').')'; $sql .= ' WHERE t.entity IN ('.getEntity('c_paiement').')';
$sql .= " AND t.code = '".$this->db->escape($ref)."'"; $sql .= " AND t.code = '".$this->db->escape($ref)."'";
} else { } else {
$sql .= ' WHERE t.id = '.$id; $sql .= ' WHERE t.id = '.((int) $id);
} }
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -736,7 +736,7 @@ class Paiement extends CommonObject
public function update_fk_bank($id_bank) public function update_fk_bank($id_bank)
{ {
// phpcs:enable // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.((int) $id_bank);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG); dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG);
@ -855,7 +855,7 @@ class Paiement extends CommonObject
*/ */
public function validate(User $user = null) public function validate(User $user = null)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.((int) $this->id);
dol_syslog(get_class($this).'::valide', LOG_DEBUG); dol_syslog(get_class($this).'::valide', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -876,7 +876,7 @@ class Paiement extends CommonObject
*/ */
public function reject(User $user = null) public function reject(User $user = null)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.((int) $this->id);
dol_syslog(get_class($this).'::reject', LOG_DEBUG); dol_syslog(get_class($this).'::reject', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -190,7 +190,7 @@ class Cchargesociales
if (null !== $ref) { if (null !== $ref) {
$sql .= " WHERE t.code = '".$this->db->escape($ref)."'"; $sql .= " WHERE t.code = '".$this->db->escape($ref)."'";
} else { } else {
$sql .= ' WHERE t.id = '.$id; $sql .= ' WHERE t.id = '.((int) $id);
} }
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -801,7 +801,7 @@ abstract class CommonInvoice extends CommonObject
{ {
// phpcs:enable // phpcs:enable
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ' WHERE rowid = '.$did; $sql .= ' WHERE rowid = '.((int) $did);
$sql .= ' AND traite = 0'; $sql .= ' AND traite = 0';
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
return 0; return 0;

View File

@ -2332,7 +2332,7 @@ abstract class CommonObject
$fieldname = 'multicurrency_tx'; $fieldname = 'multicurrency_tx';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$rate; $sql .= ' SET '.$fieldname.' = '.((float) $rate);
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
@ -2617,7 +2617,7 @@ abstract class CommonObject
$fieldname = 'retained_warranty_fk_cond_reglement'; $fieldname = 'retained_warranty_fk_cond_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id; $sql .= ' SET '.$fieldname.' = '.((int) $id);
$sql .= ' WHERE rowid='.((int) $this->id); $sql .= ' WHERE rowid='.((int) $this->id);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
@ -3062,11 +3062,11 @@ abstract class CommonObject
$fieldposition = 'position'; $fieldposition = 'position';
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
$sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql .= ' AND rang = '.($rang - 1); $sql .= ' AND rang = '.($rang - 1);
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1));
$sql .= ' WHERE rowid = '.((int) $rowid); $sql .= ' WHERE rowid = '.((int) $rowid);
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
dol_print_error($this->db); dol_print_error($this->db);
@ -3093,11 +3093,11 @@ abstract class CommonObject
$fieldposition = 'position'; $fieldposition = 'position';
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
$sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql .= ' AND rang = '.($rang + 1); $sql .= ' AND rang = '.((int) ($rang + 1));
if ($this->db->query($sql)) { if ($this->db->query($sql)) {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang + 1); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1));
$sql .= ' WHERE rowid = '.((int) $rowid); $sql .= ' WHERE rowid = '.((int) $rowid);
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
dol_print_error($this->db); dol_print_error($this->db);
@ -4221,7 +4221,7 @@ abstract class CommonObject
public function getSpecialCode($lineid) public function getSpecialCode($lineid)
{ {
$sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql .= ' WHERE rowid = '.$lineid; $sql .= ' WHERE rowid = '.((int) $lineid);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
@ -7656,7 +7656,7 @@ abstract class CommonObject
public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
{ {
foreach ($tables as $table) { foreach ($tables as $table) {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id; $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id);
if (!$db->query($sql)) { if (!$db->query($sql)) {
if ($ignoreerrors) { if ($ignoreerrors) {

View File

@ -879,7 +879,7 @@ class dolReceiptPrinter extends Printer
$error = 0; $error = 0;
$sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
$sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql .= ' WHERE rowid = '.$printerid; $sql .= ' WHERE rowid = '.((int) $printerid);
$sql .= ' AND entity = '.$conf->entity; $sql .= ' AND entity = '.$conf->entity;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

View File

@ -163,7 +163,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
} }
$newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d'); $newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d');
$sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.((int) $ref_number_int).' WHERE rowid = '.((int) $object->id);
$resqlbis = $db->query($sqlbis); $resqlbis = $db->query($sqlbis);
if (!$resqlbis) { if (!$resqlbis) {
dol_print_error($resqlbis); dol_print_error($resqlbis);

View File

@ -790,7 +790,7 @@ class ImportCsv extends ModeleImports
if (empty($keyfield)) { if (empty($keyfield)) {
$keyfield = 'rowid'; $keyfield = 'rowid';
} }
$sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; $sqlSelect .= ' WHERE '.$keyfield.' = '.((int) $lastinsertid);
$resql = $this->db->query($sqlSelect); $resql = $this->db->query($sqlSelect);
if ($resql) { if ($resql) {
@ -824,7 +824,7 @@ class ImportCsv extends ModeleImports
if (empty($keyfield)) { if (empty($keyfield)) {
$keyfield = 'rowid'; $keyfield = 'rowid';
} }
$sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; $sqlend = ' WHERE '.$keyfield.' = '.((int) $lastinsertid);
$sql = $sqlstart.$sqlend; $sql = $sqlstart.$sqlend;

View File

@ -830,7 +830,7 @@ class ImportXlsx extends ModeleImports
if (empty($keyfield)) { if (empty($keyfield)) {
$keyfield = 'rowid'; $keyfield = 'rowid';
} }
$sqlSelect .= ' WHERE ' . $keyfield . ' = ' . $lastinsertid; $sqlSelect .= ' WHERE ' . $keyfield . ' = ' .((int) $lastinsertid);
$resql = $this->db->query($sqlSelect); $resql = $this->db->query($sqlSelect);
if ($resql) { if ($resql) {
@ -864,7 +864,7 @@ class ImportXlsx extends ModeleImports
if (empty($keyfield)) { if (empty($keyfield)) {
$keyfield = 'rowid'; $keyfield = 'rowid';
} }
$sqlend = ' WHERE ' . $keyfield . ' = ' . $lastinsertid; $sqlend = ' WHERE ' . $keyfield . ' = '.((int) $lastinsertid);
$sql = $sqlstart . $sqlend; $sql = $sqlstart . $sqlend;

View File

@ -85,7 +85,7 @@ class DonationStats extends Stats
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where .= " AND d.entity = ".$conf->entity; $this->where .= " AND d.entity = ".$conf->entity;
if ($this->userid > 0) { if ($this->userid > 0) {
$this->where .= ' WHERE c.fk_user_author = '.$this->userid; $this->where .= ' WHERE c.fk_user_author = '.((int) $this->userid);
} }
} }

View File

@ -694,7 +694,7 @@ class ConferenceOrBooth extends ActionComm
$sql = 'SELECT rowid, datec as datec, tms as datem,'; $sql = 'SELECT rowid, datec as datec, tms as datem,';
$sql .= ' fk_user_author, fk_user_mod'; $sql .= ' fk_user_author, fk_user_mod';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.id = '.$id; $sql .= ' WHERE t.id = '.((int) $id);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
if ($this->db->num_rows($result)) { if ($this->db->num_rows($result)) {

View File

@ -77,10 +77,10 @@ class ExpeditionStats extends Stats
$this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
} }
if ($this->socid) { if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid; $this->where .= " AND c.fk_soc = ".((int) $this->socid);
} }
if ($this->userid > 0) { if ($this->userid > 0) {
$this->where .= ' AND c.fk_user_author = '.$this->userid; $this->where .= ' AND c.fk_user_author = '.((int) $this->userid);
} }
} }

View File

@ -973,7 +973,7 @@ class ExpenseReport extends CommonObject
{ {
$sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva'; $sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt';
$sql .= ' WHERE tt.'.$this->fk_element.' = '.$id; $sql .= ' WHERE tt.'.$this->fk_element.' = '.((int) $id);
$total_ht = 0; $total_tva = 0; $total_ttc = 0; $total_ht = 0; $total_tva = 0; $total_ttc = 0;
@ -2757,7 +2757,7 @@ class ExpenseReportLine
$sql = 'SELECT SUM(d.total_ttc) as total_amount'; $sql = 'SELECT SUM(d.total_ttc) as total_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)';
$sql .= ' WHERE e.fk_user_author = '.$fk_user; $sql .= ' WHERE e.fk_user_author = '.((int) $fk_user);
if (!empty($this->id)) { if (!empty($this->id)) {
$sql .= ' AND d.rowid <> '.$this->id; $sql .= ' AND d.rowid <> '.$this->id;
} }

View File

@ -167,7 +167,7 @@ class ExpenseReportRule extends CoreObject
if ($fk_user > 0) { if ($fk_user > 0) {
$sql .= ' AND (er.is_for_all = 1'; $sql .= ' AND (er.is_for_all = 1';
$sql .= ' OR er.fk_user = '.$fk_user; $sql .= ' OR er.fk_user = '.$fk_user;
$sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )'; $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.((int) $fk_user).') )';
} }
$sql .= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user'; $sql .= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user';

View File

@ -784,8 +784,8 @@ class FichinterRec extends Fichinter
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '.$nb; $sql .= ' SET nb_gen_max = '.((int) $nb);
$sql .= ' WHERE rowid = '.$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)) {
@ -811,8 +811,8 @@ class FichinterRec extends Fichinter
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET auto_validate = '.$validate; $sql .= ' SET auto_validate = '.((int) $validate);
$sql .= ' WHERE rowid = '.$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)) {

View File

@ -78,10 +78,10 @@ class FichinterStats extends Stats
$this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')'; $this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')';
if ($this->socid) { if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid; $this->where .= " AND c.fk_soc = ".((int) $this->socid);
} }
if ($this->userid > 0) { if ($this->userid > 0) {
$this->where .= ' AND c.fk_user_author = '.$this->userid; $this->where .= ' AND c.fk_user_author = '.((int) $this->userid);
} }
} }

View File

@ -674,8 +674,10 @@ class CommandeFournisseurDispatch extends CommonObject
$sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
} elseif ($key == 't.datec' || $key == 't.tms' || $key == 't.eatby' || $key == 't.sellby' || $key == 't.batch') { } elseif ($key == 't.datec' || $key == 't.tms' || $key == 't.eatby' || $key == 't.sellby' || $key == 't.batch') {
$sqlwhere [] = $key.' = \''.$this->db->escape($value).'\''; $sqlwhere [] = $key.' = \''.$this->db->escape($value).'\'';
} elseif ($key == 'qty') {
$sqlwhere [] = $key.' = '.((float) $value);
} else { } else {
$sqlwhere [] = $key.' = '.$this->db->escape($value); $sqlwhere [] = $key.' = '.((int) $value);
} }
} }
} }

View File

@ -1181,7 +1181,7 @@ class FactureFournisseur extends CommonInvoice
if (!$error) { if (!$error) {
// If invoice was converted into a discount not yet consumed, we remove discount // If invoice was converted into a discount not yet consumed, we remove discount
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' WHERE fk_invoice_supplier_source = '.$rowid; $sql .= ' WHERE fk_invoice_supplier_source = '.((int) $rowid);
$sql .= ' AND fk_invoice_supplier_line IS NULL'; $sql .= ' AND fk_invoice_supplier_line IS NULL';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -2092,7 +2092,7 @@ class FactureFournisseur extends CommonInvoice
// Libere remise liee a ligne de facture // Libere remise liee a ligne de facture
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' SET fk_invoice_supplier_line = NULL'; $sql .= ' SET fk_invoice_supplier_line = NULL';
$sql .= ' WHERE fk_invoice_supplier_line = '.$rowid; $sql .= ' WHERE fk_invoice_supplier_line = '.((int) $rowid);
dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); dol_syslog(get_class($this)."::deleteline", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -106,7 +106,7 @@ function checkLinkedElements($sourcetype, $targettype)
foreach ($elements as $key => $element) { foreach ($elements as $key => $element) {
if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable)) { if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable)) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_element'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_element';
$sql .= ' WHERE rowid = '.$key; $sql .= ' WHERE rowid = '.((int) $key);
$resql = $db->query($sql); $resql = $db->query($sql);
$deleted++; $deleted++;
} }

View File

@ -1347,8 +1347,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) {
$qty_for_line = min($remaining_qty, $obj_line->qty); $qty_for_line = min($remaining_qty, $obj_line->qty);
if ($first_iteration) { if ($first_iteration) {
$sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch';
$sql_attach .= ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line; $sql_attach .= ' SET fk_commandefourndet = '.((int) $obj_line->rowid).', qty = '.((float) $qty_for_line);
$sql_attach .= ' WHERE rowid = '.$obj_dispatch->rowid; $sql_attach .= ' WHERE rowid = '.((int) $obj_dispatch->rowid);
$first_iteration = false; $first_iteration = false;
} else { } else {
$sql_attach_values = array( $sql_attach_values = array(

View File

@ -1342,7 +1342,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf)
// Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons.
$check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn';
$check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
$check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.((int) $select_obj->fk_facture_fourn);
$check_resql = $db->query($check_sql); $check_resql = $db->query($check_sql);
if ($check_resql) { if ($check_resql) {
$check_num = $db->num_rows($check_resql); $check_num = $db->num_rows($check_resql);

View File

@ -591,7 +591,7 @@ class MultiCurrency extends CommonObject
{ {
global $db; global $db;
$sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_facture; $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.((int) $fk_facture);
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -3862,7 +3862,7 @@ class Product extends CommonObject
// Check not already father of id_pere (to avoid father -> child -> father links) // Check not already father of id_pere (to avoid father -> child -> father links)
$sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association';
$sql .= ' WHERE fk_product_pere = '.$id_fils.' AND fk_product_fils = '.$id_pere; $sql .= ' WHERE fk_product_pere = '.((int) $id_fils).' AND fk_product_fils = '.((int) $id_pere);
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
@ -3875,7 +3875,7 @@ class Product extends CommonObject
return -1; return -1;
} else { } else {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)';
$sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.')'; $sql .= ' VALUES ('.((int) $id_pere).', '.((int) $id_fils).', '.((float) $qty).', '.((int) $incdec).')';
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;

View File

@ -181,10 +181,8 @@ class ProductFournisseurPrice extends CommonObject
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
// Unset fields that are disabled // Unset fields that are disabled
foreach ($this->fields as $key => $val) foreach ($this->fields as $key => $val) {
{ if (isset($val['enabled']) && empty($val['enabled'])) {
if (isset($val['enabled']) && empty($val['enabled']))
{
unset($this->fields[$key]); unset($this->fields[$key]);
} }
} }
@ -241,14 +239,11 @@ class ProductFournisseurPrice extends CommonObject
if (property_exists($object, 'date_modification')) { $object->date_modification = null; } if (property_exists($object, 'date_modification')) { $object->date_modification = null; }
// ... // ...
// Clear extrafields that are unique // Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0) if (is_array($object->array_options) && count($object->array_options) > 0) {
{
$extrafields->fetch_name_optionals_label($this->table_element); $extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option) foreach ($object->array_options as $key => $option) {
{
$shortkey = preg_replace('/options_/', '', $key); $shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
{
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit; //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]); unset($object->array_options[$key]);
} }
@ -264,20 +259,16 @@ class ProductFournisseurPrice extends CommonObject
$this->errors = $object->errors; $this->errors = $object->errors;
} }
if (!$error) if (!$error) {
{
// copy internal contacts // copy internal contacts
if ($this->copy_linked_contact($object, 'internal') < 0) if ($this->copy_linked_contact($object, 'internal') < 0) {
{
$error++; $error++;
} }
} }
if (!$error) if (!$error) {
{
// copy external contacts if same company // copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid) if (property_exists($this, 'socid') && $this->socid == $object->socid) {
{
if ($this->copy_linked_contact($object, 'external') < 0) if ($this->copy_linked_contact($object, 'external') < 0)
$error++; $error++;
} }
@ -362,8 +353,7 @@ class ProductFournisseurPrice extends CommonObject
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < ($limit ? min($limit, $num) : $num)) while ($i < ($limit ? min($limit, $num) : $num)) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$record = new self($this->db); $record = new self($this->db);
@ -424,8 +414,7 @@ class ProductFournisseurPrice extends CommonObject
$error = 0; $error = 0;
// Protection // Protection
if ($this->status == self::STATUS_VALIDATED) if ($this->status == self::STATUS_VALIDATED) {
{
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
return 0; return 0;
} }
@ -435,8 +424,7 @@ class ProductFournisseurPrice extends CommonObject
$this->db->begin(); $this->db->begin();
// Define new ref // Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
{
$num = $this->getNextNumRef(); $num = $this->getNextNumRef();
} else { } else {
$num = $this->ref; $num = $this->ref;
@ -454,15 +442,13 @@ class ProductFournisseurPrice extends CommonObject
dol_syslog(get_class($this)."::validate()", LOG_DEBUG); dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($this->db); dol_print_error($this->db);
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$error++; $error++;
} }
if (!$error && !$notrigger) if (!$error && !$notrigger) {
{
// Call trigger // Call trigger
$result = $this->call_trigger('PRODUCTFOURNISSEURPRICE_VALIDATE', $user); $result = $this->call_trigger('PRODUCTFOURNISSEURPRICE_VALIDATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
@ -470,13 +456,11 @@ class ProductFournisseurPrice extends CommonObject
} }
} }
if (!$error) if (!$error) {
{
$this->oldref = $this->ref; $this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref)) {
{
// Now we rename also files into index // Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'productfournisseurprice/".$this->db->escape($this->newref)."'"; $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'productfournisseurprice/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'productfournisseurprice/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'productfournisseurprice/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
@ -488,17 +472,14 @@ class ProductFournisseurPrice extends CommonObject
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$oldref; $dirsource = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$oldref;
$dirdest = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref; $dirdest = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref;
if (!$error && file_exists($dirsource)) if (!$error && file_exists($dirsource)) {
{
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest)) {
{
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref // Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); $listoffiles = dol_dir_list($conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry) foreach ($listoffiles as $fileentry) {
{
$dirsource = $fileentry['name']; $dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource; $dirsource = $fileentry['path'].'/'.$dirsource;
@ -511,14 +492,12 @@ class ProductFournisseurPrice extends CommonObject
} }
// Set new ref and current status // Set new ref and current status
if (!$error) if (!$error) {
{
$this->ref = $num; $this->ref = $num;
$this->status = self::STATUS_VALIDATED; $this->status = self::STATUS_VALIDATED;
} }
if (!$error) if (!$error) {
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {
@ -538,8 +517,7 @@ class ProductFournisseurPrice extends CommonObject
public function setDraft($user, $notrigger = 0) public function setDraft($user, $notrigger = 0)
{ {
// Protection // Protection
if ($this->status <= self::STATUS_DRAFT) if ($this->status <= self::STATUS_DRAFT) {
{
return 0; return 0;
} }
@ -556,8 +534,7 @@ class ProductFournisseurPrice extends CommonObject
public function cancel($user, $notrigger = 0) public function cancel($user, $notrigger = 0)
{ {
// Protection // Protection
if ($this->status != self::STATUS_VALIDATED) if ($this->status != self::STATUS_VALIDATED) {
{
return 0; return 0;
} }
@ -574,8 +551,7 @@ class ProductFournisseurPrice extends CommonObject
public function reopen($user, $notrigger = 0) public function reopen($user, $notrigger = 0)
{ {
// Protection // Protection
if ($this->status != self::STATUS_CANCELED) if ($this->status != self::STATUS_CANCELED) {
{
return 0; return 0;
} }
@ -609,8 +585,7 @@ class ProductFournisseurPrice extends CommonObject
$url = dol_buildpath('/buypricehistory/productfournisseurprice_card.php', 1).'?id='.$this->id; $url = dol_buildpath('/buypricehistory/productfournisseurprice_card.php', 1).'?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
@ -618,10 +593,8 @@ class ProductFournisseurPrice extends CommonObject
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowProductFournisseurPrice"); $label = $langs->trans("ShowProductFournisseurPrice");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
@ -699,8 +672,7 @@ class ProductFournisseurPrice extends CommonObject
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
{
global $langs; global $langs;
//$langs->load("buypricehistory@buypricehistory"); //$langs->load("buypricehistory@buypricehistory");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
@ -729,30 +701,25 @@ class ProductFournisseurPrice extends CommonObject
$sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
$sql .= ' fk_user_creat, fk_user_modif'; $sql .= ' fk_user_creat, fk_user_modif';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id; $sql .= ' WHERE t.rowid = '.((int) $id);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if ($this->db->num_rows($result)) {
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author) {
{
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_valid) if ($obj->fk_user_valid) {
{
$vuser = new User($this->db); $vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid); $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser; $this->user_validation = $vuser;
} }
if ($obj->fk_user_cloture) if ($obj->fk_user_cloture) {
{
$cluser = new User($this->db); $cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture); $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser; $this->user_cloture = $cluser;
@ -794,8 +761,7 @@ class ProductFournisseurPrice extends CommonObject
$conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON = 'mod_productfournisseurprice_standard'; $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON = 'mod_productfournisseurprice_standard';
} }
if (!empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) if (!empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) {
{
$mybool = false; $mybool = false;
$file = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON.".php"; $file = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON.".php";
@ -803,16 +769,14 @@ class ProductFournisseurPrice extends CommonObject
// Include file with class // Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/buypricehistory/"); $dir = dol_buildpath($reldir."core/modules/buypricehistory/");
// Load file with numbering class (if found) // Load file with numbering class (if found)
$mybool |= @include_once $dir.$file; $mybool |= @include_once $dir.$file;
} }
if ($mybool === false) if ($mybool === false) {
{
dol_print_error('', "Failed to include file ".$file); dol_print_error('', "Failed to include file ".$file);
return ''; return '';
} }
@ -821,8 +785,7 @@ class ProductFournisseurPrice extends CommonObject
$obj = new $classname(); $obj = new $classname();
$numref = $obj->getNextValue($this); $numref = $obj->getNextValue($this);
if ($numref != '' && $numref != '-1') if ($numref != '' && $numref != '-1') {
{
return $numref; return $numref;
} else { } else {
$this->error = $obj->error; $this->error = $obj->error;

View File

@ -290,7 +290,7 @@ if (empty($reshook)) {
foreach ($extrafield_values as $key => $value) { foreach ($extrafield_values as $key => $value) {
$sql .= str_replace('options_', '', $key).' = "'.$value.'", '; $sql .= str_replace('options_', '', $key).' = "'.$value.'", ';
} }
$sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id; $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.((int) $object->product_fourn_price_id);
} }
// Execute the sql command from above // Execute the sql command from above

View File

@ -782,7 +782,7 @@ class Entrepot extends CommonObject
$parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents
$i = 0; $i = 0;
while ($parentid > 0 && $i < $protection) { while ($parentid > 0 && $i < $protection) {
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$parentid; $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.((int) $parentid);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$objarbo = $this->db->fetch_object($resql); $objarbo = $this->db->fetch_object($resql);
@ -817,7 +817,7 @@ class Entrepot extends CommonObject
$sql = 'SELECT rowid $sql = 'SELECT rowid
FROM '.MAIN_DB_PREFIX.'entrepot FROM '.MAIN_DB_PREFIX.'entrepot
WHERE fk_parent = '.$id; WHERE fk_parent = '.((int) $id);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

View File

@ -896,7 +896,7 @@ class MouvementStock extends CommonObject
$nb = 0; $nb = 0;
$sql = 'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.'stock_mouvement'; $sql = 'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.'stock_mouvement';
$sql .= ' WHERE fk_product = '.$productidselected; $sql .= ' WHERE fk_product = '.((int) $productidselected);
$sql .= " AND datem < '".$this->db->idate($datebefore)."'"; $sql .= " AND datem < '".$this->db->idate($datebefore)."'";
dol_syslog(get_class($this).__METHOD__.'', LOG_DEBUG); dol_syslog(get_class($this).__METHOD__.'', LOG_DEBUG);

View File

@ -196,7 +196,7 @@ class ProductStockEntrepot extends CommonObject
if (!empty($id)) { if (!empty($id)) {
$sql .= ' WHERE t.rowid = '.((int) $id); $sql .= ' WHERE t.rowid = '.((int) $id);
} else { } else {
$sql .= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; $sql .= ' WHERE t.fk_product = '.((int) $fk_product).' AND t.fk_entrepot = '.((int) $fk_entrepot);
} }
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -39,7 +39,7 @@ function dolDispatchToDo($order_id)
// Count nb of quantity dispatched per product // Count nb of quantity dispatched per product
$sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch';
$sql .= ' WHERE fk_commande = '.$order_id; $sql .= ' WHERE fk_commande = '.((int) $order_id);
$sql .= ' GROUP BY fk_product'; $sql .= ' GROUP BY fk_product';
$sql .= ' ORDER by fk_product'; $sql .= ' ORDER by fk_product';
$resql = $db->query($sql); $resql = $db->query($sql);
@ -51,7 +51,7 @@ function dolDispatchToDo($order_id)
// Count nb of quantity to dispatch per product // Count nb of quantity to dispatch per product
$sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet'; $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet';
$sql .= ' WHERE fk_commande = '.$order_id; $sql .= ' WHERE fk_commande = '.((int) $order_id);
$sql .= ' AND fk_product > 0'; $sql .= ' AND fk_product > 0';
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$sql .= ' AND product_type = 0'; $sql .= ' AND product_type = 0';

View File

@ -756,7 +756,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
if (!empty($conf->global->MAIN_MULTILANGS)) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$sql = 'SELECT label,description'; $sql = 'SELECT label,description';
$sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang';
$sql .= ' WHERE fk_product = '.$objp->rowid; $sql .= ' WHERE fk_product = '.((int) $objp->rowid);
$sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' AND lang = "'.$langs->getDefaultLang().'"';
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';

View File

@ -487,7 +487,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
{ {
$sql = 'SELECT label,description'; $sql = 'SELECT label,description';
$sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang';
$sql .= ' WHERE fk_product = '.$objp->rowid; $sql .= ' WHERE fk_product = '.((int) $objp->rowid);
$sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' AND lang = "'.$langs->getDefaultLang().'"';
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';

View File

@ -428,7 +428,7 @@ if ($action == 'confirm_generateinvoice') {
$lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
// Update lineid into line of timespent // Update lineid into line of timespent
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) { if (!$result) {
@ -467,7 +467,7 @@ if ($action == 'confirm_generateinvoice') {
$lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
// Update lineid into line of timespent // Update lineid into line of timespent
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) { if (!$result) {
@ -503,7 +503,7 @@ if ($action == 'confirm_generateinvoice') {
$lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
// Update lineid into line of timespent // Update lineid into line of timespent
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')'; $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')';
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) { if (!$result) {

View File

@ -122,19 +122,19 @@ if (!empty($tag)) {
//Update status of target //Update status of target
$statut = '2'; $statut = '2';
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid = ".((int) $obj->rowid); $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db); if (!$resql) dol_print_error($db);
//Update status communication of thirdparty prospect //Update status communication of thirdparty prospect
if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) { if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) {
$sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.$obj->source_id; $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.((int) $obj->source_id);
$resql = $db->query($sql); $resql = $db->query($sql);
} }
//Update status communication of contact prospect //Update status communication of contact prospect
if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) {
$sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.$obj->source_id.')'; $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '((int) $obj->source_id).')';
$resql = $db->query($sql); $resql = $db->query($sql);
} }
} }

View File

@ -463,7 +463,7 @@ class Salary extends CommonObject
public function update_fk_bank($id_bank) public function update_fk_bank($id_bank)
{ {
// phpcs:enable // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank; $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.((int) $id_bank);
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {

View File

@ -4620,7 +4620,7 @@ class Societe extends CommonObject
$resql = $db->query($sql); $resql = $db->query($sql);
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
$db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$obj->rowid); $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid));
} }
/** /**

View File

@ -1777,7 +1777,7 @@ class SupplierProposal extends CommonObject
$price = price2num($product->subprice * $product->qty, 'MU'); $price = price2num($product->subprice * $product->qty, 'MU');
$unitPrice = price2num($product->subprice, 'MU'); $unitPrice = price2num($product->subprice, 'MU');
$sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$this->db->escape($product->ref_fourn).'", ' : '').' price ='.((float) $price).', unitprice ='.((float) $unitPrice).' WHERE rowid = '.((int) $idProductFournPrice);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {

View File

@ -319,7 +319,7 @@ class ProductAttribute extends CommonObject
$newrang = $this->rang + 1; $newrang = $this->rang + 1;
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.'product_attribute SET rang = '.$this->rang.' WHERE rang = '.$newrang; $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_attribute SET rang = '.((int) $this->rang).' WHERE rang = '.((int) $newrang);
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
$this->db->rollback(); $this->db->rollback();

View File

@ -407,7 +407,7 @@ class WebsitePage extends CommonObject
$sql .= " t.object_type,"; $sql .= " t.object_type,";
$sql .= " t.fk_object"; $sql .= " t.fk_object";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid; $sql .= ' WHERE t.fk_website = '.((int) $websiteid);
// Manage filter (same than into countAll) // Manage filter (same than into countAll)
$sqlwhere = array(); $sqlwhere = array();
if (count($filter) > 0) { if (count($filter) > 0) {
@ -509,7 +509,7 @@ class WebsitePage extends CommonObject
$sql = 'SELECT COUNT(t.rowid) as nb'; $sql = 'SELECT COUNT(t.rowid) as nb';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid; $sql .= ' WHERE t.fk_website = '.((int) $websiteid);
// Manage filter (same than into fetchAll) // Manage filter (same than into fetchAll)
$sqlwhere = array(); $sqlwhere = array();
if (count($filter) > 0) { if (count($filter) > 0) {

View File

@ -416,13 +416,13 @@ class Hook extends CommonObject
$sql .= ' t.rowid'; $sql .= ' t.rowid';
// TODO Get all fields // TODO Get all fields
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.entity = '.$conf->entity; $sql .= ' WHERE t.entity = '.((int) $conf->entity);
// Manage filter // Manage filter
$sqlwhere = array(); $sqlwhere = array();
if (count($filter) > 0) { if (count($filter) > 0) {
foreach ($filter as $key => $value) { foreach ($filter as $key => $value) {
if ($key == 't.rowid') { if ($key == 't.rowid') {
$sqlwhere[] = $key.'='.$value; $sqlwhere[] = $key.' = '.((int) $value);
} elseif (strpos($key, 'date') !== false) { } elseif (strpos($key, 'date') !== false) {
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
} elseif ($key == 'customsql') { } elseif ($key == 'customsql') {