Panel/Panel/modules/website/pages/order.php
2026-06-17 14:53:00 -05:00

88 lines
4.6 KiB
PHP

<?php
declare(strict_types=1);
if ($service === null):
?>
<section class="page-heading">
<div class="container">
<h1>Order Unavailable</h1>
<p><?= website_escape((string)$error) ?></p>
</div>
</section>
<section class="section">
<div class="container">
<div class="card-actions">
<a class="button button-primary" href="<?= website_escape(website_url('serverlist.php')) ?>">Back to Game Servers</a>
<a class="button button-secondary" href="<?= website_escape(website_url('support.php')) ?>">Contact Support</a>
</div>
</div>
</section>
<?php
return;
endif;
$serviceName = trim((string)($service['cfg_game_name'] ?? $service['service_name'] ?? 'Game Server'));
$description = trim((string)($service['description'] ?? ''));
$price = (float)($service['price_monthly'] ?? 0);
$selectedSlots = max((int)$minSlots, (int)($_POST['slots'] ?? $minSlots));
?>
<section class="page-heading">
<div class="container">
<h1>Configure <?= website_escape($serviceName) ?></h1>
<p><?= website_escape($description !== '' ? $description : 'Configure this server package before adding it to your cart. Login is only required when you proceed to checkout.') ?></p>
</div>
</section>
<section class="section">
<div class="container">
<?php if ($error !== ''): ?>
<div class="alert warning"><?= website_escape($error) ?></div>
<?php endif; ?>
<div class="summary-grid">
<article class="summary-card">
<h3>Plan</h3>
<p><strong><?= website_escape($serviceName) ?></strong></p>
<p>Service ID: <?= website_escape((string)$service['service_id']) ?></p>
<p><?= $price > 0 ? 'Catalog price: $' . website_escape(number_format($price, 2)) . ' / month' : 'Catalog price: contact for pricing' ?></p>
</article>
<article class="summary-card">
<h3>Slots and location</h3>
<p>Minimum slots: <?= website_escape((string)$minSlots) ?></p>
<p><?= $maxSlots > 0 ? 'Maximum slots: ' . website_escape((string)$maxSlots) : 'Maximum slots depend on game and available location capacity.' ?></p>
<p>Location availability is confirmed before payment or provisioning.</p>
</article>
<article class="summary-card">
<h3>Checkout boundary</h3>
<p>You can add this server to your cart before logging in. Payment and final provisioning must complete server-side before the Panel creates a running game server.</p>
<p class="muted">The legacy <code>billing/order.php</code> route is no longer used.</p>
</article>
</div>
<form class="website-form summary-card" method="post" action="<?= website_escape(website_order_url((int)$service['service_id'])) ?>" style="margin-top: 18px;">
<h3>Server configuration</h3>
<label for="slots">Slots</label>
<input id="slots" name="slots" type="number" min="<?= website_escape((string)$minSlots) ?>"<?= $maxSlots > 0 ? ' max="' . website_escape((string)$maxSlots) . '"' : '' ?> value="<?= website_escape((string)$selectedSlots) ?>" required>
<label for="location_id">Location</label>
<select id="location_id" name="location_id" required>
<?php foreach ($locations as $locationId => $locationName): ?>
<option value="<?= website_escape((string)$locationId) ?>"<?= (string)($_POST['location_id'] ?? '') === (string)$locationId ? ' selected' : '' ?>><?= website_escape($locationName) ?></option>
<?php endforeach; ?>
</select>
<label for="duration_months">Billing duration</label>
<select id="duration_months" name="duration_months" required>
<?php foreach ([1, 3, 6, 12] as $duration): ?>
<option value="<?= website_escape((string)$duration) ?>"<?= (int)($_POST['duration_months'] ?? 1) === $duration ? ' selected' : '' ?>><?= website_escape((string)$duration) ?> month<?= $duration === 1 ? '' : 's' ?></option>
<?php endforeach; ?>
</select>
<p class="muted">The website stores this selection in your cart and revalidates service, slots, location, and price during checkout.</p>
<div class="card-actions">
<button class="button button-primary" type="submit">Add to Cart</button>
<a class="button button-secondary" href="<?= website_escape(website_url('serverlist.php')) ?>">Back to Catalog</a>
</div>
</form>
</div>
</section>