
<html>
  

<?php
require_once '../Clases/db.php';
require_once '../Clases/Compra.php';
require_once '../Clases/Producto.php';

?>

<div class="modal fade" id="eliminar<?php echo $compra['ID']; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
              <div class="modal-header bg-danger">
                <h5 class="modal-title" id="exampleModalLabel" style="color:white"><span class="fa fa-file"></span> ¿Quieres Eliminar Esta Compra?</h5>
               <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
              </div>
              <div class="modal-body">
              
              <?php $idcompra = $compra['ID'];
                
                    $mostrar = new compras ();
                    $detalles = $mostrar->getAllDetalles($idcompra); 
              ?>
         
                 <div class="containertabla">
                       <style type="text/css"> 
                                    .containertabla {
                                     display: grid;
                                     grid-template-columns: repeat(5, 0fr);
                                     grid-gap: 0px;
                                     background-color: #E2E1E1;
                                     text-align: center;
                                     }

                                     .item {
                                      border-bottom: 1px solid gray;
                                      border-top: 1px solid gray;
                                      padding: 0.6rem 4rem;
                                    
                                      
                                      }

                       </style>
  
                         <div class="item">Cantidad</div>
                         <div class="item">Producto</div> 
                         <div class="item">Precio Unt</div>
                         <div class="item">SubTotal</div>
  
                       <?php foreach ($detalles as $detalle) {  ?>
                      <br>
           
                         <div class="item"> <?php echo $detalle['Cantidad']; ?></div>
                         <div class="item"> <?php echo $detalle['Nombre_Producto']; ?></div>
                         <div class="item">$ <?php echo $detalle['Precio_Unt']; ?></div>
                         <div class="item">$ <?php echo $detalle['subtotal']; ?></div>

                      <?php } ?>
                        <form method="POST" action="./controladores/compras/delet_compra.php">
                        <input type="hidden" name="id" value="<?php echo $compra['ID']; ?>"> 
                        <?php foreach ($detalles as $detalle) {  ?>        
                             
                            <input type="hidden" name="cantidadp[]" value="<?php echo $detalle['Cantidad']; ?>"> 
                            <input type="hidden" name="nproducto[]" value="<?php echo $detalle['ID_Productos']; ?>"> 
                          <?php } ?>

              
                 </div> <br>
              
             <div class="col-lg-12"><h4 style="text-align:right">TOTAL $<?php echo $compra['Total_Compra']; ?>
                  <label  id="txttotal" name="txttotal"></label></h4>
             </div>

           <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
                <button type="submit" class="btn btn-danger botonBorrar">Eliminar</button>
          </div>
        </form>
    </div>
  </div>
</div>
</div>
  </html>