fixed finances my lesson etc

This commit is contained in:
2025-12-07 21:47:43 +01:00
parent 8c5b9a0d85
commit 70d01f160e
13 changed files with 2176 additions and 509 deletions
+67 -26
View File
@@ -29,6 +29,25 @@ if (!$school) {
$school_id = $school['id'];
$school_name = $school['name'];
// === RECUPERA IMPOSTAZIONI SCUOLA (valori predefiniti) ===
$stmt = $pdo->prepare("SELECT * FROM school_settings WHERE school_id = ?");
$stmt->execute([$school_id]);
$school_settings = $stmt->fetch() ?: [
'allow_freeze_global' => 1,
'freeze_max_days_global' => 30,
'auto_propagate_on_purchase' => 1,
'allow_full_access_rebooking' => 1,
'allowed_product_types' => 'subscription,carnet,drop_in'
];
// === PREPARA I TIPI DI PRODOTTO CONSENTITI ===
$allowed_types = array_filter(explode(',', $school_settings['allowed_product_types'] ?? 'subscription,carnet,drop_in'));
$types_map = [
'subscription' => 'Abbonamento',
'carnet' => 'Carnet',
'drop_in' => 'Lezione Singola'
];
// Recupera i prodotti della scuola con variazioni, classi e variazioni associate
$stmt = $pdo->prepare("
SELECT p.*,
@@ -446,6 +465,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
font-style: italic;
/* Rende il nome del prodotto in corsivo per le variazioni */
}
.precompiled-field {
background-color: #fff8c4 !important;
/* giallo chiaro, elegante */
border: 1px solid #ffe08c;
}
.precompiled-field:focus {
background-color: #fffce6 !important;
/* un po' più chiaro quando scrivi */
box-shadow: 0 0 0 0.2rem rgba(255, 200, 0, 0.25);
}
</style>
</head>
@@ -690,10 +721,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="col-md-6">
<label class="form-label">Tipo <span class="text-danger">*</span></label>
<select class="form-select" name="type" required>
<option value="carnet">Carnet</option>
<option value="subscription">Abbonamento</option>
<option value="drop_in">Lezione Singola</option>
<select class="form-select precompiled-field" name="type" required>
<?php foreach ($allowed_types as $type): ?>
<?php if (isset($types_map[$type])): ?>
<option value="<?php echo $type; ?>">
<?php echo $types_map[$type]; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6">
@@ -732,29 +767,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="col-md-6">
<label class="form-label">Permetti congelamento</label>
<select class="form-select" name="allow_freeze">
<option value="0">No</option>
<option value="1"></option>
<select class="form-select precompiled-field" name="allow_freeze">
<option value="0" <?php echo !$school_settings['allow_freeze_global'] ? 'selected' : ''; ?>>No</option>
<option value="1" <?php echo $school_settings['allow_freeze_global'] ? 'selected' : ''; ?>>Sì</option>
</select>
</div>
<div class="col-md-6">
<label class="form-label">Giorni max congelamento</label>
<input type="number" class="form-control" name="freeze_max_days">
<input type="number" class="form-control precompiled-field" name="freeze_max_days"
value="<?php echo $school_settings['freeze_max_days_global']; ?>">
</div>
<div class="col-md-6">
<label class="form-label">Accesso completo a tutte le classi</label>
<select class="form-select" id="add_product_is_full_access" name="is_full_access" onchange="toggleClassTypesSection(this.value, 'add')">
<option value="0">No</option>
<option value="1"></option>
<select class="form-select precompiled-field" id="add_product_is_full_access" name="is_full_access" onchange="toggleClassTypesSection(this.value, 'add')">
<option value="0" <?php echo !$school_settings['allow_full_access_rebooking'] ? 'selected' : ''; ?>>No</option>
<option value="1" <?php echo $school_settings['allow_full_access_rebooking'] ? 'selected' : ''; ?>>Sì</option>
</select>
</div>
<div class="col-md-6">
<label class="form-label">Propaga automaticamente all'ordine</label>
<select class="form-select" name="auto_propagate_to_order">
<option value="0">No</option>
<option value="1"></option>
<select class="form-select precompiled-field" name="auto_propagate_to_order">
<option value="0" <?php echo !$school_settings['auto_propagate_on_purchase'] ? 'selected' : ''; ?>>No</option>
<option value="1" <?php echo $school_settings['auto_propagate_on_purchase'] ? 'selected' : ''; ?>>Sì</option>
</select>
</div>
@@ -858,21 +894,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</div>
<div class="col-md-6 mb-3">
<label for="add_variation_allow_freeze" class="form-label">Permetti Congelamento</label>
<select class="form-control" id="add_variation_allow_freeze" name="allow_freeze">
<option value="0">No</option>
<option value="1"></option>
<select class="form-select precompiled-field" name="allow_freeze">
<option value="0" <?php echo !$school_settings['allow_freeze_global'] ? 'selected' : ''; ?>>No</option>
<option value="1" <?php echo $school_settings['allow_freeze_global'] ? 'selected' : ''; ?>>Sì</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="add_variation_freeze_max_days" class="form-label">Giorni Massimi di Congelamento</label>
<input type="number" class="form-control" id="add_variation_freeze_max_days" name="freeze_max_days">
<input type="number" class="form-control precompiled-field" name="freeze_max_days"
value="<?php echo $school_settings['freeze_max_days_global']; ?>">
<small class="form-text text-muted">Lascia vuoto se non applicabile.</small>
</div>
<div class="col-md-6 mb-3">
<label for="add_variation_auto_propagate" class="form-label">Propaga in Automatico all'Ordine</label>
<select class="form-control" id="add_variation_auto_propagate" name="auto_propagate_to_order">
<option value="0">No</option>
<option value="1"></option>
<select class="form-select precompiled-field" name="auto_propagate_to_order">
<option value="0" <?php echo !$school_settings['auto_propagate_on_purchase'] ? 'selected' : ''; ?>>No</option>
<option value="1" <?php echo $school_settings['auto_propagate_on_purchase'] ? 'selected' : ''; ?>>Sì</option>
</select>
<small class="form-text text-muted">Se , la variazione verrà aggiunta automaticamente agli ordini futuri.</small>
</div>
@@ -934,11 +971,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<input type="text" class="form-control" id="edit_product_variation_name" name="variation_name">
</div>
<div class="col-md-6 mb-3">
<label for="edit_product_type" class="form-label">Tipo</label>
<select class="form-control" id="edit_product_type" name="type" required>
<option value="carnet">Carnet</option>
<option value="subscription">Abbonamento</option>
<option value="drop_in">Lezione Singola</option>
<label class="form-label">Tipo <span class="text-danger">*</span></label>
<select class="form-select precompiled-field" name="type" required>
<?php foreach ($allowed_types as $type): ?>
<?php if (isset($types_map[$type])): ?>
<option value="<?php echo $type; ?>">
<?php echo $types_map[$type]; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6 mb-3" id="edit_price_section">