コード例 #1
0
ファイル: orders.php プロジェクト: rashidyusmen/myproject
 public function index()
 {
     if (isset($_SESSION['user_id']) || isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) {
         $sid = $_SESSION['user_id'];
         $products_collection = new ProductsCollection();
         $product = $products_collection->get($_GET['id']);
         $orders_collection = new OrdersCollection($_SESSION['user_id']);
         $orders = $orders_collection->get_all();
         $orders_is_accepted = 0;
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $orders = new OrderEntity();
             $orders->setName($_POST['name']);
             $orders->setEmail($_POST['email']);
             $orders->setPhone($_POST['phone']);
             $orders->setProductId($_GET['id']);
             $orders->setDate($_POST['date']);
             $orders->setIsComplete(0);
             $orders->setUserId($_POST['name']);
             $orders_collection = new OrdersCollection($_SESSION['user_id']);
             $orders_collection->save($orders);
         } else {
             $orders_is_accepted = 1;
         }
         $this->loadView('website/orders', array('orders' => $orders, 'sid' => $sid, 'product' => $product, 'orders_is_accepted' => $orders_is_accepted));
     } else {
         header('Location: index.php?frontcontroller=login');
     }
 }
コード例 #2
0
ファイル: products.php プロジェクト: rashidyusmen/myproject
 public function index()
 {
     $pic = new ProductImageCollection($_GET['id']);
     $gallery = $pic->get_latest(3);
     $products_collection = new ProductsCollection();
     $product = $products_collection->get($_GET['id']);
     $this->loadView('website/product', array('product' => $product, 'gallery' => $gallery));
 }
コード例 #3
0
ファイル: products.php プロジェクト: rashidyusmen/myproject
 public function edit()
 {
     $products_collection = new ProductsCollection();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $products = new ProductEntity();
         $products->setId($_GET['id'])->setTitle($_POST['title'])->setDescription($_POST['description'])->setPrice($_POST['price']);
         if ($_FILES['image']['tmp_name'] != '') {
             $products->saveImage($_FILES['image']);
         }
         $products_collection->save($products);
         header('Location: index.php?controller=products');
     }
     $data = $products_collection->get($_GET['id']);
     $this->loadView('cms/product_edit', array('data' => $data));
 }