<?php
$usuario = $_COOKIE["usuario"];
$nivel = $_COOKIE["nivel"];
if($nivel=="administrador"){$usuario="";}

include_once("../header.php");
include_once("../php/config.php");
include_once("../php/formatos.php");
include_once("../php/fechas.php");
$sql = mysql_query("select * from recibos where usuario like '%".$usuario."%'") 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>Reimprimir un ticket</h3>
            <div class="row"> 
                <div class="col-md-2">
                    <label>Buscar cliente</label>
                </div>
                                
                <div class="col-md-4">
                    <input type="search" class="form-control" value="<?php echo $_POST['txt-buscar']?>" placeholder="Buscar.." ind="txt-buscar" name="txt-buscar" onKeyUp="buscar(this.value)">
                </div>
                 <div class="col-md-2">
                    <button class="btn btn-sm btn-success" name="btn-buscar">Buscar</button>
                </div>                

            </div>
                                
            <div class="row">
                    <div class="col-md-10">
                       
                            <div id="lista">
                                <?php
                                if(isset($_POST["btn-buscar"])){
                                    $n = $_POST["txt-buscar"];
                                    $sql2 = mysql_query("select * from recibos where cliente like '%".$n."%' and usuario like '%".$usuario."%' and fecha='$hoy' order by cliente desc") or die(mysql_error());
                                    while($r=mysql_fetch_array($sql2)){
                                        $id_recibo = $r["id_recibo"];
                                        echo "<i class='fa fa-print'></i><span class='titulos'><a href='#'onClick='copia($id_recibo)'>".fecha($r["fecha"])." Reimprimir | </a>"."<input type='checkbox' name='[]' id='[]'>".$r["id_recibo"]."-".$r["cliente"]."(".decimal($r["monto"]).")</span>";
                                        echo "<br>";
                                        
                                    }
                                }
                                ?>
                                </div>
                       
                    </div>
            </div>
        </div>
                    
    </div>
    </form>     
            
            
</div>
          


          
</div>
    </div>

	<!---Modal Cliente-->
	<div class="modal" id="modalPrestamos" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Seleccione prestamo</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="table-responsive" style="max-height: 450px;">
		  	<table class="table table-sm table-borderred compact">
						<thead>
							<th># Prestamo</th>
							<th>Nombre/Apell. </th>
							<th>Monto</th>
							<th>Balance</th>
							<th>Accion</th>
							
						</thead>
						<tbody>
                                                        <?php while($r=mysql_fetch_array($sql)){?>
							<tr>
								<td><?php echo $r["id_prestamo"]?></td>
								<td><?php echo $r["nombre"]?></td>
								<td><?php echo @decimal($r["monto_prestado"])?></td>
								<td><span class="badge badge-success"><?php echo @decimal($r["balance"])?></span></td>
								 <td><a class="btn btn-sm btn-default mb-2" onClick="get(<?php echo $r["id_prestamo"]?>)" data-dismiss="modal"><i class="fa fa-edit"></i></a></td>
							</tr>
                                                        <?php }?>
						</tbody>
					</table>
					</div>
		   </div>
          <div class="modal-footer">
          
           <button class="btn btn-default btn-sm"  data-dismiss="modal"><i class="fa fa-home"></i>Salir</button>
          </div>
        </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>                
function copia(id){
window.open('copia_recibo.php?id_recibo='+id,'_blank', 'toolbar=no,scrollbars=no,resizable=no,top=500,left=500,width=800,height=700');

}
</script>