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/vendor-reg/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thelittlebigshow/vendor-reg/vendor_spot_roster.php
<?php
session_start();

if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: admin_login.php');
    exit();
}

require_once 'config.php';

const STREET_VENDOR_IDS = [62];

function payment_label($value) {
    $status = strtolower(trim((string)$value));
    if ($status === '1' || $status === 'paid') {
        return 'Paid';
    }
    if ($status === '2' || $status === 'pending') {
        return 'Pending';
    }
    if ($status === '0' || $status === 'unpaid') {
        return 'Unpaid';
    }
    return 'Unknown';
}

function requested_spots_for_vendor($vendor) {
    $id = (int)$vendor['id'];
    if (in_array($id, STREET_VENDOR_IDS, true)) {
        return 0;
    }
    return max(0, (int)$vendor['spots']);
}

function spot_sort_key($spot_id) {
    if (!preg_match('/^([A-J])([1-6])$/', $spot_id, $matches)) {
        return 'ZZ99';
    }
    return $matches[1] . str_pad($matches[2], 2, '0', STR_PAD_LEFT);
}

function sort_link($label, $value, $current_sort) {
    $class = $value === $current_sort ? 'sort-link active' : 'sort-link';
    return '<a class="' . $class . '" href="vendor_spot_roster.php?sort=' . urlencode($value) . '">' . htmlspecialchars($label) . '</a>';
}

$allowed_sorts = ['spot', 'vendor', 'category'];
$sort = $_GET['sort'] ?? 'spot';
if (!in_array($sort, $allowed_sorts, true)) {
    $sort = 'spot';
}

$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
    die('Connection failed: ' . $conn->connect_error);
}

$assignments = [];
$assigned_counts = [];
$assignment_sql = "
    SELECT
        a.spot_id,
        v.id,
        v.name,
        v.email,
        v.phone,
        v.category,
        v.description,
        v.spots,
        v.payment_status
    FROM vendor_spot_assignments a
    JOIN vendors v ON v.id = a.vendor_id
";
$result = $conn->query($assignment_sql);
while ($row = $result->fetch_assoc()) {
    $assigned_counts[(int)$row['id']] = ($assigned_counts[(int)$row['id']] ?? 0) + 1;
    $assignments[] = $row;
}

if ($sort === 'vendor') {
    usort($assignments, function ($a, $b) {
        return strcasecmp($a['name'], $b['name'])
            ?: strcmp(spot_sort_key($a['spot_id']), spot_sort_key($b['spot_id']));
    });
} elseif ($sort === 'category') {
    usort($assignments, function ($a, $b) {
        return strcasecmp($a['category'], $b['category'])
            ?: strcasecmp($a['name'], $b['name'])
            ?: strcmp(spot_sort_key($a['spot_id']), spot_sort_key($b['spot_id']));
    });
} else {
    usort($assignments, fn($a, $b) => strcmp(spot_sort_key($a['spot_id']), spot_sort_key($b['spot_id'])));
}

$unassigned = [];
$vendor_sql = "SELECT id, name, email, phone, category, description, spots, payment_status FROM vendors ORDER BY name";
$vendor_result = $conn->query($vendor_sql);
while ($vendor = $vendor_result->fetch_assoc()) {
    $requested = requested_spots_for_vendor($vendor);
    $assigned = $assigned_counts[(int)$vendor['id']] ?? 0;
    if ($requested > $assigned && payment_label($vendor['payment_status']) === 'Paid') {
        $vendor['requested_spots'] = $requested;
        $vendor['assigned_spots'] = $assigned;
        $unassigned[] = $vendor;
    }
}

$conn->close();
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Vendor Spot Roster</title>
    <style>
        body {
            margin: 0;
            padding: 24px;
            color: #1f2933;
            font-family: Arial, Helvetica, sans-serif;
            background: #f4f6f8;
        }
        .page {
            max-width: 1100px;
            margin: 0 auto;
            background: #fff;
            padding: 24px;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,.08);
        }
        .top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 18px;
        }
        h1, h2 {
            margin: 0;
        }
        h1 {
            font-size: 28px;
        }
        h2 {
            margin-top: 28px;
            font-size: 20px;
        }
        .actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .btn {
            display: inline-block;
            border: 0;
            border-radius: 6px;
            padding: 10px 12px;
            background: #1E90FF;
            color: #fff;
            text-decoration: none;
            cursor: pointer;
            font-size: 14px;
        }
        .btn.secondary {
            background: #4f8a42;
        }
        .summary {
            display: flex;
            gap: 14px;
            flex-wrap: wrap;
            color: #52616b;
            margin-bottom: 18px;
        }
        .sort-controls {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            margin-bottom: 18px;
            padding: 12px;
            border: 1px solid #d9e0e7;
            border-radius: 8px;
            background: #f8fafc;
        }
        .sort-controls strong {
            font-size: 14px;
        }
        .sort-link {
            display: inline-block;
            border: 1px solid #c9d4df;
            border-radius: 999px;
            padding: 7px 10px;
            background: #fff;
            color: #1f2933;
            text-decoration: none;
            font-size: 14px;
        }
        .sort-link.active {
            border-color: #1E90FF;
            background: #1E90FF;
            color: #fff;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 10px;
        }
        th, td {
            border: 1px solid #d9e0e7;
            padding: 9px 10px;
            text-align: left;
            vertical-align: top;
            font-size: 14px;
        }
        th {
            background: #1E90FF;
            color: #fff;
        }
        tr:nth-child(even) td {
            background: #f8fafc;
        }
        .spot {
            font-size: 18px;
            font-weight: 700;
            white-space: nowrap;
        }
        .muted {
            color: #667784;
        }
        .wares {
            max-width: 320px;
            line-height: 1.35;
        }
        .print-note {
            margin-top: 18px;
            color: #667784;
            font-size: 13px;
        }
        @media print {
            body {
                padding: 0;
                background: #fff;
            }
            .page {
                max-width: none;
                padding: 0;
                box-shadow: none;
            }
            .actions {
                display: none;
            }
            .sort-controls {
                border: 0;
                padding: 0;
                background: transparent;
            }
            .sort-link:not(.active) {
                display: none;
            }
            .sort-link.active {
                border: 0;
                padding: 0;
                background: transparent;
                color: #000;
                font-weight: 700;
            }
            th {
                background: #e8eef5;
                color: #000;
            }
            h2 {
                break-before: auto;
            }
        }
    </style>
</head>
<body>
    <main class="page">
        <div class="top">
            <div>
                <h1>Vendor Spot Roster</h1>
                <div class="muted">The Little Big Show ยท <?php echo date('F j, Y'); ?></div>
            </div>
            <div class="actions">
                <button class="btn secondary" type="button" onclick="window.print()">Print Roster</button>
                <a class="btn" href="vendor_spot_map.php">Back to Spot Map</a>
                <a class="btn" href="admin_dashboard.php">Admin Dashboard</a>
            </div>
        </div>

        <div class="summary">
            <span><strong><?php echo count($assignments); ?></strong> assigned park spots</span>
            <span><strong><?php echo count($unassigned); ?></strong> paid vendors still needing spots</span>
        </div>

        <div class="sort-controls">
            <strong>Print sorted by:</strong>
            <?php echo sort_link('Spot / Row', 'spot', $sort); ?>
            <?php echo sort_link('Vendor', 'vendor', $sort); ?>
            <?php echo sort_link('Category / Type', 'category', $sort); ?>
        </div>

        <h2>Assigned Spots</h2>
        <table>
            <thead>
                <tr>
                    <th>Spot</th>
                    <th>Vendor</th>
                    <th>Wares</th>
                    <th>Phone</th>
                    <th>Email</th>
                    <th>Category</th>
                    <th>Payment</th>
                </tr>
            </thead>
            <tbody>
                <?php if (count($assignments) > 0): ?>
                    <?php foreach ($assignments as $row): ?>
                        <tr>
                            <td class="spot"><?php echo htmlspecialchars($row['spot_id']); ?></td>
                            <td><?php echo htmlspecialchars($row['name']); ?></td>
                            <td class="wares"><?php echo nl2br(htmlspecialchars($row['description'])); ?></td>
                            <td><?php echo htmlspecialchars($row['phone']); ?></td>
                            <td><?php echo htmlspecialchars($row['email']); ?></td>
                            <td><?php echo htmlspecialchars($row['category']); ?></td>
                            <td><?php echo htmlspecialchars(payment_label($row['payment_status'])); ?></td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr><td colspan="7">No assigned spots yet.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>

        <h2>Paid Vendors Still Needing Spots</h2>
        <table>
            <thead>
                <tr>
                    <th>Vendor</th>
                    <th>Wares</th>
                    <th>Phone</th>
                    <th>Email</th>
                    <th>Category</th>
                    <th>Needs</th>
                    <th>Assigned</th>
                </tr>
            </thead>
            <tbody>
                <?php if (count($unassigned) > 0): ?>
                    <?php foreach ($unassigned as $vendor): ?>
                        <tr>
                            <td><?php echo htmlspecialchars($vendor['name']); ?></td>
                            <td class="wares"><?php echo nl2br(htmlspecialchars($vendor['description'])); ?></td>
                            <td><?php echo htmlspecialchars($vendor['phone']); ?></td>
                            <td><?php echo htmlspecialchars($vendor['email']); ?></td>
                            <td><?php echo htmlspecialchars($vendor['category']); ?></td>
                            <td><?php echo htmlspecialchars($vendor['requested_spots']); ?></td>
                            <td><?php echo htmlspecialchars($vendor['assigned_spots']); ?></td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr><td colspan="7">All paid vendors have their requested park spots assigned.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>

        <p class="print-note">Tip: print this on show morning after final admin adjustments.</p>
    </main>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit