| 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;
$archive_month = $_POST['archive_month'] ?? '';
$confirm = $_POST['confirm'] ?? '';
if (!$customer_id || !$archive_month) {
echo "Invalid request.";
exit;
}
// Step 1: Confirm
if ($confirm !== 'yes') {
?>
<h2>?? Confirm Unarchive</h2>
<p>Are you sure you want to move all transactions from <strong><?= htmlspecialchars(date('F Y', strtotime($archive_month . '-01'))) ?></strong> back into the current tab?</p>
<form method="post" action="unarchive_month.php">
<input type="hidden" name="customer_id" value="<?= $customer_id ?>">
<input type="hidden" name="archive_month" value="<?= htmlspecialchars($archive_month) ?>">
<input type="hidden" name="confirm" value="yes">
<input type="submit" value="? Yes, Unarchive">
<a href="view_account.php?customer_id=<?= $customer_id ?>&archive_month=<?= $archive_month ?>">Cancel</a>
</form>
<?php
exit;
}
// Step 2: Move from archive back to transactions
$stmt = $conn->prepare("
INSERT INTO transactions (customer_id, item_name, price, quantity, taxable, date)
SELECT customer_id, item_name, price, quantity, taxable, original_date
FROM archived_transactions
WHERE customer_id = ? AND DATE_FORMAT(archived_on, '%Y-%m') = ?
");
$stmt->bind_param("is", $customer_id, $archive_month);
$stmt->execute();
// Now delete from archive
$stmt = $conn->prepare("
DELETE FROM archived_transactions
WHERE customer_id = ? AND DATE_FORMAT(archived_on, '%Y-%m') = ?
");
$stmt->bind_param("is", $customer_id, $archive_month);
$stmt->execute();
header("Location: view_account.php?customer_id=" . $customer_id);
exit;