Skip to content

Commit

Permalink
FIX update of nb of period of loan
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 18, 2018
1 parent 7e488c7 commit 6a6cf95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions htdocs/loan/card.php
Expand Up @@ -182,8 +182,8 @@
$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');
Expand Down
11 changes: 9 additions & 2 deletions htdocs/loan/class/loan.class.php
Expand Up @@ -292,11 +292,18 @@ function update($user)
{
$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)."',";
Expand Down Expand Up @@ -431,12 +438,12 @@ function getNomUrl($withpicto=0,$maxlen=0)

$linkstart = '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$this->id.'" title="'.str_replace('\n', '', dol_escape_htmltag($tooltip, 1)).'" class="classfortooltip">';
$linkend = '</a>';

$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;
}

Expand Down

0 comments on commit 6a6cf95

Please sign in to comment.