<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("../ingreso/cIngreso.php");
$oIngreso = new cIngreso();
require_once("../formatos/formato.php");
$fecha1 = $_POST['txt_fil_ing_fec1']; 
$fecha2 = $_POST['txt_fil_ing_fec2']; 
			if ($_SESSION['usuariogrupo_id']=='6'){
		
			$dts1=$oIngreso->mostrar_filtro($_SESSION['puntoventa_id'],$_POST['cmb_fil_caj_id'],fecha_mysql($fecha1),fecha_mysql($fecha2),$_POST['cmb_fil_cue_id'],$_POST['cmb_fil_subcue_id'],$_POST['cmb_fil_doc_id'],$_POST['txt_fil_ing_numdoc'],$_POST['hdd_fil_cli_id'],$_POST['cmb_fil_ing_est'],$_POST['cmb_moneda_id']);	
			}else{
			$dts1=$oIngreso->mostrar_filtro('',$_POST['cmb_fil_caj_id'],fecha_mysql($fecha1),fecha_mysql($fecha2),$_POST['cmb_fil_cue_id'],$_POST['cmb_fil_subcue_id'],$_POST['cmb_fil_doc_id'],$_POST['txt_fil_ing_numdoc'],$_POST['hdd_fil_cli_id'],$_POST['cmb_fil_ing_est'],$_POST['cmb_moneda_id']);	
			}
$num_rows= mysqli_num_rows($dts1);
?>
<section class="content">
	<div class="container-fluid">
	<div class="row">
	    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
		    <div class="card">
				<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding:5px;">
	
					<div class="table-responsive">
	
          <table id="tabla_ingreso" class="table table-bordered table-striped">
           <thead>
        <tr>
          <th nowrap title="Fecha">FECHA</th>
          <th  class="hidden-lg hidden-xs hidden-md hidden-sm" >DOCUMENTO</th>
          <th>CLIENTE</th>
          <th>DETALLE</th>
          <th>CUENTA</th>
          <th  class="hidden-lg hidden-xs hidden-md hidden-sm" nowrap>SUB CUENTA</th>
          <th align="right">IMPORTE</th>
          <th align="center">ESTADO</th>
          <th align="center">CAJA</th>
          <th align="right">ID</th>
          <th title="Editar">&nbsp;</th>
          </tr>
        </thead> 
            <tbody>
<?php
while($dt1 = mysqli_fetch_array($dts1)){
  $sum_imp+=$dt1['tb_ingreso_imp'];
  
  
  if($dt1['tb_cliente_id']>0){
		$nom = $dt1['tb_cliente_nom'];
		$doc = $dt1['tb_cliente_doc'];
	}
	else{
		$nom = 'INGRESO S/CLIENTE';
		$doc = '';
	}
	
  
?>
        <tr>
          <td nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_ingreso_fec'])?></td>
          <td  class="hidden-lg hidden-xs hidden-md hidden-sm" nowrap="nowrap">
            <?php $documento=$dt1['tb_documento_abr'].' '.$dt1['tb_ingreso_numdoc']?>
            <a style="color: ORANGE;" title="Imprimir" href="#imprimir" onClick="ingreso_impresion('<?php echo $dt1['tb_ingreso_id']?>')"><?php echo $documento?></a>
          </td>
          <td><?php echo $doc.' '.$nom?></td>  
          <td nowrap ><?php echo $dt1['tb_ingreso_det']?></td>
          <td><?php echo $dt1['tb_cuenta_nom']?></td>
          <td  class="hidden-lg hidden-xs hidden-md hidden-sm" ><?php echo $dt1['tb_subcuenta_des']?></td>
          <td align="right"><?php echo formato_money($dt1['tb_ingreso_imp'])?></td>
          <td align="center">
            <?php 
              if($dt1['tb_ingreso_est']==1)echo 'CANCELADO';
              if($dt1['tb_ingreso_est']==2)echo 'EMITIDO';
            ?>
          </td>
          <td align="center" nowrap="nowrap"><?php echo $dt1['tb_caja_nom']?></td>
          <td align="right"><?php echo $dt1['tb_ingreso_id']?></td>
          <td align="center" nowrap="nowrap">
          <?php 
          if($dt1['tb_ingreso_modide']==0)
          { 
            ?>
            <button class="btn btn-info" style="padding:2px 5px;margin:0px 2px" onClick="ingreso_form('editar','<?php echo $dt1['tb_ingreso_id']?>')"><i class="fa fa-edit"></i></button>
             <button  class="btn btn-danger" style="padding:2px 5px;margin:0px 2px" onClick="ingreso_eliminar('<?php echo $dt1['tb_ingreso_id']?>')"><i class="fa fa-trash"></i></button> 
          <?php
        }
          ?>
          </td>
          </tr>
<?php
}
mysqli_free_result($dts1);
?>
    </tbody>
    <tr class="even">
          <td colspan="6"><strong>TOTAL</strong></td>
          <td align="right"><strong><?php echo formato_money($sum_imp)?></strong></td>
          <td colspan="4">&nbsp;</td>
        </tr>
        </table>
      </div>
    </div>
    </div>
  </div>
</div>
</div>
</section>
<script type="text/javascript">
  $(function() {  
  
	 $('#tabla_ingreso').DataTable({
 
        "language": {
                "lengthMenu": "Mostrar _MENU_ registros",
                "zeroRecords": "No se encontraron resultados",
                "info": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
                "infoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
                "infoFiltered": "(filtrado de un total de _MAX_ registros)",
                "sSearch": "Buscar:",
                "oPaginate": {
                    "sFirst": "Primero",
                    "sLast":"Último",
                    "sNext":"Siguiente",
                    "sPrevious": "Anterior"
			     },
			     "sProcessing":"Procesando...",
            }
    });  
	
	
  }); 
</script>  