<?php

include_once "../header.php";

include_once("../php/config.php");

$sql = mysql_query("select * from ventas where estado='Abierta' and usuario='".$_GET['usuario']."' and  caja='".$_GET['caja']."' and total<=0") or die(mysql_error());

$sql2 = mysql_query("select DISTINCT id_prestamo from cuotas where vence<='$hoy' and balance>1") or die(mysql_error());

while($d = mysql_fetch_array($sql2)){

    $cc++;

}



$sql3 = mysql_query("select DISTINCT idrentas from rentas where vence<='$hoy' and estado!='Cerrado'") or die(mysql_error());

while($d2 = mysql_fetch_array($sql3)){

    $cc2++;

}


$sql4 = mysql_query("select costo, stock  from catalogo_renta") or die(mysql_error());

while($d4 = mysql_fetch_array($sql4)){
$totalInventario+=$d4["costo"] * $d4["stock"];
  

}
?>

<center>

    <h3>Financiamientos</h3>

</hr>



</center>



<div class="container">

    

    <div class="row">

        <div class="col-md-12">

            <div class="row">

                <div class="col-md-3">

                    <div class="panel panel-default">

                        <div class="panel-heading">

                            <h4>Financiamientos</h4>

                        </div>

                            <div class="panel-body">

                                <b><a class="mt-2 ml-2" href="prestamos.php"> Registro de prestamos</a></b><br>

                                 <a href="cobros_prestamos.php" class="mt-2 ml-2"> Cobros</a><br>

                                 <a href="prestamos_atrasados.php" class="mt-2 ml-2"> Prest. atrasados</a><b style="float:right;" class="text-danger badge bg-info btn-danger"><?php echo $cc?></b>
                                <hr>
                                <a href="historial_cliente.php" class="mt-2 ml-2"> Historial de cliente</a>

                            </div>

                        

                    </div>

                </div>

                

                <div class="col-md-3">

                    <div class="panel panel-default">

                        <div class="panel-heading">

                            <h4>Alquiler</h4>

                        </div>

                            <div class="panel-body">

                                <b><a class="mt-2 ml-2" href="rentas.php"> Registro de alquiler</a></b><br>

                                 <a class="mt-2 ml-2" href="cobros_rentas.php"> Cobros de alquiler</a><br>

                                 <a href="alquileres_atrasados.php" class="mt-2 ml-2"> Alquiler en atraso</a><b style="float:right;" class="text-danger badge badge-danger"><?php echo $cc2?></b>
                                <hr>
                                <a href="catalogo_renta.php" class="mt-2 ml-2"> Inventario</a><b style="float:right;" class="badge badge-success"><?php echo decimal($totalInventario)?></b>



                                 

                            </div>

                        

                    </div>

                </div>

                

                

            </div>

            

        </div>

    </div>

</div>



<?php

include_once "../footer.php";

?>



<script>

function nueva(){

    window.location.href="nueva_venta.php?caja="+myCaja+"&usuario="+myUser;
    

   }  

</script>