<?php
session_start();
require_once ("../../config/Cado.php");
require_once ("cDevolucioncliente.php");
$oDevolucioncliente = new cDevolucioncliente();
require_once ("../compra/cComprapago.php");
$oComprapago = new cComprapago();
require_once ("../egreso/cEgreso.php");
$oEgreso = new cEgreso();
require_once ("../formatos/formato.php");
$dts1=$oDevolucioncliente->mostrar_filtro2($_POST['cmb_puntoventa_id'],$_POST['hdd_fil_cli_id'],$_POST['txt_dev_numdocfil']);
$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_venta" class="table table-bordered table-striped">
		  
<?php 
//echo $_POST['cmb_fil_mon_id'];
/* echo fecha_mysql($fecha1).'-'.fecha_mysql($fecha2).'-'.$_POST['cmb_fil_doc_id'].'-'.$_POST['hdd_fil_cli_id'].'-'.$_POST['cmb_fil_ven_est'].'-'.$_SESSION['usuario_id'].'-p'. */
/* $_SESSION['puntoventa_id'].'-'.$_POST['chk_fil_ven_may'].'-'.$_POST['cmb_fil_moz_id']; */
/* echo $_POST['txt_fil_docnum']; */
?>
		  
           <thead>
    <tr>
      <th class="" ></th>
      <th class="" >FECHA</th>
      <th >DOCUMENTO</th>
      <th>CLIENTE</th>
      <th class="">RUC/DNI</th>
      <th class="">VENDEDOR</th>
      <th class="">EMPRESA</th>
      <th align="right">TOTAL</th>
      
    </tr>
  </thead> 
            <tbody>
    <?php
    if($num_rows>0){
    while($dt1 = mysqli_fetch_array($dts1))
    {
       $ven_est = $dt1['tb_venta_est']; 
	 
      $total_valven+=$dt1['tb_venta_valven'];
      $total_igv+=$dt1['tb_venta_igv'];
      $total_ventas +=$dt1['tb_venta_tot'];
	  $reg = mostrarFechaHora($dt1['tb_venta_reg']);
 
      $total_pagar += $dt1['tb_venta_tot'];
	 if($dt1['tb_documento_abr']=='B'){
		 
		if($ven_est==0){
		$col="bg-red";
		$title = ' title="Boleta anulada ::: NOTA DE CREDITO EMITIDA"';
	}else{
		$col="";
		$title ="";
	}
		 
	 }else if($dt1['tb_documento_abr']=='F'){
		 if($ven_est==0){
		$col="bg-red";
		$title = ' title="Factura anulada ::: NOTA DE CREDITO EMITIDA"';
	}else{
		$col="";
		$title ="";
	}
	 }else if($dt1['tb_documento_abr']=='T'){
		 if($ven_est==0){
		$col="bg-red";
		$title = ' title="Ticket anulado ::: DOCUMENTO INTERNO "';
	}else{
		$col="";
		$title ="";
	}
	 }
	
	
    ?>
	
	
	
    <tr class="<?php echo $col; ?>" <?php echo $title;  ?> style="cursor:pointer;" >
     <td class="" nowrap="nowrap"> 
		<span class="btn btn-primary" onclick="ver_detalles(<?php echo $dt1['tb_venta_id']?>);" ><i class="fas fa-list"></i></span>
		</td>
	  <td class="" title="FECHA DE REGISTRO : <?php echo "$reg";  ?> " nowrap="nowrap"><?php echo mostrarFecha($dt1['tb_venta_fec'])?></td>
      <td nowrap="nowrap"><?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_venta_numdoc']?></td>
      <td><?php echo $dt1['tb_cliente_nom'];?></td>
      <td class="" ><?php echo $dt1['tb_cliente_doc'];?></td>
      <td class="" align="right"><?php echo $dt1['tb_usuario_nom'].' '.$dt1['tb_usuario_ape']?></td>
      <td class="" align="right"><?php echo $dt1['tb_empresa_nomcom']?></td>
      <td align="right"><?php echo formato_money($dt1['tb_venta_tot'])?></td>
	</tr>
    <?php
  }
  mysqli_free_result($dts1);
  }
  ?> 
			
</tbody> 
<tr class="even">
			<td colspan="">TOTAL</td>
			<td class="" colspan=""></td>
			<td colspan=""></td>
			<td colspan=""></td>
			<td colspan=""></td>
			<td colspan=""></td>
			<td colspan=""></td>
			<td align="right"><strong><?php echo formato_money($total_pagar)?></strong></td>
			</tr>
			
        </table>
		 
			</div>
		</div>
      </div>
    </div>
  </div>
</div>
</section>
  
   <script type="text/javascript">
  $(function() {  
  
  agregar_producto('restablecer');
  
    $("#tabla_compra").DataTable( {
      paging: true,
	  searching: false,
	  ordering:false,
	  "columnDefs": [
        { "orderable": true, "targets": [0] }
      ],
    });
  }); 
</script>  