From 42938ffe31da85c013dc7e8598b5f913736f2393 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 21:15:09 +0200 Subject: [PATCH] FIX #yogosha5879 --- .../accountancy/class/bookkeeping.class.php | 8 +++--- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/admin/boxes.php | 4 +-- htdocs/compta/bank/class/account.class.php | 26 +++++++++++-------- .../cheque/class/remisecheque.class.php | 2 +- .../class/bonprelevement.class.php | 4 +-- htdocs/compta/tva/class/tva.class.php | 2 +- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 00ed8879076..a93b36cf2b4 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -371,8 +371,8 @@ class BookKeeping extends CommonObject $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); $sql .= ", '".$this->db->escape($this->doc_type)."'"; $sql .= ", '".$this->db->escape($this->doc_ref)."'"; - $sql .= ", ".$this->fk_doc; - $sql .= ", ".$this->fk_docdet; + $sql .= ", ".((int) $this->fk_doc); + $sql .= ", ".((int) $this->fk_docdet); $sql .= ", ".(!empty($this->thirdparty_code) ? ("'".$this->db->escape($this->thirdparty_code)."'") : "NULL"); $sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL"); $sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL"); @@ -632,8 +632,8 @@ class BookKeeping extends CommonObject $sql .= ' '.(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'").','; $sql .= ' '.(!isset($this->doc_type) ? 'NULL' : "'".$this->db->escape($this->doc_type)."'").','; $sql .= ' '.(!isset($this->doc_ref) ? 'NULL' : "'".$this->db->escape($this->doc_ref)."'").','; - $sql .= ' '.(empty($this->fk_doc) ? '0' : $this->fk_doc).','; - $sql .= ' '.(empty($this->fk_docdet) ? '0' : $this->fk_docdet).','; + $sql .= ' '.(empty($this->fk_doc) ? '0' : (int) $this->fk_doc).','; + $sql .= ' '.(empty($this->fk_docdet) ? '0' : (int) $this->fk_docdet).','; $sql .= ' '.(!isset($this->thirdparty_code) ? 'NULL' : "'".$this->db->escape($this->thirdparty_code)."'").','; $sql .= ' '.(!isset($this->subledger_account) ? 'NULL' : "'".$this->db->escape($this->subledger_account)."'").','; $sql .= ' '.(!isset($this->subledger_label) ? 'NULL' : "'".$this->db->escape($this->subledger_label)."'").','; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 95bbe79804f..1285b12b2d0 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -165,7 +165,7 @@ class Subscription extends CommonObject } else { $type = $this->fk_type; } - $sql .= " VALUES (".$this->fk_adherent.", '".$this->db->escape($type)."', '".$this->db->idate($now)."',"; + $sql .= " VALUES (".((int) $this->fk_adherent).", '".$this->db->escape($type)."', '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->dateh)."',"; $sql .= " '".$this->db->idate($this->datef)."',"; $sql .= " ".$this->amount.","; diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index fc3e30a484b..44629525a26 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -114,8 +114,8 @@ if ($action == 'add') { if (empty($arrayofexistingboxid[$boxid['value']])) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; $sql .= "box_id, position, box_order, fk_user, entity"; - $sql .= ") values ("; - $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; + $sql .= ") VALUES ("; + $sql .= $boxid['value'].", ".((int) $pos).", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; $sql .= ")"; dol_syslog("boxes.php activate box", LOG_DEBUG); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4e2e60908d8..5a00e93e83f 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -508,6 +508,10 @@ class Account extends CommonObject dol_syslog(__METHOD__.": using numeric operations is deprecated", LOG_WARNING); } + if (empty($this->id) && !empty($this->rowid)) { // For backward compatibility + $this->id = $this->rowid; + } + // Clean parameters $emetteur = trim($emetteur); $banque = trim($banque); @@ -534,8 +538,8 @@ class Account extends CommonObject $this->error = "oper not defined"; return -1; } - if (!$this->rowid) { - $this->error = "this->rowid not defined"; + if (!$this->id) { + $this->error = "this->id not defined"; return -2; } if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { @@ -556,7 +560,7 @@ class Account extends CommonObject $accline->label = $label; $accline->amount = $amount; $accline->fk_user_author = $user->id; - $accline->fk_account = $this->rowid; + $accline->fk_account = $this->id; $accline->fk_type = $oper; $accline->numero_compte = $accountancycode; $accline->num_releve = $num_releve; @@ -575,10 +579,10 @@ class Account extends CommonObject if ($accline->insert() > 0) { if ($categorie > 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class("; $sql .= "lineid, fk_categ"; $sql .= ") VALUES ("; - $sql .= $accline->id.", ".$categorie; + $sql .= ((int) $accline->id).", '".$this->db->escape($categorie)."'"; $sql .= ")"; $result = $this->db->query($sql); @@ -611,7 +615,7 @@ class Account extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf; $error = 0; @@ -770,7 +774,7 @@ class Account extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf; $error = 0; @@ -796,9 +800,9 @@ class Account extends CommonObject $sql .= " ref = '".$this->db->escape($this->ref)."'"; $sql .= ",label = '".$this->db->escape($this->label)."'"; - $sql .= ",courant = ".$this->courant; - $sql .= ",clos = ".$this->clos; - $sql .= ",rappro = ".$this->rappro; + $sql .= ",courant = ".((int) $this->courant); + $sql .= ",clos = ".((int) $this->clos); + $sql .= ",rappro = ".((int) $this->rappro); $sql .= ",url = ".($this->url ? "'".$this->db->escape($this->url)."'" : "null"); $sql .= ",account_number = '".$this->db->escape($this->account_number)."'"; $sql .= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); @@ -824,7 +828,7 @@ class Account extends CommonObject $sql .= ",ics = '".$this->db->escape($this->ics)."'"; $sql .= ",ics_transfer = '".$this->db->escape($this->ics_transfer)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 489d4c7cec0..0c05a1bc03a 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -171,7 +171,7 @@ class RemiseCheque extends CommonObject $sql .= "'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".$user->id; - $sql .= ", ".$account_id; + $sql .= ", ".((int) $account_id); $sql .= ", 0"; $sql .= ", 0"; $sql .= ", 0"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ea44a75899d..dbf2d67778a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -229,9 +229,9 @@ class BonPrelevement extends CommonObject $sql .= ", cle_rib"; $sql .= ") VALUES ("; $sql .= $this->id; - $sql .= ", ".$client_id; + $sql .= ", ".((int) $client_id); $sql .= ", '".$this->db->escape($client_nom)."'"; - $sql .= ", '".price2num($amount)."'"; + $sql .= ", ".((float) price2num($amount)); $sql .= ", '".$this->db->escape($code_banque)."'"; $sql .= ", '".$this->db->escape($code_guichet)."'"; $sql .= ", '".$this->db->escape($number)."'"; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 25d622d825d..ff35ece947b 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -585,7 +585,7 @@ class Tva extends CommonObject $sql .= " '".$this->db->idate($this->datec)."'"; $sql .= ", '".$this->db->idate($this->datep)."'"; $sql .= ", '".$this->db->idate($this->datev)."'"; - $sql .= ", ".$this->amount; + $sql .= ", ".((float) $this->amount); $sql .= ", '".$this->db->escape($this->type_payment)."'"; $sql .= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) {