| 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';
$tax_rate = 0.082;
$start_date = $_GET['start'] ?? date('Y-m-01');
$end_date = $_GET['end'] ?? date('Y-m-t');
$stmt = $conn->prepare("
SELECT DATE(date) as day, SUM(quantity * price) AS subtotal,
SUM(CASE WHEN taxable = 1 THEN quantity * price * ? ELSE 0 END) AS tax
FROM transactions
WHERE date BETWEEN ? AND ?
GROUP BY day
ORDER BY day DESC
");
$stmt->bind_param('dss', $tax_rate, $start_date, $end_date);
$stmt->execute();
$result = $stmt->get_result();
$totals = [];
while ($row = $result->fetch_assoc()) {
$total_with_tax = $row['subtotal'] + $row['tax'];
$totals[] = [
'day' => $row['day'],
'subtotal' => $row['subtotal'],
'tax' => $row['tax'],
'total' => $total_with_tax
];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Daily Totals Report</title>
<style>
body { font-family: 'Segoe UI', sans-serif; padding: 30px; background: #f9f9f9; color: #333; }
.container { background: #fff; padding: 20px; max-width: 800px; margin: auto; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: right; }
th { background: #f0f0f0; text-align: left; }
.form-group { margin-bottom: 20px; }
.btn { padding: 8px 16px; background: #4CAF50; color: #fff; text-decoration: none; border: none; cursor: pointer; }
.btn:hover { background: #45a049; }
h2 { margin-bottom: 20px; }
a.totals-link { text-decoration: none; color: #333; display: block; }
a.totals-link:hover { text-decoration: underline; }
</style>
</head>
<body>
<div class="container">
<h2>Daily Totals Report</h2>
<form method="get">
<div class="form-group">
<label>Start Date: <input type="date" name="start" value="<?= htmlspecialchars($start_date) ?>"></label>
<label>End Date: <input type="date" name="end" value="<?= htmlspecialchars($end_date) ?>"></label>
<button class="btn" type="submit">Filter</button>
</div>
</form>
<table>
<tr>
<th>Date</th>
<th>Subtotal</th>
<th>Tax</th>
<th>Total with Tax</th>
</tr>
<?php foreach ($totals as $day): ?>
<tr>
<td>
<a class="totals-link" href="daily_details.php?date=<?= urlencode($day['day']) ?>">
<?= htmlspecialchars($day['day']) ?>
</a>
</td>
<td>$<?= number_format($day['subtotal'], 2) ?></td>
<td>$<?= number_format($day['tax'], 2) ?></td>
<td><strong>$<?= number_format($day['total'], 2) ?></strong></td>
</tr>
<?php endforeach; ?>
</table>
<br>
<a href="export_daily_totals_pdf.php?start=<?= urlencode($start_date) ?>&end=<?= urlencode($end_date) ?>" class="btn">Download PDF</a>
<br><br>
<a href="index.php">← Back to Dashboard</a>
</div>
</body>
</html>