getConnection(); if (!isset($iduserlogin)) { header("Location: login.php"); exit; } if ((int)$kindofrole !== ROLE_ADMIN) { header("Location: index.php"); exit; } function e(?string $v): string { return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8'); } function getFlash(): ?array { if (!isset($_SESSION['flash'])) return null; $f = $_SESSION['flash']; unset($_SESSION['flash']); return $f; } // Etichette + badge per stato abbonamento function subMeta(?string $status): array { switch ($status) { case 'active': return ['badge' => 'bg-success', 'label' => 'Attivo']; case 'trialing': return ['badge' => 'bg-info text-dark', 'label' => 'In prova']; case 'expired': return ['badge' => 'bg-warning text-dark', 'label' => 'Scaduto']; case 'blocked': return ['badge' => 'bg-danger', 'label' => 'Bloccato']; case 'pending': return ['badge' => 'bg-secondary', 'label' => 'In attesa']; default: return ['badge' => 'bg-light text-dark', 'label' => 'Nessuno']; } } // --- Filtri --- $q_search = trim($_GET['q'] ?? ''); $q_status = trim($_GET['status'] ?? ''); $where = ["1=1"]; $params = []; if ($q_search !== '') { $where[] = "(sh.name LIKE ? OR sh.city LIKE ?)"; $like = '%' . $q_search . '%'; array_push($params, $like, $like); } if ($q_status !== '') { if ($q_status === 'none') { $where[] = "sub.id IS NULL"; } else { $where[] = "sub.status = ?"; $params[] = $q_status; } } $whereSql = implode(' AND ', $where); // Tutti i saloni + eventuale abbonamento (LEFT JOIN: mostra anche chi non ne ha) $sql = " SELECT sh.id AS shop_id, sh.name AS shop_name, sh.city, sh.active AS shop_active, sub.id AS sub_id, sub.plan_id, sub.status, sub.started_at, sub.expires_at, sub.block_reason, p.name AS plan_name, CONCAT(u.first_name, ' ', u.last_name) AS owner_name FROM shops sh LEFT JOIN shop_subscriptions sub ON sub.shop_id = sh.id LEFT JOIN subscription_plans p ON sub.plan_id = p.id LEFT JOIN auth_users u ON sh.owner_id = u.id WHERE $whereSql ORDER BY sh.name ASC "; $stmt = $pdo->prepare($sql); $stmt->execute($params); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // Piani per le select $plans = $pdo->query("SELECT id, name, price, billing_period FROM subscription_plans WHERE is_active = 1 ORDER BY price ASC")->fetchAll(PDO::FETCH_ASSOC); $flash = getFlash(); $ret = http_build_query(array_filter(['q' => $q_search, 'status' => $q_status])); $today = date('Y-m-d'); ?> Abbonamenti Saloni
Abbonamenti Saloni
saloni
(int)$r['shop_id'], 'shop_name' => $r['shop_name'], 'plan_id' => $r['plan_id'] ? (int)$r['plan_id'] : 0, 'status' => $r['status'] ?: 'active', 'started_at' => $r['started_at'] ?: '', 'expires_at' => $r['expires_at'] ?: '', 'has_sub' => $r['sub_id'] ? 1 : 0, 'block_reason' => $r['block_reason'] ?: '', ], JSON_UNESCAPED_UNICODE)); ?>
Salone Piano Stato Scadenza Salone attivo? Azioni
Nessun salone trovato.
·
—' ?> — Sì' : 'No' ?>

I saloni scaduti vengono spenti automaticamente dallo script giornaliero. Qui puoi intervenire manualmente in qualsiasi momento.