/** * Generates the view for a specific schedule. * * Also used for a specific task (schedule without a related event). * * @param int $id * @return view scheduleViewById * @return Schedule $schedule * @return ScheduleEntry[] $entries */ public function showSchedule($id) { $schedule = Schedule::with('getClubEvent.getPlace')->findOrFail($id); if (!Session::has('userId') and (is_null($schedule->evnt_id) or $schedule->getClubEvent()->GetResults()->evnt_is_private == 1)) { Session::put('message', Config::get('messages_de.access-denied')); Session::put('msgType', 'danger'); return Redirect::action('MonthController@showMonth', array('year' => date('Y'), 'month' => date('m'))); } $entries = ScheduleEntry::where('schdl_id', '=', $id)->with('getJobType', 'getPerson.getClub')->get(); $clubs = Club::lists('clb_title', 'id'); $persons = Cache::remember('personsForDropDown', 10, function () { $timeSpan = new DateTime("now"); $timeSpan = $timeSpan->sub(DateInterval::createFromDateString('3 months')); return Person::whereRaw("prsn_ldap_id IS NOT NULL\n\t\t\t\t\t\t\t\t\t AND (prsn_status IN ('aktiv', 'kandidat')\n\t\t\t\t\t\t\t\t\t OR updated_at>='" . $timeSpan->format('Y-m-d H:i:s') . "')")->orderBy('clb_id')->orderBy('prsn_name')->get(); }); return View::make('scheduleViewById', compact('entries', 'schedule', 'clubs', 'persons')); }