@extends('layouts.worker')
@section('title', \App\Helpers\TranslationHelper::getUserTranslations()['translations']['my_schedules'] ?? 'Mes horaires')
@php
// Cache busting pour CSS aussi
$cssVersion = filemtime(public_path('css/pages/worker/horaires.css')) ?: time();
// Le bouton Valider le mois n'est actif que si l'admin a validé au moins un élément
$canValidateMonth = $canValidateMonth ?? ($adminHasValidated ?? false);
$monthValidated = $monthValidated ?? false;
$currentMonth = $currentMonth ?? ($selectedMonth ?? date('Y-m'));
@endphp
@push('styles')
@endpush
@section('content')
@php
// Extraire l'année et le mois
list($year, $month) = explode('-', $selectedMonth);
$year = (int)$year;
$month = (int)$month;
// Mois précédent
$prevMonth = $month > 1 ?
$year . '-' . str_pad($month - 1, 2, '0', STR_PAD_LEFT) :
($year - 1) . '-12';
// Mois suivant
$nextMonth = $month < 12 ?
$year . '-' . str_pad($month + 1, 2, '0', STR_PAD_LEFT) :
($year + 1) . '-01';
// Vérifier si le mois suivant est dans le futur
$currentYear = (int)date('Y');
$currentMonth = (int)date('m');
$isNextMonthDisabled = ($month == 12 && $year + 1 > $currentYear) ||
($year > $currentYear || ($year == $currentYear && $month + 1 > $currentMonth));
// Formater le mois pour l'affichage
// Récupérer les noms des mois dans la langue de l'utilisateur
$translations = \App\Helpers\TranslationHelper::getUserTranslations()['translations'];
$monthNames = [];
// Vérifier si les traductions des mois existent
if (isset($translations['months'])) {
$monthNames = [
1 => $translations['months']['january'] ?? 'janvier',
2 => $translations['months']['february'] ?? 'février',
3 => $translations['months']['march'] ?? 'mars',
4 => $translations['months']['april'] ?? 'avril',
5 => $translations['months']['may'] ?? 'mai',
6 => $translations['months']['june'] ?? 'juin',
7 => $translations['months']['july'] ?? 'juillet',
8 => $translations['months']['august'] ?? 'août',
9 => $translations['months']['september'] ?? 'septembre',
10 => $translations['months']['october'] ?? 'octobre',
11 => $translations['months']['november'] ?? 'novembre',
12 => $translations['months']['december'] ?? 'décembre'
];
} else {
// Fallback en français si les traductions n'existent pas
$monthNames = [
1 => 'janvier',
2 => 'février',
3 => 'mars',
4 => 'avril',
5 => 'mai',
6 => 'juin',
7 => 'juillet',
8 => 'août',
9 => 'septembre',
10 => 'octobre',
11 => 'novembre',
12 => 'décembre'
];
}
// Format du mois selon la langue
$monthYearFormat = $translations['schedules']['month_year_format'] ?? '{month} {year}';
$displayMonth = ucfirst($monthNames[$month]);
$displayMonth = str_replace('{month}', $displayMonth, $monthYearFormat);
$displayMonth = str_replace('{year}', $year, $displayMonth);
@endphp
{{ $displayMonth }}
{{-- Message "aucun divers" (visible seulement si non masqué et liste vide) --}}
@if(!(isset($allMiscItemsHidden) && $allMiscItemsHidden) && (!isset($miscItems) || count($miscItems) === 0))
{{ \App\Helpers\TranslationHelper::getUserTranslations()['translations']['schedules']['no_misc_items'] ?? 'Aucun élément divers pour ce mois.' }}
{{ \App\Helpers\TranslationHelper::getUserTranslations()['translations']['schedules']['no_schedules_this_month'] ?? 'Aucun horaire enregistré pour ce mois.' }}
{{ \App\Helpers\TranslationHelper::getUserTranslations()['translations']['schedules']['summary_remaining'] ?? 'Total restant à payer' }}0,00 €
{{ \App\Helpers\TranslationHelper::getUserTranslations()['translations']['schedules']['validation_warning'] ?? 'Une fois validé, vous ne pourrez plus modifier vos horaires pour ce mois.' }}
@php
// Cache busting : FORCE un nouveau timestamp à chaque chargement pour éviter le cache navigateur
$cacheVersion = time();
@endphp
@push('scripts')
@endpush