public function index() { $catDAO = new CatDAO(DataSource::getInstance()); $brandDAO = new BrandDAO(DataSource::getInstance()); $productDAO = new ProductDAO(DataSource::getInstance()); $this->registry->template->list_category = $catDAO->findByAll(); $this->registry->template->list_brand = $brandDAO->findByAll(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $t = remove_slashes(trim($_POST['s_product_code'])); if ($t != '') { $this->registry->template->s_product_code = $t; $this->registry->template->list_prod = $productDAO->findByCode_Manage($t); } else { $info = array(); if ($_POST['s_category_id'] != '-1') { $info['category_id'] = $_POST['s_category_id']; } if ($_POST['s_brand_id'] != '-1') { $info['brand_id'] = $_POST['s_brand_id']; } $this->registry->template->list_prod = $productDAO->findByInfo_Manage($info); $this->registry->template->s_category_id = $_POST['s_category_id']; $this->registry->template->s_brand_id = $_POST['s_brand_id']; } } else { if ($_SERVER['REQUEST_METHOD'] == 'GET') { $this->registry->template->list_prod = $productDAO->findByAll_Manage(); } } $this->registry->template->tile_title = 'Danh sách sản phẩm'; $this->registry->template->tile_content = 'admin/product-index.php'; $this->registry->template->show('admin/layout/admin.php'); }