Example #1
0
 public function actionEdit()
 {
     $categories = Category::getCategoryList();
     if (!$categories) {
         $categories = array();
     }
     $email = User::isLogged();
     $user = User::getUserByEmail($email);
     $name = $user['name'];
     $password = '';
     $result = '';
     if (isset($_POST['submit'])) {
         $name = FunctionLibrary::clearStr($_POST['name']);
         $password = FunctionLibrary::clearStr($_POST['password']);
         $errors = array();
         if (!User::checkName($name)) {
             $errors[] = 'Имя должно быть больше 1 символа.';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль должен быть больше 5 символов.';
         }
         if (empty($errors)) {
             $result = User::edit($user['id'], $name, $password);
         }
     }
     require_once ROOT . '/views/cabinet/edit.php';
     return true;
 }
Example #2
0
 public function actionContact()
 {
     $categories = Category::getCategoryList();
     if (!$categories) {
         $categories = array();
     }
     $email = '';
     $subject = '';
     $message = '';
     $result = '';
     if (isset($_POST['submit'])) {
         $email = FunctionLibrary::clearStr($_POST['email']);
         $subject = FunctionLibrary::clearStr($_POST['subject']);
         $message = FunctionLibrary::clearStr($_POST['message']);
         $errors = array();
         if (!User::checkEmail($email)) {
             $errors[] = 'Невалидный Email.';
         }
         if (!User::checkName($subject)) {
             $errors[] = 'Тема должна быть больше 1 символа.';
         }
         if (!User::checkName($message)) {
             $errors[] = 'Сообщение должно быть больше 1 символа.';
         }
         if (empty($errors)) {
             $adminEmail = '*****@*****.**';
             $sub = "Тема письма: {$subject}. От: {$email}";
             $mess = "Текст письма: {$message}";
             $result = mail($adminEmail, $sub, $mess);
         }
     }
     require_once ROOT . '/views/site/contact.php';
     return true;
 }
 public function actionView($productId)
 {
     $categores = array();
     $categores = Category::getCategoryList();
     // Получаем инфомрацию о товаре
     $product = Product::getProductById($productId);
     require_once ROOT . '/sourse/views/product/view.php';
     return true;
 }
Example #4
0
 public function actionIndex()
 {
     $categores = array();
     $categores = Category::getCategoryList();
     $lastProduct = array();
     $lastProduct = Product::getLatestProducts();
     require_once ROOT . '/sourse/views/index.php';
     return true;
 }
 public function actionCategory($categoryId)
 {
     $categories = Category::getCategoryList();
     $categoriesPhoto = Category::getCategoryGallery();
     $allPhotos = Gallery::getPhotoListByCategoryId($categoryId);
     // Подключаем вид
     require_once ROOT . '/views/photo/view.php';
     return true;
 }
 public function actionUpdate($id)
 {
     $categories = Category::getCategoryList(false);
     if (!$categories) {
         $categories = array();
     }
     $product = Product::getProductById($id, false);
     if (!$product) {
         $product = array();
     }
     if (isset($_POST['submit'])) {
         $options['name'] = FunctionLibrary::clearStr($_POST['name']);
         $options['code'] = FunctionLibrary::clearStr($_POST['code']);
         $options['price'] = FunctionLibrary::clearStr($_POST['price']);
         $options['brand'] = FunctionLibrary::clearStr($_POST['brand']);
         $options['category_id'] = FunctionLibrary::clearStr($_POST['category_id']);
         $options['availability'] = FunctionLibrary::clearStr($_POST['availability']);
         $options['is_new'] = FunctionLibrary::clearStr($_POST['is_new']);
         $options['is_recommended'] = FunctionLibrary::clearStr($_POST['is_recommended']);
         $options['status'] = FunctionLibrary::clearStr($_POST['status']);
         $options['description'] = FunctionLibrary::clearStr($_POST['description']);
         $errors = array();
         if (!User::checkName($options['name'])) {
             $errors[] = 'Название товара должно быть больше 1 символа.';
         }
         if (empty($errors)) {
             if ($id) {
                 $result = Product::updateProductById($id, $options);
                 if (!$result) {
                     $message = 'Произошла ошибка при редактировании.';
                 } else {
                     if (!empty($_FILES['image']['tmp_name'])) {
                         $tmpName = $_FILES['image']['tmp_name'];
                         if (is_uploaded_file($tmpName)) {
                             /*
                                Следующие две строки для того
                                чтобы иметь возможность поменять
                                картинку no-image в базе
                                (а не то меняется только картинка в папке)
                             */
                             $imagePath = "/images/home/product{$id}.jpg";
                             $result = Product::putImageToDataBase($id, $imagePath);
                             if ($result) {
                                 $destination = $_SERVER['DOCUMENT_ROOT'] . "/template" . $imagePath;
                                 move_uploaded_file($tmpName, $destination);
                             }
                         }
                     }
                     FunctionLibrary::redirectTo('admin/product');
                 }
             }
         }
     }
     require_once ROOT . '/views/admin_product/update.php';
     return true;
 }
 /**
  * Action для главной страницы
  */
 public function actionIndex()
 {
     // Список категорий для левого меню
     $categories = Category::getCategoryList();
     //        $categories2 = Category::getCategoryList2();
     //        $categories3 = Category::mapTree($categories2);
     // Подключаем вид
     require_once ROOT . '/views/site/index.php';
     return true;
 }
 /**
  * Action для страницы портфолио
  */
 public function actionIndex()
 {
     // Список категорий для меню
     $categories = Category::getCategoryList();
     // Список категорий для меню категорий фотогалереи
     $categoriesPhoto = Category::getCategoryGallery();
     $allPhotos = Gallery::getAllPhotos(26);
     // Подключаем вид
     require_once ROOT . '/views/photo/index.php';
     return true;
 }
 public function actionCategory($categoryId, $page = 1)
 {
     $categories = array();
     $categories = Category::getCategoryList();
     $categoryProduct = array();
     $categoryProduct = Product::getProductListByCategory($categoryId, $page);
     $total = Product::getTotalProductsInCategory($categoryId);
     $pagination = new Pagination($total, $page, Product::SHOW_BY_DEFAULT, 'page-');
     require_once ROOT . '/views/catalog/category.php';
     return true;
 }
Example #10
0
 public function actionCategory($categoryId, $page = 1)
 {
     $categores = array();
     $categores = Category::getCategoryList();
     $categoryProducts = array();
     $categoryProducts = Product::getProductListByCategory($categoryId, $page);
     // Общее количетсво товаров (необходимо для постраничной навигации)
     $total = Product::getTotalProductsInCategory($categoryId);
     // Создаем объект Pagination - постраничная навигация
     $pagination = new Pagination($total, $page, Product::SHOW_BY_DEFAULT, 'page-');
     require_once ROOT . '/sourse/views/catalog/category.php';
     return true;
 }
Example #11
0
 public function actionView($id)
 {
     $categories = Category::getCategoryList();
     if (!$categories) {
         $categories = array();
     }
     $product = Product::getProductById($id);
     if (!$product) {
         $product = array();
     }
     require_once ROOT . '/views/product/view.php';
     return true;
 }
Example #12
0
 public function actionCategory($categoryId, $page = 1)
 {
     $categories = Category::getCategoryList();
     if (!$categories) {
         $categories = array();
     }
     $page = (int) $page;
     $products = Product::getProductsByCategoryId($categoryId, $page);
     if (!$products) {
         $products = array();
     }
     $total = Product::getTotalProductsInCategory($categoryId);
     $pagination = FunctionLibrary::buildPagination($page, $total, Product::SHOW_BY_DEFAULT, 'page-');
     require_once ROOT . '/views/catalog/category.php';
     return true;
 }
Example #13
0
File: index2.php Project: JoDu/gb
<?php

include_once "include/db.php";
include_once "include/func_category.php";
$conn_ategory = new Category();
$result = $conn_ategory->getCategoryList('');
$subject_result = $conn_ategory->getSubjectList('', '');
$chapter_result = $conn_ategory->getChapterList('');
$section_result = $conn_ategory->getSectionList('');
$part_result = $conn_ategory->getPartList('');
$item_result = $conn_ategory->getItemList('');
//print_r($part_result);
//exit;
$arr_subject = array();
foreach ($subject_result as $key => $val) {
    $id = $val["subject_id"] . "-" . $val["sub_id"];
    $arr_subject[$val["category_id"]][$id] = $val["subject_name"];
}
$arr_chapter = array();
foreach ($chapter_result as $key => $val) {
    $subject_id = $val["subject_id"] . "-" . $val["sub_id"];
    $arr_chapter[$subject_id][$val["chapter_id"]] = $val["chapter_name"];
}
$arr_section = array();
foreach ($section_result as $key => $val) {
    $arr_section[$val["chapter_id"]][$val["section_id"]] = $val["section_name"];
}
$arr_part = array();
foreach ($part_result as $key => $val) {
    $arr_part[$val["section_id"]][$val["part_id"]] = $val["part_name"];
}
Example #14
0
 public function actionOrder()
 {
     $categories = Category::getCategoryList();
     if (!$categories) {
         $categories = array();
     }
     $name = '';
     $phone = '';
     $message = '';
     $result = '';
     if (isset($_POST['submit'])) {
         $name = FunctionLibrary::clearStr($_POST['name']);
         $phone = FunctionLibrary::clearStr($_POST['phone']);
         $message = FunctionLibrary::clearStr($_POST['message']);
         $errors = array();
         if (!User::checkName($name)) {
             $errors[] = 'Имя должно быть больше 1 символа.';
         }
         if (!User::checkPhone($phone)) {
             $errors[] = 'Невалидный телефон.';
         }
         if (!User::checkName($message)) {
             $errors[] = 'Сообщение не может быть пустым.';
         }
         $sessionProducts = Cart::returnSessionProducts();
         if ($sessionProducts) {
             $idsArray = array_keys($sessionProducts);
             $products = Product::getProductsInCart($idsArray);
             $totalPrice = Cart::getTotalPrice($products);
             $totalCount = Cart::countProductsInCart();
             if (User::isUser()) {
                 $email = User::isLogged();
                 $user = User::getUserByEmail($email);
                 $userName = $user['name'];
                 $userId = $user['id'];
             } else {
                 $userName = '';
                 $userId = 0;
             }
         }
         if (empty($errors)) {
             $result = Order::save($name, $phone, $message, $userId, $sessionProducts);
             if ($result) {
                 $adminEmail = '*****@*****.**';
                 $sub = "Новый заказ";
                 $mess = "{$message}";
                 mail($adminEmail, $sub, $mess);
                 $_SESSION['message'] = 'Заказ оформлен';
                 Cart::deleteProductsInCart();
                 FunctionLibrary::redirectTo('/cart');
             }
         }
     } else {
         /* Выясняем есть ли товары в корзине */
         $sessionProducts = Cart::returnSessionProducts();
         if (!$sessionProducts) {
             FunctionLibrary::redirectTo('/');
         } else {
             $idsArray = array_keys($sessionProducts);
             $products = Product::getProductsInCart($idsArray);
             $totalPrice = Cart::getTotalPrice($products);
             $totalCount = Cart::countProductsInCart();
         }
         /* Выясняем зарегистрирован ли покупатель */
         if (User::isUser()) {
             $email = User::isLogged();
             $user = User::getUserByEmail($email);
             $userName = $user['name'];
         } else {
             $userName = '';
         }
     }
     require_once ROOT . '/views/cart/order.php';
     return true;
 }
Example #15
0
 /**
  * Action для страницы "Оформление покупки"
  */
 public function actionCheckout()
 {
     // Получием данные из корзины
     $productsInCart = Cart::getProducts();
     // Если товаров нет, отправляем пользователи искать товары на главную
     if ($productsInCart == false) {
         header("Location: /");
     }
     // Список категорий для левого меню
     $categories = Category::getCategoryList();
     // Находим общую стоимость
     $productsIds = array_keys($productsInCart);
     $products = Product::getProdustsByIds($productsIds);
     $totalPrice = Cart::getTotalPrice($products);
     // Количество товаров
     $totalQuantity = Cart::countItems();
     // Поля для формы
     $userName = false;
     $userPhone = false;
     $userComment = false;
     // Статус успешного оформления заказа
     $result = false;
     // Проверяем является ли пользователь гостем
     if (!User::isGuest()) {
         // Если пользователь не гость
         // Получаем информацию о пользователе из БД
         $userId = User::checkLogged();
         $user = User::getUserById($userId);
         $userName = $user['name'];
     } else {
         // Если гость, поля формы останутся пустыми
         $userId = false;
     }
     // Обработка формы
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Получаем данные из формы
         $userName = $_POST['userName'];
         $userPhone = $_POST['userPhone'];
         $userComment = $_POST['userComment'];
         // Флаг ошибок
         $errors = false;
         // Валидация полей
         if (!User::checkName($userName)) {
             $errors[] = 'Неправильное имя';
         }
         if (!User::checkPhone($userPhone)) {
             $errors[] = 'Неправильный телефон';
         }
         if ($errors == false) {
             // Если ошибок нет
             // Сохраняем заказ в базе данных
             $result = Order::save($userName, $userPhone, $userComment, $userId, $productsInCart);
             if ($result) {
                 // Если заказ успешно сохранен
                 // Оповещаем администратора о новом заказе по почте
                 $adminEmail = '*****@*****.**';
                 $message = '<a href="http://digital-mafia.net/admin/orders">Список заказов</a>';
                 $subject = 'Новый заказ!';
                 mail($adminEmail, $subject, $message);
                 // Очищаем корзину
                 Cart::clear();
             }
         }
     }
     // Подключаем вид
     require_once ROOT . '/sourse/views/cart/checkout.php';
     return true;
 }
Example #16
0
 public function main_context($context)
 {
     $context["categorize"] = Category::getCategoryList();
     return $context;
 }
Example #17
0
include_once "include/db.php";
include_once "include/func_category.php";
$conn_ategory = new Category();
$submit_name = "類別";
/*
if($_POST["submitType"] == "addExam"){
	header('Location: '.$ROOTURL.'question_add.php?item_id='.$_POST["jitem"]);
	exit;
}
*/
//print_r($_POST);exit;
$page_title = "新增類別";
if (!empty($_POST["jcategory"])) {
    $jcategory = $_POST["jcategory"];
    $result = $conn_ategory->getCategoryList($_POST["jcategory"]);
    $submit_name = "學科";
    $page_title = "新增學科";
}
if (!empty($_POST["jsubject"])) {
    $jsubject = $_POST["jsubject"];
    $pieces = explode("-", $jsubject);
    $subject_result = $conn_ategory->getSubjectList($pieces[0], $pieces[1]);
    $submit_name = "章";
    $page_title = "新增章";
}
if (!empty($_POST["jchapter"])) {
    $jchapter = $_POST["jchapter"];
    $chapter_result = $conn_ategory->getChapterList($jchapter);
    $submit_name = "節";
    $page_title = "新增節";