<?php
require_once '../../config/config.php';
require_once '../../config/database.php';
require_once '../../core/helpers.php';
requireRole('admin');

$id  = (int)($_GET['id'] ?? 0);
$row = Database::fetchOne("SELECT * FROM pengembangan_diri WHERE id=?", [$id]);
if (!$row) { setFlash('error','Data tidak ditemukan.'); redirect(BASE_URL.'/modules/pengembangan_diri/index.php'); }

if (!empty($row['sertifikat_file'])) deleteFile('sertifikat', $row['sertifikat_file']);
Database::execute("DELETE FROM pengembangan_diri WHERE id=?", [$id]);
auditLog('DELETE','pengembangan_diri',$id,$row['judul_kegiatan']);
setFlash('success','Data '.$row['judul_kegiatan'].' berhasil dihapus.');
redirect(BASE_URL.'/modules/pengembangan_diri/index.php');
