| 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';
$customer_id = isset($_POST['customer_id']) ? intval($_POST['customer_id']) : 0;
$confirm = $_POST['confirm'] ?? '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Step 1: First confirmation
if ($confirm === 'start') {
?>
<h2>?? Confirm: Close Out This Customer's Current Tab</h2>
<p>This will archive their current tab and reset it for a new month.</p>
<form method="post" action="clear_balance.php">
<input type="hidden" name="customer_id" value="<?= $customer_id ?>">
<input type="hidden" name="confirm" value="final">
<input type="submit" value="? Yes, Continue">
<a href="view_account.php?customer_id=<?= $customer_id ?>">Cancel</a>
</form>
<?php
exit;
}
// Step 2: Final confirmation
if ($confirm === 'final') {
?>
<h2>?? Final Warning</h2>
<p>This will <strong>move all active transactions to history</strong> and clear the tab.</p>
<form method="post" action="clear_balance.php">
<input type="hidden" name="customer_id" value="<?= $customer_id ?>">
<input type="hidden" name="confirm" value="yes">
<input type="submit" value="?? Yes, Archive and Reset Tab">
<a href="view_account.php?customer_id=<?= $customer_id ?>">Cancel</a>
</form>
<?php
exit;
}
// Step 3: Archive and delete
if ($confirm === 'yes' && $customer_id > 0) {
// Archive to new table
$conn->query("
INSERT INTO archived_transactions (customer_id, item_name, price, quantity, taxable, original_date, archived_on)
SELECT customer_id, item_name, price, quantity, taxable, date, CURDATE()
FROM transactions
WHERE customer_id = $customer_id
");
// Delete original
$stmt = $conn->prepare("DELETE FROM transactions WHERE customer_id = ?");
$stmt->bind_param("i", $customer_id);
$stmt->execute();
header("Location: view_account.php?customer_id=$customer_id");
exit;
}
}
echo "Invalid request.";