<?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 title="Editar">&nbsp;</th>
          <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="d-none" nowrap>SUB CUENTA</th>
          <th align="right">IMPORTE</th>
          <th align="center">ESTADO</th>
          <th align="center">CAJA</th>
          <th align="right">ID</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 align="center" nowrap="nowrap">
          <?php 
          if($dt1['tb_ingreso_modide']==0)
          { 
            ?>
            <span class="btn btn-sm btn-info"  onClick="ingreso_form('editar','<?php echo $dt1['tb_ingreso_id']?>')"><i class="fa fa-edit"></i></span>
             <span  class="btn btn-sm btn-danger"  onClick="ingreso_eliminar('<?php echo $dt1['tb_ingreso_id']?>')"><i class="fa fa-trash"></i></span> 
          <?php
        }
          ?>

          <span class="btn btn-sm btn-warning" title="IMPRIMIR FORMATO TICKET" data-toggle="tooltip" data-placement="top" onclick="ingreso_ticket_datos('<?php echo $dt1['tb_ingreso_id']?>')"><i class="fa fa-print"></i></span>

          </td>
          <td nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_ingreso_fec'])?></td>
          <td  class="" nowrap="nowrap">
          <?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_ingreso_numdoc'] ?></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="d-none" ><?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 '<label class="badge badge-danger" >REGISTRADO</label>';
            ?>
          </td>
          <td align="center" nowrap="nowrap"><?php echo $dt1['tb_caja_nom']?></td>
          <td align="right"><?php echo $dt1['tb_ingreso_id']?></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>  