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 loadReductions($what)
 {
     switch ($what) {
         case 'Promotion':
             $responses = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
         case 'Voucher':
             $responses = Voucher::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
         case 'Discount':
             $responses = Discount::all();
             break;
         case 'Charge':
             $responses = Charge::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
         default:
             $responses = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
             break;
     }
     return $responses;
 }
 public function reductionsFilter($types, $id)
 {
     $reductable_type = $types;
     $reduction_id = $id;
     $reductions = Reduction::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('reductable_type', '=', $reductable_type)->where('reductable_id', '=', $reduction_id)->get();
     switch ($reductable_type) {
         case 'Promotion':
             $discounts = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
             $discount = Promotion::find($reduction_id);
             break;
         case 'Voucher':
             $discounts = Voucher::where('project_id', '=', Auth::user()->curr_project_id)->get();
             $discount = Voucher::find($reduction_id);
             break;
         case 'Discount':
             $discounts = Discount::all();
             $discount = Discount::find($reduction_id);
             break;
         case 'Charge':
             $discounts = Charge::where('project_id', '=', Auth::user()->curr_project_id)->get();
             $discount = Charge::find($reduction_id);
             break;
         default:
             $discounts = Promotion::where('project_id', '=', Auth::user()->curr_project_id)->get();
             $discount = Promtion::find($reduction_id);
             break;
     }
     $menu = 'report';
     return View::make('reports.reductions', compact('reductable_type', 'reduction_id', 'reductions', 'discounts', 'discount', 'menu'));
 }