diff --git a/public/userarea/certificate/2-1768494750-CONTRATTO_CONTO_DEPOSITO_5_Novembre_2024.pdf b/public/userarea/certificate/2-1768494750-CONTRATTO_CONTO_DEPOSITO_5_Novembre_2024.pdf new file mode 100644 index 0000000..51dd137 Binary files /dev/null and b/public/userarea/certificate/2-1768494750-CONTRATTO_CONTO_DEPOSITO_5_Novembre_2024.pdf differ diff --git a/public/userarea/certificate/2-1768494842-CONTRATTO_CONTO_DEPOSITO_5_Novembre_2024.pdf b/public/userarea/certificate/2-1768494842-CONTRATTO_CONTO_DEPOSITO_5_Novembre_2024.pdf new file mode 100644 index 0000000..51dd137 Binary files /dev/null and b/public/userarea/certificate/2-1768494842-CONTRATTO_CONTO_DEPOSITO_5_Novembre_2024.pdf differ diff --git a/public/userarea/certificate/2-1768494853-2026-01-14_14-05__1_.pdf b/public/userarea/certificate/2-1768494853-2026-01-14_14-05__1_.pdf new file mode 100644 index 0000000..07a6e84 Binary files /dev/null and b/public/userarea/certificate/2-1768494853-2026-01-14_14-05__1_.pdf differ diff --git a/public/userarea/include/navbar.php b/public/userarea/include/navbar.php index 2fc13d4..17d1734 100644 --- a/public/userarea/include/navbar.php +++ b/public/userarea/include/navbar.php @@ -18,6 +18,12 @@ +
  • + +
    + +
    +
  • diff --git a/public/userarea/my_certificates.php b/public/userarea/my_certificates.php new file mode 100644 index 0000000..8d6bd01 --- /dev/null +++ b/public/userarea/my_certificates.php @@ -0,0 +1,319 @@ +getConnection(); + +// ============================================= +// CARICAMENTO CERTIFICATO (POST) +// ============================================= +$success = $error = ""; + +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['certificate']) && $_FILES['certificate']['error'] === UPLOAD_ERR_OK) { + $file = $_FILES['certificate']; + $allowed_ext = ['jpg', 'jpeg', 'png', 'pdf', 'heic', 'heif']; + $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); + + if (!in_array($ext, $allowed_ext)) { + $error = "Formato non supportato. Ammessi: jpg, jpeg, png, pdf, heic, heif"; + } elseif ($file['size'] > 10 * 1024 * 1024) { + $error = "File troppo grande (max 10MB)"; + } elseif (empty($_POST['expiry_date'])) { + $error = "La data di scadenza รจ obbligatoria"; + } else { + $upload_dir = __DIR__ . '/certificate/'; + if (!is_dir($upload_dir)) { + mkdir($upload_dir, 0755, true); + } + + $safe_name = preg_replace('/[^a-zA-Z0-9\._-]/', '_', basename($file['name'])); + $new_filename = $iduserlogin . '-' . time() . '-' . $safe_name; + $destination = $upload_dir . $new_filename; + + if (move_uploaded_file($file['tmp_name'], $destination)) { + $document_name = trim($_POST['document_name'] ?? 'certificato'); + if (empty($document_name)) $document_name = 'certificato'; + + $expiry_date = $_POST['expiry_date']; + $notes = trim($_POST['notes'] ?? ''); + + $stmt = $pdo->prepare(" + INSERT INTO user_medical_certificates + (user_id, filename, stored_path, document_name, expiry_date, notes, uploaded_at) + VALUES (?, ?, ?, ?, ?, ?, NOW()) + "); + $stmt->execute([ + $iduserlogin, + $file['name'], + 'certificate/' . $new_filename, + $document_name, + $expiry_date, + $notes + ]); + + $success = "Certificato caricato correttamente!"; + } else { + $error = "Errore durante il salvataggio del file."; + } + } +} + +// ============================================= +// ELIMINAZIONE CERTIFICATO +// ============================================= +if (isset($_GET['delete']) && is_numeric($_GET['delete'])) { + $cert_id = (int)$_GET['delete']; + + $stmt = $pdo->prepare("SELECT stored_path FROM user_medical_certificates WHERE id = ? AND user_id = ?"); + $stmt->execute([$cert_id, $iduserlogin]); + $cert = $stmt->fetch(); + + if ($cert) { + $full_path = __DIR__ . '/' . $cert['stored_path']; + if (file_exists($full_path)) { + @unlink($full_path); + } + + $stmt = $pdo->prepare("DELETE FROM user_medical_certificates WHERE id = ? AND user_id = ?"); + $stmt->execute([$cert_id, $iduserlogin]); + + $success = "Certificato eliminato."; + } +} + +// ============================================= +// LISTA CERTIFICATI +// ============================================= +$stmt = $pdo->prepare(" + SELECT id, filename, stored_path, document_name, expiry_date, uploaded_at, notes + FROM user_medical_certificates + WHERE user_id = ? + ORDER BY uploaded_at DESC +"); +$stmt->execute([$iduserlogin]); +$certificates = $stmt->fetchAll(PDO::FETCH_ASSOC); + +// Dati utente base (solo per titolo o saluto) +$stmt = $pdo->prepare("SELECT first_name FROM auth_users WHERE id = ?"); +$stmt->execute([$iduserlogin]); +$user = $stmt->fetch(); +?> + + + + + + + + I miei Certificati Medici - Yogiboook + + + + + + +
    + + + +
    +
    +
    + +
    +
    +

    I miei Certificati Medici

    +
    + +
    + + +
    + + +
    + + + +
    + + +
    + + + +
    +
    +
    +
    + +
    Trascina qui il file oppure clicca per selezionare
    +

    Formati: jpg, jpeg, png, pdf, heic, heif (max 10 MB)

    + +
    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + + +
    + +
    +
    +
    + + + +
    + +
    Nessun certificato caricato
    +
    + +
    Certificati caricati ()
    +
    + + + + + + + + + + + + + + + + + + + + + +
    Data caricamentoNome documento / FileScadenzaNoteAzioni
    + + +
    + () +
    +
    + + SCADUTO' : '' ?> + 100 ? '...' : '') : 'โ€”' ?> + + Elimina + +
    +
    + + +
    +
    + +
    +
    +
    + + +
    + + + + + + + \ No newline at end of file diff --git a/public/userarea/school_settings.php b/public/userarea/school_settings.php index 3e12ecc..531d054 100644 --- a/public/userarea/school_settings.php +++ b/public/userarea/school_settings.php @@ -18,6 +18,11 @@ $stmt = $pdo->prepare("SELECT * FROM school_settings WHERE school_id = ?"); $stmt->execute([$school_id]); $settings = $stmt->fetch(); +// Ricarica con default se manca la colonna (per scuole vecchie) +if ($settings && !array_key_exists('portal_purchases_enabled', $settings)) { + $settings['portal_purchases_enabled'] = 1; +} + $is_new = !$settings; $success_message = $error = ""; @@ -48,15 +53,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!empty($_POST['allow_drop_in'])) $product_types[] = 'drop_in'; $allowed_product_types = !empty($product_types) ? implode(',', $product_types) : 'none'; + + $portal_purchases_enabled = !empty($_POST['portal_purchases_enabled']) ? 1 : 0; + + // Se acquisti portale disabilitati โ†’ forza anche propagate a 0 + $auto_propagate_on_purchase = $portal_purchases_enabled + ? (!empty($_POST['auto_propagate_on_purchase']) ? 1 : 0) + : 0; // === SALVATAGGIO === try { if ($is_new) { $stmt = $pdo->prepare(" - INSERT INTO school_settings ( - school_id, header_color, sidebar_color, payment_methods, currency_code, enable_notifications, - allow_freeze_global, freeze_max_days_global, auto_propagate_on_purchase, - allow_full_access_rebooking, allowed_product_types - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + INSERT INTO school_settings ( + school_id, header_color, sidebar_color, payment_methods, currency_code, enable_notifications, + allow_freeze_global, freeze_max_days_global, auto_propagate_on_purchase, + allow_full_access_rebooking, allowed_product_types, + portal_purchases_enabled + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); $stmt->execute([ $school_id, @@ -69,15 +82,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $freeze_max_days_global, $auto_propagate_on_purchase, $allow_full_access_rebooking, - $allowed_product_types + $allowed_product_types, + $portal_purchases_enabled ]); $success_message = "Impostazioni create con successo!"; } else { $stmt = $pdo->prepare(" - UPDATE school_settings SET + UPDATE school_settings SET header_color = ?, sidebar_color = ?, payment_methods = ?, currency_code = ?, enable_notifications = ?, allow_freeze_global = ?, freeze_max_days_global = ?, auto_propagate_on_purchase = ?, - allow_full_access_rebooking = ?, allowed_product_types = ? + allow_full_access_rebooking = ?, allowed_product_types = ?, + portal_purchases_enabled = ? WHERE school_id = ? "); $stmt->execute([ @@ -91,7 +106,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $auto_propagate_on_purchase, $allow_full_access_rebooking, $allowed_product_types, + $portal_purchases_enabled, $school_id + ]); $success_message = "Impostazioni aggiornate con successo!"; } @@ -178,6 +195,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { +
    +
    + > + +
    + Se disattivato, anche la propagazione automatica e i pagamenti vengono forzati a NO. +
    +
    @@ -231,6 +259,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    + +
    > @@ -286,6 +316,45 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { document.querySelector('input[name="freeze_max_days_global"]').disabled = !this.checked; }); + \ No newline at end of file