Merge pull request 'refacto : var currency and zone applied' (#2) from param_foyer into main
Deploy HouseHub / deploy (push) Successful in 1s

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-05-20 11:26:08 +02:00
9 changed files with 68 additions and 25 deletions
+5 -2
View File
@@ -35,8 +35,11 @@ require __DIR__ . '/header.php';
<div id="modalHolidays" class="pf-modal">
<div class="pf-modal-content">
<div class="pf-modal-header">
<h3 class="pf-modal-title"><?= tr('fc_modal_holidays_title') ?></h3>
<button id="btnCloseHolidays" class="pf-modal-close" onclick="document.getElementById('modalHolidays').classList.remove('open'); document.body.classList.remove('no-scroll');">&times;</button>
<h3 class="pf-modal-title">
<?= tr('fc_modal_holidays_title') ?>
<?php if (defined('ZONE_SCOLAIRE') && ZONE_SCOLAIRE !== 'Autre') echo '(Zone ' . htmlspecialchars(ZONE_SCOLAIRE) . ')'; ?>
</h3>
<button id="btnCloseHolidays" class="pf-modal-close" onclick="document.getElementById('modalHolidays').classList.remove('active')">&times;</button>
</div>
<div class="pf-modal-body" style="padding:0;">
<div style="width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;">
+2 -1
View File
@@ -134,7 +134,8 @@ $currentLang = $_SESSION['app_lang'] ?? 'fr';
window.CONFIG = {
ID_ALEX: <?php echo defined('ID_ALEX') ? ID_ALEX : 2; ?>,
ID_LAIA: <?php echo defined('ID_LAIA') ? ID_LAIA : 3; ?>,
CURRENCY: '<?php echo defined('CURRENCY') ? CURRENCY : "€"; ?>'
CURRENCY: '<?php echo defined('CURRENCY') ? CURRENCY : "€"; ?>',
ZONE_SCOLAIRE: '<?php echo defined('ZONE_SCOLAIRE') ? ZONE_SCOLAIRE : "C"; ?>'
};
function tr(key) {
+1 -1
View File
@@ -163,7 +163,7 @@ return [
'fc_main_header' => 'Calendari Familiar',
'fc_btn_correct_balances' => 'Corregir els saldos',
'fc_btn_school_holidays' => 'Vacances escolars',
'fc_modal_holidays_title' => 'Vacances Escolars (Zona C)',
'fc_modal_holidays_title' => 'Vacances Escolars',
'fc_modal_snap_title' => 'Ajustar un saldo',
'fc_col_period' => 'Període',
'fc_col_from' => 'Des del',
+1 -1
View File
@@ -164,7 +164,7 @@ return [
'fc_main_header' => 'Family Calendar',
'fc_btn_correct_balances' => 'Adjust balances',
'fc_btn_school_holidays' => 'School holidays',
'fc_modal_holidays_title' => 'School Holidays (Zone C)',
'fc_modal_holidays_title' => 'School Holidays',
'fc_modal_snap_title' => 'Adjust a balance',
'fc_col_period' => 'Period',
'fc_col_from' => 'From',
+1 -1
View File
@@ -163,7 +163,7 @@ return [
'fc_main_header' => 'Calendrier Familial',
'fc_btn_correct_balances' => 'Corriger les soldes',
'fc_btn_school_holidays' => 'Vacances scolaires',
'fc_modal_holidays_title' => 'Vacances Scolaires (Zone C)',
'fc_modal_holidays_title' => 'Vacances Scolaires',
'fc_modal_snap_title' => 'Ajuster un solde',
'fc_col_period' => 'Période',
'fc_col_from' => 'Du',
+7 -7
View File
@@ -666,18 +666,18 @@ function updateSummaryTable() {
const laiaSum = dataByTarget[targetName] ? dataByTarget[targetName].laia : 0;
const globalSum = alexSum + laiaSum;
row.cells[1].innerText = Math.round(alexSum).toLocaleString(window.appLang) + ' ';
row.cells[2].innerText = Math.round(laiaSum).toLocaleString(window.appLang) + ' ';
row.cells[3].innerText = Math.round(globalSum).toLocaleString(window.appLang) + ' ';
row.cells[1].innerText = Math.round(alexSum).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
row.cells[2].innerText = Math.round(laiaSum).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
row.cells[3].innerText = Math.round(globalSum).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
grandTotalAlex += alexSum;
grandTotalLaia += laiaSum;
});
}
document.getElementById('grand_total_alex').innerText = Math.round(grandTotalAlex).toLocaleString(window.appLang) + ' ';
document.getElementById('grand_total_laia').innerText = Math.round(grandTotalLaia).toLocaleString(window.appLang) + ' ';
document.getElementById('grand_total_global').innerText = Math.round(grandTotalAlex + grandTotalLaia).toLocaleString(window.appLang) + ' ';
document.getElementById('grand_total_alex').innerText = Math.round(grandTotalAlex).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
document.getElementById('grand_total_laia').innerText = Math.round(grandTotalLaia).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
document.getElementById('grand_total_global').innerText = Math.round(grandTotalAlex + grandTotalLaia).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
}
function saveData(action, data) {
@@ -788,7 +788,7 @@ function updateSumResult() {
total += val;
});
document.getElementById('sumResultValue').innerText = new Intl.NumberFormat(window.appLang, { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }).format(total);
document.getElementById('sumResultValue').innerText = Math.round(total).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
}
async function deleteCategory(id) {
+1 -1
View File
@@ -528,7 +528,7 @@ function updateSumResult() {
total += val;
});
document.getElementById('sumResultValue').innerText = new Intl.NumberFormat(window.appLang, { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }).format(total);
document.getElementById('sumResultValue').innerText = Math.round(total).toLocaleString(window.appLang) + ' ' + window.CONFIG.CURRENCY;
}
document.addEventListener('click', function(e) {
+24 -2
View File
@@ -119,7 +119,16 @@ document.addEventListener("DOMContentLoaded", () => {
options += `<option value="${y}" ${selected}>${y} - ${y + 1}</option>`;
}
headerTitle.innerHTML = `🏖️ ${tr("fc_modal_holidays_title")}
// --- NOUVEAU : Récupération de la zone dynamique ---
const zoneText =
window.CONFIG &&
window.CONFIG.ZONE_SCOLAIRE &&
window.CONFIG.ZONE_SCOLAIRE !== "Autre"
? `(Zone ${window.CONFIG.ZONE_SCOLAIRE})`
: "";
// Injection du texte de la zone dans le header
headerTitle.innerHTML = `🏖️ ${window.I18N["fc_modal_holidays_title"]} ${zoneText}
<select id="holidayYearSelect" class="pf-input" style="width:auto; display:inline-block; margin-left:10px; padding:4px 10px; height:auto;">
${options}
</select>`;
@@ -332,8 +341,21 @@ document.addEventListener("DOMContentLoaded", () => {
async fetchAndSaveGovHolidays(yearStart) {
try {
const yearStr = `${yearStart}-${yearStart + 1}`;
const url = `https://data.education.gouv.fr/api/explore/v2.1/catalog/datasets/fr-en-calendrier-scolaire/records?where=annee_scolaire='${yearStr}' AND zones LIKE '%Zone C%'&limit=100`;
const zone = window.CONFIG?.ZONE_SCOLAIRE || "C";
if (zone === "Autre") {
alert(
"L'importation automatique n'est disponible que pour les zones A, B ou C (France).",
);
const btn = document.getElementById("btnFetchGovHolidays");
if (btn) {
btn.innerText = "Non disponible";
btn.disabled = true;
}
return;
}
const url = `https://data.education.gouv.fr/api/explore/v2.1/catalog/datasets/fr-en-calendrier-scolaire/records?where=annee_scolaire='${yearStr}' AND zones LIKE '%Zone ${zone}%'&limit=100`;
const res = await fetch(url);
const data = await res.json();
const rawRecords = data.results || [];
+26 -9
View File
@@ -37,9 +37,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($action === 'update_family_info') {
require_once __DIR__ . '/includes/db.php';
$currency = trim($_POST['currency'] ?? '€');
$zone = trim($_POST['zone_scolaire'] ?? 'C');
$foyer = $pdo->query("SELECT currency, zone_scolaire FROM pf_foyer_settings WHERE id = 1")->fetch();
$currency = isset($_POST['currency']) ? trim($_POST['currency']) : ($foyer['currency'] ?? '€');
$zone = isset($_POST['zone_scolaire']) ? trim($_POST['zone_scolaire']) : ($foyer['zone_scolaire'] ?? 'C');
$stmtSave = $pdo->prepare("UPDATE pf_foyer_settings SET currency = ?, zone_scolaire = ? WHERE id = 1");
$stmtSave->execute([$currency, $zone]);
$success = "Paramètres du foyer mis à jour avec succès.";
@@ -453,23 +454,36 @@ require __DIR__ . '/header.php';
<!-- ── Famille ──────────────────────────────────────────────────────────── -->
<?php
$currentCurrency = defined('CURRENCY') ? CURRENCY : '€';
$currentZone = defined('ZONE_SCOLAIRE') ? ZONE_SCOLAIRE : 'C';
$enabledMods = $_SESSION['enabled_modules'] ?? [];
// On cible précisément qui a besoin de quoi
$showCurrency = count(array_intersect(['budget', 'holidays', 'gifts', 'garage'], $enabledMods)) > 0;
$showZone = in_array('calendar', $enabledMods);
// Si au moins un des champs doit être affiché, on rend la section visible
if ($family_id && ($showCurrency || $showZone)):
$currentCurrency = defined('CURRENCY') ? CURRENCY : '€';
$currentZone = defined('ZONE_SCOLAIRE') ? ZONE_SCOLAIRE : 'C';
?>
<section class="pf-panel-card">
<h2 class="pf-card-h2">👪 Configuration du foyer</h2>
<p class="pf-muted-note">Configurez les informations partagées par l'ensemble de votre foyer.</p>
<p class="pf-muted-note">Configurez les indicateurs partagés par votre foyer.</p>
<form method="post" class="pf-stack-md">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars(csrf_token()) ?>">
<input type="hidden" name="action" value="update_family_info">
<div class="form-row">
<div class="form-group">
<?php if ($showCurrency): ?>
<div class="pf-form-group">
<label class="pf-label">Devise monétaire</label>
<input type="text" name="currency" class="pf-input" value="<?= htmlspecialchars($currentCurrency) ?>" placeholder="ex: €, $, CHF" required maxlength="10">
</div>
<div class="form-group">
<?php endif; ?>
<?php if ($showZone): ?>
<div class="pf-form-group">
<label class="pf-label">Zone de vacances scolaires (France)</label>
<select name="zone_scolaire" class="pf-input" style="background:var(--bg-panel);">
<option value="A" <?= $currentZone === 'A' ? 'selected' : '' ?>>Zone A</option>
@@ -478,11 +492,14 @@ require __DIR__ . '/header.php';
<option value="Autre" <?= $currentZone === 'Autre' ? 'selected' : '' ?>>Hors France / Autre</option>
</select>
</div>
<?php endif; ?>
</div>
<button type="submit" class="pf-btn">Enregistrer</button>
<button type="submit" class="pf-btn">Enregistrer les paramètres du foyer</button>
</form>
</section>
<?php endif; ?>
<!-- ── Profil ──────────────────────────────────────────────────────────── -->