<?php require_once("includes/topo.php");
$usuario_id = $_GET["id"];
$query = $pdo->query("SELECT * FROM candidatos WHERE id = $usuario_id");
$usuario_p_visu = $query->fetchAll(PDO::FETCH_ASSOC);
$total_reg = @count($usuario_p_visu);
?>


<div class="content-body">
    <div class="container-fluid">
        <div class="row">



            <div class="col-xl-3 col-lg-4">
                <div class="clearfix">
                    <div class="card card-bx profile-card author-profile m-b30">
                        <div class="card-body">
                            <div class="p-5">
                                <div class="author-profile">
                                    <div>
                                        <h4 class="title"><?php echo $usuario_p_visu[0]['nome'] ?></h4>
                                    </div>
                                    <div class="author-media">
                                        <img src="<?php echo $usuario_p_visu[0]['foto'] ?>" alt="">
                                    </div>
                                    <form method="post" action="processar_imagem_candidato.php?id=<?php echo $usuario_p_visu[0]['id'] ?>" enctype="multipart/form-data">

                                        <input class="form-control" name="imagem" type="file" id="formFile" Required>
                                        <hr>
                                        <input type="submit" class="btn btn-primary" value="Atualizar imagem">
                                    </form>

                                    <hr>

                                    <button type="button" id="executar-codigo-btn" onclick="executarCodigo()" class="btn btn-danger">Deletar conta <span class="btn-icon-end"><i class="fa fa-close"></i></span> </button>
                                    <?php
                                    $pegaid = "includes/add_candidato.php?candidato=2&iduser=" . $usuario_id . "";
                                    $peganome = $usuario_p_visu[0]['nome'];
                                    ?>



                                    <script>
                                        var pegou = "<?php echo $pegaid ?>";
                                        var pegounome = "<?php echo $peganome ?>";

                                        function executarCodigo() {

                                            Swal.fire({
                                                icon: 'warning',
                                                title: 'Realmente deseja apagar esta conta?',
                                                text: 'Este processo é irreversível!',
                                                showCancelButton: true,
                                                confirmButtonColor: '#3085d6',
                                                cancelButtonColor: '#d33',
                                                confirmButtonText: 'Sim apagar'
                                            }).then((result) => {
                                                if (result.value) {
                                                    window.location = pegou;
                                                }
                                            })
                                        }
                                    </script>

                                </div>
                            </div>

                        </div>

                    </div>
                </div>
            </div>
            <div class="col-xl-9 col-lg-8">
                <div class="card profile-card card-bx m-b30">
                    <div class="card-header">
                        <h6 class="title">Seus dados</h6>
                    </div>
                    <form action="includes/class_update_candidato.php?iduser=<?php echo $usuario_p_visu[0]['id'] ?>" method="post" class="profile-form">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-sm-6 m-b30">
                                    <label class="form-label">Nome</label>
                                    <input type="text" name="nome" class="form-control" value="<?php echo $usuario_p_visu[0]['nome'] ?>" style="color: rgb(191 191 191 / 68%)" readonly>
                                </div>
                                <div class="col-sm-6 m-b30">
                                    <label class="form-label">Email</label>
                                    <input type="text" name="email" class="form-control" value="<?php echo $usuario_p_visu[0]['email'] ?>" style="color: rgb(191 191 191 / 68%)" readonly>
                                </div>
                                <div class="col-sm-6 m-b30">
                                    <label class="form-label">Nova senha</label>
                                    <input type="password" name="new_password" class="form-control <?php echo (!empty($new_password_err)) ? 'is-invalid' : ''; ?>" value="">
                                    <span class="invalid-feedback"><?php echo $new_password_err; ?></span>
                                </div>
                                <div class="col-sm-6 m-b30">
                                    <label class="form-label">Confirmar senha</label>
                                    <input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>" value="">
                                    <span class="invalid-feedback"><?php echo $confirm_password_err; ?></span>
                                </div>



                            </div>
                        </div>
                        <div class="card-footer">
                            <button class="btn btn-primary">Atualizar</button>
                        </div>
                    </form>
                </div>
            </div>


        </div>
    </div>
</div>

<?php require_once("includes/rodape.php");  ?>
<?php if (!empty($_GET['status']) == "ok") { ?>
    <script>
        window.onload = function() {
            swal({
                title: 'Perfeito!',
                text: ("Imagem atualizada com sucesso!"),
                type: 'success',
                confirmButtonText: 'Fechar'
            })
        };
    </script>
<?php } ?>

<?php if (!empty($_GET['senhaok']) == "ok") { ?>
    <script>
        window.onload = function() {
            swal({
                title: 'Perfeito!',
                text: ("Senha atualizada com sucesso!"),
                type: 'success',
                confirmButtonText: 'Fechar'
            })
        };
    </script>
<?php } ?>