Skip to content

Commit

Permalink
Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 12, 2018
2 parents 55d3e72 + d045dca commit ae5080d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions htdocs/loan/card.php
Expand Up @@ -423,11 +423,11 @@

print '<script type="text/javascript">' . "\n";
print ' function popEcheancier() {' . "\n";
print ' $div = $(\'<div id="popCalendar"><iframe width="100%" height="100%" frameborder="0" src="createschedule.php?loanid=' . $object->id . '"></iframe></div>\');' . "\n";
print ' $div = $(\'<div id="popCalendar"><iframe width="100%" height="98%" frameborder="0" src="createschedule.php?loanid=' . $object->id . '"></iframe></div>\');' . "\n";
print ' $div.dialog({' . "\n";
print ' modal:true' . "\n";
print ' ,width:"90%"' . "\n";
print ' ,height:$(window).height() - 150' . "\n";
print ' ,height:$(window).height() - 160' . "\n";
print ' });' . "\n";
print ' }' . "\n";
print '</script>';
Expand Down
45 changes: 26 additions & 19 deletions htdocs/loan/createschedule.php
Expand Up @@ -22,14 +22,11 @@
*/

require '../main.inc.php';

require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php';

global $user;

$loanid = GETPOST('loanid', 'int');
$action = GETPOST('action','aZ09');

Expand Down Expand Up @@ -107,6 +104,7 @@
var idcap=echeance-1;
idcap = '#hi_capital'+idcap;
var capital=$(idcap).val();
console.log("Change montly amount echeance="+echeance+" idcap="+idcap+" capital="+capital);
$.ajax({
dataType: 'json',
url: 'calcmens.php',
Expand Down Expand Up @@ -135,50 +133,59 @@
print '<form name="createecheancier" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="loanid" value="' . $loanid . '">';
if(count($echeance->lines)>0){
if(count($echeance->lines)>0)
{
print '<input type="hidden" name="action" value="updateecheancier">';
}else{
print '<input type="hidden" name="action" value="createecheancier">';
}
print '<table class="border" width="100%">';
print '<tr class="liste_titre">';
print '<th align="center" colspan="5">' . "Création d'échéancier</th>";
print '<th align="center" colspan="5">';
print $langs->trans("FinancialCommitment");
print '</th>';
print '</tr>';

print '<tr class="liste_titre">';
Print '<th width="10%" align="center"> Echéance </th>';
Print '<th width="10%" align="center"> Date </th>';
Print '<th width="10%" align="center"> Montant </th>';
Print '<th width="20%" align="center"> Intérêts </th>';
Print '<th width="40%" align="center"> Capital restant du </th>';
print '</tr>';
Print '<th width="10%" align="center">'.$langs->trans("DueDate").'</th>';
Print '<th width="10%" align="center">'.$langs->trans("Date").'</th>';
Print '<th width="10%" align="center">'.$langs->trans("Amount").'</th>';
Print '<th width="20%" align="center">'.$langs->trans("InterestAmount").'</th>';
Print '<th width="40%" align="center">'.$langs->trans("Remain");
print ' ('.price2num($object->capital).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>';
print '</tr>'."\n";

if ($object->nbterm > 0 && count($echeance->lines)==0)
{
$i=1;
$capital = $object->capital;
while($i <$object->nbterm+1){
$mens = round($echeance->calc_mens($capital, $object->rate/100, $object->nbterm-$i+1),2,PHP_ROUND_HALF_UP);
while($i <$object->nbterm+1)
{
$mens = price2num($echeance->calc_mens($capital, $object->rate/100, $object->nbterm-$i+1), 'MT');
$int = ($capital*($object->rate/12))/100;
$int = round($int,2,PHP_ROUND_HALF_UP);
$cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP);
$int = price2num($int, 'MT');
$cap_rest = price2num($capital - ($mens-$int), 'MT');
print '<tr>';
print '<td align="center" id="n'.$i.'">' . $i .'</td>';
print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . '</td>';
print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '</tr>';
print '</tr>'."\n";
$i++;
$capital = $cap_rest;
}
}elseif(count($echeance->lines)>0){
}
elseif(count($echeance->lines)>0)
{
$i=1;
$capital = $object->capital;
foreach ($echeance->lines as $line){
$mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest;
$int = $line->amount_interest;
$cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP);
$cap_rest = price2num($capital - ($mens-$int), 'MT');
print '<tr>';
print '<td align="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>';
print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep,'day') . '</td>';
Expand All @@ -189,7 +196,7 @@
}
print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '</tr>';
print '</tr>'."\n";
$i++;
$capital = $cap_rest;
}
Expand Down

0 comments on commit ae5080d

Please sign in to comment.