Exemplo n.º 1
0
 public function addVisitor()
 {
     $response['age_group'] = getAgeGroup();
     $response['marital_status'] = getMaritalStatus();
     $response['dob_months'] = getDobMonths();
     $response['dob_days'] = getDobDays();
     $this->load->view('controlcentre/members/add_visitor', $response);
 }
Exemplo n.º 2
0
 public function check(Requests\EventSelectionRequest $request)
 {
     $doc_type = $request->get('doc_type');
     $doc_num = $request->get('doc_num');
     $gender = $request->get('gender');
     $dob = Carbon::parse($request->get('dob'));
     $race = Race::find($request->get('race_id'));
     $event = Event::find($request->get('event_id'));
     $payment = Payment::find($request->get('payment_id'));
     if (!($code = Code::where('code', $request->get('code'))->first())) {
         $code = Code::makeDummy();
     }
     if (!($gateway = Gateway::find($request->get('gateway_id')))) {
         $gateway = Gateway::makeDummy();
     }
     if (!($coupon = Coupon::where('coupon', $request->get('coupon'))->first())) {
         $coupon = Coupon::makeDummy();
     }
     if ($race->locality_enabled == true) {
         $locality = $code->getLocality();
         $mask = $event->mask;
         $event = Event::where([['race_id', $race->id], ['locality', $locality], ['mask', $mask]])->first();
     }
     if (!$event) {
         $age_group = getAgeGroup($race, $dob);
         $event = Event::find($age_group->event_id);
     } else {
         $age_group = getAgeGroup($race, $dob, $event);
     }
     //==== ALL MODELS AVAILABLE ====//
     // CHECK RUNNER AGE
     if ($error = checkRunnerAge($event, $age_group)) {
         return redirect($race->prefix . '/error')->with('age', $error);
     }
     // CHECK RUNNER GENDER
     if ($error = checkRunnerGender($event, $gender)) {
         return redirect($race->prefix . '/error')->with('gender', $error);
     }
     // CHECK RUNNER DOC
     if ($error = checkRunnerDoc($race, $doc_num)) {
         return redirect($race->prefix . '/error')->with('doc', $error);
     }
     // CHECK CODE
     if ($error = checkCode($payment, $event, $code, $request->get('code'))) {
         return redirect($race->prefix . '/error')->with('code', $error);
     }
     // CHECK COUPON
     if ($error = checkCoupon($coupon, $request->get('coupon'))) {
         return redirect($race->prefix . '/error')->with('coupon', $error);
     }
     // POPULATE TICKET
     if ($event->free_event == false) {
         if ($payment->id == 1) {
             $rate = $event->getCurrentRate();
             $transaction = new Transaction();
             $transaction->gateway_id = $gateway->id;
             $transaction->event_id = $event->id;
             $transaction->price = $rate->price;
             $transaction->coupon = $coupon->coupon;
             $transaction->discount = $coupon->calculateDiscount($transaction->price);
             $transaction->amount = $transaction->price - $transaction->discount;
             $transaction->save();
             $ticket = $transaction->id;
         } else {
             $ticket = $code->code;
             $transaction = Transaction::makeDummy();
         }
     } else {
         $ticket = $doc_num;
         $transaction = Transaction::makeDummy();
     }
     $type = $request->get('type');
     return redirect($race->prefix . '/runner')->with(['doc_type' => $doc_type, 'doc_num' => $doc_num, 'gender' => $gender, 'dob' => $dob, 'race_id' => $race->id, 'event_id' => $event->id, 'age_group_id' => $age_group->id, 'payment_id' => $payment->id, 'ticket' => $ticket, 'gateway_id' => $gateway->id, 'transaction_id' => $transaction->id, 'code_id' => $code->id, 'coupon_id' => $coupon->id, 'type' => $type]);
 }