added cron and waiting

This commit is contained in:
2026-09-18 15:36:44 +02:00
parent c9a0cc6034
commit 9a423414a7
8 changed files with 406 additions and 514 deletions
+61 -4
View File
@@ -22,6 +22,7 @@ $message = $_GET['message'] ?? '';
$sql = "SELECT e.*,
COALESCE(b.booked, 0) AS booked,
COALESCE(b.bookings_count, 0) AS bookings_count,
COALESCE(w.waiting, 0) AS waiting,
u.first_name AS creator_first,
u.last_name AS creator_last
FROM events e
@@ -33,6 +34,12 @@ $sql = "SELECT e.*,
WHERE status IN ('confirmed','pending','offered')
GROUP BY event_id
) b ON b.event_id = e.id
LEFT JOIN (
SELECT event_id, SUM(seats) AS waiting
FROM event_bookings
WHERE status = 'waiting'
GROUP BY event_id
) w ON w.event_id = e.id
LEFT JOIN auth_users u ON u.id = e.user_id
ORDER BY e.starts_at ASC";
$events = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
@@ -63,11 +70,13 @@ function statusBadge(string $status): array
{
switch ($status) {
case 'published':
return ['Aperto', '#e7f7ee', '#1a7f52'];
return ['Aperto', '#e7f7ee', '#1a7f52'];
case 'scheduled':
return ['Programmato', '#eef2fb', '#3a5bb8'];
case 'cancelled':
return ['Annullato', '#fdecea', '#c0392b'];
return ['Annullato', '#fdecea', '#c0392b'];
default:
return ['Bozza', '#eef0f3', '#6b7280'];
return ['Bozza', '#eef0f3', '#6b7280'];
}
}
?>
@@ -209,6 +218,29 @@ function statusBadge(string $status): array
color: #c0392b;
}
.wait-pill {
display: inline-block;
background: #eef2fb;
color: #3a5bb8;
font-weight: 700;
font-size: 12px;
padding: 2px 9px;
border-radius: 20px;
margin-left: 6px;
}
.id-chip {
display: inline-block;
background: #eef0f3;
color: #4b5563;
font-weight: 700;
font-size: 11px;
padding: 1px 8px;
border-radius: 6px;
margin-left: 6px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.status-badge {
display: inline-block;
font-size: 12px;
@@ -375,7 +407,7 @@ function statusBadge(string $status): array
<span class="event-thumb placeholder" style="background: <?php echo e($ev['color']); ?>22;"><i class="bx bx-image" style="color: <?php echo e($ev['color']); ?>;"></i></span>
<?php endif; ?>
<span class="color-dot" style="background: <?php echo e($ev['color']); ?>;"></span>
<span><?php echo e($ev['title']); ?> <span class="event-id">(ID: <?php echo (int) $ev['id']; ?>)</span></span>
<span><?php echo e($ev['title']); ?> <span class="id-chip">ID <?php echo (int) $ev['id']; ?></span></span>
</div>
</td>
<td><?php echo e($organizer); ?></td>
@@ -383,11 +415,15 @@ function statusBadge(string $status): array
<span class="seats-pill <?php echo $isFull ? 'full' : ''; ?>">
<?php echo $booked; ?> / <?php echo $maxSeats; ?>
</span>
<?php if ((int) $ev['waiting'] > 0) : ?>
<span class="wait-pill" title="In lista d'attesa">+<?php echo (int) $ev['waiting']; ?> in lista</span>
<?php endif; ?>
</td>
<td>
<span class="status-badge" style="background: <?php echo $stBg; ?>; color: <?php echo $stColor; ?>;"><?php echo e($stLabel); ?></span>
</td>
<td class="text-end">
<button type="button" class="btn-act btn-shortcode" data-code='[yogasoul_eventi ids="<?php echo (int) $ev['id']; ?>"]'><i class="bx bx-code-alt"></i> Shortcode</button>
<a href="event_preview.php?id=<?php echo (int) $ev['id']; ?>" target="_blank" class="btn-act"><i class="bx bx-show"></i> Anteprima</a>
<a href="event_participants.php?id=<?php echo (int) $ev['id']; ?>" class="btn-act"><i class="bx bx-group"></i> Partecipanti</a>
<a href="event_form.php?id=<?php echo (int) $ev['id']; ?>" class="btn-act"><i class="bx bx-edit"></i> Modifica</a>
@@ -428,6 +464,27 @@ function statusBadge(string $status): array
<script>
$(document).ready(function() {
// Copia shortcode
$('.btn-shortcode').on('click', function() {
var code = $(this).data('code');
var btn = $(this);
var original = btn.html();
function done() {
btn.html('<i class="bx bx-check"></i> Copiato!');
setTimeout(function() {
btn.html(original);
}, 1500);
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(code).then(done).catch(function() {
window.prompt('Copia lo shortcode:', code);
});
} else {
window.prompt('Copia lo shortcode:', code);
}
});
$('.btn-annulla').on('click', function() {
var id = $(this).data('id');
var title = $(this).data('title');