<?php
include_once("../header.php");
include_once("../php/config.php");

$sql_productos= mysql_query("select * from productos order by descripcion asc") or die(mysql_error());
$sql_variedad = mysql_query("select * from variedad_productos  order by variedad asc") or die(mysql_error());
$sql_almacen = mysql_query("select * from almacen  order by nombre asc") or die(mysql_error());
$sql_proveedor = mysql_query("select * from proveedores  order by nombre asc") or die(mysql_error());


?>
<style>
    .titulos{
        font-family: verdana;
        font-size: 12px;
    }
	
	.form-control{
		font-weight:lighter;
	}
</style>
<div class="container-fluid">
    <!-- Breadcrumbs-->
          

               
   <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> Costo de invnetario</h3>
            <hr>
                 <div class="row">
                        <div class="col-md-1">
                            <b>Productos</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="productos">

                                <option value="" selected>Todos los prodcutos</option>
                                <?php while ($r = mysql_fetch_array($sql_productos)) { ?>
                                    <option value="<?php echo $r['codigo'] ?>"><?php echo $r['descripcion'] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                     
                      
                     
                     
                    </div>
                                
           <div class="row">
              <div class="col-md-1">
                            <b>Variead</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="variedad">
                                 <option value="" selected>Todas las variedades</option>
                                <?php while ($r2 = mysql_fetch_array($sql_variedad)) { ?>
                                    <option value="<?php echo $r2['variedad'] ?>"><?php echo $r2['variedad'] ?></option>
                                <?php } ?>
                                
                            </select>
                </div>  
               
               
               

           </div>
		   
		    <div class="row">
              <div class="col-md-1">
                            <b>Almacen</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="almacen">
                                 <option value="" selected>Todos los almacenes</option>
                                <?php while ($r3 = mysql_fetch_array($sql_almacen)) { ?>
                                    <option value="<?php echo $r3['nombre'] ?>"><?php echo $r3['nombre'] ?></option>
                                <?php } ?>
                                
                            </select>
                </div>  
           </div>
		   
		   	    <div class="row">
              <div class="col-md-1">
                            <b>Proveedor</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="proveedor">
                                 <option value="" selected>Todos los proveedores</option>
                                <?php while ($r4 = mysql_fetch_array($sql_proveedor)) { ?>
                                    <option value="<?php echo $r4['nombre'] ?>"><?php echo $r4['nombre'] ?></option>
                                <?php } ?>
                                
                            </select>
                </div>  
           </div>
		   
<div class="row">
              <div class="col-md-1">
                            <b>Stock</b>
                        </div>
                        <div class="col-md-3">
                            <select  class="form-control  mb-2" id="stock">
                                 <option value="" selected>Todos</option>
								 <option value=">0">Con existencia</option>
								 <option value="<=0">Sin existencia</option>
                            </select>
                </div>  
           </div>
		   
            
            
            
          
           <div class="row">
                <div class="col-md-1">
                            <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>
		   <br>
		    <div class="row">
			<div class="col-md-1"></div>
			<div class="col-md-2">
				        <a href="#" onClick="reporte()" class="btn btn-default"><i class="fa fa-invoice"></i>Generar Reporte</a>

			</div>
        </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 productos = $("#productos").val();
                        var proveedor = $("#proveedor").val();
						var variedad = $("#variedad").val();
                        var stock = $("#stock").val();
                      
                        
                        var param="";
                        param="productos="+productos;
                        param+="&proveedor="+proveedor;
						param+="&variedad="+variedad;
						param+="&almacen="+$("#almacen").val();
						param+="&stock="+stock;
                        
                        
                        window.open('rptInventario.php?'+param,'_blank', 'toolbar=no,scrollbars=no,resizable=no,top=500,left=500,width=800,height=700');
                        
                        
                    }
                </script>