public function delete() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { echo '0'; return; } $id = (int) $_POST['id']; $brandDAO = new BrandDAO(DataSource::getInstance()); $brandDAO->delete($id); echo '1'; }
public function index() { if (empty($_GET['seo_url'])) { $this->notFound(); return; } $productDAO = new ProductDAO(DataSource::getInstance()); $product = $productDAO->findBySeoUrl($_GET['seo_url']); if (!$product) { $this->notFound(); return; } $categoryDAO = new CatDAO(DataSource::getInstance()); $brandDAO = new BrandDAO(DataSource::getInstance()); $cat_id = $product['category_id']; $brand_id = $product['brand_id']; $categories_list = $categoryDAO->findByAll_Navigation(); $brands_list = $brandDAO->findByAll(); $products_list_in_cat = $productDAO->findByCatId($cat_id); $products_list_in_brand = $productDAO->findByBrandId($brand_id); $promoDAO = new PromoDAO(DataSource::getInstance()); $this->registry->template->promo_seo_url_newest = $promoDAO->findNewestSeoUrl(); $this->registry->template->cart = getCart(); $this->registry->template->categories_list = $categories_list; $this->registry->template->brands_list = $brands_list; $this->registry->template->current_cat_id = $cat_id; $this->registry->template->current_brand_id = $brand_id; $this->registry->template->products_list_in_cat = $products_list_in_cat; $this->registry->template->products_list_in_brand = $products_list_in_brand; $this->registry->template->product = $product; $this->registry->template->product_pics = explode_pics($product['pics']); $this->registry->template->tile_title = $categories_list[$cat_id]['name'] . ' / ' . $brands_list[$brand_id] . ' / ' . $product['code']; $this->registry->template->facebook_description = $product['description']; $this->registry->template->facebook_image = __SITE_CONTEXT . __UPLOAD_DIR . get_pic_at($product['pics'], 1); $this->registry->template->body_class = 'product-template'; $this->registry->template->tile_content = 'product.php'; $this->registry->template->tile_footer = 'footer.php'; $this->registry->template->show('layout/user.php'); }
public function update() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->updatePost(); } else { if ($_SERVER['REQUEST_METHOD'] == 'GET') { $this->updateGet(); } } $catDAO = new CatDAO(DataSource::getInstance()); $brandDAO = new BrandDAO(DataSource::getInstance()); $this->registry->template->cats = $catDAO->findByAll(); $this->registry->template->brands = $brandDAO->findByAll(); $this->registry->template->tile_title = 'Sửa thông tin sản phẩm'; $this->registry->template->tile_content = 'admin/product-update.php'; $this->registry->template->show('admin/layout/admin.php'); }