222 lines
9.0 KiB
PHP
222 lines
9.0 KiB
PHP
<?php
|
|
require_once('include/headscript.php');
|
|
require_once('include/event_mailer.php');
|
|
|
|
/**
|
|
* Promemoria manuale: apre un editor col testo prefissato (modificabile) e il
|
|
* punto di ritrovo come link mappa (prefill dal luogo evento). Invio da
|
|
* event_reminder_send.php a tutti gli iscritti confermati.
|
|
*/
|
|
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
|
|
|
function e($value): string
|
|
{
|
|
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
$eventId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
|
if ($eventId <= 0) {
|
|
header('Location: events.php');
|
|
exit();
|
|
}
|
|
|
|
$stmt = $pdo->prepare("SELECT * FROM events WHERE id = ?");
|
|
$stmt->execute([$eventId]);
|
|
$event = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
if (!$event) {
|
|
header('Location: events.php?message=error');
|
|
exit();
|
|
}
|
|
|
|
$cnt = $pdo->prepare("SELECT COUNT(*) FROM event_bookings WHERE event_id = ? AND status = 'confirmed'");
|
|
$cnt->execute([$eventId]);
|
|
$recipients = (int) $cnt->fetchColumn();
|
|
|
|
$defaultMsg = "Ti ricordiamo il tuo prossimo appuntamento. Ti aspettiamo, a presto!";
|
|
$meetingLink = yse_maps_link($event); // prefill: link mappa derivato dall'indirizzo/coordinate
|
|
$message = $_GET['message'] ?? '';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="it">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>YogiBook - Promemoria</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
|
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
|
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
|
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
|
|
<style>
|
|
.admin-card {
|
|
border: none;
|
|
border-radius: 14px;
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
|
|
}
|
|
|
|
.admin-card .card-body {
|
|
padding: 26px 30px;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
letter-spacing: 0.04em;
|
|
text-transform: uppercase;
|
|
color: #6b7280;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.section-lead {
|
|
color: #9ca3af;
|
|
font-size: 14px;
|
|
margin-bottom: 22px;
|
|
}
|
|
|
|
.form-label {
|
|
font-weight: 600;
|
|
font-size: 14px;
|
|
color: #374151;
|
|
}
|
|
|
|
.form-control {
|
|
border-radius: 8px;
|
|
border: 1px solid #e2e4e9;
|
|
padding: 10px 12px;
|
|
}
|
|
|
|
.form-control:focus {
|
|
border-color: #1ebf73;
|
|
box-shadow: 0 0 0 3px rgba(30, 191, 115, 0.12);
|
|
}
|
|
|
|
.hint {
|
|
color: #9ca3af;
|
|
font-size: 12px;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
.recap {
|
|
background: #f7f8fa;
|
|
border-radius: 10px;
|
|
padding: 12px 14px;
|
|
font-size: 14px;
|
|
color: #4b5563;
|
|
margin-bottom: 18px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="layout-wrapper">
|
|
<header id="page-topbar" class="isvertical-topbar">
|
|
<div class="navbar-header">
|
|
<div class="d-flex">
|
|
<?php include('include/logoarea.php'); ?>
|
|
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
|
<i class="bx bx-menu align-middle"></i>
|
|
</button>
|
|
<div class="page-title-box align-self-center d-none d-md-block">
|
|
<h4 class="page-title mb-0">Promemoria</h4>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex">
|
|
<?php include('include/languageselection.php'); ?>
|
|
<?php include('include/profiletopbar.php'); ?>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<?php include('include/sidebar.php'); ?>
|
|
<header class="ishorizontal-topbar">
|
|
<div class="navbar-header">
|
|
<div class="d-flex"></div>
|
|
</div>
|
|
<div class="topnav">
|
|
<div class="container-fluid">
|
|
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="main-content">
|
|
<div class="page-content">
|
|
<div class="container-fluid">
|
|
<?php if ($message === 'sent') : ?>
|
|
<div class="alert alert-success" role="alert">Promemoria inviato.</div>
|
|
<?php elseif ($message === 'error') : ?>
|
|
<div class="alert alert-danger" role="alert">Errore durante l'invio.</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="row">
|
|
<div class="col-lg-8">
|
|
<div class="card admin-card">
|
|
<div class="card-body">
|
|
<div class="section-title">Invia promemoria</div>
|
|
<p class="section-lead">Controlla il testo e il punto di ritrovo, poi invia agli iscritti confermati.</p>
|
|
|
|
<div class="recap">
|
|
<strong style="color:#1f2937;"><?php echo e($event['title']); ?></strong> · <?php echo e(date('d-m-Y H:i', strtotime($event['starts_at']))); ?><br>
|
|
Destinatari confermati: <strong><?php echo $recipients; ?></strong>
|
|
</div>
|
|
|
|
<form action="event_reminder_send.php" method="POST" id="rem-form">
|
|
<input type="hidden" name="id" value="<?php echo (int) $eventId; ?>">
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Messaggio</label>
|
|
<textarea class="form-control" name="message" rows="5"><?php echo e($defaultMsg); ?></textarea>
|
|
<div class="hint">Data, ora e luogo dell'evento vengono aggiunti automaticamente sotto al messaggio.</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Punto di ritrovo (link mappa)</label>
|
|
<input type="url" class="form-control" name="meeting_link" value="<?php echo e($meetingLink); ?>" placeholder="Incolla qui il link di Google Maps del punto di ritrovo">
|
|
<div class="hint">Prefissato dal luogo dell'evento. Puoi incollare un link di Google Maps più preciso (es. la condivisione della posizione). Lascia vuoto per non includerlo.</div>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between mt-2">
|
|
<a href="events.php" class="btn btn-light" style="border-radius:8px;font-weight:600;"><i class="bx bx-arrow-back"></i> Indietro</a>
|
|
<button type="submit" class="btn btn-success" style="border-radius:8px;font-weight:600;" <?php echo $recipients === 0 ? 'disabled' : ''; ?>>
|
|
<i class="bx bx-send"></i> Invia a <?php echo $recipients; ?> iscritt<?php echo $recipients === 1 ? 'o' : 'i'; ?>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php include('include/footer.php'); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
|
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
|
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
|
<script src="assets/js/app.js"></script>
|
|
<script>
|
|
document.getElementById('rem-form').addEventListener('submit', function(ev) {
|
|
ev.preventDefault();
|
|
var form = this;
|
|
Swal.fire({
|
|
title: 'Inviare il promemoria?',
|
|
text: 'Verrà inviato a <?php echo $recipients; ?> iscritti confermati.',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Invia',
|
|
cancelButtonText: 'Annulla',
|
|
confirmButtonColor: '#1ebf73',
|
|
reverseButtons: true
|
|
}).then(function(r) {
|
|
if (r.isConfirmed) form.submit();
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|