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/wcfs/tabs/Backups/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/wcfs/tabs/Backups/view_account.php.nao-working but no styling
<?php
include 'db.php';

$tax_rate = 0.072;
$customer_id = isset($_GET['customer_id']) ? intval($_GET['customer_id']) : 0;
$archive_month = $_GET['archive_month'] ?? '';
$show_archives = isset($_GET['view_archives']) && $_GET['view_archives'] == '1';

$transactions = [];
$total = 0.0;
$customer_name = '';

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

// Get customer name
if ($customer_id > 0) {
    $stmt = $conn->prepare("SELECT first_name, last_name FROM customers WHERE id = ?");
    $stmt->bind_param("i", $customer_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($row = $result->fetch_assoc()) {
        $customer_name = $row['first_name'] . ' ' . $row['last_name'];
    } else {
        $customer_id = 0;
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>View Account - <?= htmlspecialchars($customer_name) ?></title>
    <style>
        body { font-family: 'Segoe UI', sans-serif; background-color: #f9f9f9; margin: 0; padding: 30px; color: #333; }
        .container { max-width: 1000px; margin: auto; background: #fff; padding: 30px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
        .top-bar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
        .top-bar select { padding: 8px; font-size: 16px; min-width: 250px; }
        .actions { display: flex; gap: 10px; }
        .actions form { display: inline-block; }
        .actions input[type="submit"] { padding: 8px 12px; background-color: #f44336; border: none; color: #fff; cursor: pointer; border-radius: 4px; }
        .actions input[type="submit"]:hover { background-color: #c62828; }
        .archive-list a { margin-right: 10px; text-decoration: none; }
        .unarchive-form { margin-top: 10px; }
        .unarchive-form input[type="submit"] { background-color: #2196F3; color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; }
        .unarchive-form input[type="submit"]:hover { background-color: #1976D2; }
    </style>
</head>
<body>
<div class="container">
    <h1>View Customer Account</h1>

    <div class="top-bar">
        <form method="get">
            <label>Select Customer: </label>
            <select name="customer_id" onchange="this.form.submit()">
                <option value="">-- Choose --</option>
                <?php while ($c = $customers->fetch_assoc()): ?>
                    <option value="<?= $c['id'] ?>" <?= $c['id'] == $customer_id ? 'selected' : '' ?>>
                        <?= htmlspecialchars($c['last_name'] . ', ' . $c['first_name']) ?>
                    </option>
                <?php endwhile; ?>
            </select>
        </form>

        <?php if ($customer_id): ?>
        <div class="actions">
            <form method="post" action="clear_balance.php" onsubmit="return confirm('Archive this customer�s current tab?')">
                <input type="hidden" name="customer_id" value="<?= $customer_id ?>">
                <input type="hidden" name="confirm" value="start">
                <input type="submit" value="Archive Tab">
            </form>

            <form method="post" action="delete_customer.php" onsubmit="return confirm('Are you sure you want to delete this customer?')">
                <input type="hidden" name="customer_id" value="<?= $customer_id ?>">
                <input type="hidden" name="confirm" value="start">
                <input type="submit" value="Delete Customer">
            </form>
        </div>
        <?php endif; ?>
    </div>

    <?php if ($customer_id): ?>
        <h2><?= htmlspecialchars($customer_name) ?></h2>
        <p><a href="view_account.php?customer_id=<?= $customer_id ?>&view_archives=1">View Archived Months</a></p>

        <?php
        // Load archive months
        $months = [];
        $stmt = $conn->prepare("SELECT DISTINCT DATE_FORMAT(archived_on, '%Y-%m') AS month FROM archived_transactions WHERE customer_id = ? ORDER BY month DESC");
        $stmt->bind_param("i", $customer_id);
        $stmt->execute();
        $result = $stmt->get_result();
        while ($row = $result->fetch_assoc()) {
            $months[] = $row['month'];
        }
        ?>

        <?php if ($months && ($archive_month || $show_archives)): ?>
        <div class="archive-list">
            <h4>Archived Months:</h4>
            <?php foreach ($months as $m): ?>
                <a href="view_account.php?customer_id=<?= $customer_id ?>&archive_month=<?= $m ?>">
                    <?= date('F Y', strtotime($m . '-01')) ?>
                </a>
            <?php endforeach; ?>

            <?php if ($archive_month): ?>
                <p><a href="view_account.php?customer_id=<?= $customer_id ?>">Return to Current Tab</a></p>
                <form method="post" action="unarchive_month.php" class="unarchive-form" onsubmit="return confirm('Unarchive this month and return items to current tab?')">
                    <input type="hidden" name="customer_id" value="<?= $customer_id ?>">
                    <input type="hidden" name="month" value="<?= $archive_month ?>">
                    <input type="submit" value="Unarchive This Month">
                </form>
            <?php endif; ?>
        </div>
        <?php endif; ?>
    <?php endif; ?>

    <p><a href="index.php">&larr; Back to Dashboard</a></p>

<?php if ($customer_id && !$archive_month): ?>

    <!-- Current Balance -->
    <?php
    $stmt = $conn->prepare("SELECT * FROM transactions WHERE customer_id = ?");
    $stmt->bind_param("i", $customer_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $total = 0;
    while ($row = $result->fetch_assoc()) {
        $line_total = $row['price'] * $row['quantity'];
        if ($row['taxable']) {
            $line_total *= (1 + $tax_rate);
        }
        $total += $line_total;
    }
    ?>
    <p><strong>Current Balance:</strong> $<?= number_format($total, 2) ?></p>

    <!-- Add Items -->
    <div class="add-items">
        <h3>Add More Items</h3>
        <form method="post" action="add_transaction.php">
            <input type="hidden" name="customer_id" value="<?= $customer_id ?>">
            <table id="items-table">
                <tr>
                    <th>Qty</th>
                    <th>Item</th>
                    <th>Price</th>
                    <th>Taxable</th>
                    <th>Notes</th>
                </tr>
                <?php for ($i = 0; $i < 3; $i++): ?>
                <tr>
                    <td><input type="number" name="quantity[]" value="1" min="1"></td>
                    <td><input type="text" name="item_name[]"></td>
                    <td><input type="number" step="0.01" name="price[]"></td>
                    <td><input type="checkbox" name="taxable[]" checked></td>
                    <td><input type="text" name="notes[]"></td>
                </tr>
                <?php endfor; ?>
            </table>
            <button type="button" onclick="addRow()">+ Add More Rows</button><br><br>
            <input class="submit-btn" type="submit" value="Add Items to Account">
        </form>
    </div>

    <!-- Live Transactions -->
    <?php
    $stmt = $conn->prepare("SELECT * FROM transactions WHERE customer_id = ? ORDER BY date DESC");
    $stmt->bind_param("i", $customer_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $transactions = [];
    $total = 0;
    while ($row = $result->fetch_assoc()) {
        $line_total = $row['price'] * $row['quantity'];
        if ($row['taxable']) {
            $line_total *= (1 + $tax_rate);
        }
        $total += $line_total;
        $transactions[] = $row;
    }
    ?>

    <?php if ($transactions): ?>
        <table>
            <tr>
                <th>Date</th>
                <th>Qty</th>
                <th>Item</th>
                <th>Price</th>
                <th>Taxable</th>
                <th>Total</th>
                <th>Notes</th>
            </tr>
            <?php foreach ($transactions as $t): ?>
            <?php
                $line_total = $t['price'] * $t['quantity'];
                if ($t['taxable']) {
                    $line_total *= (1 + $tax_rate);
                }
            ?>
            <tr>
                <td><?= $t['date'] ?></td>
                <td><?= $t['quantity'] ?></td>
                <td><?= htmlspecialchars($t['item_name']) ?></td>
                <td>$<?= number_format($t['price'], 2) ?></td>
                <td><?= $t['taxable'] ? 'Yes' : 'No' ?></td>
                <td>$<?= number_format($line_total, 2) ?></td>
                <td><?= htmlspecialchars($t['notes']) ?></td>
            </tr>
            <?php endforeach; ?>
            <tr class="total-row">
                <td colspan="5" align="right">Total:</td>
                <td colspan="2">$<?= number_format($total, 2) ?></td>
            </tr>
        </table>
    <?php else: ?>
        <p><em>No transactions yet for this customer.</em></p>
    <?php endif; ?>

<?php endif; ?>

</div>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit