<?php
include "../session.php"; 

if($role!="ADMIN"){
  header("Location:index.php");
  die();
}


include "conect.php";
session_start();

//error_reporting(0);

$session=$_SESSION['usuario'];

if ($session==null || $session == "") {
  header("Location:includes/session.php");

  die();
}

 

date_default_timezone_set('America/Guatemala');
$today="2022-06-01";
$lastday="2022-06-30";
$codigoTransaccion=$_POST['codigoEr'];
$usuario=$_POST['usuario'];
$rol=$_POST['rol'];




$consulta = mysqli_query($con, "SELECT * FROM ventas WHERE ID='$codigoTransaccion'");
$conteo   = mysqli_num_rows($consulta);

if ($conteo>0) {

?>


<table class="tableRegular"> 

  <tr>
    <th>ID</th>
    <th>C.Asociado</th>
     <th>N.Asociado</th>
    <th>Valor</th>
    <th>Fecha</th>
    <th>Hora</th>
    <th>Estado</th>
    <th></th>
    
    
    
  </tr>

<?php 




while ($row3 = mysqli_fetch_array($consulta)) {

                  $id = $row3['ID'];
                  $codigo_as = $row3['CODIGO_AS'];
                  $nombre_as = $row3['NOMBRE_AS'];
                  $total = $row3['TOTAL'];
                  $fechaIng = $row3['DATE_ING'];
                  $horaIng = $row3['HORA_INGRESO'];
                  $status = $row3['STATUS'];



                   ?>

                  <tr>
                      
                    <td><?php echo $id; ?></td>
                    <td><?php echo $codigo_as; ?></td>
                    <td><?php echo $nombre_as; ?></td>
                    <td> <?php echo $total; ?> </td>
                    <td><?php echo $fechaIng; ?></td>
                    <td><?php echo $horaIng; ?></td>
                    <td><?php echo $status; ?></td>
                    <td>

                       <form method="" id="consErroresForm" onsubmit="return false" class="flexI">
                        <input type="hidden" id="idTrans" value="<?php echo $id; ?>">
                        <input type="hidden" id="codigoAso" value="<?php echo $codigo_as; ?>">
                        <input type="hidden" id="usrAutoriza" value="<?php echo $usuario; ?>">
                        <input type="hidden" id="roleAutoriza" value="<?php echo $rol; ?>">

                      <button onclick="anularFun()">
                        <i class="fa-solid fa-trash-can"></i>
                      </button>
                    </form>


                    </td>
                   </tr>

                   <?php 
                    

                }




                ?>

 
 </table>

<?php 

  
}
else {
  echo "0";
}


   ?>


        

