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

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

$dts1=$oDevolucioncliente->mostrar_filtro(fecha_mysql($_POST['txt_fil_dev_fec1']),fecha_mysql($_POST['txt_fil_dev_fec2']),
$_POST['cmb_puntoventa_id'],$_POST['hdd_fil_cli_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 class="" >NUM. DOC.</th>
                <th>EMPRESA</th>                    
                <th class="" >CLIENTE</th>
               
                <th class="" >COMPROBANTE CLIENTE</th>
                <th class="" >COMPROBANTE GENERADO</th>
                <th class="" >OBSERVACION</th>
                <th NOWRAP class="" align="right">TOTAL</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_devolucioncliente_tot'];
	   
		}else if($dt1['tb_moneda_id']==2){
				$monsim = '<span class="text-green">'.$dt1['tb_moneda_sim'].'</span>';
				$total_pagar_dol += $dt1['tb_devolucioncliente_tot'];
		}
      
	$reg = mostrarFechaHora($dt1['tb_devolucionproveedor_reg']);					
	  
	  if($dt1['tb_devolucioncliente_est']==0){
			$est = '<badge class="badge badge-danger">DEVUELTO</badge>';
	  }
	  
	  if($dt1['tb_devolucionproveedor_tranom']!="" && $dt1['tb_devolucionproveedor_tracom'] !=""){
				$tra = $dt1['tb_devolucionproveedor_tranom'].' | '.$dt1['tb_devolucionproveedor_tracom'];
	  }else if($dt1['tb_devolucionproveedor_tranom']!="" && $dt1['tb_devolucionproveedor_tracom'] ==""){
				$tra = $dt1['tb_devolucionproveedor_tranom'];
	  }else if($dt1['tb_devolucionproveedor_tranom']=="" && $dt1['tb_devolucionproveedor_tracom'] !=""){
				$tra = $dt1['tb_devolucionproveedor_tracom'];
	  }
	  
	  
      ?>
      <tr  >
        <td class="" nowrap="nowrap">
		
		<a href="../../files/devolucion/devolucion_impcpe_doc.php?devid=<?php echo $dt1['tb_devolucioncliente_id']; ?>" target="_blank" class="btn btn-sm" style="background-color:#00897b;color:#fff;" title="DESCARGAR E IMPRIMIR PDF"><i class="fas fa-file-pdf"></i></a>		 
				
		<?php 
		if($dt1['tb_devolucionproveedor_est']==0){
		?>
	<!--	<span class="btn btn-success btn-sm glyphicon glyphicon-zoom-in" onclick="devolucionproveedor_relacionar('relacionar',<?php echo $dt1['tb_devolucionproveedor_id'];?>,<?php echo $dt1['tb_empresa_id'];?>)"></span>
		<span class="btn btn-warning btn-sm glyphicon glyphicon-remove" onclick="devolucionproveedor_cancelar('cancelar',<?php echo $dt1['tb_devolucionproveedor_id'];?>,<?php echo $dt1['tb_empresa_id'];?>)" ></span>
	-->
	<?php 
		}
		?>
		
		</td>
        <td  title="FECHA DE REGISTRO : <?php echo "$reg";  ?>" class="" nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_devolucioncliente_fec'])?></td>
        <td NOWRAP > <strong class="text text-red"> <?php echo $dt1['tb_devolucioncliente_numdoc']?></strong></td>
		<td NOWRAP class="" ><?php echo $dt1['tb_empresa_nomcom']?></td>
		<td NOWRAP ><?php echo $dt1['tb_cliente_nom']?></td>
		<!--
		<td NOWRAP class="" ><?php echo $tra?></td>
		-->
		<td NOWRAP class="" >
			<a class="badge badge-primary" href="../../files/venta/venta_impcpe_doc.php?venid=<?php echo $dt1['tb_documentomod_id']; ?>" target="_blank"><?php echo $dt1['tb_venta_numdoc']?></a>		 
		</td>
		<td NOWRAP class="" >
		<?php if($dt1['tb_documento_abr']=='F' || $dt1['tb_documento_abr']=='B'){
		?>
		<a class="badge badge-success" title="NOTA DE CREDITO ELECTRONICA" href="../../files/notacredito/notacredito_impcpe_doc.php?notid=<?php echo $dt1['tb_documentogen_id']; ?>" target="_blank"><?php echo $dt1['tb_documentogen_numdoc']?></a>		 
		<?php }else{
		?>
		<a class="badge badge-success" title="GUIA DE REMISION ELECTRONICA" href="../../files/guiaremision/guiaremision_impcpe_doc.php?guiaid=<?php echo $dt1['tb_documentogen_id']; ?>" target="_blank"><?php echo $dt1['tb_documentogen_numdoc']?></a>		 
		<?php 
		}?>
		
			
		</td>
        <td NOWRAP class="" ><?php echo $dt1['tb_devolucioncliente_obs1']?></td>
        <td NOWRAP align="right"><?php echo  $monsim.' '.formato_money($dt1['tb_devolucioncliente_tot'])?></td>
         </tr>
      <?php
    }
    mysqli_free_result($dts1);
    }
    ?>
  </tbody>
        </table>
		
				</div>
			</div>
			</div>
        </div>
      </div>
    </div>
 </section>

  
   <script type="text/javascript">
  $(function() {  
    $("#tabla_compra").DataTable( {
      paging: true,
	  searching: false,
	  ordering:false,
	  "columnDefs": [
        { "orderable": true, "targets": [0] }
      ],
    });
  }); 
</script>  