| 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/ |
Upload File : |
<?php
include 'db.php';
// Accept date range via GET or CLI
if (php_sapi_name() == 'cli') {
parse_str(implode('&', array_slice($argv, 1)), $_GET);
}
$start = $_GET['start'] ?? date('Y-m-01');
$end = $_GET['end'] ?? date('Y-m-d');
// Log the date range for debugging
$log_file = __DIR__ . '/qbo_export_log.txt';
file_put_contents($log_file, "Exporting from $start to $end\n", FILE_APPEND);
// Prepare CSV output
if (php_sapi_name() !== 'cli') {
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="qbo_export_' . date('Ymd_His') . '.csv"');
$output = fopen('php://output', 'w');
} else {
$output = fopen('php://stdout', 'w');
}
fputcsv($output, ['Date', 'Invoice', 'Customer', 'Item', 'Quantity', 'Price', 'Taxable', 'Notes']);
// Query
$stmt = $conn->prepare("
SELECT t.date, c.id AS customer_id, 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();
$count = 0;
while ($row = $result->fetch_assoc()) {
$invoice_number = "WCFS-{$row['customer_id']}-" . date('Ymd', strtotime($row['date']));
fputcsv($output, [
$row['date'],
$invoice_number,
$row['first_name'] . ' ' . $row['last_name'],
$row['item_name'],
$row['quantity'],
$row['price'],
$row['taxable'] ? 'Yes' : 'No',
$row['notes']
]);
$count++;
}
fclose($output);
// Log record count
file_put_contents($log_file, "Exported $count records for $start to $end\n", FILE_APPEND);
exit;
?>
---
### ? **Next Step:**
1. Upload this updated `export_qbo.php`.
2. Run your export script manually.
3. Then check the **`qbo_export_log.txt`** file � it should tell you: