<?php
require_once __DIR__ . '/../includes/bootstrap.php'; require_login(); ensure_can_manage_master_data();
$id = (int)($_GET['id'] ?? $_POST['id'] ?? 0);
if (is_post()) {
  $stmt = db()->prepare("UPDATE recruitment_candidates SET full_name=?, document_number=?, phone=?, email=?, notes=? WHERE id=?");
  $stmt->execute([trim($_POST['full_name'] ?? ''), trim($_POST['document_number'] ?? ''), trim($_POST['phone'] ?? ''), trim($_POST['email'] ?? ''), trim($_POST['notes'] ?? ''), $id]);
  audit_log('update','recruitment_candidates',$id,'Candidato editado');
  set_flash('success','Candidato actualizado.'); redirect('recruitment/index.php');
}
$stmt = db()->prepare("SELECT * FROM recruitment_candidates WHERE id=?"); $stmt->execute([$id]); $item = $stmt->fetch(); include __DIR__ . '/candidate_form.php';
