<?php
include_once("../header.php");
include_once("../php/config.php");
$sql = mysql_query("select * from recibos") or die(mysql_error());
$sql_prestamos = mysql_query("select * from prestamos inner join clientes on prestamos.id_cliente=clientes.id order by clientes.nombre asc") or die(mysql_error());
$sql_rutas= mysql_query("select * from rutas where estado_ruta='1'") or die(mysql_error());
$sql_cobradores= mysql_query("select * from cobradores where estado_cobrador='1'") or die(mysql_error());
$sql_carteras= mysql_query("select * from cartera") or die(mysql_error());

?>
<style>
    .titulos{
        font-family: verdana;
        font-size: 12px;
    }
</style>
<div class="container-fluid">
    <!-- Breadcrumbs-->
          
    <?php include_once("../barra_lateral.php") ?>  
               
   <form id="frm" name="frm" action="" method="post">           
    <div class="row">
       
        <div class="col-md-12">
            <h3 class="text-success"><i class="fa fa-calendar"></i> Reporte de prestamos</h3>
            <hr>
                 <div class="row">
                        <div class="col-md-2">
                            <b>Clientes</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="clientes">

                                <option value="" selected>Sel. cliente</option>
                                <?php while ($r = mysql_fetch_array($sql_prestamos)) { ?>
                                    <option value="<?php echo $r['nombre'] ?>"><?php echo $r['nombre'] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                     
                      <div class="col-md-2">
                            <b>Tipo prestamo</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="tipo">

                                <option value="" selected>Sel. tipo</option>
                                <option value="Mensual" >Mensual</option>
                                <option value="Quincenal">Quincenal</option>
                                <option value="Semanal">Semanal</option>
                                <option value="Diario">Diarios</option>
                            </select>
                        </div>
                     
                     
                    </div>
                                
           <div class="row">
              <div class="col-md-2">
                            <b>Ruta</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="ruta">
                                 <option value="" selected>Sel. ruta</option>
                                <?php while ($r2 = mysql_fetch_array($sql_rutas)) { ?>
                                    <option value="<?php echo $r2['nombre'] ?>"><?php echo $r2['nombre'] ?></option>
                                <?php } ?>
                                
                            </select>
                </div>  
               
               
               
                <div class="col-md-2">
                            <b>Cobrador</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="cobrador">
                                 <option value="" selected>Sel. cobrador</option>
                                <?php while ($r3 = mysql_fetch_array($sql_cobradores)) { ?>
                                    <option value="<?php echo $r3['nombre'] ?>"><?php echo $r3['nombre'] ?></option>
                                <?php } ?>
                                
                            </select>
                </div> 
           </div>
            
            
            
          
           <div class="row">
              <div class="col-md-2">
                            <b>Cartera</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="cartera">
                                 <option value="" selected>Sel. cartera</option>
                                <?php while ($r3 = mysql_fetch_array($sql_carteras)) { ?>
                                    <option value="<?php echo $r3['nombre'] ?>"><?php echo $r3['nombre'] ?></option>
                                <?php } ?>
                                
                            </select>
                        </div>  
               
               
               
                <div class="col-md-2">
                            <b>Fechas</b>
                        </div>
                        <div class="col-md-2">
                            <input type="date" class="form-control" id="fecha1">
                        </div> 
                         <div class="col-md-2">
                            <input type="date" class="form-control" id="fecha2">
                        </div> 
           </div>
        <a href="#" onClick="reporte()" class="btn btn-warning btn-sm"><i class="fa fa-invoice"></i> Reporte</a>
        </div>
                    
    </div>
    </form>     
            
            
</div>
          


          
</div>
    </div>



        	<!---Modal mora-->
	<div class="modal" id="modalMora" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ajuste de mora manual</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">
              <div class="row">
                  <label for="monto_mora" class="col-sm-4 col-form-label" >Monto</label>
                  <div class="col-sm-8">
                      <input autocomplete="off" type="number"  class="form-control mb-2" id="monto_mora" name="monto_mora" value="">
                  </div>
              </div>
          </div>
          <div class="modal-footer">
          <button  onClick="ajuste_mora()" class="btn btn-warning"  data-dismiss="modal"><i class="fa fa-check"></i>Aceptar</button>
           <button class="btn btn-default"  data-dismiss="modal"><i class="fa fa-home"></i>Salir</button>
          </div>
        </div>
      </div>
    </div>
        
        
	<?php
	include_once("../footer.php");
	?>
            
                <script>    
                    $("#fecha1").val(hoySql);
                    $("#fecha2").val(hoySql);
                    function reporte(){
                        var cliente = $("#clientes").val();
                        var ruta = $("#ruta").val();
                        var cartera = $("#cartera").val();
                        var tipo = $("#tipo").val();
                        var cobrador = $("#cobrador").val();
                      
                        var fecha1 = $("#fecha1").val();
                        var fecha2 = $("#fecha2").val();
                        var cliente = $("#clientes").val();
                        var param="";
                        param="cliente="+cliente;
                        param+="&ruta="+ruta;
                        param+="&cobrador="+cobrador;
                        param+="&cartera="+cartera;
                        param+="&tipo="+tipo;
                        param+="&usuario="+cobrador;
                        param+="&fecha1="+fecha1;
                        param+="&fecha2="+fecha2;
                        
                        window.open('rptPrestamos.php?'+param,'_blank', 'toolbar=no,scrollbars=no,resizable=no,top=500,left=500,width=800,height=700');
                        
                        
                    }
                </script>