<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("../egreso/cEgreso.php");
$oEgreso = new cEgreso();
require_once("../cliente/cCliente.php");
$oCliente = new cCliente();
require_once("../proveedor/cProveedor.php");
$oProveedor = new cProveedor();
require_once("../formatos/formato.php");
//echo $_POST['cmb_fil_caj_id'].'-';
	$dts1=$oEgreso->mostrar_filtro($_SESSION['puntoventa_id'],$_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_egr_numdoc'],$_POST['hdd_fil_pro_id'],$_POST['cmb_fil_egr_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_egreso" class="table table-bordered  table-hover table-striped">
            <thead>
        <tr>
          <th nowrap title="Fecha">FECHA</th>
          <th >DOCUMENTO</th>
          <th>ANEXO</th>
          <th>DETALLE</th>
          <th >CUENTA</th>
          <th align="right">IMPORTE</th>
          <th >&nbsp;</th>
          </tr>
        </thead>
        <tbody>
<?php
while($dt1 = mysqli_fetch_array($dts1)){
	$sum_imp+=$dt1['tb_egreso_imp'];
	
	 if($dt1['modid']==20 || $dt1['modid']==7){
	
	$dts=$oCliente->mostrarUno($dt1['perid']);
	$dt = mysqli_fetch_array($dts);
	$nom=$dt['tb_cliente_nom'];
	$doc=$dt['tb_cliente_doc'];
	mysqli_free_result($dts);
	
  }else{
	
	if($dt1['perid']>0){
	
	$dts=$oProveedor->mostrarUno($dt1['perid']);
	$dt = mysqli_fetch_array($dts);
	$nom=$dt['tb_proveedor_nom'];
	$doc=$dt['tb_proveedor_doc'];
	mysqli_free_result($dts);
	}
	else{
		$nom = 'SALIDA S/PROVEEDOR';
		$doc= '';
	}
  }
	
?>
        <tr title="<?php echo $dt1['tb_egreso_id'].' ::: '.$dt1['tb_caja_nom'].'- Mod.: '.$dt1['modid']; ?>" style="cursor:pointer;" >
          <td nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_egreso_fec'])?></td>
          <td><?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_egreso_numdoc']?></td>
          <td><?php echo $doc.' '.$nom?></td>  
          <td><?php echo $dt1['tb_egreso_det']?></td>
          <td><?php echo $dt1['tb_cuenta_nom']?></td>
          <td align="right"><?php echo formato_money($dt1['tb_egreso_imp'])?></td>         
          <td align="center" nowrap="nowrap">
          <?php
          if($dt1['tb_egreso_modide']==0){
            ?>
             <a class="btn btn-info btn-sm"  onClick="egreso_form('editar','<?php echo $dt1['tb_egreso_id']?>')"><i class="fa fa-edit"></i></a> 
          
          <a class="btn btn-danger btn-sm"  onClick="egreso_eliminar('<?php echo $dt1['tb_egreso_id']?>')"><i class="fa fa-trash"></i> </a>  
          <?php //}
          }//transf
          ?>
          </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" align="right"></td> 
        <td colspan="1" align="right"><strong><?php echo formato_money($sum_imp)?></strong></td>
        <td colspan="1" align="right"></td>
		  
        </tr>
      </table>
<input name="hdd_gasto_total" id="hdd_gasto_total" type="hidden" value="<?php echo $sum_imp?>">
</div>
</div>
 <script type="text/javascript">
  $(function() {  
     $('#tabla_egreso').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> 