| 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';
require_once __DIR__ . '/brand_header.php';
require_once __DIR__ . '/donation_helpers.php';
require_once __DIR__ . '/gift_card_helpers.php';
$message = '';
$error = '';
$donations = array();
function hDonationArchive($value)
{
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = isset($_POST['action']) ? trim((string) $_POST['action']) : '';
try {
if ($action === 'restore_donation') {
restoreDonationAndLinkedGiftCard($conn, isset($_POST['donation_id']) ? (int) $_POST['donation_id'] : 0);
$message = 'Donation restored.';
} elseif ($action === 'delete_donation_permanently') {
deleteDonationAndLinkedGiftCard($conn, isset($_POST['donation_id']) ? (int) $_POST['donation_id'] : 0);
$message = 'Donation permanently deleted.';
}
} catch (Exception $e) {
$error = $e->getMessage();
}
}
try {
$donations = fetchArchivedDonations($conn);
} catch (Exception $e) {
$error = $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Donation Archive</title>
<style>
body { font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif; margin:0; padding:30px; background:#f8fafc; color:#1f2937; }
.container { max-width:1100px; margin:0 auto; background:#fff; padding:28px; border-radius:16px; box-shadow:0 12px 32px rgba(15,23,42,0.08); }
.header-row { display:flex; justify-content:space-between; align-items:flex-end; gap:16px; flex-wrap:wrap; margin-bottom:18px; }
.btn { display:inline-block; padding:10px 14px; background:#1d4ed8; color:#fff; text-decoration:none; border:none; border-radius:10px; font-weight:700; cursor:pointer; }
.btn-secondary { background:#64748b; }
.btn-danger { background:#b91c1c; }
.msg { margin-bottom:16px; padding:12px 14px; border-radius:10px; }
.msg.ok { background:#ecfdf5; border:1px solid #86efac; color:#166534; }
.msg.err { background:#fef2f2; border:1px solid #fca5a5; color:#991b1b; }
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:10px 8px; border-bottom:1px solid #e5e7eb; vertical-align:top; }
th { background:#eff6ff; white-space:nowrap; }
.muted { color:#64748b; font-size:0.92rem; }
</style>
<?php echo appBrandStyles(); ?>
</head>
<body>
<div class="container">
<?php renderAppBrandHeader(); ?>
<div class="header-row">
<div>
<h1 style="margin:0;">Donation Archive</h1>
<div class="muted" style="margin-top:4px;">Removed donations land here first. Restore them, or delete them permanently from this page.</div>
</div>
<a class="btn btn-secondary" href="donations.php">← Back to Donations</a>
</div>
<?php if ($message !== ''): ?><div class="msg ok"><?php echo hDonationArchive($message); ?></div><?php endif; ?>
<?php if ($error !== ''): ?><div class="msg err"><?php echo hDonationArchive($error); ?></div><?php endif; ?>
<?php if (!$donations): ?>
<div class="muted">No archived donations right now.</div>
<?php else: ?>
<table>
<thead>
<tr>
<th>Date</th>
<th>Recipient</th>
<th>Description</th>
<th>Total</th>
<th>Archived</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($donations as $donation): ?>
<tr>
<td><?php echo hDonationArchive($donation['donation_date']); ?></td>
<td><?php echo hDonationArchive($donation['recipient_name']); ?></td>
<td>
<?php echo hDonationArchive($donation['item_description']); ?>
<?php if (donationLinkedGiftCardId($conn, (int) $donation['id']) > 0): ?>
<div class="muted" style="margin-top:4px;color:#166534;">Linked gift card donation</div>
<?php endif; ?>
</td>
<td>$<?php echo hDonationArchive(number_format((float) $donation['line_total'], 2)); ?></td>
<td><?php echo hDonationArchive($donation['archived_at']); ?></td>
<td>
<form method="post" style="margin:0 0 8px;">
<input type="hidden" name="action" value="restore_donation">
<input type="hidden" name="donation_id" value="<?php echo hDonationArchive($donation['id']); ?>">
<button class="btn btn-secondary" type="submit">Restore</button>
</form>
<form method="post" onsubmit="return confirm('Permanently delete this donation? If it is linked to a gift card, that card will be permanently deleted too.');" style="margin:0;">
<input type="hidden" name="action" value="delete_donation_permanently">
<input type="hidden" name="donation_id" value="<?php echo hDonationArchive($donation['id']); ?>">
<button class="btn btn-danger" type="submit">Delete Permanently</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
</body>
</html>