<?php
require_once __DIR__ . '/../includes/auth.php';
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/functions.php';
$conn = offers_db();
if (!$conn) die('Database connection not found.');
admin_require_post_action('offer_delete', admin_url('offers/list.php'));
$type = $_POST['type'] ?? '';
$id = (int)($_POST['id'] ?? 0);
if ($id > 0 && offers_delete($conn, $type, $id)) {
    offers_flash_set('success', 'تم حذف العرض.');
} else {
    offers_flash_set('error', 'تعذر حذف العرض.');
}
if ($id > 0) { admin_log_activity('offer.delete', 'حذف عرض', 'تم حذف العرض.', 'offer', $id, ['type' => $type], true); }
redirect_to(admin_url('offers/list.php'));
?>