diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 6c52359979e..9b767cde34c 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -83,7 +83,7 @@ class CompanyBankAccount extends Account $now = dol_now(); $error = 0; // Correct default_rib to be sure to have always one default - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".((int) $this->socid)." AND default_rib = 1 AND type = 'ban'"; $result = $this->db->query($sql); if ($result) { $numrows = $this->db->num_rows($result); @@ -96,7 +96,7 @@ class CompanyBankAccount extends Account } $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)"; - $sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; + $sql .= " VALUES (".((int) $this->socid).", 'ban', '".$this->db->idate($now)."')"; $resql = $this->db->query($sql); if ($resql) { if ($this->db->affected_rows($resql)) { @@ -135,6 +135,7 @@ class CompanyBankAccount extends Account public function update(User $user = null, $notrigger = 0) { global $conf; + $error = 0; if (!$this->id) { @@ -160,7 +161,7 @@ class CompanyBankAccount extends Account $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; $sql .= ",default_rib = ".((int) $this->default_rib); - if ($conf->prelevement->enabled) { + if (!empty($conf->prelevement->enabled)) { $sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; $sql .= ",rum = '".$this->db->escape($this->rum)."'"; $sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 93c4fbc2202..97d92007885 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -161,9 +161,6 @@ if (empty($reshook)) { if (empty($companybankaccount->rum)) { $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); } - if (empty($companybankaccount->date_rum)) { - $companybankaccount->date_rum = dol_now(); - } $result = $companybankaccount->update($user); if (!$result) { @@ -268,9 +265,9 @@ if (empty($reshook)) { $companybankaccount->domiciliation = GETPOST('domiciliation', 'alpha'); $companybankaccount->proprio = GETPOST('proprio', 'alpha'); $companybankaccount->owner_address = GETPOST('owner_address', 'alpha'); - $companybankaccount->frstrecur = GETPOST('frstrecur'); + $companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha'); $companybankaccount->rum = GETPOST('rum', 'alpha'); - $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); + $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth', 'int'), GETPOST('date_rumday', 'int'), GETPOST('date_rumyear', 'int')); $companybankaccount->datec = dol_now(); $companybankaccount->status = 1; @@ -300,7 +297,6 @@ if (empty($reshook)) { if (empty($companybankaccount->rum)) { $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); - $companybankaccount->date_rum = dol_now(); } } @@ -1638,8 +1634,10 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) { print '