438 lines
16 KiB
PHP
438 lines
16 KiB
PHP
<?php
|
|
// checkout.php — Riepilogo piano + form registrazione/dati fiscali + pagamento (SIMULATO)
|
|
// Arriva da pricing.php?plan=ID&cycle=monthly|yearly
|
|
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
require_once(__DIR__ . '/userarea/class/db-functions.php');
|
|
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
|
|
|
function getFlash(): ?array
|
|
{
|
|
if (!isset($_SESSION['flash'])) return null;
|
|
$f = $_SESSION['flash'];
|
|
unset($_SESSION['flash']);
|
|
return $f;
|
|
}
|
|
function euro($v): string
|
|
{
|
|
return number_format((float)$v, 2, ',', '.');
|
|
}
|
|
|
|
$plan_id = (int)($_GET['plan'] ?? 0);
|
|
$cycle = ($_GET['cycle'] ?? 'monthly') === 'yearly' ? 'yearly' : 'monthly';
|
|
|
|
if ($plan_id <= 0) {
|
|
header('Location: pricing.php');
|
|
exit;
|
|
}
|
|
|
|
// Piano scelto
|
|
$st = $pdo->prepare("SELECT id, name, description, price FROM subscription_plans WHERE id = ? AND is_active = 1");
|
|
$st->execute([$plan_id]);
|
|
$plan = $st->fetch(PDO::FETCH_ASSOC);
|
|
if (!$plan) {
|
|
header('Location: pricing.php');
|
|
exit;
|
|
}
|
|
|
|
$monthly = (float)$plan['price'];
|
|
$total = $cycle === 'yearly' ? $monthly * 11 : $monthly; // annuale = 11 mesi
|
|
$cycleLabel = $cycle === 'yearly' ? 'Annuale (1 mese gratis)' : 'Mensile';
|
|
|
|
// Ripopola i campi in caso di errore (tornano da checkout_process)
|
|
$old = $_SESSION['checkout_old'] ?? [];
|
|
unset($_SESSION['checkout_old']);
|
|
function old(string $k, array $old): string
|
|
{
|
|
return htmlspecialchars($old[$k] ?? '', ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
$flash = getFlash();
|
|
?>
|
|
<!doctype html>
|
|
<html class="no-js" lang="it">
|
|
|
|
<head>
|
|
<?php include('tophead.php'); ?>
|
|
<?php include('cssinclude.php'); ?>
|
|
<style>
|
|
.co-wrap {
|
|
max-width: 1000px;
|
|
margin: 40px auto 80px;
|
|
}
|
|
|
|
.co-title {
|
|
font-size: 30px;
|
|
font-weight: 800;
|
|
color: #2b2540;
|
|
text-align: center;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.co-sub {
|
|
text-align: center;
|
|
color: #6b6480;
|
|
margin-bottom: 36px;
|
|
}
|
|
|
|
.co-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 340px;
|
|
gap: 30px;
|
|
align-items: start;
|
|
}
|
|
|
|
@media (max-width: 850px) {
|
|
.co-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
.co-card {
|
|
background: #fff;
|
|
border: 1.5px solid #f0e6ee;
|
|
border-radius: 18px;
|
|
padding: 28px;
|
|
}
|
|
|
|
.co-card h3 {
|
|
font-size: 17px;
|
|
font-weight: 800;
|
|
color: #2b2540;
|
|
margin: 0 0 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.co-card h3 .n {
|
|
width: 26px;
|
|
height: 26px;
|
|
border-radius: 50%;
|
|
background: linear-gradient(120deg, #e6007e, #ff6a3d);
|
|
color: #fff;
|
|
font-size: 13px;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.co-card .hint {
|
|
color: #9a93ac;
|
|
font-size: 13px;
|
|
margin: 0 0 18px 34px;
|
|
}
|
|
|
|
.co-field {
|
|
margin-bottom: 14px;
|
|
}
|
|
|
|
.co-field label {
|
|
display: block;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: #4a4458;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.co-field input {
|
|
width: 100%;
|
|
padding: 11px 13px;
|
|
border: 1.5px solid #eee3ec;
|
|
border-radius: 10px;
|
|
font-size: 14.5px;
|
|
}
|
|
|
|
.co-field input:focus {
|
|
outline: none;
|
|
border-color: #e6007e;
|
|
}
|
|
|
|
.co-row {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 12px;
|
|
}
|
|
|
|
.co-row-3 {
|
|
display: grid;
|
|
grid-template-columns: 2fr 1fr 1fr;
|
|
gap: 12px;
|
|
}
|
|
|
|
@media (max-width: 500px) {
|
|
|
|
.co-row,
|
|
.co-row-3 {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
.req {
|
|
color: #e6007e;
|
|
}
|
|
|
|
/* Riepilogo sticky */
|
|
.co-summary {
|
|
position: sticky;
|
|
top: 20px;
|
|
background: linear-gradient(160deg, #fff 60%, #fff5f9);
|
|
border: 1.5px solid #ffd9e8;
|
|
border-radius: 18px;
|
|
padding: 26px;
|
|
}
|
|
|
|
.co-summary h4 {
|
|
font-size: 15px;
|
|
text-transform: uppercase;
|
|
letter-spacing: .04em;
|
|
color: #9a93ac;
|
|
margin: 0 0 16px;
|
|
}
|
|
|
|
.co-plan-name {
|
|
font-size: 24px;
|
|
font-weight: 900;
|
|
color: #2b2540;
|
|
}
|
|
|
|
.co-plan-cycle {
|
|
color: #ff6a3d;
|
|
font-weight: 700;
|
|
font-size: 14px;
|
|
margin-bottom: 18px;
|
|
}
|
|
|
|
.co-line {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 8px 0;
|
|
font-size: 14px;
|
|
color: #4a4458;
|
|
border-bottom: 1px dashed #f0e6ee;
|
|
}
|
|
|
|
.co-total {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: baseline;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.co-total .lbl {
|
|
font-weight: 700;
|
|
color: #2b2540;
|
|
}
|
|
|
|
.co-total .amt {
|
|
font-size: 30px;
|
|
font-weight: 900;
|
|
color: #2b2540;
|
|
}
|
|
|
|
.co-pay-note {
|
|
background: #fff8e6;
|
|
border: 1px solid #ffe4a3;
|
|
border-radius: 10px;
|
|
padding: 10px 12px;
|
|
font-size: 12.5px;
|
|
color: #9a7a1a;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.co-btn {
|
|
display: block;
|
|
width: 100%;
|
|
text-align: center;
|
|
padding: 15px;
|
|
margin-top: 18px;
|
|
border: none;
|
|
border-radius: 12px;
|
|
font-weight: 800;
|
|
font-size: 16px;
|
|
color: #fff;
|
|
background: linear-gradient(120deg, #e6007e, #ff6a3d);
|
|
cursor: pointer;
|
|
box-shadow: 0 12px 26px rgba(230, 0, 126, .28);
|
|
}
|
|
|
|
.co-btn:hover {
|
|
opacity: .94;
|
|
}
|
|
|
|
.co-secure {
|
|
text-align: center;
|
|
color: #9a93ac;
|
|
font-size: 12px;
|
|
margin-top: 12px;
|
|
}
|
|
|
|
.co-alert {
|
|
background: #fdecef;
|
|
border: 1px solid #f5c2cd;
|
|
color: #b3143a;
|
|
padding: 12px 16px;
|
|
border-radius: 10px;
|
|
margin-bottom: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<?php include('preloader.php'); ?>
|
|
<?php include('offcanvas.php'); ?>
|
|
<header class="tp-header-height"><?php include('topbar.php'); ?></header>
|
|
|
|
<main>
|
|
<div class="container">
|
|
<div class="co-wrap">
|
|
<h1 class="co-title">Completa il tuo abbonamento</h1>
|
|
<p class="co-sub">Crea il tuo account e attiva il salone in un solo passaggio.</p>
|
|
|
|
<?php if ($flash): ?>
|
|
<div class="co-alert"><?= htmlspecialchars($flash['text']) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" action="checkout_process.php">
|
|
<input type="hidden" name="plan_id" value="<?= (int)$plan['id'] ?>">
|
|
<input type="hidden" name="cycle" value="<?= $cycle ?>">
|
|
|
|
<div class="co-grid">
|
|
<!-- Colonna form -->
|
|
<div>
|
|
<!-- 1. Account -->
|
|
<div class="co-card mb-3">
|
|
<h3><span class="n">1</span> Il tuo account</h3>
|
|
<p class="hint">Con questi dati accederai alla tua area titolare.</p>
|
|
<div class="co-row">
|
|
<div class="co-field">
|
|
<label>Nome <span class="req">*</span></label>
|
|
<input type="text" name="first_name" value="<?= old('first_name', $old) ?>" required>
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Cognome <span class="req">*</span></label>
|
|
<input type="text" name="last_name" value="<?= old('last_name', $old) ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Email <span class="req">*</span></label>
|
|
<input type="email" name="email" value="<?= old('email', $old) ?>" required>
|
|
</div>
|
|
<div class="co-row">
|
|
<div class="co-field">
|
|
<label>Password <span class="req">*</span></label>
|
|
<input type="password" name="password" minlength="8" required>
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Conferma password <span class="req">*</span></label>
|
|
<input type="password" name="password_confirm" minlength="8" required>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 2. Salone -->
|
|
<div class="co-card mb-3">
|
|
<h3><span class="n">2</span> Il tuo salone</h3>
|
|
<p class="hint">Il nome con cui i clienti ti troveranno.</p>
|
|
<div class="co-field">
|
|
<label>Nome del salone <span class="req">*</span></label>
|
|
<input type="text" name="shop_name" value="<?= old('shop_name', $old) ?>" placeholder="Es. Salone Bellezza Anna" required>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 3. Dati fiscali -->
|
|
<div class="co-card">
|
|
<h3><span class="n">3</span> Dati di fatturazione</h3>
|
|
<p class="hint">Necessari per emettere la fattura dell'abbonamento.</p>
|
|
<div class="co-field">
|
|
<label>Ragione sociale <span class="req">*</span></label>
|
|
<input type="text" name="business_name" value="<?= old('business_name', $old) ?>" required>
|
|
</div>
|
|
<div class="co-row">
|
|
<div class="co-field">
|
|
<label>Partita IVA <span class="req">*</span></label>
|
|
<input type="text" name="vat_number" value="<?= old('vat_number', $old) ?>" required>
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Codice Fiscale</label>
|
|
<input type="text" name="tax_code" value="<?= old('tax_code', $old) ?>">
|
|
</div>
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Indirizzo <span class="req">*</span></label>
|
|
<input type="text" name="address" value="<?= old('address', $old) ?>" required>
|
|
</div>
|
|
<div class="co-row-3">
|
|
<div class="co-field">
|
|
<label>Città <span class="req">*</span></label>
|
|
<input type="text" name="city" value="<?= old('city', $old) ?>" required>
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Prov.</label>
|
|
<input type="text" name="province" value="<?= old('province', $old) ?>" maxlength="2">
|
|
</div>
|
|
<div class="co-field">
|
|
<label>CAP <span class="req">*</span></label>
|
|
<input type="text" name="zip_code" value="<?= old('zip_code', $old) ?>" required maxlength="10">
|
|
</div>
|
|
</div>
|
|
<div class="co-row">
|
|
<div class="co-field">
|
|
<label>PEC <span class="req">*</span></label>
|
|
<input type="email" name="pec" value="<?= old('pec', $old) ?>" placeholder="oppure compila SDI">
|
|
</div>
|
|
<div class="co-field">
|
|
<label>Codice SDI <span class="req">*</span></label>
|
|
<input type="text" name="sdi_code" value="<?= old('sdi_code', $old) ?>" maxlength="7" placeholder="oppure compila PEC">
|
|
</div>
|
|
</div>
|
|
<p class="hint" style="margin-left:0;">Per la fattura elettronica è obbligatorio almeno uno tra PEC e Codice SDI.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Colonna riepilogo -->
|
|
<div>
|
|
<div class="co-summary">
|
|
<h4>Riepilogo ordine</h4>
|
|
<div class="co-plan-name"><?= htmlspecialchars($plan['name']) ?></div>
|
|
<div class="co-plan-cycle"><?= $cycleLabel ?></div>
|
|
|
|
<div class="co-line"><span>Prezzo mensile</span><span>€<?= euro($monthly) ?></span></div>
|
|
<?php if ($cycle === 'yearly'): ?>
|
|
<div class="co-line"><span>Durata</span><span>12 mesi</span></div>
|
|
<div class="co-line"><span>Sconto</span><span style="color:#ff6a3d;">−€<?= euro($monthly) ?></span></div>
|
|
<?php else: ?>
|
|
<div class="co-line"><span>Durata</span><span>1 mese</span></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="co-total">
|
|
<span class="lbl">Totale</span>
|
|
<span class="amt">€<?= euro($total) ?></span>
|
|
</div>
|
|
|
|
<div class="co-pay-note">
|
|
<i class="fa-solid fa-flask"></i> Pagamento <strong>simulato</strong>: nessun addebito reale. L'integrazione con Stripe arriverà a breve.
|
|
</div>
|
|
|
|
<button type="submit" class="co-btn">Attiva abbonamento</button>
|
|
<p class="co-secure"><i class="fa-solid fa-lock"></i> Dati protetti · disdici quando vuoi</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer><?php include('footer.php'); ?></footer>
|
|
<?php include('jsinclude.php'); ?>
|
|
</body>
|
|
|
|
</html>
|