<?php
require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/../includes/helpers.php';

require_post();
$data = json_input();
require_fields($data, ['id']);

$pdo = getConnection();

try {
    $id = (int)$data['id'];
    $stmt = $pdo->prepare("DELETE FROM promocion_productos WHERE id = ?");
    $stmt->execute([$id]);

    json_success([], 'Producto eliminado de la promocion');
} catch (Exception $e) {
    json_error("Error: " . $e->getMessage());
}
