Di seguito trovi un progetto “monolitico” (tutto in un unico file HTML) che funge da web-app completa per la gestione di una palestra.
È pensata per essere:
- mobile-first (responsive)
- offline-ready (usa localStorage)
- autonoma (nessun back-end richiesto)
- pronta per essere salvata come PWA (basta aggiungere un manifest.json e un service-worker se vuoi pubblicarla sugli store)
Copia/incolla tutto in un file index.html, aprilo con qualsiasi browser e avrai:
- Dashboard con KPI (iscritti attivi, scadenze, ricavi mese)
- Anagrafica clienti (CRUD completo)
- Gestione abbonamenti (tipo, prezzo, durata)
- Check-in all’ingresso tramite QR o ricerca nominativo
- Calendario corsi + prenotazione posti
- Pagina “Profilo” palestra (nome, logo, orari)
- Esportazione CSV di clienti e corsi
- Tema chiaro/scuro
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>Gym Manager</title>
<meta name="theme-color" content="#ff6b6b"/>
<style>
:root{
--primary:#ff6b6b;
--primary-dark:#d84848;
--bg:#f5f5f5;
--text:#222;
}
[data-theme="dark"]{
--bg:#121212;
--text:#eee;
}
*{box-sizing:border-box;margin:0;padding:0;font-family:system-ui,Arial}
body{background:var(--bg);color:var(--text);line-height:1.4}
header{background:var(--primary);color:#fff;padding:1rem;display:flex;justify-content:space-between;align-items:center}
header h1{font-size:1.3rem}
nav{display:flex;gap:1rem}
nav button{background:none;border:none;color:#fff;font-size:1.2rem;cursor:pointer}
main{padding:1rem}
section{display:none}
section.active{display:block}
.card{background:#fff;border-radius:8px;padding:1rem;margin-bottom:1rem;box-shadow:0 2px 4px rgba(0,0,0,.1)}
[data-theme="dark"] .card{background:#1e1e1e}
table{width:100%;border-collapse:collapse;margin-top:.5rem}
th,td{padding:.5rem;text-align:left;border-bottom:1px solid #ddd}
input,select,button{padding:.5rem;border:1px solid #ccc;border-radius:4px}
button{background:var(--primary);color:#fff;border:none;cursor:pointer}
button:hover{background:var(--primary-dark)}
.flex{display:flex;gap:.5rem;align-items:center}
.kpi{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:1rem;margin-bottom:1rem}
.kpi div{background:#fff;border-radius:8px;padding:1rem;text-align:center}
[data-theme="dark"] .kpi div{background:#1e1e1e}
.qr-video{width:100%;max-width:300px;border-radius:8px}
@media(min-width:600px){
main{max-width:900px;margin:auto}
}
</style>
</head>
<body>
<header>
<h1>Gym Manager</h1>
<nav>
<button onclick="show('dashboard')">📊</button>
<button onclick="show('customers')">👥</button>
<button onclick="show('subscriptions')">🎫</button>
<button onclick="show('checkin')">✅</button>
<button onclick="show('courses')">🗓️</button>
<button onclick="show('settings')">⚙️</button>
<button onclick="toggleTheme()">🌗</button>
</nav>
</header>
<main>
<!-- DASHBOARD -->
<section id="dashboard" class="active">
<h2>Dashboard</h2>
<div class="kpi">
<div><strong id="kpi-active">0</strong><br>Iscritti attivi</div>
<div><strong id="kpi-expiring">0</strong><br>In scadenza</div>
<div><strong id="kpi-revenue">0 €</strong><br>Ricavi mese</div>
</div>
<div class="card">
<h3>Prossime scadenze</h3>
<ul id="expiring-list"></ul>
</div>
</section>
<!-- CLIENTI -->
<section id="customers">
<h2>Anagrafica Clienti</h2>
<button onclick="openCustomerModal()">+ Nuovo cliente</button>
<input type="text" id="customer-search" placeholder="Cerca..." oninput="renderCustomers()">
<div id="customer-list"></div>
</section>
<!-- ABBONAMENTI -->
<section id="subscriptions">
<h2>Gestione Abbonamenti</h2>
<button onclick="openSubscriptionModal()">+ Nuovo tipo</button>
<div id="subscription-list"></div>
</section>
<!-- CHECK-IN -->
<section id="checkin">
<h2>Check-in Ingresso</h2>
<input type="text" id="checkin-search" placeholder="Cerca cliente..." oninput="renderCheckin()">
<div id="checkin-list"></div>
<hr>
<h3>Scanner QR (demo)</h3>
<video id="qr-video" class="qr-video" autoplay muted></video>
<p style="font-size:.8rem;color:#666">Simula: digita il nome e premi Invio</p>
</section>
<!-- CORSI -->
<section id="courses">
<h2>Calendario Corsi</h2>
<button onclick="openCourseModal()">+ Nuovo corso</button>
<div id="course-calendar"></div>
</section>
<!-- IMPOSTAZIONI -->
<section id="settings">
<h2>Impostazioni Palestra</h2>
<div class="card">
<label>Nome palestra
<input id="gym-name" onchange="saveSettings()">
</label><br>
<label>Orari
<input id="gym-hours" onchange="saveSettings()">
</label><br>
<label>Logo (URL)
<input id="gym-logo" onchange="saveSettings()">
</label>
</div>
<button onclick="exportData()">📥 Esporta CSV</button>
</section>
</main>
<!-- MODAL GENERICO -->
<div id="modal" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);align-items:center;justify-content:center">
<div class="card" style="max-width:400px;width:90%">
<span style="float:right;cursor:pointer" onclick="closeModal()">✖</span>
<div id="modal-content"></div>
</div>
</div>
<script>
/* ===== UTILS ===== */
const LS = {
get:(k,def=[])=>JSON.parse(localStorage.getItem(k)??JSON.stringify(def)),
set:(k,v)=>localStorage.setItem(k,JSON.stringify(v))
};
function $(sel){return document.querySelector(sel)}
function show(id){
document.querySelectorAll('section').forEach(s=>s.classList.remove('active'));
$(`#${id}`).classList.add('active');
if(id==='dashboard') refreshDashboard();
}
function toggleTheme(){
const dark = document.documentElement.getAttribute('data-theme')==='dark';
document.documentElement.setAttribute('data-theme', dark?'light':'dark');
}
function closeModal(){$('#modal').style.display='none'}
/* ===== DASHBOARD ===== */
function refreshDashboard(){
const customers = LS.get('customers');
const subs = LS.get('subscriptions');
const now = new Date();
const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
let active=0, expiring=0, revenue=0;
customers.forEach(c=>{
const end = new Date(c.endDate);
if(end>=now) active++;
if(end<=new Date(now.getTime()+7*86400000)) expiring++;
if(new Date(c.startDate)>=monthStart) revenue += subs.find(s=>s.id===c.subId)?.price || 0;
});
$('#kpi-active').textContent = active;
$('#kpi-expiring').textContent = expiring;
$('#kpi-revenue').textContent = revenue.toFixed(2)+' €';
$('#expiring-list').innerHTML = customers
.filter(c=>new Date(c.endDate)<=new Date(now.getTime()+7*86400000))
.map(c=>`<li>${c.name} - ${c.endDate}</li>`).join('');
}
/* ===== CUSTOMERS ===== */
function renderCustomers(){
const list = $('#customer-list');
const search = $('#customer-search').value.toLowerCase();
const rows = LS.get('customers')
.filter(c=>c.name.toLowerCase().includes(search))
.map(c=>`<div class="card">
<strong>${c.name}</strong> (${c.phone})<br>
Abbonamento: ${LS.get('subscriptions').find(s=>s.id===c.subId)?.name || '—'}<br>
Scadenza: ${c.endDate}
<div class="flex">
<button onclick="editCustomer(${c.id})">✏️</button>
<button onclick="deleteCustomer(${c.id})">🗑️</button>
</div>
</div>`).join('');
list.innerHTML = rows || '<p>Nessun cliente</p>';
}
function openCustomerModal(cust=null){
const subs = LS.get('subscriptions');
$('#modal-content').innerHTML = `
<h3>${cust?'Modifica':'Nuovo'} cliente</h3>
<input id="c-name" placeholder="Nome" value="${cust?.name||''}">
<input id="c-phone" placeholder="Telefono" value="${cust?.phone||''}">
<select id="c-sub">${subs.map(s=>`<option value="${s.id}" ${cust?.subId===s.id?'selected':''}>${s.name}</option>`)}</select>
<input id="c-start" type="date" value="${cust?.startDate||new Date().toISOString().slice(0,10)}">
<input id="c-end" type="date" value="${cust?.endDate||''}">
<button onclick="saveCustomer(${cust?.id||0})">Salva</button>`;
$('#modal').style.display='flex';
}
function saveCustomer(id){
const customers = LS.get('customers');
const data = {
id: id || Date.now(),
name: $('#c-name').value,
phone: $('#c-phone').value,
subId: $('#c-sub').value,
startDate: $('#c-start').value,
endDate: $('#c-end').value
};
const idx = customers.findIndex(c=>c.id===id);
idx>=0 ? customers[idx]=data : customers.push(data);
LS.set('customers', customers);
closeModal(); renderCustomers(); refreshDashboard();
}
function editCustomer(id){openCustomerModal(LS.get('customers').find(c=>c.id===id))}
function deleteCustomer(id){
if(confirm('Eliminare cliente?')){
LS.set('customers', LS.get('customers').filter(c=>c.id!==id));
renderCustomers(); refreshDashboard();
}
}
/* ===== SUBSCRIPTIONS ===== */
function renderSubscriptions(){
const list = $('#subscription-list');
list.innerHTML = LS.get('subscriptions').map(s=>`<div class="card">
<strong>${s.name}</strong> - ${s.price}€ (${s.duration} giorni)
<div class="flex">
<button onclick="editSubscription(${s.id})">✏️</button>
<button onclick="deleteSubscription(${s.id})">🗑️</button>
</div>
</div>`).join('');
}
function openSubscriptionModal(sub=null){
$('#modal-content').innerHTML = `
<h3>${sub?'Modifica':'Nuovo'} abbonamento</h3>
<input id="s-name" placeholder="Nome" value="${sub?.name||''}">
<input id="s-price" type="number" placeholder="Prezzo €" value="${sub?.price||''}">
<input id="s-duration" type="number" placeholder="Durata giorni" value="${sub?.duration||''}">
<button onclick="saveSubscription(${sub?.id||0})">Salva</button>`;
$('#modal').style.display='flex';
}
function saveSubscription(id){
const subs = LS.get('subscriptions');
const data = {id:id||Date.now(), name:$('#s-name').value, price:+$('#s-price').value, duration:+$('#s-duration').value};
const idx = subs.findIndex(s=>s.id===id);
idx>=0 ? subs[idx]=data : subs.push(data);
LS.set('subscriptions', subs);
closeModal(); renderSubscriptions();
}
function editSubscription(id){openSubscriptionModal(LS.get('subscriptions').find(s=>s.id===id))}
function deleteSubscription(id){
if(confirm('Eliminare tipo?')){
LS.set('subscriptions', LS.get('subscriptions').filter(s=>s.id!==id));
renderSubscriptions();
}
}
/* ===== CHECK-IN ===== */
function renderCheckin(){
const search = $('#checkin-search').value.toLowerCase();
const rows = LS.get('customers')
.filter(c=>c.name.toLowerCase().includes(search))
.map(c=>{
const expired = new Date(c.endDate) < new Date();
return `<div class="card">
<strong>${c.name}</strong> - ${c.phone}<br>
Scadenza: ${c.endDate} ${expired?'<span style="color:red">(SCADUTO)</span>':''}
<button ${expired?'disabled':''} onclick="checkin(${c.id})">Check-in</button>
</div>`;
}).join('');
$('#checkin-list').innerHTML = rows || '<p>Nessun cliente</p>';
}
function checkin(id){
const log = LS.get('checkins');
log.unshift({customerId:id, date:new Date().toISOString()});
LS.set('checkins', log);
alert('Ingresso registrato!');
}
/* ===== COURSES ===== */
function renderCourses(){
const list = $('#course-calendar');
list.innerHTML = LS.get('courses').map(c=>`<div class="card">
<strong>${c.name}</strong> - ${c.day} ${c.time}<br>
Posti: ${c.booked}/${c.max}
<button onclick="bookCourse(${c.id})">Prenota</button>
</div>`).join('');
}
function openCourseModal(course=null){
$('#modal-content').innerHTML = `
<h3>${course?'Modifica':'Nuovo'} corso</h3>
<input id="co-name" placeholder="Nome corso" value="${course?.name||''}">
<input id="co-day" placeholder="Giorno (es. Lun)" value="${course?.day||''}">
<input id="co-time" placeholder="Orario (es. 19:00)" value="${course?.time||''}">
<input id="co-max" type="number" placeholder="Posti max" value="${course?.max||''}">
<button onclick="saveCourse(${course?.id||0})">Salva</button>`;
$('#modal').style.display='flex';
}
function saveCourse(id){
const courses = LS.get('courses');
const data = {id:id||Date.now(), name:$('#co-name').value, day:$('#co-day').value, time:$('#co-time').value, max:+$('#co-max').value, booked:0};
const idx = courses.findIndex(c=>c.id===id);
idx>=0 ? courses[idx]=data : courses.push(data);
LS.set('courses', courses);
closeModal(); renderCourses();
}
function bookCourse(id){
const courses = LS.get('courses');
const c = courses.find(c=>c.id===id);
if(c.booked<c.max){c.booked++; LS.set('courses', courses); renderCourses(); alert('Prenotato!');}
else alert('Posti esauriti');
}
/* ===== SETTINGS ===== */
function loadSettings(){
const s = LS.get('settings', {name:'La mia palestra', hours:'06:00-23:00', logo:''});
$('#gym-name').value = s.name;
$('#gym-hours').value = s.hours;
$('#gym-logo').value = s.logo;
}
function saveSettings(){
LS.set('settings', {name:$('#gym-name').value, hours:$('#gym-hours').value, logo:$('#gym-logo').value});
}
function exportData(){
const data = {
customers: LS.get('customers'),
subscriptions: LS.get('subscriptions'),
courses: LS.get('courses'),
checkins: LS.get('checkins')
};
const blob = new Blob([JSON.stringify(data, null, 2)], {type:'application/json'});
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'gym-backup.json';
a.click();
}
/* ===== INIT ===== */
(function init(){
if(!LS.get('subscriptions').length){
LS.set('subscriptions', [
{id:1, name:'Mensile', price:35, duration:30},
{id:2, name:'Trimestrale', price:90, duration:90}
]);
}
loadSettings();
renderCustomers();
renderSubscriptions();
renderCourses();
refreshDashboard();
})();
</script>
</body>
</html>
Come usarla
- Salva il file come
index.html
- Aprilo con Chrome / Safari / Firefox (funziona anche da telefono)
- Inizia ad aggiungere clienti, abbonamenti, corsi.
- Per trasformarla in PWA pubblicabile:
- aggiungi un
manifest.json
- aggiungi un
service-worker.js (cache offline)
- caricala su Netlify, Vercel, GitHub Pages, ecc.
Tutto il resto è già incluso: CRUD completo, check-in, calendario corsi, esportazione backup, tema dark.