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 create() { $menu = 'registration'; $generations = Generation::all(); $classifications = Classification::where('category', '=', 'Registration')->get(); $locations = Location::where('id', '<>', Auth::user()->location_id)->get(); $employees = Employee::all(); $courses = Course::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('availability', '=', 1)->where('active', '=', 1)->get(); $discounts = Discount::all(); $promotions = Promotion::all(); $vouchers = Voucher::all(); $charges = Charge::all(); $partners = Partner::where('location_id', '=', Auth::user()->location_id)->get(); return View::make('registrations.create', compact('classifications', 'locations', 'employees', 'generations', 'courses', 'charges', 'discounts', 'promotions', 'vouchers', 'partners', '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 index() { $discounts = Discount::all(); $menu = 'project'; return View::make('discounts.index', compact('discounts', 'menu')); }
public function ajaxDiscounts() { $i = Input::all(); $arr = []; $arr = getallheaders(); $count = null; if (isset($arr['Range'])) { $response_array = array(); $range = $arr['Range']; $response_array['Accept-Ranges'] = 'items'; $response_array['Range-Unit'] = 'items'; $arr = explode('-', $arr['Range']); $items = $arr[1] - $arr[0] + 1; $skip = $arr[0]; $skip = $skip < 0 ? 0 : $skip; $c = null; if (isset($_GET['query'])) { $query = $_GET['query']; if ($_GET['orderBy'] != '') { $orderBy = $_GET['orderBy']; $count = Discount::where('name', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%")->get()->count(); $c = Discount::where('name', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%")->orderBy("{$orderBy}", 'DESC')->skip($skip)->take($items)->get(); } else { $count = Discount::where('name', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%")->get()->count(); $c = Discount::where('name', 'LIKE', "%{$query}%")->orWhere('code', 'LIKE', "%{$query}%")->skip($skip)->take($items)->get(); } } else { $count = Discount::all()->count(); $c = Discount::skip($skip)->take($items)->get(); } $response = Response::make($c, 200); $response_array['Content-Ranges'] = 'items ' . $range . '/' . $count; $response->header('Content-Range', $response_array['Content-Ranges'])->header('Accept-Ranges', 'items')->header('Range-Unit', 'items')->header('Total-Items', $count)->header('Flash-Message', 'Now showing pages ' . $arr[0] . '-' . $arr[1] . ' out of ' . $count); return $response; } $c = Customer::all(); $response = Response::make($c, 200); $response->header('Content-Ranges', 'test'); return $response; }
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')); }