<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("cDevolucionproveedor.php");
$oDevolucionproveedor = new cDevolucionproveedor();

require_once ("../formatos/formato.php");

$dts1=$oDevolucionproveedor->mostrar_filtro($_POST['cmb_dev_emp_id'],$_POST['hdd_fil_pro_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 id="tabla_compra" class="table">
            <thead>
              <tr>
                <th class="" ></th>
                <th class="" >FECHA</th>
                <th>EMPRESA</th>                    
                <th>GUIA DEVOLUCION</th>
                <th class="" >PROVEEDOR</th>
                <th class="" >COMPROBANTE TRANSPORTISTA</th>
                <th class="" >COMPROBANTE PROVEEDOR</th>
                <th class="" >OBSERVACION</th>
                <th NOWRAP class="" align="right">TOTAL</th> 
				 <th class="" >ESTADO</th>
              </tr>
            </thead>
            <tbody>
      <?php
       if($num_rows>0){
      while($dt1 = mysqli_fetch_array($dts1))
    {

		if($dt1['tb_moneda_id']==1){
				$monsim = '<span class="text-primary">'.$dt1['tb_moneda_sim'].'</span>';
				$total_pagar_sol += $dt1['tb_compra_tot'];
	   
		}else if($dt1['tb_moneda_id']==2){
				$monsim = '<span class="text-green">'.$dt1['tb_moneda_sim'].'</span>';
				$total_pagar_dol += $dt1['tb_compra_tot'];
		}
      
	$reg = mostrarFechaHora($dt1['tb_devolucionproveedor_reg']);					
	  
	  if($dt1['tb_devolucionproveedor_est']==0){
			$est = '<badge class="badge badge-danger">SIN ESTADO</badge>';
	  }else  if($dt1['tb_devolucionproveedor_est']==1){
			 $est = '<badge class="badge badge-success">RESUELTA</badge>';
	  }else  if($dt1['tb_devolucionproveedor_est']==2){
			 $est = '<badge class="badge badge-warning">CANCELADA</badge>';
	  }
	  
      ?>
      <tr  >
        <td class="" nowrap="nowrap">
		
		<span class="btn btn-primary btn-sm " style="cursor:pointer" onclick="devolucionproveedor_formvista('editar','<?php echo $dt1['tb_devolucionproveedor_id'];?>');" ><i class="fas fa-edit"></i></span>
		
		<?php 
		if($dt1['tb_devolucionproveedor_est']==0){
		?>
		<span class="btn btn-success btn-sm"  style="cursor:pointer"
		onclick="devolucionproveedor_relacionar('relacionar','<?php echo $dt1['tb_devolucionproveedor_id'];?>','<?php echo $dt1['tb_empresa_id'];?>')"><i class="fas fa-search-plus"></i></span>
		
		<span class="btn btn-danger btn-sm" style="cursor:pointer"
		onclick="devolucionproveedor_cancelar('cancelar','<?php echo $dt1['tb_devolucionproveedor_id'];?>','<?php echo $dt1['tb_empresa_id'];?>')" ><i class="fas fa-times"></i></span>
		<?php 
		}
		?>
		
		</td>
        <td  title="FECHA DE REGISTRO : <?php echo "$reg";  ?>" class="" nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_devolucionproveedor_fec'])?></td>
        <td NOWRAP class="" ><?php echo $dt1['tb_empresa_nomcom']?></td>
        <td NOWRAP class="" ><?php echo $dt1['tb_guiaremision_numdoc']?></td>
		<td NOWRAP ><?php echo $dt1['tb_proveedor_nom']?></td>
		<td NOWRAP class="" ><?php echo $dt1['tb_devolucionproveedor_tranom'].' | '.$dt1['tb_devolucionproveedor_tracom']?></td>
		<td NOWRAP class="" ><?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_compra_numdoc'].' | '.$dt1['DO'].' '.$dt1['NC']?></td>
        <td NOWRAP class="" ><?php echo $dt1['tb_devolucionproveedor_obs1']?></td>
        <td NOWRAP align="right"><?php echo  $monsim.' '.formato_money($dt1['tb_devolucionproveedor_tot'])?></td>
		<td NOWRAP class="" ><?php echo $est ?></td>
         </tr>
      <?php
    }
    mysqli_free_result($dts1);
    }
    ?>
  </tbody>
        </table>
		</div>
        </div>
        </div>
        </div>
      </div>
    </div>
  </section>

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