<?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?>



<script type="text/javascript">
   function comprobar_url()
   {
      if(window.location.hash.substring(1) == 'export')
      {
         $("#b_importar").removeClass('active');
         $("#g_importar").hide();
         $("#b_exportar").addClass('active');
         $("#g_exportar").show();
         $("#b_ventasp").removeClass('active');
         $("#g_ventasp").hide();        
      }
      else if(window.location.hash.substring(1) == 'import')
      {
         $("#b_exportar").removeClass('active');
         $("#g_exportar").hide();
         $("#b_ventasp").removeClass('active');
         $("#g_ventasp").hide();  
         $("#b_importar").addClass('active');
         $("#g_importar").show();
      
      }
      else if(window.location.hash.substring(1) == 'ventasp')
      {
         $("#b_ventasp").addClass('active');
         $("#g_ventasp").show(); 
         $("#b_importar").removeClass('active');
         $("#g_importar").hide();
         $("#b_exportar").removeClass('active');
         $("#g_exportar").hide();
 
     
     }

    }
   $(document).ready(function() {
      comprobar_url();
      window.onpopstate = function(){ 
         comprobar_url();
      }
   });
</script>
<script type="text/javascript">
   $(document).ready(function () {
      $("#ac_referencia").autocomplete({
         serviceUrl: '<?php echo $fsc->url();?>',
         paramName: 'buscar_referencia',
         onSelect: function (suggestion) {
            if(suggestion)
            {
               if( $("#ac_referencia").val() != suggestion.data)
               {
                  $("#ac_referencia").val(suggestion.data);
               }
            }
         }
      });

   });
</script>

<div class="container-fluid" style="margin-top: 10px;">
   <div class="row" style="margin-bottom: 10px;">
      <div class="col-xs-2">
         <a class="btn btn-sm btn-default" href="<?php echo $fsc->url();?>" title="Recargar la pÃ¡gina">
            <span class="glyphicon glyphicon-refresh"></span>
         </a>
      </div>
      <div class="col-xs-10 text-right">
         <h3 style="margin-top: 0px;">CONSULTA PRODUCTOS E INVENTARIOS</h3>
      </div>
   </div>
   <div class="row">
      <div class="col-lg-2 col-md-2 col-sm-2">
         <div class="list-group">
            <a id="b_exportar" href="#export" class="list-group-item active">
               <span class="glyphicon glyphicon-export"></span> &nbsp; Inventario
            </a>
            <a id="b_ventasp" href="#ventasp" class="list-group-item">
               <span class="glyphicon glyphicon-export"></span> &nbsp; Inventario Prod. vendidos
            </a>
             <!--a id="b_importar" href="#import" class="list-group-item">
               <span class="glyphicon glyphicon-export"></span> &nbsp; SIN FUNCIONALIDAD
            </a-->

         </div>
      </div>
      <div class="col-lg-10 col-md-10 col-sm-12">
         <div id="g_exportar">
            <form action="<?php echo $fsc->url();?>" method="post" class="form">
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <h3 class="panel-title">Inventario de Productos</h3>
                    </div>
                    
               
                    <div class="row col-sm-12"> 
                        
                            <div class="col-sm-3">   
                              Fecha:
                              <input type="text" readonly name="fechafinC" class="form-control" value="<?php echo $fsc->today();?>" autocomplete="off"/>
                           </div>  
                           <!--div class="col-sm-3">
                              Familia:
                              <select class="form-control" name="b_codfamilia" >
                                 <option value="">Todas las familias</option>
                                 <option value="">-----</option>
                                 <?php $loop_var1=$fsc->tfamilia->all(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                    <?php if( $value1->codfamilia==$fsc->b_codfamilia ){ ?>

                                    <option value="<?php echo $value1->codfamilia;?>" selected=""><?php echo $value1->descripcion;?></option>
                                    <?php }else{ ?>

                                    <option value="<?php echo $value1->codfamilia;?>"><?php echo $value1->descripcion;?></option>
                                    <?php } ?>

                                 <?php } ?>

                              </select>
                           </div-->


                  <div class="col-sm-3">
                     Familia:
                     <div class='form-group<?php if( $fsc->b_codfamilia ){ ?> has-success<?php } ?>'>
                        <div class="input-group">
                           <select class="form-control" name="b_codfamilia" onchange="this.form.submit()">
                              <option value="">Todas las familias</option>
                              <option value="">-----</option>
                              <?php $loop_var1=$fsc->tfamilia->all(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                 <?php if( $value1->codfamilia==$fsc->b_codfamilia ){ ?>

                                 <option value="<?php echo $value1->codfamilia;?>" selected=""><?php echo $value1->nivel;?><?php echo $value1->descripcion;?></option>
                                 <?php }else{ ?>

                                 <option value="<?php echo $value1->codfamilia;?>"><?php echo $value1->nivel;?><?php echo $value1->descripcion;?></option>
                                 <?php } ?>

                              <?php } ?>

                           </select>
                           <span class="input-group-addon" title="incluir subfamilias">
                              <?php if( $fsc->b_subfamilias ){ ?>

                              <input type="checkbox" name="b_subfamilias" value="TRUE" checked="" onchange="this.form.submit()">
                              <?php }else{ ?>

                              <input type="checkbox" name="b_subfamilias" value="TRUE" onchange="this.form.submit()">
                              <?php } ?>

                              <i class="fa fa-sitemap" aria-hidden="true"></i>
                           </span>
                        </div>
                     </div>
                  </div>
                  <div class="form-group col-sm-2">
                               Fabricante:
                               <div class='form-group<?php if( $fsc->d_codfabricante ){ ?> has-success<?php } ?>'>
                                   <select class="form-control" name="d_codfabricante" >  <!--onchange="this.form.submit()">-->
                                     <option value="">Todos los fabricantes</option>
                                     <option value="">-----</option>
                                     <?php $loop_var1=$fsc->fabricante->all(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                        <?php if( $value1->codfabricante==$fsc->d_codfabricante ){ ?>

                                        <option value="<?php echo $value1->codfabricante;?>" selected=""><?php echo $value1->nombre;?></option>
                                        <?php }else{ ?>

                                        <option value="<?php echo $value1->codfabricante;?>"><?php echo $value1->nombre;?></option>
                                        <?php } ?>

                                     <?php } ?>

                                  </select>
                               </div>
               </div>

                        <div class="form-group col-sm-3">
                            <div class="panel-footer">
                              <input type="checkbox" id="repcero" name="repcero" value="1">
                              <label for="repcero" title="Se reportan tambi¨¦n los Art¨ªculos que no tienen stock">SIN stock </label>
                                <input type="checkbox" id="repxls" name="repxls" value="XX">
                                <label for="repxls"> Imprimir </label><br>
                                <button class="btn btn-sm btn-primary" type="submit" onclick="this.disabled=true;this.form.submit();">
                                <span class="glyphicon glyphicon-book"></span> &nbsp; Generar XLS
                                </button>
                            </div>
                        </div>
                        
                           <div  class="form-group col-sm-4">
                              <h5><b>Atencion:&nbsp;</b>&nbsp;Para obtener el archivo Excel <br> * Primero presione Generar XLS,  luego tildar Imprimir y otrra vez Generar xls</h5> 
                           </div>   
                     </div>   

                      <div>
                        <table class="table table-hover">
                           <thead>
                              <tr>                                 
                                 <th class="text-left">Factura/tipo</th>
                                 <th class="text-left">Referencia</th>
                                 <th class="text-left">Fecha Fact</th>
                                 <th class="text-left">Cantidad</th>
                                 <th class="text-left">Prec-Compra</th>
                                 <th class="text-left">Prec-Total</th>
                                 <th class="text-left">Salida</th>
                                 <th class="text-left">saldo</th>
                                 
                              </tr>
                           </thead>
                           <?php $loop_var1=$fsc->lineas_stock; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>


                               <td class="text-left"><?php echo $value1['codigo'];?>/<?php echo $value1['tipo'];?>  </td>
                               <td class="text-left"><?php echo $value1['referencia'];?> </td>
                               <td class="text-LEFT"><?php echo $value1['fecha'];?> </td>
                               <td class="text-LEFT"><?php echo $value1['cantidad'];?> </td>
                               <td class="text-center"><?php echo $value1['precompra'];?> </td>
                               <td class="text-center"><?php echo $value1['prectotal'];?> </td>
                               <td class="text-center"><?php echo $value1['salida'];?> </td>
                               <td class="text-center"><?php echo $value1['saldo'];?> </td>
                               

                           </tr>
                           <?php } ?>

                              <tfoot>
                                <tr>
                                  <td class="text-left">TOTALES</td>
                                  <td ></td>
                                  <td ></td>
                                  <td ></td>
                                  <td ></td>
                                  <td ></td>
                                  <td><?php echo $fsc->preciototal;?></td>
                                  <td ></td>
                                  <td ></td>
                                  <td ></td>
                                  <!--<td><?php echo $fsc->precantregul;?></td>-->
                                </tr>
                              </tfoot>
                        </table>

                    </div> 
                </div>
            </form>      
        </div>    
        
         <div id="g_ventasp" style="display: none;">
            <form action="<?php echo $fsc->url();?>#ventasp" method="post" class="form">
               
               <div class="panel panel-info">
                  <div class="panel-heading">
                        <h3 class="panel-title">Inventario de productos vendidos a una fecha</h3>
                  </div>
                  <div class="row"> 
                     <div class="">
                        <div class="form-group col-sm-2">
                            Fecha de Proceso:
                            <input type="text" name="fechaini3" class="form-control datepicker" value="<?php echo $fsc->today();?>" autocomplete="off"/>
                        </div>
                        <div class="col-sm-3">
                           Familia:
                           <div class='form-group<?php if( $fsc->b_codfamilia ){ ?> has-success<?php } ?>'>
                              <div class="input-group">
                                 <select class="form-control" name="b_codfamilia" onchange="this.form.submit()">
                                    <option value="">Todas las familias</option>
                                    <option value="">-----</option>
                                    <?php $loop_var1=$fsc->tfamilia->all(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                       <?php if( $value1->codfamilia==$fsc->b_codfamilia ){ ?>

                                       <option value="<?php echo $value1->codfamilia;?>" selected=""><?php echo $value1->nivel;?><?php echo $value1->descripcion;?></option>
                                    <?php }else{ ?>

                                       <option value="<?php echo $value1->codfamilia;?>"><?php echo $value1->nivel;?><?php echo $value1->descripcion;?></option>
                                    <?php } ?>

                                    <?php } ?>

                                 </select>
                                 <span class="input-group-addon" title="incluir subfamilias">
                                    <?php if( $fsc->b_subfamilias ){ ?>

                                       <input type="checkbox" name="b_subfamilias" value="TRUE" checked="" onchange="this.form.submit()">
                                    <?php }else{ ?>

                                       <input type="checkbox" name="b_subfamilias" value="TRUE" onchange="this.form.submit()">
                                    <?php } ?>

                                    <i class="fa fa-sitemap" aria-hidden="true"></i>
                                 </span>
                              </div>
                           </div>
                        </div>
                        <div class="form-group col-sm-2">
                           Fabricante:
                           <div class='form-group<?php if( $fsc->d_codfabricante ){ ?> has-success<?php } ?>'>
                              <select class="form-control" name="d_codfabricante" >  <!--onchange="this.form.submit()">-->
                                 <option value="">Todos los fabricantes</option>
                                    <option value="">-----</option>
                                       <?php $loop_var1=$fsc->fabricante->all(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                          <?php if( $value1->codfabricante==$fsc->d_codfabricante ){ ?>

                                             <option value="<?php echo $value1->codfabricante;?>" selected=""><?php echo $value1->nombre;?></option>
                                          <?php }else{ ?>

                                             <option value="<?php echo $value1->codfabricante;?>"><?php echo $value1->nombre;?></option>
                                          <?php } ?>

                                       <?php } ?>

                              </select>
                           </div>
                        </div>

                        <div class="form-group col-sm-3">
                           <div class="panel-footer">
                              <!--input type="checkbox" id="repcero" name="repcero" value="1">
                              <label for="repcero" title="Se reportan también los Articulos que no tienen stock">SIN stock </label-->
                                 <input type="checkbox" id="repxls" name="repxls" value="ZZ">
                                 <label for="repxls"> Imprimir </label><br>
                                 <button class="btn btn-sm btn-primary" type="submit" onclick="this.disabled=true;this.form.submit();">
                                 <span class="glyphicon glyphicon-book"></span> &nbsp; Generar XLS
                                 </button>
                           </div>
                        </div>
                        
                        <div  class="form-group col-sm-4">
                           <h5><b>Atencion:&nbsp;</b>&nbsp;Para obtener el archivo Excel <br> * Primero seleccione la fecha de proceso, la familia, el fabricante  <br> * Generar XLS  <br> * tildar Imprimir y finalmente otrra vez Generar xls</h5> 
                        </div>   
                     </div>
                  </div>                    
               </div>
            </form>      
        </div>    

        <div id="g_importar" style="display: none;">
            <form action="<?php echo $fsc->url();?>#import" method="post" enctype='multipart/form-data' class="form">
               <input name='import' type='hidden' value='TRUE'/>
               <div class="panel panel-info">
                  <div class="panel-heading">
                     <h3 class="panel-title">Generación de Información para EXCEL</h3>
                  </div>
                  <div class="row"> 
                    <div class="">
                        <div class="form-group col-sm-2">
                            Fecha Ini:
                            <input type="text" name="fechaini1" class="form-control datepicker" value="<?php echo $fsc->today();?>" autocomplete="off"/>
                        </div>
                        
                        <div class="form-group col-sm-2 ">
                            <div class="form-group">   
                              Fecha fin:
                              <input type="text" name="fechafin1" class="form-control datepicker" value="<?php echo $fsc->today();?>" autocomplete="off"/>
                            </div>  
                        </div> 
                        <!-- almacen a procesar jl-->
                        <div class="col-sm-3">
                           Vendedor:
                            <div class="form-group">
                                <select name="codagente" class="form-control">
                                    <option value="<?php echo $fsc->agente->codagente;?>"><?php echo $fsc->agente->get_fullname();?></option>
                                    <?php $loop_var1=$fsc->agente->all(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                    <option value="<?php echo $value1->codagente;?>"><?php echo $value1->get_fullname();?></option>
                                    <?php } ?>

                                </select>
                            </div>
                           </div>                      
                        <div class="form-group col-sm-1">
                            <div class="panel-footer">
                                <button class="btn btn-sm btn-primary" type="submit" onclick="this.disabled=true;this.form.submit();">
                                <span class="glyphicon glyphicon-import"></span> &nbsp; Exportar XLS
                                </button>
                            </div>
                        </div>    
                    </div>
                   </div>
                </div>   
            </form>
      </div>

   </div>
</div>
</div>

<?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("footer") . ( substr("footer",-1,1) != "/" ? "/" : "" ) . basename("footer") );?>



