<?php
session_start();
require_once(__DIR__ . '/../../backend/db/conexion.php');
require_once __DIR__ . '/../includes/valida_posiciones.php';

    // Validar conexion a DB 
if (!$conn) {
    die("Error: No se pudo conectar a la base de datos.");
} else {
    echo "Conexión exitosa.";
}



if (!isset($_SESSION['user_id'])) {
    header("Location: ../login.php");
    exit();
}

$user_id = $_SESSION['user_id'];

$sql = "SELECT nombre, apellido_paterno, apellido_materno, fecha_nacimiento, attuid, puesto, correo, telefono, no_empleado FROM reclutadores WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mi Perfil | Reclutador Pro</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/6.4.0/mdb.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="../assets/css/recruiter.css" rel="stylesheet">
</head>
<body>
  <!-- Sidebar -->
<?php include '../includes/sidebar.php'; ?>

<!-- Main Content -->
<div class="main-content">
  <?php include '../includes/topbar.php'; ?>

            <div class="container-fluid p-4">
                <div class="row mb-4">
                    <div class="col-12">
                        <h2 class="fw-bold text-dark mb-2">Mi Perfil</h2>
                    </div>
                </div>

                <div class="row">
                    <div class="col-lg-4 mb-4">
                        <div class="card h-100 text-center">
                            <div class="card-body">
                                <div class="avatar-profile mx-auto mb-3">
                                    <i class="fas fa-user-circle fa-5x text-primary"></i>
                                </div>
                                <h4 class="mb-1"><?php echo htmlspecialchars($user['nombre'] . ' ' . $user['apellido_paterno']); ?></h4>
                                <p class="text-muted mb-3"><?php echo htmlspecialchars($user['puesto']); ?></p>
                                <hr>
                               <!-- <button class="btn btn-sm btn-outline-primary">
                                    <i class="fas fa-key me-1"></i> Cambiar Contraseña
                                </button> -->
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-8">
                        <div class="card">
                            <div class="card-body">
                                <form>
                                    <h5 class="mb-4 text-primary"><i class="fas fa-id-card me-2"></i> Información Personal</h5>
                                    <div class="row g-3 mb-4">
                                    <div class="col-md-4">
                                        <label class="form-label">Nombre(s)</label>
                                        <input type="text" class="form-control" 
                                        value="<?php echo isset($user['nombre']) ? htmlspecialchars($user['nombre']) : ''; ?>" readonly>
                                    </div>
                                    <div class="col-md-4">
                                        <label class="form-label">Apellido Paterno</label>
                                        <input type="text" class="form-control" 
                                        value="<?php echo isset($user['apellido_paterno']) ? htmlspecialchars($user['apellido_paterno']) : ''; ?>" readonly>
                                    </div>
                                    <div class="col-md-4">
                                        <label class="form-label">Apellido Materno</label>
                                        <input type="text" class="form-control" 
                                        value="<?php echo isset($user['apellido_materno']) ? htmlspecialchars($user['apellido_materno']) : ''; ?>" readonly>
                                    </div>
                                    <div class="col-md-4">
                                        <label class="form-label">No. Empleado</label>
                                        <input type="text" class="form-control" 
                                        value="<?php echo isset($user['no_empleado']) ? htmlspecialchars($user['no_empleado']) : ''; ?>" readonly>
                                    </div>
                                    <div class="col-md-4">
                                        <label class="form-label">ATTUID</label>
                                        <input type="text" class="form-control" 
                                        value="<?php echo isset($user['attuid']) ? htmlspecialchars($user['attuid']) : ''; ?>" readonly>
                                    </div>
                                    </div>
                                    <h5 class="mb-4 text-primary"><i class="fas fa-phone-alt me-2"></i> Contacto</h5>
                                    <div class="row g-3">
                                        <div class="col-md-6">
                                            <label class="form-label">Correo Electrónico</label>
                                            <input type="email" class="form-control"
                                             value="<?php echo htmlspecialchars($user['correo']); ?>" readonly>
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label">Teléfono</label>
                                            <input type="tel" class="form-control"
                                             value="<?php echo htmlspecialchars($user['telefono']); ?>" readonly>
                                        </div>
                                    </div>
                                     <!--  <div class="d-flex justify-content-end gap-2 mt-4">
                                        <button type="submit" class="btn btn-primary">Actualizar Perfil</button>
                                    </div> -->
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/6.4.0/mdb.min.js"></script>
</body>
</html>
