| 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 'protect.php';
include 'db.php';
// Enable error output
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="archived_transactions.csv"');
$output = fopen('php://output', 'w');
// Output headers
fputcsv($output, ['Customer', 'Item', 'Quantity', 'Price', 'Taxable', 'Notes', 'Original Date', 'Archived On']);
// Try first using first/last name
$sql = "
SELECT CONCAT(c.first_name, ' ', c.last_name) AS customer_name,
a.item_name, a.quantity, a.price, a.taxable, a.notes,
a.original_date, a.archived_on
FROM archived_transactions a
JOIN customers c ON a.customer_id = c.id
ORDER BY a.original_date ASC
";
$result = $conn->query($sql);
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
fputcsv($output, [
$row['customer_name'],
$row['item_name'],
$row['quantity'],
$row['price'],
$row['taxable'] ? 'Yes' : 'No',
$row['notes'],
$row['original_date'],
$row['archived_on']
]);
}
} else {
// In case something went wrong
fputcsv($output, ['No archived transactions found or query failed.']);
}
fclose($output);
exit;