<style>
    th,td{
        text-align: left;
    }
    *{
        font-family: Arial;
        font-size: 12px;
        font-wight:light;

    }
table,td,th{
    border:gray 1px solid;
    border-collapse: collapse;
    font-size: 12px;
}

th{
    background: green;
    color:white;
}
</style>

<br>

<?php
include_once("../php/config.php");
    $sql_empresa = mysql_query("SELECT * FROM empresa") or die(mysql_error());
$enombre= @mysql_result($sql_empresa,0,"nombre");
$etelefono= @mysql_result($sql_empresa,0,"telefono");   
$edireccion= @mysql_result($sql_empresa,0,"direccion"); 
$ernc= @mysql_result($sql_empresa,0,"rnc"); 
$eemail= @mysql_result($sql_empresa,0,"email"); 
    
?>
<span class="datos_empres2" style="font-size: 30px;font-weight: bolder;font-family: 'Arial black'"><?php echo $enombre;?></span><b><br>
<span class="datos_empres"><?php echo $etelefono;?> </span><br>
<span class="datos_empres"><?php echo $edireccion;?> </span><br>
<span class="datos_empres"><?php echo $ernc;?></span><br>

<h3 style="font-size: 25px;">Historial de clientes</h3>

<?php
$cedula  = $_GET["cedula"];
include_once("../php/formatos.php");
$sql_cliente = mysql_query("SELECT * FROM clientes where cedula='$cedula'") or die(mysql_error());
$cliente= @mysql_result($sql_cliente,0,"nombre");
if($cliente==""){$cliente="........................";}
$id_cliente= @mysql_result($sql_cliente,0,"id_cliente");

echo "<b>Cliente:</b> <font color='blue'>".$cliente."</font>, ";

$sql1 = mysql_query("select * from prestamos  where 
                    id_cliente ='$id_cliente'") or die(mysql_error());
echo "<br>";
echo "<b>PRESTAMOS OTORGADOS:</b><br>";
echo "<table><th># Prestamo</th><th>Fecha</th><th>Cliente</th><th>Monto</th><th>Tasa</th><th>Tipo</th><th>Balance</th>";
while($r = mysql_fetch_array($sql1)){
    $c_prestamo++;
    $total+=$r["monto_prestado"];
	$balance+=$r["balance"];
    $id_prestamo = $r["id_prestamo"];
   //// $cliente = $r["cliente"];
	////echo "id:::".$id_prestamo;
    echo "<tr>";
    echo "<td>".$r["id_prestamo"]."</td>";
    echo "<td>".fecha($r["fecha"])."</td>";
    //echo "<td>".$r["cuota"]."</td>";
    echo "<td>".$r["cliente"]."</td>";
    echo "<td>".decimal($r["monto_prestado"])."</td>";
    echo "<td>".decimal($r["tasa"])."</td>";
    echo "<td>".($r["tipo"])."</td>";
	echo "<td>".decimal($r["balance"])."</td>";
    echo "</tr>";
}
 echo "</table>";
 echo "<br>";
 echo "<hr>";

 $sql3 = mysql_query("select * from cobros  where 
                    cliente ='$cliente'") or die(mysql_error());
echo "<b>HISTORIAL DE COBROS:</b><br>";
echo "<table><th># Prestamo</th><th>Fecha del pago</th><th>Interes</th><th>Capital</th><th>Mora</th><th>Total</th>";
while($r3 = mysql_fetch_array($sql3)){
    $c_cobros++;
   
	
    echo "<tr>";
    echo "<td>".$r3["id_prestamo"]."</td>";
    echo "<td>".fecha($r3["fecha"])."</td>";
    echo "<td>".decimal($r3["interes"])."</td>";
    echo "<td>".decimal($r3["capital"])."</td>";
    echo "<td>".decimal($r3["mora"])."</td>";
    
    echo "<td>".decimal($r3["total"])."</td>";
    $total_pagado+=$r3["total"];
    $total_mora+=$r3["mora"];
    echo "</tr>";
}
 echo "</table>";
 echo "<br>";
 

 $sql2 = mysql_query("select * from cuotas  where 
 cliente ='$cliente' and balance>1") or die(mysql_error());
echo "<b>CUOTAS PENDIENTE:</b><br>";
echo "<table><th># Cuota</th><th>Fecha de pago</th><th>Balance</th>";
while($r2 = mysql_fetch_array($sql2)){
$c_cuotas++;


echo "<tr>";
echo "<td>".$r2["numero"]."</td>";
echo "<td>".fecha($r2["vence"])."</td>";
//echo "<td>".$r["cuota"]."</td>";

echo "<td>".decimal($r2["balance"])."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";

 echo "<div style='width:250px;'>";
 echo "<b>Prestamos: ".$c_prestamo."<br>";
 echo "<b>TOTAL PRESTADO:</b><font color='blue' style='float:right'>".decimal($total)."</font><br>";
 echo "<b>MORA PAGADA:</b><font color='blue' style='float:right'>".decimal($total_mora)."</font><br>";
 echo "<b>TOTAL PAGADO:</b><font color='blue' style='float:right'>".decimal($total_pagado)."</font><br>";
 echo "<hr>";
 echo "<br><b>BALANCE:</b><font color='blue' style='float:right'>".decimal($balance)."</font><br>";

 echo "</div>";
 
?>
