Skip to content
Permalink
Browse files

Merge pull request #12646 from frederic34/patch-13

do not trim int
  • Loading branch information
eldy committed Dec 9, 2019
2 parents 9e9bc64 + f379f51 commit 668dc1e7c2fd70d4c226f58ab23e044186961c98
Showing with 19 additions and 13 deletions.
  1. +19 −13 htdocs/don/class/paymentdonation.class.php
@@ -121,14 +121,14 @@ public function create($user, $notrigger = false)
}

// Clean parameters
if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation);
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
if (isset($this->amount)) $this->amount=trim($this->amount);
if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;

$totalamount = 0;
foreach ($this->amounts as $key => $value) // How payment is dispatch
@@ -275,14 +275,14 @@ public function update($user, $notrigger = 0)

// Clean parameters

if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation);
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
if (isset($this->amount)) $this->amount=trim($this->amount);
if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;

// Check parameters
// Put here code to add control on parameters values
@@ -300,13 +300,16 @@ public function update($user, $notrigger = 0)
$sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").",";
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
$sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null")."";
$sql.= " WHERE rowid=".$this->id;
$sql.= " WHERE rowid=".(int) $this->id;

$this->db->begin();

dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $resql) {
$error++;
$this->errors[]="Error ".$this->db->lasterror();
}

if (! $error)
{
@@ -358,7 +361,7 @@ public function delete($user, $notrigger = 0)
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
$sql.= " WHERE type='payment_donation' AND url_id=".$this->id;
$sql.= " WHERE type='payment_donation' AND url_id=".(int) $this->id;

dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -372,7 +375,10 @@ public function delete($user, $notrigger = 0)

dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $resql) {
$error++;
$this->errors[]="Error ".$this->db->lasterror();
}
}

if (! $error)
@@ -609,7 +615,7 @@ public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom
public function update_fk_bank($id_bank)
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".(int) $id_bank." WHERE rowid = ".(int) $this->id;

dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
$result = $this->db->query($sql);

0 comments on commit 668dc1e

Please sign in to comment.
You can’t perform that action at this time.