certificati aggiunti
This commit is contained in:
@@ -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') {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" name="portal_purchases_enabled" id="portal_enabled"
|
||||
<?php echo ($settings['portal_purchases_enabled'] ?? 1) ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="portal_enabled">
|
||||
Acquisti pacchetti attivi nel portale YoGiBook
|
||||
</label>
|
||||
</div>
|
||||
<small class="form-text text-muted">Se disattivato, anche la propagazione automatica e i pagamenti vengono forzati a NO.</small>
|
||||
</div>
|
||||
<br>
|
||||
<div class="col-12 mb-4">
|
||||
<label class="form-label">Metodi di pagamento accettati</label>
|
||||
<div class="row g-3">
|
||||
@@ -231,6 +259,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="mt-4">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" name="allow_full_access_rebooking" id="full_access" <?php echo ($settings['allow_full_access_rebooking'] ?? 1) ? 'checked' : ''; ?>>
|
||||
@@ -286,6 +316,45 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
document.querySelector('input[name="freeze_max_days_global"]').disabled = !this.checked;
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
const portal = document.getElementById('portal_enabled');
|
||||
const propagate = document.getElementById('auto_propagate');
|
||||
const stripe = document.getElementById('pay_stripe');
|
||||
const paypal = document.getElementById('pay_paypal');
|
||||
const manual = document.getElementById('pay_manual');
|
||||
|
||||
function syncPortalState() {
|
||||
if (!portal) return;
|
||||
|
||||
const isEnabled = portal.checked;
|
||||
|
||||
// Propaga
|
||||
if (propagate) {
|
||||
propagate.disabled = !isEnabled;
|
||||
if (!isEnabled) propagate.checked = false;
|
||||
}
|
||||
|
||||
// Stripe + PayPal
|
||||
if (stripe) {
|
||||
stripe.disabled = !isEnabled;
|
||||
if (!isEnabled) stripe.checked = false;
|
||||
}
|
||||
if (paypal) {
|
||||
paypal.disabled = !isEnabled;
|
||||
if (!isEnabled) paypal.checked = false;
|
||||
}
|
||||
if (manual) {
|
||||
manual.disabled = !isEnabled;
|
||||
if (!isEnabled) manual.checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (portal) {
|
||||
portal.addEventListener('change', syncPortalState);
|
||||
// Esegui subito (importante per il caricamento iniziale)
|
||||
syncPortalState();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user