<?php
require_once('../conf/conf.php');
header('Content-Type: application/json');

if(isset($_POST['id'])) {
    $id = validTeks($_POST['id']);
    $kd_dokter = validTeks($_SESSION['ses_dokter']); // Pastikan hanya pemilik yang bisa menghapus
    
    $sql = "DELETE FROM template_resume_pasien_ranap 
            WHERE id = '$id' AND kd_dokter = '$kd_dokter'";
    
    if(bukaquery($sql)) {
        echo json_encode([
            'success' => true,
            'message' => 'Template berhasil dihapus'
        ]);
    } else {
        echo json_encode([
            'success' => false,
            'message' => 'Gagal menghapus template'
        ]);
    }
} else {
    echo json_encode([
        'success' => false,
        'message' => 'ID template tidak valid'
    ]);
}
?> 