| 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'; ?>
<?php
include 'db.php';
$today = date('Y-m-d');
$archive_cutoff = $_POST['archive_date'] ?? '';
$confirm = $_POST['confirm'] ?? '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $confirm === 'yes' && !empty($archive_cutoff)) {
// Get transactions older than the cutoff date
$stmt = $conn->prepare("SELECT * FROM transactions WHERE date < ?");
$stmt->bind_param("s", $archive_cutoff);
$stmt->execute();
$transactions = $stmt->get_result();
// Prepare insert into archive
$insert = $conn->prepare("
INSERT INTO archived_transactions (customer_id, item_name, quantity, price, taxable, notes, original_date, archived_on)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
");
while ($t = $transactions->fetch_assoc()) {
$insert->bind_param(
"isidisss",
$t['customer_id'],
$t['item_name'],
$t['quantity'],
$t['price'],
$t['taxable'],
$t['notes'],
$t['date'],
$today
);
$insert->execute();
}
// Delete those same transactions
$del = $conn->prepare("DELETE FROM transactions WHERE date < ?");
$del->bind_param("s", $archive_cutoff);
$del->execute();
echo "<p><strong>All transactions before <code>$archive_cutoff</code> have been archived.</strong></p>";
echo "<p><a href='export_qbo_zip.php?month=" . date('Y-m') . "'>Download ZIP of QBO exports</a></p>";
echo "<p><a href='index.php'>← Back to Dashboard</a></p>";
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Archive Transactions</title>
<style>
body { font-family: 'Segoe UI', sans-serif; background: #f9f9f9; padding: 40px; }
.box { background: white; padding: 30px; max-width: 600px; margin: auto; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
h1 { margin-top: 0; }
.form-group { margin-bottom: 20px; }
.confirm-btn { padding: 10px 20px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; }
.confirm-btn:hover { background: #45a049; }
.cancel-btn { background: #ccc; color: #333; margin-left: 10px; }
.cancel-btn:hover { background: #bbb; }
</style>
</head>
<body>
<div class="box">
<h1>Archive Transactions</h1>
<p>Select a cutoff date. All transactions older than this date will be archived and removed from active tabs.</p>
<form method="post" onsubmit="return confirm('Are you sure you want to archive all transactions before the selected date? This cannot be undone.')">
<div class="form-group">
<label for="archive_date">Archive transactions before: </label>
<input type="date" name="archive_date" id="archive_date" required>
</div>
<input type="hidden" name="confirm" value="yes">
<input type="submit" class="confirm-btn" value="Archive Now">
<a href="index.php" class="confirm-btn cancel-btn">Cancel</a>
</form>
</div>
</body>
</html>