public function show($id)
 {
     $student = Issue::with('placements', 'placement', 'receivable.installments', 'educations', 'education', 'earnings', 'punishments', 'returnments', 'presences', 'points', 'retrievals', 'timelines', 'masteries')->find($id);
     $periods = Teach::with(array('presences' => function ($q) use($id) {
         $q->where('issue_id', '=', $id);
     }))->select(DB::raw('month(course_date) as months'), DB::raw('year(course_date) as years'))->groupBy(DB::raw('month(course_date)'))->get();
     $presences = array();
     foreach ($periods as $period) {
         $presences[] = array('month' => $period->months, 'year' => $period->years, 'presences' => $this->countPresences($id, $period->months, $period->years), 'presents' => $this->countPresents($id, $period->months, $period->years), 'absents' => $this->countAbsents($id, $period->months, $period->years), 'sicks' => $this->countSicks($id, $period->months, $period->years), 'permits' => $this->countPermits($id, $period->months, $period->years));
     }
     $points = array();
     foreach ($student->points as $point) {
         if ($point->pointable_type == 'Activity') {
             $points[] = array('date' => $point->pointable->agenda, 'event' => $point->pointable->name, 'point' => $point->point, 'lowest' => $this->getLowest($point->pointable_id), 'highest' => $this->getHighest($point->pointable_id));
         }
     }
     $handbooks = Handbook::where('project_id', '=', Auth::user()->curr_project_id)->where('generation_id', '=', $student->generation_id)->get();
     $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get();
     $discounts = Discount::all();
     $promotions = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $vouchers = Voucher::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $charges = Charge::where('project_id', '=', Auth::user()->curr_project_id)->get();
     $menu = 'student';
     return View::make('students.show', compact('student', 'handbooks', 'courses', 'discounts', 'promotions', 'vouchers', 'charges', 'presences', 'points', 'menu'));
 }
 public function destroy($id)
 {
     $retrieval = Retrieval::find($id);
     $handbook = Handbook::find($retrieval->handbook_id);
     $handbook->feasible = $handbook->feasible + 1;
     $handbook->save();
     Retrieval::destroy($id);
     Session::flash('message', 'Pengambilan Handbook telah dibatalkan');
 }
 public function destroy($id)
 {
     $handbook = Handbook::find($id);
     if ($handbook->retrievals()->count() > 0) {
         Session::flash('message', 'Data Handbook tidak dapat dihapus! Handbook ini pernah digunakan');
     } else {
         Handbook::destroy($id);
         Session::flash('message', 'Data Handbook telah dihapus');
     }
 }
 public function show($id)
 {
     $registration = Registration::has('issue')->has('receivable')->find($id);
     $handbooks = Handbook::where('project_id', '=', Auth::user()->curr_project_id)->where('generation_id', '=', $registration->issue->generation_id)->get();
     $menu = 'registration';
     return View::make('registrations.show', compact('menu', 'registration', 'handbooks'));
 }
 public function filterHandbookByIssue($issue_id)
 {
     $issue = Issue::find($issue_id);
     $handbooks = Handbook::where('project_id', '=', Auth::user()->curr_project_id)->where('generation_id', '=', $issue->generation_id)->get();
     return $handbooks;
 }