<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("../ingreso/cIngreso.php");
$oIngreso = new cIngreso();
require_once("../formatos/formato.php");
		  $dts1=$oIngreso->mostrar_filtro('',$_POST['cmb_fil_caj_id'],
      fecha_mysql($_POST['txt_fil_caj_fec1']),fecha_mysql($_POST['txt_fil_caj_fec2']),
		  $_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_fil_usuario_id']);
$num_rows= mysqli_num_rows($dts1);
?>
<div class="table-responsive">
		
		<div class="col-lg-12 col-md-12 col-xs-12 " >
<table cellspacing="1" id="tabla_ingreso" class="table table-striped table-bordered">
  <thead>
    <tr>
      <th nowrap>FECHA</th>
      <th>DOCUMENTO</th>
      <th>CLIENTE</th>
      <th>DETALLE</th>
      <th>CUENTA</th>
      <th align="right">IMPORTE</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 title="<?php echo $dt1['tb_ingreso_id'].' ::: '.$dt1['tb_caja_nom']; ?>" >
      <td nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_ingreso_fec'])?></td>
      <td><?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_ingreso_numdoc']?></td>
      <td><?php echo $doc.' '.$nom?></td>  
      <td><?php echo $dt1['tb_ingreso_det'] ?></td>
      <td ><?php echo $dt1['tb_cuenta_nom']?></td>
      <td align="right"><?php echo formato_money($dt1['tb_ingreso_imp'])?></td>        
      <td align="center" nowrap="nowrap">
        <?php 
        if($dt1['tb_ingreso_modide']==0){
          ?> 
          <a class="btn btn-info btn-sm"  onClick="ingreso_form('editar','<?php echo $dt1['tb_ingreso_id']?>')" ><i class="fa fa-edit"></i></a> 
          
          <a class="btn btn-danger btn-sm"   onClick="ingreso_eliminar('<?php echo $dt1['tb_ingreso_id']?>')"><i class="fa fa-trash"></i> </a> 
          <?php 
          }
          ?>
        </td>
      </tr>
      <?php
    }
    mysqli_free_result($dts1);
    ?>
  </tbody>
  <tr class="even">
    <td colspan="4"><strong>TOTAL <?php echo $num_rows." registros";?></strong></td>
	<td colspan="1">&nbsp;</td>
    <td colspan="1" align="right"><strong><?php echo formato_money($sum_imp)?></strong></td>
    <td colspan="1">&nbsp;</td>
  </tr>
</table>
<input name="hdd_ingreso_total" id="hdd_ingreso_total" type="hidden" value="<?php echo $sum_imp?>">
</div>
</div>
 <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> 