<?php
require_once __DIR__ . "/../../config/database.php";
require_once __DIR__ . "/../../classes/Sales.php";

$db = new Database();
$sales = new Sales($db->getConnection());

$branchId = $_POST['branchId'];
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];

if ($sales->generateSalesReport($branchId, $startDate, $endDate)) {
    echo json_encode(["message" => "Sales report generated successfully."]);
} else {
    echo json_encode(["message" => "Failed to generate sales report."]);
}
?>