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.calendar_display'); } 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->data['event_name'])."

"; } echo '
'.date("j", strtotime($today)).'
'.$text.'
'; } echo '
'; } public function load() { $lang = str_replace('_', '-', app()->getLocale()); setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); $Requestdate = request('date'); $url = str_replace("-","_", $Requestdate); /** Dont work ... API stuff * Log::saveLog("a consulté l'horaire du ".$date); **/ $today = Schedule::where('date','=',$Requestdate)->get(); $isEmpty = $today->isEmpty(); echo ''; } public function add($date) { $lang = str_replace('_', '-', app()->getLocale()); setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); $date = str_replace("_", "-", $date); $UserList = User::all(); $LocalList = Local::all(); return view('admin.calendar.calendar_add' ,['RequestDate' => $date, 'Userslist' => $UserList, 'LocalsList' => $LocalList]); } public function edit($id) { $schedule = Schedule::find($id); $UserList = User::all(); $LocalList = Local::all(); return view('admin.calendar.calendar_edit' ,['RequestSchedule' => $schedule, 'Userslist' => $UserList, 'LocalsList' => $LocalList]); } public function store() { $schedule = new Schedule; $schedule->date = request('event_date'); $schedule->type = request('event_type'); if(request('event_type') == "regular") { $eventData = [ "event_name" => request('event_name'), "is_event_mandatory" => request('is_event_mandatory'), "event_date" => request('event_date'), "event_begin_time" => request('event_begin_time'), "event_end_time" => request('event_end_time'), "event_location" => request('event_location'), "event_desc" => request('event_desc'), "n1_p1_name" => request('n1_p1_name'), "n1_p1_ocom" => request('n1_p1_ocom'), "n1_p1_instructor" => request('n1_p1_instructor'), "n1_p1_local" => request('n1_p1_local'), "n1_p1_plandone" => request('n1_p1_plandone'), "n1_p2_name" => request('n1_p2_name'), "n1_p2_ocom" => request('n1_p2_ocom'), "n1_p2_instructor" => request('n1_p2_instructor'), "n1_p2_local" => request('n1_p2_local'), "n1_p2_plandone" => request('n1_p2_plandone'), "n2_p1_name" => request('n2_p1_name'), "n2_p1_ocom" => request('n2_p1_ocom'), "n2_p1_instructor" => request('n2_p1_instructor'), "n2_p1_local" => request('n2_p1_local'), "n2_p1_plandone" => request('n2_p1_plandone'), "n2_p2_name" => request('n2_p2_name'), "n2_p2_ocom" => request('n2_p2_ocom'), "n2_p2_instructor" => request('n2_p2_instructor'), "n2_p2_local" => request('n2_p2_local'), "n2_p2_plandone" => request('n2_p2_plandone'), "n3_p1_name" => request('n3_p1_name'), "n3_p1_ocom" => request('n3_p1_ocom'), "n3_p1_instructor" => request('n3_p1_instructor'), "n3_p1_local" => request('n3_p1_local'), "n3_p1_plandone" => request('n3_p1_plandone'), "n3_p2_name" => request('n3_p2_name'), "n3_p2_ocom" => request('n3_p2_ocom'), "n3_p2_instructor" => request('n3_p2_instructor'), "n3_p2_local" => request('n3_p2_local'), "n3_p2_plandone" => request('n3_p2_plandone'), ]; } else { $eventData = [ "event_name" => request('event_name'), "is_event_mandatory" => request('is_event_mandatory'), "event_date" => request('event_date'), "event_begin_time" => request('event_begin_time'), "event_end_time" => request('event_end_time'), "event_location" => request('event_location'), "event_desc" => request('event_desc'), ]; } $schedule->data = $eventData; $schedule->save(); } public function patch($id) { $schedule = Schedule::find($id); $schedule->date = request('event_date'); $schedule->type = request('event_type'); if(request('event_type') == "regular") { $eventData = [ "event_name" => request('event_name'), "is_event_mandatory" => request('is_event_mandatory'), "event_date" => request('event_date'), "event_begin_time" => request('event_begin_time'), "event_end_time" => request('event_end_time'), "event_location" => request('event_location'), "event_desc" => request('event_desc'), "n1_p1_name" => request('n1_p1_name'), "n1_p1_ocom" => request('n1_p1_ocom'), "n1_p1_instructor" => request('n1_p1_instructor'), "n1_p1_local" => request('n1_p1_local'), "n1_p1_plandone" => request('n1_p1_plandone'), "n1_p2_name" => request('n1_p2_name'), "n1_p2_ocom" => request('n1_p2_ocom'), "n1_p2_instructor" => request('n1_p2_instructor'), "n1_p2_local" => request('n1_p2_local'), "n1_p2_plandone" => request('n1_p2_plandone'), "n2_p1_name" => request('n2_p1_name'), "n2_p1_ocom" => request('n2_p1_ocom'), "n2_p1_instructor" => request('n2_p1_instructor'), "n2_p1_local" => request('n2_p1_local'), "n2_p1_plandone" => request('n2_p1_plandone'), "n2_p2_name" => request('n2_p2_name'), "n2_p2_ocom" => request('n2_p2_ocom'), "n2_p2_instructor" => request('n2_p2_instructor'), "n2_p2_local" => request('n2_p2_local'), "n2_p2_plandone" => request('n2_p2_plandone'), "n3_p1_name" => request('n3_p1_name'), "n3_p1_ocom" => request('n3_p1_ocom'), "n3_p1_instructor" => request('n3_p1_instructor'), "n3_p1_local" => request('n3_p1_local'), "n3_p1_plandone" => request('n3_p1_plandone'), "n3_p2_name" => request('n3_p2_name'), "n3_p2_ocom" => request('n3_p2_ocom'), "n3_p2_instructor" => request('n3_p2_instructor'), "n3_p2_local" => request('n3_p2_local'), "n3_p2_plandone" => request('n3_p2_plandone'), ]; } else { $eventData = [ "event_name" => request('event_name'), "is_event_mandatory" => request('is_event_mandatory'), "event_date" => request('event_date'), "event_begin_time" => request('event_begin_time'), "event_end_time" => request('event_end_time'), "event_location" => request('event_location'), "event_desc" => request('event_desc'), ]; } $schedule->data = $eventData; $schedule->save(); $check = Schedule::find($id); dd($check); } }