From 6a6cf956b1afe9a05d2ecf61cfbf09c2611e4595 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Mar 2018 23:32:06 +0100 Subject: [PATCH] FIX update of nb of period of loan --- htdocs/loan/card.php | 4 ++-- htdocs/loan/class/loan.class.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 06e0066968d..59b4da544db 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -182,8 +182,8 @@ if (empty($reshook)) $object->datestart = $datestart; $object->dateend = $dateend; $object->capital = $capital; - $object->nbterm = GETPOST("nbterm"); - $object->rate = GETPOST("rate"); + $object->nbterm = GETPOST("nbterm",'int'); + $object->rate = price2num(GETPOST("rate",'alpha')); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 19e8f5f84bf..1de0e908c97 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -292,11 +292,18 @@ class Loan extends CommonObject { $this->db->begin(); + if (! is_numeric($this->nbterm)) + { + $this->error='BadValueForParameterForNbTerm'; + return -1; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " capital='".price2num($this->db->escape($this->capital))."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',"; + $sql.= " nbterm=".$this->nbterm.","; $sql.= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',"; $sql.= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',"; $sql.= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',"; @@ -431,12 +438,12 @@ class Loan extends CommonObject $linkstart = ''; $linkend = ''; - + $result .= $linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); $result .= $linkend; - + return $result; }