Exemple #1
0
 public function index()
 {
     $categories = new \Models\Category();
     $allCategories = $categories->find();
     $products = new \Models\Product();
     $allProducts = $products->getProductsWithDiscount();
     $data = array();
     $data[] = $allCategories;
     $data[] = $allProducts;
     $this->view->appendToLayout('body', 'index');
     $this->view->display('layouts.default', $data);
 }
Exemple #2
0
 public function category()
 {
     $category_id = $this->input->get(0);
     $productDb = new \Models\Product();
     $products = $productDb->getByCategory($category_id);
     $categories = new \Models\Category();
     $allCategories = $categories->find();
     $data = array();
     $data[] = $allCategories;
     $data[] = $products;
     $this->view->appendToLayout('body', 'index');
     $this->view->display('layouts.default', $data);
 }
Exemple #3
0
 public function index()
 {
     if (!isset($_SESSION['userId'])) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $this->getUser();
     $productDb = new \Models\Product();
     $userProducts = $productDb->getProductsByBuyer($_SESSION['userId']);
     $data = array();
     $data[] = $this->user;
     $data[] = $userProducts;
     $this->view->appendToLayout('body', 'profile');
     $this->view->display('layouts.default', $data);
 }
Exemple #4
0
 public function index()
 {
     if (!isset($_SESSION['userId'])) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $categories = new \Models\Category();
     $allCategories = $categories->find();
     $products = new \Models\Product();
     $allProducts = $products->getProductsWithDiscount();
     $data = array();
     $data[] = $allCategories;
     $data[] = $allProducts;
     $this->view->appendToLayout('body', 'index');
     $this->view->display('layouts.default', $data);
 }
Exemple #5
0
 public function index()
 {
     if (!isset($_SESSION['userId']) && $_SESSION['editor'] != true && $_SESSION['admin'] != true) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $categories = new \Models\Category();
     $allCategories = $categories->find();
     $products = new \Models\Product();
     $allProducts = $products->find();
     $promotionDb = new \Models\Promotion();
     $allPromos = $promotionDb->find();
     $data = array();
     $data[] = $allCategories;
     $data[] = $allProducts;
     $data[] = $allPromos;
     $this->view->appendToLayout('body', 'editorIndex');
     $this->view->display('layouts.default', $data);
 }
Exemple #6
0
 public function promo()
 {
     if (!isset($_SESSION['userId']) && $_SESSION['editor'] != true && $_SESSION['admin'] != true) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $promoDb = new \Models\Promotion();
     $product_id = $this->input->get(0);
     $productDb = new \Models\Product();
     $product = $productDb->get('product_id=' . $product_id)[0];
     if (isset($_POST['name'])) {
         $updateProduct = array();
         $promoName = $_POST['name'];
         $promotion = $promoDb->get('promotion_name = "' . $promoName . '"')[0];
         if ($product['promotion_id'] == null) {
             $updateProduct['promotion_id'] = $promotion['promotion_id'];
             $updateProduct['product_id'] = $product['product_id'];
             $productDb->update('product', $updateProduct);
             header('Location: /php_project/application/public/editor/index');
             exit;
         } else {
             $oldPromo = $promoDb->get('promotion_id = ' . $product['promotion_id'])[0];
             if ($oldPromo['discount'] >= $promotion['discount']) {
                 header('Location: /php_project/application/public/editor/index');
                 exit;
             } else {
                 $updateProduct['promotion_id'] = $promotion['promotion_id'];
                 $updateProduct['product_id'] = $product['product_id'];
                 $productDb->update('product', $updateProduct);
                 header('Location: /php_project/application/public/editor/index');
                 exit;
             }
         }
     }
     if (!is_numeric($product_id) || !$product) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $promos = $promoDb->find();
     $this->view->appendToLayout('body', 'addPromoProduct');
     $this->view->display('layouts.default', $promos);
 }
Exemple #7
0
 public function remove()
 {
     if (!isset($_SESSION['userId']) && $_SESSION['admin'] != true) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $productDb = new \Models\Product();
     $product_id = $this->input->get(0);
     $product = $productDb->get('product_id=' . $product_id)[0];
     if (!is_numeric($product_id) || !$product) {
         header('Location: /php_project/application/public/');
         exit;
     }
     $updateProduct = array();
     $updateProduct['product_id'] = $product_id;
     $updateProduct['deleted'] = true;
     $productDb->update('product', $updateProduct);
     header('Location: /php_project/application/public/editor/index');
     exit;
 }
Exemple #8
0
         case 'live':
             $log_filename = sprintf("/log/%s_%s.log", (string) date('d.m.y_H-i-s'), $offset . '_' . ($limit ? $limit : 'end'));
             $log->pushHandler(new StreamHandler(__DIR__ . $log_filename));
             break;
     }
 }
 while (($data = fgetcsv($handle, 9000, ';')) !== FALSE) {
     $data = array_map(function ($str) {
         return iconv("Windows-1251", "UTF-8", $str);
     }, $data);
     $i++;
     if ($offset > 0 && $offset >= $i) {
         continue;
     }
     $product = new \Classes\Opencart\Product($data, DOWNLOAD_IMAGES, $margin);
     $db = new \Models\Product();
     if ($db->get($product->product_id)) {
         if ($updated = $db->put($product, DELETE_ABSENT, DELETE_IMAGES)) {
             if (defined('LOG') && LOG == true) {
                 $log->addInfo(json_encode(array('#' => $i - 1) + $updated));
             }
         }
     } else {
         if ($created = $db->post($product, IMPORT_ABSENT)) {
             if (defined('LOG') && LOG == true) {
                 $log->addInfo(json_encode(array('#' => $i - 1) + $created));
             }
         }
     }
     if ($limit > 0 && $limit + $offset == $i) {
         break;