File "delete.php"
Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/question_paper_orders/delete.php
File size: 1.12 KiB (1143 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
require_once '../../config/config.php';
require_once '../helper/audit_log.php';
header('Content-Type: application/json');
try {
$order_id = (int)($_POST['id'] ?? 0);
if ($order_id <= 0) { echo json_encode(['status'=>'error','message'=>'ID required']); exit; }
$stmt = $pdo->prepare('SELECT * FROM question_paper_orders WHERE order_id = ?');
$stmt->execute([$order_id]);
$before = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$before) { echo json_encode(['status'=>'error','message'=>'Not found']); exit; }
$pdo->prepare('DELETE FROM question_paper_orders WHERE order_id = ?')->execute([$order_id]);
write_audit_log($pdo, [
'module' => 'Question Papers',
'action' => 'delete',
'entity_table' => 'question_paper_orders',
'entity_id' => $order_id,
'before_data' => $before,
'message' => 'Question paper order deleted'
]);
echo json_encode(['status'=>'success','message'=>'Order deleted']);
} catch (Throwable $e) {
http_response_code(500);
echo json_encode(['status'=>'error','message'=>$e->getMessage()]);
}
?>