<?php
require_once __DIR__ . '/../../../app/Models/Gst.php';
$model = new Gst();
$start = $_GET['start'] ?? date('Y-m-01');
$end = $_GET['end'] ?? date('Y-m-t');
$data = $model->getTransactions($start, $end, 'sales');
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="gst_report_'.$start.'_'.$end.'.csv"');
$out = fopen('php://output','w');
fputcsv($out, ['Ref No','Name','Date','Total Amt','GST Amt','Rate']);
foreach($data as $row) fputcsv($out, $row);
fclose($out);
