public function actionView($productId)
 {
     $categories = array();
     $categories = Platform::getPlatformList();
     $product = Products::getProductById($productId);
     $productId = $product['id'];
     $platform = Platform::getPlatformById($product['platform_id']);
     $comments = Comment::getCommentsByProductId($productId);
     //COMMENTS
     if (isset($_POST['submit'])) {
         $userComment = $_POST['message'];
         $errors = false;
         if (!Comment::validateMessage($userComment)) {
             $errors[] = "Введите собщение";
         }
         if (User::isGuest()) {
             $userName = $_POST['name'];
             $userEmail = $_POST['email'];
             if (!User::validateUsername($userName)) {
                 $errors[] = "Неверное имя";
             }
             if (!User::validateEmail($userEmail)) {
                 $errors[] = "Неверный Email";
             }
             $userId = false;
         } else {
             $userId = User::validateLogged();
             $user = User::getUserById($userId);
             $userName = $user['name'];
         }
         Comment::addComment($userComment, $userId, $userName, $productId);
     }
     require_once ROOT . '/views/product/view.php';
     return true;
 }
 public function actionIndex()
 {
     $platforms = array();
     $platforms = Platform::getPlatformList();
     $genres = array();
     $genres = Genre::getGenreList();
     $productList = array();
     $productList = Products::getProducts(6);
     require_once ROOT . '/views/site/index.php';
     return true;
 }
 public function actionGenre($genreId, $page = 1)
 {
     $platforms = array();
     $platforms = Platform::getPlatformList();
     $genres = array();
     $genres = Genre::getGenreList();
     $products = array();
     $products = Products::getProductsListByGenre($genreId, $page);
     $total = Products::getTotalProductInGenre($genreId);
     $pagination = new Pagination($total, $page, Products::SHOW_BY_DEFAULT, 'page-');
     require_once ROOT . '/views/catalog/category.php';
     return true;
 }
 public function actionOrder()
 {
     $platform = array();
     $errors = array();
     $userName = '';
     $userEmail = '';
     $userPhone = '';
     $userComment = '';
     $platform = Platform::getPlatformList();
     $result = false;
     if (isset($_POST['submit'])) {
         $userName = $_POST['name'];
         $userEmail = $_POST['email'];
         $userPhone = $_POST['phone'];
         $userComment = $_POST['message'];
         $errors = false;
         if (!User::validateUsername($userName)) {
             $errors[] = "Неверное имя";
         }
         if (!User::validateEmail($userEmail)) {
             $errors[] = "Неверный Email";
         }
         if (!User::validatePhone($userPhone)) {
             $errors[] = "Неккоректный телефон";
         }
         if ($errors == false) {
             $productsBasket = Basket::getProducts();
             if (User::isGuest()) {
                 $userId = false;
             } else {
                 $userId = User::validateLogged();
             }
             $result = Order::save($userName, $userEmail, $userPhone, $userComment, $userId, $productsBasket);
             if ($result) {
                 $adminEmail = "*****@*****.**";
                 $subject = "Новый заказ";
                 mail($adminEmail, $subject, $userComment);
                 Basket::clear();
             }
         } else {
             $productsInBasket = Basket::getProducts();
             $productId = array_keys($productsInBasket);
             $products = Products::getProductsByIdInBasket($productId);
             $totalPrice = Basket::getTotalPrice($products);
             $total = array_sum($totalPrice);
             $totalQuantity = Basket::countItem();
         }
     } else {
         $productsInbasket = Basket::getProducts();
         if ($productsInbasket == false) {
             header("Loaction: /");
         } else {
             $productId = array_keys($productsInbasket);
             $products = Products::getProductsByIdInBasket($productId);
             $totalPrice = Basket::getTotalPrice($products);
             $totalQuantity = Basket::countItem();
             $userName = false;
             $userEmail = false;
             $userPhone = false;
             $userComment = false;
             if (User::isGuest()) {
             } else {
                 $userId = User::validateLogged();
                 $user = User::getUserById($userId);
                 $userName = $user['name'];
                 $userEmail = $user['email'];
             }
         }
     }
     require_once ROOT . "/views/basket/order.php";
     return true;
 }