<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("cTraspaso.php");
$oTraspaso = new cTraspaso();
require_once ("../formatos/formato.php");


$dts1=$oTraspaso->mostrar_filtro(fecha_mysql($_POST['txt_fil_tra_fec1']),fecha_mysql($_POST['txt_fil_tra_fec2']),$_POST['cmb_fil_tra_alm_ori'],$_POST['cmb_fil_tra_alm_des'],$_SESSION['empresa_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 cellspacing="1" id="tabla_traspaso"  class="table table-bordered table-striped">
    <thead>
        <tr>
		<th>&nbsp;</th>
          <th>FECHA</th>
          <th>NUMERO DOC.</th>
          <th>ESTADO</th>
          <th>ALM. ORI</th>
          <th>ALM. DES</th>
          <th>OBSERVACIÓN</th>
          <th>ID</th>
          
        </tr>
    </thead>
		<?php
			if($num_rows>0){
		?>
    <tbody>
		<?php
			while($dt1 = mysqli_fetch_array($dts1)){
				
			if($dt1['tb_traspaso_est']==1){
				$est = '<label class="badge badge-success">EN TRANSITO</label>';
			}else if ($dt1['tb_traspaso_est']==2){
				$est = '<label class="badge badge-primary">ACEPTADO / VALIDADO</label>';
			}	
				
		?>
        <tr>
           <td nowrap >
			<span class="btn btn-sm btn-primary " onClick="traspaso_form('editar','<?php echo $dt1['tb_traspaso_id']?>')" ><i class="fas fa-edit"></i></span>
			
			<a title="VER DESCARGAR Y/O IMPRIMIR PDF" data-toggle="tooltip" data-placement="top" 
			href="../../files/traspaso/traspaso_impcpe_doc.php?tra_id=<?php echo $dt1['tb_traspaso_id']; ?>" target="_blank" class="btn btn-sm " 
			style="background-color:#3B71CA;color:#fff;" title="DESCARGAR E IMPRIMIR PDF"><i class="fas fa-file-pdf"></i></a>	
				
			
			<?php if($dt1['tb_traspaso_est']==1){
			?>
			  <span class="btn btn-success btn-sm " onClick="traspaso_form_val('<?php echo $dt1['tb_traspaso_id']?>')" ><i class="fas fa-truck"></i></span>
			  <!--
			  <span class="btn btn-sm btn-danger " onClick="eliminar_traspaso('<?php echo $dt1['tb_traspaso_id']?>')" ><i class="fas fa-times"></i></span>
			-->
			<?php 
			}?>
		  </td>
          <td nowrap ><?php echo mostrarFechaHora($dt1['tb_traspaso_reg'])?></td>
          <td nowrap ><?php echo $dt1['tb_traspaso_numdoc']?></td>
          <td><?php echo $est?></td>
          <td><?php echo $dt1['alm_ori']?></td>
          <td><?php echo $dt1['alm_des']?></td>
          <td><?php echo $dt1['tb_traspaso_obs']?></td>
          <td> <?php echo $dt1['tb_traspaso_id'] ?></td>
         

        </tr>
      <?php
			}
      mysqli_free_result($dts1);
      ?>
    </tbody>
    <?php
		}else{
			?>
		<tr class="even">
			<td colspan="8">No hay registros</td>
		</tr>
			<?php 
		}
		?>
      <tr class="even">
        <td colspan="8"><?php echo $num_rows.' registros'?></td>
      </tr>
</table>

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



<script type="text/javascript">
  $(function() {  
   
	
	 $('#tabla_traspaso').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>  


