/** * loadCampaign function. * * @access public * * @param string $urn * * @return Campaign */ public function loadCampaign($urn) { $campaign = $this->model->where('urn', '=', $urn)->first(); if ($campaign) { return $campaign; } return false; }
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 static function now($pin, $uid, $method = 'pin') { $voucher = Voucher::where('pin', $pin)->firstOrFail(); $rc['voucher_id'] = $voucher->id; $rc['recharged_on'] = date('Y-m-d H:i:s'); $rc['aq_invocked'] = 0; $rc['expiration'] = AccessManager::makeExpiry($voucher->validity, $voucher->validity_unit, 'd M Y H:i'); $rc['time_limit'] = NULL; $rc['data_limit'] = NULL; if ($voucher->plan_type == 1) { //if limited $limit = $voucher->limits; // $rc['limit_type'] = $limit->limit_type; if ($limit->limit_type == 0 || $limit->limit_type == 2) { $rc['time_limit'] = $limit->time_limit * constant($limit->time_unit); } if ($limit->limit_type == 1 || $limit->limit_type == 2) { $rc['data_limit'] = $limit->data_limit * constant($limit->data_unit); } } $recharge = Recharge::firstOrNew(['user_id' => $uid]); $recharge->fill($rc); if (!$recharge->save()) { return FALSE; } $voucher->fill(['user_id' => $uid, 'method' => $method]); if (!$voucher->save()) { return FALSE; } return TRUE; }
private static function _generatePin() { $number = false; do { $number = mt_rand(1111111, 99999999999); $exists = Voucher::where('pin', '=', $number)->count(); } while ($exists); return $number; }
public function getActiveServices($user_id) { $profile = Subscriber::findOrFail($user_id); $plan = Subscriber::getActiveServices($profile); $framedIP = SubnetIP::where('user_id', $user_id)->first(); $framedRoute = UserRoute::where('user_id', $user_id)->first(); switch ($profile->plan_type) { case FREE_PLAN: case PREPAID_PLAN: $rc_history = Voucher::where('user_id', $user_id)->leftJoin('voucher_limits as l', 'l.id', '=', 'limit_id')->paginate(5); return View::make("admin.accounts.services")->with('profile', $profile)->with('rc_history', $rc_history)->with('plan', $plan)->with('framedIP', $framedIP)->with('framedRoute', $framedRoute); break; case ADVANCEPAID_PLAN: $rproducts = APRecurringProduct::where('user_id', $profile->id)->get(); $nrproducts = APNonRecurringProduct::where('user_id', $profile->id)->get(); return View::make('admin.accounts.services-ap2')->with('profile', $profile)->with('plan', $plan)->with('framedIP', $framedIP)->with('framedRoute', $framedRoute)->with('rproducts', $rproducts)->with('nrproducts', $nrproducts); break; } }
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')); }