| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wcfs/tabs/Backups/ |
Upload File : |
<?php
include 'db.php';
$start = $_GET['start'] ?? date('Y-m-01');
$end = $_GET['end'] ?? date('Y-m-t');
// Save last export range
file_put_contents(__DIR__ . '/last_export_range.txt', "$start to $end");
$filename = "qbo_export_" . date('Ymd_His') . ".csv";
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename=' . $filename);
$output = fopen('php://output', 'w');
fputcsv($output, ['Date', 'Customer', 'Item', 'Quantity', 'Price', 'Taxable', 'Notes']);
$stmt = $conn->prepare("
SELECT t.date, c.first_name, c.last_name, t.item_name, t.quantity, t.price, t.taxable, t.notes
FROM transactions t
JOIN customers c ON t.customer_id = c.id
WHERE t.date BETWEEN ? AND ?
ORDER BY t.date ASC
");
$stmt->bind_param("ss", $start, $end);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
fputcsv($output, [
$row['date'],
$row['first_name'] . ' ' . $row['last_name'],
$row['item_name'],
$row['quantity'],
$row['price'],
$row['taxable'] ? 'Yes' : 'No',
$row['notes']
]);
}
fclose($output);
exit;