<!DOCTYPE html>
<html lang="PT-br">
    <?php include_once '../paginas/header.php';?>
<body>
    <?php include_once '../paginas/menu.php';?>
<br>
<br>
<br>
    <div class="services-details-area default-padding">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                   <!--   <div class="col-lg-8">
                        <h2>Lista de clientes</h2>
                        
                        <br>
                      <form>
							<input name="pesquisar" id="pesquisar" class="form-control" type="text" placeholder="Pesquisar"><br>
							<input class="btn btn-success pull-right"  type="submit" value="Pesquisar / Limpar pesquisa"><br>
                            <br>
                            <br>
						</form>
                    </div>-->


<!----modallll----->

<div class="blog-area single full-blog full-blog default-padding-forms">
<div class="container">
        <div class="form-title text-center">
            <h2>Cadastrar novo cliente</h2>
        </div>
        
        
        <form action="../efetiva/cadastrarcliente.php" method="POST">

           
            <input type="text" class="form-control" id="nome[]" name="nome[]" placeholder="Digite o nome do cliente...">
                
            <br>
                
            <input type="text" class="form-control" id="sobrenome[]" name="sobrenome[]" placeholder="Digite o sobrenome do cliente...">
                
            <br>
            <br>
            <button class="btn circle btn-theme border btn-sm" value="Cadastrar" type="submit" name="CadUsuario">Enviar</button>
        

        </form>
    
        <br>
        <br>


        <h2>Lista de Clientes</h2>
        
        </div>
</div>



<!----FIM MODAL--->


                    <?php

                    // Include config file
                    require_once "../banco/config.php";

                    $pescliente_id = $_GET['pesquisar'];
                    
                    // Attempt select query execution
                    $sql = "SELECT * FROM clientes";
                    if($result = mysqli_query($link, $sql)){
                        if(mysqli_num_rows($result) > 0){
                            echo '<table class="table table-bordered table-striped">';
                                echo "<thead>";
                                    echo "<tr>";
                                        echo "<th>Nome</th>";
                                        echo "<th>Sobrenome</th>";
                                        echo "<th>Data</th>";
                                    echo "</tr>";
                                echo "</thead>";
                                echo "<tbody>";
                                while($row = mysqli_fetch_array($result)){
                                    echo "<tr>";
                                        echo "<td>" . $row['nome'] . "</td>";
                                        echo "<td>" . $row['sobrenome'] . "</td>";
                                        echo "<td>" . $row['data'] . "</td>";
                                        echo "<td>";
                                            echo '<a href="clienteseditar.php?id='. $row['id'] .'" class="mr-3" title="Update Record" data-toggle="tooltip"><span class="fa fa-pencil"></span></a>';
                                            echo '<a href="../editar/deletecliente.php?id='. $row['id'] .'" title="Delete Record" data-toggle="tooltip"><span class="fa fa-trash"></span></a>';
                                        echo "</td>";
                                    echo "</tr>";
                                echo "</tbody>";                            
                            echo "</table>";
                            // Free result set
                            mysqli_free_result($result);
                        } else{
                            echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
                        }
                    } else{
                        echo "Oops! Something went wrong. Please try again later.";
                    }
 
                    // Close connection
                    mysqli_close($link);
                    ?>
                </div>
            </div>        
        </div>
    </div>
    <?php include_once '../paginas/foorter.php';?>
</body>
</html>

