예제 #1
0
 public function actionIndex()
 {
     $product_count_main_page = FL::fileGetContents('product_count_main_page.txt');
     $product_count_catalog_page = FL::fileGetContents('product_count_catalog_page.txt');
     $product_count_category_page = FL::fileGetContents('product_count_category_page.txt');
     if (isset($_POST['submit'])) {
         if (isset($_POST['productCountMainPage'])) {
             $productCountMainPage = FL::clearInt($_POST['productCountMainPage']);
             AdminModel::filePutContents(ROOT . '/config/product_count_main_page.txt', $productCountMainPage);
         }
         if (isset($_POST['productCountCatalogPage'])) {
             $productCountCatalogPage = FL::clearInt($_POST['productCountCatalogPage']);
             AdminModel::filePutContents(ROOT . '/config/product_count_catalog_page.txt', $productCountCatalogPage);
         }
         if (isset($_POST['productCountCategoryPage'])) {
             $productCountCategoryPage = FL::clearInt($_POST['productCountCategoryPage']);
             AdminModel::filePutContents(ROOT . '/config/product_count_category_page.txt', $productCountCategoryPage);
         }
         FL::redirectTo('/admin/view');
     }
     $view = new View();
     $view->product_count_main_page = $product_count_main_page;
     $view->product_count_catalog_page = $product_count_catalog_page;
     $view->product_count_category_page = $product_count_category_page;
     $view->display('admin_view/index.php');
     return true;
 }
예제 #2
0
 public function actionDelete($id)
 {
     if ($id) {
         ProductOrderModel::delete($id);
         FL::redirectTo('/admin/order');
     }
     return true;
 }
예제 #3
0
 public function actionDelete($id)
 {
     $product = ProductModel::getById($id);
     if (isset($_POST['delNo'])) {
         FL::redirectTo('/admin/product');
     }
     if (isset($_POST['delYes'])) {
         $result = ProductModel::delete($id);
         if ($result) {
             FL::redirectTo('/admin/product');
         }
     }
     $view = new View();
     $view->product = $product;
     $view->display('admin_product/delete.php');
     return true;
 }
예제 #4
0
 public function actionEdit($id)
 {
     $id = (int) $id;
     $name = '';
     $password = '';
     $errors = [];
     $user = UserModel::getUser('user');
     if (!$user) {
         FL::redirectTo('/');
     }
     $categories = CategoryModel::getAllUsingColumns();
     if (isset($_POST['submit'])) {
         $name = FL::clearStr($_POST['name']);
         $password = FL::clearStr($_POST['password']);
         if (!FL::isValue($name)) {
             $errors[] = 'Имя не может быть пустым';
         }
         if (!FL::isPassword($password)) {
             $errors[] = 'Пароль должен быть больше 5 символов';
         }
         if (empty($errors)) {
             $user = UserModel::getById($id);
             $user->name = $name;
             $user->password = $password;
             Session::deleteSession('user');
             Cookie::deleteCookie('user');
             $result = $user->save(false, true);
             if ($result) {
                 FL::redirectTo('/cabinet');
             }
         }
     }
     $view = new View();
     $view->categories = $categories;
     $view->id = $id;
     $view->errors = $errors;
     $view->password = $password;
     $view->user = $user;
     $view->display('cabinet/edit.php');
     return true;
 }
예제 #5
0
 public function actionDelete($id)
 {
     UserModel::delete($id);
     FL::redirectTo('/admin/user');
     return true;
 }
예제 #6
0
 public function actionOrder()
 {
     $userName = '';
     $errors = [];
     $categories = CategoryModel::getAllUsingColumns();
     $productsKeysArray = Session::getSession('products');
     if ($productsKeysArray) {
         $keysArray = array_keys($productsKeysArray);
         $keysString = implode(',', $keysArray);
         if ($keysString) {
             $products = ProductModel::getAll($keysString);
             $amountPrice = CartModel::amountProductsPriceInCart($productsKeysArray, $products);
         }
     }
     $user = UserModel::getUser('user');
     if ($user) {
         $userName = $user->name;
         $userId = $user->id;
     } else {
         $userId = 0;
     }
     if (isset($_POST['submit'])) {
         $name = FL::clearStr($_POST['name']);
         $phone = FL::clearStr($_POST['phone']);
         $comment = FL::clearStr($_POST['comment']);
         if (!FL::isValue($name)) {
             $errors[] = 'Имя не может быть пустым';
         }
         if (!FL::isValue($phone)) {
             $errors[] = 'Телефон не может быть пустым';
         }
         if (!FL::isPhone($phone)) {
             $errors[] = 'Невалидный телефон';
         }
         if (!FL::isValue($comment)) {
             $errors[] = 'Комментарий не может быть пустым';
         }
         if (empty($errors)) {
             $productsKeysArray = Session::getSession('products');
             if ($productsKeysArray) {
                 $products = json_encode($productsKeysArray);
             }
             $cart = new CartModel();
             $cart->user_name = $name;
             $cart->user_phone = $phone;
             $cart->user_comment = $comment;
             $cart->user_id = $userId;
             $cart->products = $products;
             $orderId = $cart->save();
             if ($orderId) {
                 Session::deleteSession('products');
                 Session::createSession('message', 'Заказ оформлен!');
                 FL::redirectTo('/cart');
             }
         }
     } else {
         $countProducts = CartModel::countProductsInCart();
         if ($countProducts <= 0) {
             FL::redirectTo('/');
         }
     }
     $view = new View();
     $view->categories = $categories;
     $view->amountPrice = $amountPrice;
     $view->userName = $userName;
     $view->errors = $errors;
     $view->display('cart/order.php');
     return true;
 }
예제 #7
0
 public function actionDelete($id)
 {
     $blog = BlogModel::delete($id);
     if ($blog) {
         FL::redirectTo('/admin/blog');
     }
     return true;
 }
예제 #8
0
 public function actionLogout()
 {
     Session::deleteSession('user');
     Cookie::deleteCookie('user');
     FL::redirectTo('/');
 }
예제 #9
0
 public function actionDelete($id)
 {
     CategoryModel::delete($id);
     FL::redirectTo('/admin/category');
     return true;
 }