<?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="label label-success">EN TRANSITO</label>';
			}else if ($dt1['tb_traspaso_est']==2){
				$est = '<label class="label label-primary">ACEPTADO / VALIDADO</label>';
			}	
				
		?>
        <tr>
           <td nowrap >
			<span class="btn btn-sm btn-primary glyphicon glyphicon-pencil" onClick="traspaso_form('editar','<?php echo $dt1['tb_traspaso_id']?>')" ></span>
			<?php if($dt1['tb_traspaso_est']==1){
			?>
			  <span class="btn btn-success btn-sm " onClick="traspaso_form_val('<?php echo $dt1['tb_traspaso_id']?>')" ></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>  


