Ejemplo n.º 1
0
 /**
  * @before _secure, _vendor
  */
 public function editPackage($package_id)
 {
     $this->seo(array("title" => "Edit Packages", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $package = Package::first(array("id = ?" => $package_id, "organization_id = ?" => $this->organization->id));
     if (!$package) {
         $this->redirect("/vendor");
     }
     $tests = Test::all(array(), array("id", "title"));
     $items = Item::all(array("package_id = ?" => $package->id));
     $sorted = array();
     foreach ($items as $i) {
         $sorted[$i->test_id] = $i;
     }
     $fields = $package->render();
     $errors = array();
     $view->set("fields", $fields);
     if (RequestMethods::post("action") == "savePackage") {
         foreach ($fields as $f) {
             $package->{$f}['name'] = RequestMethods::post($f['name']);
         }
         if ($package->validate()) {
             $package->save();
             $view->set("message", "Package Saved Successfully");
         } else {
             $errors = $package->errors;
         }
         $sorted = $this->_saveTests($package, $sorted);
     }
     $view->set("package", $package)->set("items", $sorted)->set("tests", $tests)->set("errors", $errors);
 }
Ejemplo n.º 2
0
 public function booking_form($package_id)
 {
     $view = $this->getActionView();
     $package = Package::first(array('id = ?' => $package_id));
     $view->set('package', $package);
     /*        if($this->user){
                 if(RequestMethods::){
     
                     
                 }
             }else{
                 
                echo "<script> alert('login first') </script>";
             }
     */
 }
Ejemplo n.º 3
0
 /**
  * @before _secure, _admin
  */
 public function editPackage($package_id)
 {
     $package = Package::first(array("id = ?" => $package_id));
     if (!$package) {
         $this->redirect("/admin");
     }
     $this->seo(array("title" => "Create Package", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $errors = array();
     if (RequestMethods::post("action") == "submitPackage") {
         $response = $this->_savePackage($package);
         if ($response["success"]) {
             $view->set("success", "Package is Updated");
         } else {
             $errors = $response["errors"];
         }
     }
     $items = Item::all(array(), array("id", "name"));
     $view->set("items", $items)->set("package", $package)->set("errors", $errors);
 }
Ejemplo n.º 4
0
 protected function addSubscription($transaction)
 {
     $package = Package::first(array("id = ?" => $transaction->property_id));
     $items = json_decode($package->item);
     $user = User::first(array("id = ?" => $transaction->user_id));
     $user->live = 1;
     $user->save();
     $days = (int) $package->period;
     foreach ($items as $key => $value) {
         $s = new Subscription(array("user_id" => $user->id, "item_id" => $value, "period" => $days, "expiry" => strftime("%Y-%m-%d", strtotime("+" . ($days + 1) . " Day")), "is_promo" => false));
         $s->save();
     }
     $this->session($user);
     $this->redirect('/member/index.html');
 }