<?php
require_once __DIR__ . '/../includes/bootstrap.php'; require_login(); ensure_can_manage_master_data();
if (is_post()) {
  $stmt = db()->prepare("INSERT INTO recruitment_candidates (full_name, document_number, phone, email, notes, created_at) VALUES (?,?,?,?,?,?)");
  $stmt->execute([trim($_POST['full_name'] ?? ''), trim($_POST['document_number'] ?? ''), trim($_POST['phone'] ?? ''), trim($_POST['email'] ?? ''), trim($_POST['notes'] ?? ''), now()]);
  audit_log('insert','recruitment_candidates', (int)db()->lastInsertId(), 'Candidato creado');
  set_flash('success','Candidato creado correctamente.'); redirect('recruitment/index.php');
}
$item = []; include __DIR__ . '/candidate_form.php';
