Ejemplo n.º 1
0
 public function packages()
 {
     $view = $this->getActionView();
     $states = State::all();
     $view->set('states', $states);
     $source = RequestMethods::get('source');
     $source_state = State::first(array('id = ?' => $source));
     $dest = RequestMethods::get('dest');
     $dest_state = State::first(array('id = ?' => $dest));
     $month = RequestMethods::get('month');
     $year = RequestMethods::get('year');
     $page = RequestMethods::get('page', 1);
     $limit = 9;
     if (RequestMethods::get('source')) {
         $count = Package::count(array('source Like ?' => $source, 'destination Like ?' => $dest, 'month = ?' => $month, 'year = ?' => $year));
         $total_pages = $count / 9 + 1;
         for ($i = 1; $i <= $total_pages; $i++) {
             $pages[$i] = $i;
         }
         $packages = Package::all(array('source Like ?' => $source, 'destination Like ?' => $dest, 'month = ?' => $month, 'year = ?' => $year, 'live = ?' => 1), array("*"), null, null, $limit, $page);
         $view->set('n', 'http://planyourtours.io/travels/packages?source=' . $source . '&dest=' . $dest . '&type=Group&month=' . $month . '&year=' . $year . '&page=')->set('source', $source_state)->set('dest', $dest_state)->set('month', $month)->set('year', $year);
     } else {
         $count = Package::count();
         $total_pages = $count / 9 + 1;
         for ($i = 1; $i <= $total_pages; $i++) {
             $pages[$i] = $i;
         }
         $packages = Package::all(array('live = ?' => 1), array("*"), null, null, $limit, $page);
         $view->set('n', 'http://planyourtours.io/travels/packages?&page=');
     }
     if (!empty($packages)) {
         $view->set('packages', $packages)->set('pages', $pages);
     }
 }
 public function __construct()
 {
     $this->header("Content-Type: text/html; charset=utf-8");
     $this->total_packages = Package::count();
     $this->sidebar = array();
     $this->title = '';
     if ($this->is_logged_in()) {
         $this->login_user();
     }
 }
 public function testDeleteBobsPackage()
 {
     $_SERVER['SERVER_NAME'] = 'bob.localhost.com';
     $count = Package::count();
     $v_count = Version::count();
     $p = Package::find_by_name('bobs_other_package');
     $versions = $p->count('versions');
     $this->delete('delete', array(), array('id' => $p->id), array('user' => User::find_by_username('bob')->id));
     $this->assertEquals($count - 1, Package::count(array('cache' => false)));
     $this->assertEquals($v_count - $versions, Version::count(array('cache' => false)));
     $this->assertRedirect('/');
 }
Ejemplo n.º 4
0
 public function popularPackages()
 {
     $this->seo(array("title" => "Popular Packages", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $organizations = Organization::all(array("live = ?" => true), array("id", "name"));
     $limit = RequestMethods::get("limit", 10);
     $page = RequestMethods::get("page", 1);
     $packages = Package::all(array("live = ?" => 1), array("title", "organization_id", "charge", "id"), "created", "desc", $limit, $page);
     $total = (int) Package::count(array("live = ?" => 1));
     $results = array();
     foreach ($packages as $p) {
         $data = array("title" => $p->title, "lab" => $organizations[$p->organization_id]->name, "lab_id" => $p->organization_id, "charge" => $p->charge, "id" => $p->id);
         $results[] = ArrayMethods::toObject($data);
     }
     $view->set("packages", $results)->set("total", $total);
 }
Ejemplo n.º 5
0
 /**
  * @before _secure, changeLayout
  */
 public function create_package()
 {
     $this->seo(array("title" => "Dashboard", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $states = State::all();
     $view->set('states', $states);
     if (RequestMethods::post('name')) {
         $imageFileType1 = pathinfo($_FILES["package1"]["name"], PATHINFO_EXTENSION);
         if (!empty($_FILES["package2"]["name"])) {
             $imageFileType2 = pathinfo($_FILES["package2"]["name"], PATHINFO_EXTENSION);
         } else {
             $imageFileType2 = NULL;
         }
         if (!empty($_FILES["package3"]["name"])) {
             $imageFileType3 = pathinfo($_FILES["package3"]["name"], PATHINFO_EXTENSION);
         } else {
             $imageFileType3 = NULL;
         }
         if (!empty($_FILES["package4"]["name"])) {
             $imageFileType4 = pathinfo($_FILES["package4"]["name"], PATHINFO_EXTENSION);
         } else {
             $imageFileType4 = NULL;
         }
         if (!empty($_FILES["package5"]["name"])) {
             $imageFileType5 = pathinfo($_FILES["package5"]["name"], PATHINFO_EXTENSION);
         } else {
             $imageFileType5 = NULL;
         }
         $package = new Package(array('name' => RequestMethods::post('name'), 'source' => RequestMethods::post('source'), 'destination' => RequestMethods::post('dest'), 'desc' => RequestMethods::post('desc'), 'start_date' => RequestMethods::post('startdate'), 'end_date' => RequestMethods::post('enddate'), 'month' => RequestMethods::post('month'), 'year' => RequestMethods::post('year'), 'price' => RequestMethods::post('price'), 'people' => RequestMethods::post('people'), 'people_left' => RequestMethods::post('people'), 'imgext1' => $imageFileType1, 'imgext2' => $imageFileType2, 'imgext3' => $imageFileType3, 'imgext4' => $imageFileType4, 'imgext5' => $imageFileType5));
         if ($package->validate()) {
             $package->save();
             $view->set('success', 'success');
             $count = Package::count();
             $target_dir = "/public/uploads/packages/";
             $target_file = APP_PATH . $target_dir . $count . '_';
             $img = 0;
             // Check if image file is a actual image or fake image
             $check = getimagesize($_FILES["package1"]["tmp_name"]);
             if ($check !== false) {
                 $img++;
             }
             if ($imageFileType1 != "jpg" && $imageFileType1 != "png" && $imageFileType1 != "jpeg" && $_FILES["package"]["size"] > 5000000) {
                 $img--;
             }
             if ($img == 1) {
                 $flag = 0;
                 if (move_uploaded_file($_FILES["package1"]["tmp_name"], $target_file . '1.' . $imageFileType1)) {
                     $flag++;
                 }
                 if ($flag == 1) {
                 } else {
                     $view->set('errorimg', 'Error in first image. Not uploaded');
                 }
             }
             if (!empty($imageFileType2)) {
                 $img = 0;
                 // Check if image file is a actual image or fake image
                 $check = getimagesize($_FILES["package2"]["tmp_name"]);
                 if ($check !== false) {
                     $img++;
                 }
                 if ($imageFileType2 != "jpg" && $imageFileType2 != "png" && $imageFileType2 != "jpeg" && $_FILES["package2"]["size"] > 5000000) {
                     $img--;
                 }
                 if ($img == 1) {
                     $flag = 0;
                     if (move_uploaded_file($_FILES["package2"]["tmp_name"], $target_file . '2.' . $imageFileType2)) {
                         $flag++;
                     }
                     if ($flag == 1) {
                     } else {
                         $view->set('errorimg', 'Error in second image. Not uploaded');
                     }
                 }
             }
             if (!empty($imageFileType3)) {
                 $img = 0;
                 // Check if image file is a actual image or fake image
                 $check = getimagesize($_FILES["package3"]["tmp_name"]);
                 if ($check !== false) {
                     $img++;
                 }
                 if ($imageFileType3 != "jpg" && $imageFileType3 != "png" && $imageFileType3 != "jpeg" && $_FILES["package3"]["size"] > 5000000) {
                     $img--;
                 }
                 if ($img == 1) {
                     $flag = 0;
                     if (move_uploaded_file($_FILES["package3"]["tmp_name"], $target_file . '3.' . $imageFileType3)) {
                         $flag++;
                     }
                     if ($flag == 1) {
                     } else {
                         $view->set('errorimg', 'Error in third image. Not uploaded');
                     }
                 }
             }
             if (!empty($imageFileType4)) {
                 $img = 0;
                 // Check if image file is a actual image or fake image
                 $check = getimagesize($_FILES["package4"]["tmp_name"]);
                 if ($check !== false) {
                     $img++;
                 }
                 if ($imageFileType4 != "jpg" && $imageFileType4 != "png" && $imageFileType4 != "jpeg" && $_FILES["package4"]["size"] > 5000000) {
                     $img--;
                 }
                 if ($img == 1) {
                     $flag = 0;
                     if (move_uploaded_file($_FILES["package4"]["tmp_name"], $target_file . '4.' . $imageFileType4)) {
                         $flag++;
                     }
                     if ($flag == 1) {
                     } else {
                         $view->set('errorimg', 'Error in fourth image. Not uploaded');
                     }
                 }
             }
             if (!empty($imageFileType5)) {
                 $img = 0;
                 // Check if image file is a actual image or fake image
                 $check = getimagesize($_FILES["package5"]["tmp_name"]);
                 if ($check !== false) {
                     $img++;
                 }
                 if ($imageFileType5 != "jpg" && $imageFileType5 != "png" && $imageFileType5 != "jpeg" && $_FILES["package5"]["size"] > 5000000) {
                     $img--;
                 }
                 if ($img == 1) {
                     $flag = 0;
                     if (move_uploaded_file($_FILES["package5"]["tmp_name"], $target_file . '5.' . $imageFileType5)) {
                         $flag++;
                     }
                     if ($flag == 1) {
                     } else {
                         $view->set('errorimg', 'Error in fifth image. Not uploaded');
                     }
                 }
             }
         } else {
             echo 'validation not good';
         }
     }
 }
 public function attach()
 {
     $member_id = Request::segment(3);
     $member = Member::find($member_id);
     if (empty($member) || !is_object($member)) {
         return Redirect::to('members')->with("error", "Member doesnt exists.");
     }
     $this->data['packages'] = Package::all();
     if (Package::count() == 0) {
         return Redirect::to('members/packages/' . $member_id)->with("error", "No Available Packages.");
     }
     $this->data['member'] = $member;
     return $this->layout->content = View::make('members_packages_attach', $this->data);
 }