<?php
include 'db.php';

if (!isset($_GET['type'])) {
    die("Invalid request");
}

$type = $_GET['type'];

switch ($type) {
    case 'sales':
        $conn->query("DELETE FROM sale_items");
        $conn->query("DELETE FROM sales");
        $conn->query("DELETE FROM shifts");
        $conn->query("DELETE FROM hold_items");
        $conn->query("DELETE FROM hold_orders");
        break;

    case 'inventory':
        $conn->query("DELETE FROM purchase_items");
        $conn->query("DELETE FROM purchases");
        $conn->query("DELETE FROM inventory_movements");
        break;

    case 'expenses':
        $conn->query("DELETE FROM expenses");
        $conn->query("DELETE FROM expense_accounts");
        break;

    default:
        die("Invalid type");
}

header("Location: clear_data_panel.php?cleared=$type");
exit;
?>
