public function getAdd()
 {
     $result['title'] = 'Shop';
     $result['action'] = '/promotion/add';
     $result['submit'] = 'add';
     $categories = $this->category->getCategories();
     $result['categories'][] = array('text' => 'No category', 'options' => array('value' => 0));
     foreach ($categories as $c) {
         $currentCategory = array();
         $currentCategory['text'] = $c['name'];
         $currentCategory['options'] = array('value' => $c['id']);
         $result['categories'][] = $currentCategory;
     }
     $products = $this->product->getProducts();
     $result['products'][] = array('text' => 'No product', 'options' => array('value' => 0));
     foreach ($products as $c) {
         $currentProduct = array();
         $currentProduct['text'] = $c['name'];
         $currentProduct['options'] = array('value' => $c['id']);
         $result['products'][] = $currentProduct;
     }
     View::make('promotion.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getUsers()
 {
     $result['users'] = $this->user->getUsersWithRoles();
     $result['title'] = 'Users';
     View::make('admin.roles', $result);
     View::appendTemplateToLayout('topBar', 'top_bar/user');
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getUsers()
 {
     $result['users'] = $this->user->getUsersWithRoles();
     $result['title'] = 'Shop';
     $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin'));
     $result['isAdmin'] = Auth::isUserInRole(array('admin'));
     View::make('admin.roles', $result);
     View::appendTemplateToLayout('topBar', 'top_bar/user');
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getEdit($id)
 {
     $result = array('city' => $this->city->getCity($id));
     $result['title'] = 'Edit city';
     $result['action'] = '/admin/city/' . $result['city']->id . '/edit';
     $result['submit'] = 'Edit';
     View::make('city.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getAdd($id)
 {
     $result['title'] = 'Send Messages';
     /* @var $estate \Models\ViewModels\EstateViewModel */
     $estate = $this->estate->getEstate($id);
     $result['estateInfo'] = 'ID: ' . $estate->id . '; Category: ' . $estate->category . '; Type: ' . ($estate->ad_type == 1 ? 'For Sale' : 'For Rent') . '; City: ' . $estate->city . '; Location: ' . $estate->location . '; Price: ' . $estate->price . ' EUR';
     View::make('message.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getAll()
 {
     $cart = array();
     if (Session::containKey('cart')) {
         $cart = Session::get('cart');
     }
     $result['title'] = 'Shop';
     $result['products'] = $this->getProductsFromCart($cart);
     $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin'));
     $result['isAdmin'] = Auth::isUserInRole(array('admin'));
     $result['user_cash'] = $this->user->getUserMoney(Auth::getUserId());
     View::make('cart', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->appendTemplateToLayout('catMenu', 'side_bar/category_menu')->render();
 }
 public function getProducts($id)
 {
     if (!(Auth::isUserInRole(array('admin')) || $id == Auth::getUserId())) {
         Redirect::back();
     }
     $result['products'] = $this->user->getProducts($id);
     $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin'));
     $result['isAdmin'] = Auth::isUserInRole(array('admin'));
     View::make('user.products', $result);
     View::appendTemplateToLayout('topBar', 'top_bar/user');
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getEdit($id)
 {
     $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin'));
     $result['isAdmin'] = Auth::isUserInRole(array('admin'));
     if ($result['isEditor']) {
         $result = array('product' => $this->product->getProductWitnUnavailable($id));
     } else {
         $result = array('product' => $this->product->getProduct($id));
     }
     $result['title'] = 'Shop';
     $result['action'] = '/product/edit/' . $result['product']['id'];
     $result['submit'] = 'edit';
     $categories = $this->category->getCategories();
     foreach ($categories as $c) {
         $currentCategory = array();
         $currentCategory['text'] = $c['name'];
         $currentCategory['options'] = array('value' => $c['id']);
         if ($id == $c['id']) {
             $currentCategory['options']['selected'] = 'true';
         }
         $result['categories'][] = $currentCategory;
     }
     View::make('product.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getEdit($id)
 {
     $result['title'] = 'Edit';
     /* @var $estate \Models\ViewModels\EstateViewModel */
     $estate = $this->estate->getEstate($id);
     if ($estate == null) {
         Session::setError('The estate id is incorrect');
         Redirect::to('');
     }
     $estate->images = $this->image->getImagesByEstate($id);
     foreach ($estate->images as $i) {
         $i->thumbnailName = $this->setImageThumb($i->name);
     }
     $result['estate'] = $estate;
     $result['action'] = '/admin/estate/' . $estate->id . '/edit';
     $result['submit'] = 'Edit';
     $result['categories'] = $this->setCategoryFormOptions($this->category->getCategories(), $estate);
     $result['cities'] = $this->setCityFormOptions($this->city->getCities(), $estate);
     View::make('estate.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getFavourites()
 {
     $result['title'] = 'User Favorites';
     $userFavourite = array();
     if (Auth::isAuth()) {
         $favorites = $this->user->getFavourites(Auth::getUserId());
         foreach ($favorites as $f) {
             $userFavourite[] = $f['estate_id'];
         }
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         $userFavourite = Session::get('favourites');
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     /* @var $estates \Models\ViewModels\EstateBasicViewModel[] */
     if (!empty($userFavourite)) {
         $estates = $this->estate->getFavoritesEstates($userFavourite);
         foreach ($estates as $estate) {
             $estate->image = EstateController::setEstateMainImage($estate);
             $estate->thumbnailName = EstateController::setImageThumb($estate->image);
         }
         $result['estates'] = $estates;
     } else {
         $result['estates'] = array();
     }
     View::make('user.favorites', $result);
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getEdit($id)
 {
     $result = array('category' => $this->category->getCategory($id));
     $result['title'] = 'Shop';
     $result['action'] = '/category/edit/' . $result['category']['id'];
     $result['submit'] = 'edit';
     View::make('category.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }