forPage(1,4); return view('ecc.dashboard',['userClasse' => \Auth::User()->getClasse()->forPage(1,8), 'messages' => $messages,'AlluserClasse' => \Auth::User()->getClasse()]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update() { return view('ecc.update'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } public function messages($page = 1) { if ($page < 1) { $page = 1; } $messages = \App\Message::all()->forPage($page,6); return view('ecc.messages',['messages' => $messages,'page'=>$page]); } public function message($id) { $messages = \App\Message::find($id); return view('ecc.message',['message' => $messages]); } public function guide() { return view('ecc.guide'); } public function calendar() { return view('ecc.calendar'); } public function generateCalendar() { $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 '
'.ucfirst(strftime("%B %Y", strtotime("01-".$month."-".$year))).'
'; echo '
Dimanche
Lundi
Mardi
Mercredi
Jeudi
Vendredi
Samedi
'; echo '
'; echo '
'; for ($i=0; $i < 6 ; $i++) { echo ''; } } public function calendar_date($date) { $schedules = \App\Schedule::all()->where('date',$date); return view('ecc.calendar_date',['schedules' => $schedules]); } public function booking($id,$niveau,$periode) { $schedule = Schedule::find($id); $periode_item = 'n'.$niveau.'_p'.$periode.'_item'; $periode_instr = 'n'.$niveau.'_p'.$periode.'_instructor'; if(\Auth::User()->id != $schedule->data[$periode_instr]) { abort(401); } $items = collect(); if (isset($schedule->$periode_item)) { $items_array = explode("-",$schedule->$periode_item); foreach ($items_array as $item_array) { if ($item_array != "") { $items->push(\App\Item::find($item_array)); } } } return view('ecc.booking',['schedule' => $schedule, 'periode' => $periode, 'niveau' => $niveau, 'items' => $items, 'dispo_item' => $schedule->getInventory($periode)]); } public function booking_add($id,$periode,$niveau) { $schedule = Schedule::find($id); $periode_item = 'n'.$niveau.'_p'.$periode.'_item'; if (isset($schedule->$periode_item)) { $array_items = explode("-",$schedule->$periode_item); array_push($array_items,request('add')); } else { $array_items = []; array_push($array_items,request('add')); } $final_items = implode("-",$array_items); $schedule->$periode_item = $final_items; $schedule->save(); return redirect('/ecc/inventory/'.$id.'/'.$niveau.'/'.$periode); } public function booking_remove($id,$periode,$niveau) { $schedule = Schedule::find($id); $remove = [request('remove')]; $periode_item = 'n'.$niveau.'_p'.$periode.'_item'; if (isset($schedule->$periode_item)) { $array_items = explode("-",$schedule->$periode_item); $array_items = array_diff($array_items,$remove); } else { $array_items = []; $array_items = array_diff($array_items,$remove); } $final_items = implode("-",$array_items); $schedule->$periode_item = $final_items; $schedule->save(); return redirect('/ecc/inventory/'.$id.'/'.$niveau.'/'.$periode); } }