middleware('auth', ['except' => ['generate','load']]); } /** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { Log::saveLog("Affichage de l'horaire"); return view('admin.calendar'); } public function generate() { $lang = str_replace('_', '-', app()->getLocale()); setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); $month = request('month'); $year = request('year'); $nextMonth = $month + 1; $nextYear = $year; if ($nextMonth > 12) { $nextMonth = 1; $nextYear = $nextYear + 1; } $prevMonth = $month - 1; $prevYear = $year; if ($prevMonth < 1) { $prevMonth = 12; $prevYear = $prevYear - 1; } $calendar = array(); $dayinmonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); $firstdaymonth = date("w", strtotime("01-".$month."-".$year)); $addingday = 0; for ($i=$firstdaymonth ; $addingday < $dayinmonth ; $i++) { $addingday = $addingday + 1; $calendar[$i] = $addingday; } echo ''; echo ''; echo ''; echo ''; echo ''; for ($i=0; $i < 6 ; $i++) { echo ''; for ($a=0; $a < 7 ; $a++) { if (isset($calendar[(($i*7) + $a)])) { echo ''; } else { echo ''; } } echo ''; } echo '
'.ucfirst(strftime("%B %Y", strtotime("01-".$month."-".$year))).'
DimancheLundiMardiMercrediJeudiVendrediSamedi
'; $today = date("Y-m-d", strtotime($year."-".$month."-".$calendar[(($i*7) + $a)])); $activityToday = Schedule::where('date','=',$today)->get(); if ($activityToday->isEmpty()) { echo '
'.date("j", strtotime($today)).'
'; } else { $text = ""; foreach ($activityToday as $activity) { $text = '
'.$text.ucfirst($activity->type)."

"; } echo '
'.date("j", strtotime($today)).'
'.$text.'
'; } echo '
'; } public function load() { $lang = str_replace('_', '-', app()->getLocale()); setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); $date = request('date'); $today = Schedule::where('date','=',$date)->get(); $isEmpty = $today->isEmpty(); if ($isEmpty) { ?> id) { switch ($date->type) { case 'pilotage': $this->loadPilotage($date); break; case 'instruction': $this->loadInstruction($date); break; default: # code... break; } } } } } private function loadPilotage($schedule) { ?>