public function actionCreate()
 {
     $model = new Point();
     $model->unsetAttributes();
     if (isset($_POST['Point'])) {
         $model->attributes = $_POST['Point'];
         $model->tv_schedule_blocks = '';
         $TVshceduleFromDatetime = array();
         $TVshceduleToDatetime = array();
         if (isset($_POST['Point']['TVshceduleFromDatetime']) && isset($_POST['Point']['TVshceduleToDatetime'])) {
             $TVshceduleFromDatetime = $_POST['Point']['TVshceduleFromDatetime'];
             $TVshceduleToDatetime = $_POST['Point']['TVshceduleToDatetime'];
         }
         if ($model->save()) {
             $modelId = $model->getPrimaryKey();
             $this->CreateTVBlocks($modelId, $TVshceduleFromDatetime, $TVshceduleToDatetime);
             $model->SendRequestForUpdate($model->ip);
             $model->PrepareFilesForSync($model->getPrimaryKey());
             $model->CreateChannelsForWindows($model->screen_id, $model->id);
             $this->redirect(['point/update', 'id' => $model->id]);
         } else {
             $this->render('create', array('model' => $model));
         }
     } else {
         $this->render('create', array('model' => $model));
     }
 }
 public function store()
 {
     $issues = Input::get('issues');
     $points = Input::get('points');
     if ($this->quizzed(Input::get('course_id'), Input::get('subject_id'), Input::get('quiz_date'))) {
         $quiz = Quiz::where('course_id', '=', Input::get('course_id'))->where('subject_id', '=', Input::get('subject_id'))->where('quiz_date', '=', Input::get('quiz_date'))->first();
     } else {
         $quiz = new Quiz();
         $quiz->project_id = Auth::user()->curr_project_id;
         $quiz->location_id = Auth::user()->location_id;
         $quiz->course_id = Input::get('course_id');
         $quiz->subject_id = Input::get('subject_id');
         $quiz->employee_id = Input::get('employee_id');
         $quiz->name = Input::get('name');
         $quiz->quiz_date = Input::get('quiz_date');
         $quiz->save();
     }
     for ($i = 0; $i < count($issues); $i++) {
         if (!$this->existed('Quiz', $quiz->id, $issues[$i])) {
             $point = new Point();
             $point->project_id = Auth::user()->curr_project_id;
             $point->location_id = Auth::user()->location_id;
             $point->issue_id = $issues[$i];
             $point->pointable_type = 'Quiz';
             $point->pointable_id = $quiz->id;
             $point->point = $points[$i];
             $point->save();
         }
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Point();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Point'])) {
         $model->attributes = $_POST['Point'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function store()
 {
     $issues = Input::get('issues');
     $points = Input::get('points');
     $activity_id = Input::get('activity_id');
     for ($i = 0; $i < count($issues); $i++) {
         if (!$this->existed('Activity', $activity_id, $issues[$i])) {
             $point = new Point();
             $point->project_id = Auth::user()->curr_project_id;
             $point->location_id = Auth::user()->location_id;
             $point->issue_id = $issues[$i];
             $point->pointable_type = 'Activity';
             $point->pointable_id = $activity_id;
             $point->point = $points[$i];
             $point->save();
         }
     }
     Session::flash('message', 'Suskes menyetorkan Nilai Baru!');
 }
 private function add_daily_comment_points()
 {
     $user_id = Auth::user()->id;
     $LastCommentPoints = Point::where('user_id', '=', $user_id)->where('description', '=', Lang::get('lang.daily_comment'))->orderBy('created_at', 'desc')->take(5)->get();
     $total_daily_comments = 0;
     foreach ($LastCommentPoints as $CommentPoint) {
         if (date('Ymd') == date('Ymd', strtotime($CommentPoint->created_at))) {
             $total_daily_comments += 1;
         }
     }
     if ($total_daily_comments < 5) {
         $point = new Point();
         $point->user_id = $user_id;
         $point->description = Lang::get('lang.daily_comment');
         $point->points = 1;
         $point->save();
         return true;
     } else {
         return false;
     }
 }
Exemple #6
0
 private function add_user_login_point()
 {
     $user_id = Auth::user()->id;
     $LastLoginPoints = Point::where('user_id', '=', $user_id)->where('description', '=', Lang::get('lang.daily_login'))->orderBy('created_at', 'desc')->first();
     if (!isset($LastLoginPoints) || date('Ymd') != date('Ymd', strtotime($LastLoginPoints->created_at))) {
         $point = new Point();
         $point->user_id = $user_id;
         $point->description = Lang::get('lang.daily_login');
         $point->points = 5;
         $point->save();
         return true;
     } else {
         return false;
     }
 }
Exemple #7
0
 public function add_admin_user()
 {
     if (Request::ajax()) {
         try {
             $user = User::first();
             if ($user) {
                 return Redirect::to('/');
             } else {
                 throw new Exception('We cannot detect any current user. Okay to add new admin');
             }
         } catch (Exception $e) {
             $admin_username = Input::get('admin_username');
             $admin_email = Input::get('admin_email');
             $admin_password = Hash::make(Input::get('admin_password'));
             $user = new User();
             $user->username = $admin_username;
             $user->email = $admin_email;
             $user->password = $admin_password;
             $user->admin = 1;
             $new_user = $user->save();
             $point = new Point();
             $point->user_id = $user->id;
             $point->points = 200;
             $point->description = Lang::get('lang.registration');
             $point->save();
             if ($new_user) {
                 Auth::attempt(array('email' => Input::get('admin_email'), 'password' => Input::get('admin_password')));
                 echo true;
             } else {
                 echo false;
             }
         }
     } else {
         echo false;
     }
 }
 public function recharge()
 {
     $v = Validator::make(Input::all(), ["code" => "required|size:22"], ["required" => "<span class='glyphicon glyphicon-exclamation-sign'></span> Please typr the code.", "size" => "<span class='glyphicon glyphicon-exclamation-sign'></span> Invalid code"]);
     if ($v->fails()) {
         return Redirect::back()->withErrors($v)->withInput();
     }
     $find = Product::where("code", Input::get("code"));
     if ($find->count() > 0) {
         // Give the point associated with the code
         $point = $find->get()->first()->point;
         $p = new Point();
         $p->user_id = Auth::user()->id;
         $p->point = $point;
         $p->product_id = $find->get()->first()->id;
         $p->save();
         // Set user's designation
         $active_member = User::find(Auth::user()->id);
         $active_member->designation = "Active member";
         $active_member->save();
         // Remove the code from product. So that any user can't use the same code twice.
         $find->update(["code" => ""]);
         // If the user has 1000 points then add amount 500
         $how_many_points = Point::where('user_id', Auth::user()->id)->sum('point');
         if ($how_many_points >= 1000) {
             // Set the user's designation to Model member
             $model_member = User::find(Auth::user()->id);
             $model_member->designation = "Model member";
             $model_member->save();
             // Check the user's referal is an admin or not
             $my_referal = User::find(Auth::user()->referal_id);
             if ($my_referal->type == 'admin') {
                 $distributed_amount = 600;
             } else {
                 $distributed_amount = 300;
             }
             Amount::create(['user_id' => Auth::user()->id, 'amount' => 500, 'status' => 1]);
             Amount::create(['user_id' => Auth::user()->referal_id, 'amount' => $distributed_amount]);
             Point::where('user_id', Auth::user()->id)->delete();
         }
         return Redirect::back()->with("event", "<p class='alert alert-success'><span class='glyphicon glyphicon-ok'></span> Congratulation! You got " . $point . " points.</p>");
     }
     return Redirect::back()->with("event", "<p class='alert alert-danger'><span class='glyphicon glyphicon-exclamation-sign'></span> Invalid code.</p>");
 }
Exemple #9
0
 public function success()
 {
     $this->seo(array("title" => "Thank You", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $configuration = Registry::get("configuration");
     $payment_request_id = RequestMethods::get("payment_request_id");
     if ($payment_request_id) {
         $instamojo = Instamojo::first(array("payment_request_id = ?" => $payment_request_id));
         if ($instamojo) {
             $imojo = $configuration->parse("configuration/payment");
             $curl = new Curl();
             $curl->setHeader('X-Api-Key', $imojo->payment->instamojo->key);
             $curl->setHeader('X-Auth-Token', $imojo->payment->instamojo->auth);
             $curl->get('https://www.instamojo.com/api/1.1/payment-requests/' . $payment_request_id . '/');
             $payment = $curl->response;
             $instamojo->status = $payment->payment_request->status;
             $instamojo->save();
             $order = Order::first(array("id = ?" => $instamojo->purpose_id));
             $order->ref_id = $instamojo->id;
             $order->save();
             $appointments = Appointment::all(array("order_id = ?" => $order->id), array("id"));
             foreach ($appointments as $appointment) {
                 $appointment = Appointment::first(array("id = ?" => $appointment->id));
                 $appointment->live = 1;
                 $appointment->save();
             }
             $user = User::first(array("id = ?" => $instamojo->user_id));
             $point = new Point(array("user_id" => $instamojo->user_id, "property" => "appointment", "property_id" => $instamojo->purpose_id, "unit" => 0.01 * ($order->amount / 1.12)));
             $point->save();
             $this->generateinvoice($order->id, $instamojo->id);
             Shared\Services\Mail::notify(array("template" => "confirmAppointment", "subject" => "Appointment Confirmed", "appointment" => $appointment, "instamojo" => $instamojo, "point" => $point, "user" => $user, "attachment" => APP_PATH . "/public/assets/uploads/files/orders/{$order->id}.pdf"));
         }
     }
 }