<?php
include("config.php");

	$monto = $_POST["monto"];
	$ccuotas = $_POST["cuotas"];
	$tasa = $_POST["tasau"];


	$id = $_POST["id"];;
	$id_cliente =  $_POST["id_cliente"];
	$cobrador = $_POST["cobrador"];

	$deuda=$monto;
	$anos=$ccuotas;
	$interes=$tasa;
 
	// hacemos los calculos...
	$interes=($interes/100);
	$m=($deuda*$interes*(pow((1+$interes),($anos))))/((pow((1+$interes),($anos)))-1);
 
	echo "<div>Capital Inicial: ".number_format($deuda,2,".",",")." RD$";
	echo "<br>Cuota a pagar mensualmente: ".number_format($m,2,".",",")." RD$</div>";
	
	echo "<table border=1 cellpadding=5 cellspacing=0>
		<tr>
			<th>Mes</th>
			<th>Intereses</th>
			<th>Amortización</th>
			<th>Cuota</th>
			<th>Capital Pendiente</th>
		</tr>";
	
		// mostramos todos los meses...
		for($i=1;$i<=$anos;$i++)
		{
			echo "<tr>";
				echo "<td align=right>".$i."</td>";
				$totalint=$totalint+($deuda*$interes);
				echo "<td align=right>".number_format($deuda*$interes,2,".",",")."</td>";
				echo "<td align=right>".number_format($m-($deuda*$interes),2,".",",")."</td>";
				$a = $deuda*$interes;
				$b = $m-($deuda*$interes);
				$cuota = $a + $b;
				echo "<td align=right>".number_format($cuota,2,".",",")."</td>";
				$deuda=$deuda-($m-($deuda*$interes));
				if ($deuda<0)
				{
					echo "<td align=right>0</td>";
				}else{
					echo "<td align=right>".number_format($deuda,2,".",",")."</td>";
				}
			echo "</tr>";
		}
echo "</table>";
?>