<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("cTransferencia.php");
$oTransferencia = new cTransferencia();
require_once("../formatos/formato.php");
$fecha1 = $_POST['txt_fil_tra_fec1']; 
$fecha2 = $_POST['txt_fil_tra_fec1']; 
$dts1=$oTransferencia->mostrar_filtro($_SESSION['empresa_id'],fecha_mysql($fecha1),fecha_mysql($fecha2),$_POST['cmb_fil_caj_id_ori'],$_POST['cmb_fil_caj_id_des']);
$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_transferencia" class="table table-bordered table-striped">
           <thead>
            <tr>
              <th nowrap title="Fecha Contable">FECHA</th>
              <th>ID</th>
              <th>DETALLE</th>
              <th>CAJA ORIGEN</th>
              <th>CAJA DESTINO</th>
              <th align="right">IMPORTE</th>
              <th align="center">ESTADO</th>
              <th title="Editar">&nbsp;</th>
            </tr>
          </thead>
          <tbody>
            <?php
            while($dt1 = mysqli_fetch_array($dts1)){
             $sum_imp+=$dt1['tb_transferencia_imp'];
             ?>
             <tr>
              <td nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_transferencia_fec'])?></td>
              <td><?php echo $dt1['tb_transferencia_id']?></td>
              <td><?php echo $dt1['tb_transferencia_det']?></td>
              <td><?php echo $dt1['caja_ori']?></td>
              <td><?php echo $dt1['caja_des']?></td>
              <td align="right"><?php echo formato_money($dt1['tb_transferencia_imp'])?></td>
              <td align="center"><?php 
                if($dt1['tb_transferencia_est']==1)echo 'CANCELADO';
                if($dt1['tb_transferencia_est']==2)echo 'EMITIDO';
                ?></td>
                <td align="center" nowrap="nowrap"> 
                 <button title="Editar" class="btn btn-primary" style="padding:2px 5px;margin:0px 2px" onClick="transferencia_form('editar','<?php echo $dt1['tb_transferencia_id']?>')"><i class="fa fa-edit"></i></button>
                 <?php if($dt1['tb_transferencia_est']!='ANULADA'){?>
                 <?php if($_SESSION['usuariogrupo_id']==2){?>
                 <button  title="Eliminar" class="btn btn-primary" style="padding:2px 5px;margin:0px 2px" onClick="transferencia_eliminar('<?php echo $dt1['tb_transferencia_id']?>')"><i class="fa fa-trash"></i></button> 
                 <?php 
          }//cierre de caja
          }//consulta
          ?>
        </td>
      </tr>
      <?php
    }
    mysqli_free_result($dts1);
    ?>
  </tbody>
  <tr class="even">
    <td colspan="5"><strong>TOTAL</strong></td>
    <td align="right"><strong><?php echo formato_money($sum_imp)?></strong></td>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>

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

<script type="text/javascript">
  $(function() {  
    $("#tabla_transferencia").DataTable( {
      "columnDefs": [
      { "orderable": false, "targets": [1] }
      ],
      "searching": false,
      "order":[[0,"asc"]]
    });
  }); 
</script>  