<?php
require_once '../Clases/db.php';
require_once '../Clases/Cliente.php';
$mostrar = new clientes ();
$clientes = $mostrar->getAllCliente();


?>

<!DOCTYPE html>
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
          
          
            <!--##::Link del DataTables::##-->
            <link href="../DataTables/datatables.min.css" rel="stylesheet">
      </head>

<div class="modal fade" id="register1" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"
data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalLabel">Agregar Cliente</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
      
           <table id="myTable1" class="table table-dark table-striped w-100 ">
                <thead>
                        <tr>
                        <td>ID</td>
                        <td>Nombre Cliente</td>
                        <td>Cedula Cliente</td> 
                        <td></td>                        
                        </tr>
                </thead>
                      <tbody>
                           <?php foreach ($clientes as $cliente) { ?>
                                 <tr>
                                     <td><?php echo $cliente['ID']; ?></td>
                                     <td><?php echo $cliente['Nombre_cliente']; ?></td>
                                     <td><?php echo $cliente['Cedula_cliente']; ?></td>
                                
                                    
                                        <form action='./controladores/ventas/agregarc.php' method='post'>
                          <input type='hidden' name='IdC' value="<?php echo $cliente['ID']; ?>">
                            <input type='hidden' name='NombreC' value="<?php echo $cliente['Nombre_cliente']; ?>">
                            <input type='hidden' name='CedulaC' value="<?php echo $cliente['Cedula_cliente']; ?>">
                            
                    <td><input type='submit' class="btn btn-primary" name='btnAnadir' value='Añadir'>
                     </form></td>
                                  </tr>
                                     
                            <?php } ?>
                    </tbody>
          </table>


          <div class="modal-footer">
               <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
                
          </div>
    </div>
  </div>
</div>

</form>


    <script src="../ArchivosJS/jquery-3.6.0.min.js"></script> 
   
    <script src="../DataTables/datatables.min.js"></script>

    <script type="text/javascript">
    $(document).ready( function () {
    $('#myTable1').DataTable({
        language: {
            processing:     "Tratamiento en curso...",
            search:         "Buscar:" ,
            lengthMenu:    "Filtro de _MENU_ clientes",
            info:           "Mostrando del cliente _START_ al _END_ de un total de _TOTAL_ clientes",
            infoEmpty:      "No existen registros",
            infoFiltered:   "(filtrado de _MAX_ clientes en total)",
            infoPostFix:    "",
            loadingRecords: "Cargando elementos...",
            zeroRecords:    "No se encontraron los datos de tu busquda..",
            emptyTable:     "No hay ningun registro en la tabla",
            paginate: {
                first:      "Primero",
                previous:   "Anterior",
                next:       "Siguiente",
                last:       "Ultimo"
            },
            aria: {
                sortAscending:  ": Active para odernar en modo ascendente",
                sortDescending: ": Active para ordenar en modo descendente  ",
            }
         }
       } );
      } );
     </script>

 
</html>