public function index()
 {
     $data = array();
     //last 3 blog posts
     $blogCollection = new BlogCollection();
     $lastBlogposts = $blogCollection->getAll(array(), 3, 0, array('id', 'DESC'));
     //random 6 tours
     $toursCollection = new ToursCollection();
     $randomTours = $toursCollection->getAll(array(), 6, 0, array('id', 'desc'), array(), 1);
     $data['lastBlogPosts'] = $lastBlogposts;
     $data['randomTours'] = $randomTours;
     $this->loadFrontView('landingPage', $data);
 }
Exemplo n.º 2
0
 public function index()
 {
     $data = array();
     $categoryId = isset($_GET['id']) ? $_GET['id'] : 0;
     $toursCollection = new ToursCollection();
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 6;
     $offset = $page ? ($page - 1) * $perPage : 0;
     if ($categoryId > 0) {
         $where = array('category_id' => $categoryId);
         $rows = count($toursCollection->getAll($where));
         $tours = $toursCollection->getAll($where, $offset, $perPage);
     } else {
         $rows = count($toursCollection->getAll());
         $tours = $toursCollection->getAll(array(), $offset, $perPage);
     }
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/index.php?c=tours&m=index&id=" . $categoryId);
     $data['pagination'] = $pagination;
     $data['tours'] = $tours;
     $this->loadFrontView('tours/listing', $data);
 }
 public function index()
 {
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $data = array();
     //users
     $userCollection = new UserCollection();
     $users = count($userCollection->getAll());
     //customers
     $clientCollection = new ClientsCollection();
     $client = count($clientCollection->getAll());
     //tours
     $toursCollection = new ToursCollection();
     $tours = count($toursCollection->getAll());
     //blog posts
     $blogpostCollection = new BlogCollection();
     $blogs = count($blogpostCollection->getAll());
     $data['users'] = $users;
     $data['client'] = $client;
     $data['tours'] = $tours;
     $data['blogs'] = $blogs;
     $this->loadView('dashboard', $data);
 }
Exemplo n.º 4
0
 public function index()
 {
     $data = array();
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $search = isset($_GET['search']) ? $_GET['search'] : '';
     if (trim($search) != '') {
         $like = array('name', htmlspecialchars(trim($search)));
     } else {
         $like = array();
     }
     $perPageSelect = isset($_GET['perPage']) ? (int) $_GET['perPage'] : 0;
     switch ($perPageSelect) {
         case 0:
             $perPage = 10;
             break;
         case 1:
             $perPage = 5;
             break;
         case 2:
             $perPage = 10;
             break;
         case 3:
             $perPage = 20;
             break;
         case 4:
             $perPage = 50;
             break;
         default:
             $perPage = 10;
     }
     $orderBy = isset($_GET['orderBy']) ? (int) $_GET['orderBy'] : 0;
     switch ($orderBy) {
         case 0:
             $order = array('id', 'DESC');
             break;
         case 1:
             $order = array('name', 'ASC');
             break;
         case 2:
             $order = array('name', 'DESC');
             break;
         case 3:
             $order = array('category_id', 'ASC');
             break;
         case 4:
             $order = array('category_id', 'DESC');
             break;
         default:
             $order = array('id', 'DESC');
     }
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $offset = $page ? ($page - 1) * $perPage : 0;
     $toursCollection = new ToursCollection();
     $rows = count($toursCollection->getAll(array(), -1, 0, $order, $like)) == 0 ? 1 : count($toursCollection->getAll(array(), -1, 0, $order, $like));
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/index.php?c=tour&m=index&perPage={$perPageSelect}&orderBy={$orderBy}&search={$search}");
     $tours = $toursCollection->getAll(array(), $offset, $perPage, $order, $like);
     $data['tours'] = $tours;
     $data['pagination'] = $pagination;
     $data['search'] = $search;
     $data['perPageSelect'] = $perPageSelect;
     $data['orderBy'] = $orderBy;
     $data['page'] = $page;
     $this->loadView('tours/listing', $data);
 }