示例#1
0
 function search()
 {
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $searchKey = $this->input->post('searchKey');
         redirect("tim-kiem/" . urlencode(htmlentities($searchKey)));
     }
     $searchKey = $this->uri->segment(2, "");
     $viewType = $this->uri->segment(3, "all");
     $page = $this->uri->segment(4, "trang-1");
     $limitProduct = 50;
     $limitNews = 10;
     $dis['page'] = $page;
     //$searchKey = urldecode($searchKey);
     $searchKeyEncode = $searchKey;
     $searchKey = html_entity_decode(urldecode($searchKey));
     if ($searchKey == "") {
         $resultStatus = false;
     }
     if ($viewType == "all") {
         $resultStatus = true;
         //find dien thoai & mtb
         $phoneCat = new productcat($this->config->item('catPhoneId'));
         $phoneChildCat = $this->getListId($phoneCat->getAllChildCat());
         $tabletCat = new productcat($this->config->item('catTabletId'));
         $tabletChildCat = $this->getListId($tabletCat->getAllChildCat());
         $phoneTabletCat = array_merge($phoneChildCat, $tabletChildCat);
         $phoneTabletProduct = new product();
         $phoneTabletProduct->distinct();
         $phoneTabletProduct->group_start();
         $phoneTabletProduct->like('name', $searchKey);
         $phoneTabletProduct->or_like('searchKey', $searchKey);
         $phoneTabletProduct->group_end();
         $phoneTabletProduct->where_in_related_productcat('id', $phoneTabletCat);
         $phoneTabletProduct->where('active', 1);
         $phoneTabletProduct->order_by('id', 'desc');
         $phoneTabletProduct->group_by('id');
         $phoneTabletProduct->get_iterated(10);
         $dis['phoneTabletProduct'] = $phoneTabletProduct;
         //find accessory with the searchkey condition
         $accessoryCat = new productcat();
         $accessoryCat->where_in('id', $this->config->item('allAccessoriesId'));
         $accessoryCat->get_iterated();
         $accessoryChildCat = array();
         foreach ($accessoryCat as $row) {
             $accessoryChildCat = array_merge($accessoryChildCat, $this->getListId($row->getAllChildCat()));
         }
         $accessoryProduct = new product();
         $accessoryProduct->distinct();
         $accessoryProduct->group_start();
         $accessoryProduct->like('name', $searchKey);
         $accessoryProduct->or_like('searchKey', $searchKey);
         $accessoryProduct->group_end();
         $accessoryProduct->where_in_related_productcat('id', $accessoryChildCat);
         $accessoryProduct->where('active', 1);
         $accessoryProduct->group_by('id');
         $accessoryProduct->order_by('id', 'desc');
         $accessoryProduct->get_iterated(10);
         $dis['accessoryProduct'] = $accessoryProduct;
         //find the new by keyword
         $newCat = array(58, 59, 60, 61, 62, 64);
         $newsResult = new article();
         $newsResult->where_in('newscatalogue_id', $newCat);
         $newsResult->like('title_vietnamese', $searchKey);
         $newsResult->where('active', 1);
         $newsResult->where('recycle', 0);
         $newsResult->order_by('id', 'desc');
         $newsResult->get_iterated(10);
         $dis['newsResult'] = $newsResult;
         $dis['view'] = 'product/search_all';
     }
     if ($viewType == "dien-thoai-may-tinh-bang") {
         $resultStatus = true;
         //find dien thoai & mtb
         $phoneCat = new productcat($this->config->item('catPhoneId'));
         $phoneChildCat = $this->getListId($phoneCat->getAllChildCat());
         $tabletCat = new productcat($this->config->item('catTabletId'));
         $tabletChildCat = $this->getListId($tabletCat->getAllChildCat());
         $phoneTabletCat = array_merge($phoneChildCat, $tabletChildCat);
         $offset = ($this->getPageNumber($page) - 1) * $limitProduct;
         $phoneTabletProduct = new product();
         $phoneTabletProduct->distinct();
         $phoneTabletProduct->group_start();
         $phoneTabletProduct->like('name', $searchKey);
         $phoneTabletProduct->or_like('searchKey', $searchKey);
         $phoneTabletProduct->group_end();
         $phoneTabletProduct->where_in_related_productcat('id', $phoneTabletCat);
         $phoneTabletProduct->where('active', 1);
         $phoneTabletProduct->order_by('id', 'desc');
         $phoneTabletProduct->group_by('id');
         $phoneTabletProduct->get_paged_iterated($offset, $limitProduct);
         $dis['phoneTabletProduct'] = $phoneTabletProduct;
         $dis['view'] = 'product/search_product';
         $url = "tim-kiem/" . $searchKeyEncode . '/dien-thoai-may-tinh-bang';
         $dis['url'] = $url;
         $config['base_url'] = site_url($url . "/trang-");
         $config['total_rows'] = $phoneTabletProduct->paged->total_rows;
         $config['per_page'] = $limitProduct;
         $config['use_page_numbers'] = TRUE;
         $config['uri_segment'] = 4;
         $config['num_links'] = 3;
         $config['full_tag_open'] = '<span class="pagin">';
         $config['full_tag_close'] = "</span>";
         $config['first_link'] = FALSE;
         $config['first_tag_open'] = '';
         $config['first_tag_close'] = '';
         $config['last_link'] = FALSE;
         $config['last_tag_open'] = '';
         $config['last_tag_close'] = '';
         $config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />';
         $config['next_tag_open'] = '';
         $config['next_tag_close'] = '';
         $config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /';
         $config['prev_tag_open'] = '';
         $config['prev_tag_close'] = '';
         $config['num_tag_open'] = '';
         $config['num_tag_close'] = '';
         $config['cur_tag_open'] = '<span class="active fl">';
         $config['cur_tag_close'] = '</span>';
         $this->pagination->initialize($config);
     }
     if ($viewType == "phu-kien") {
         $resultStatus = true;
         //find dien thoai & mtb
         $phoneCat = new productcat($this->config->item('catPhoneId'));
         $phoneChildCat = $this->getListId($phoneCat->getAllChildCat());
         $tabletCat = new productcat($this->config->item('catTabletId'));
         $tabletChildCat = $this->getListId($tabletCat->getAllChildCat());
         $phoneTabletCat = array_merge($phoneChildCat, $tabletChildCat);
         $offset = ($this->getPageNumber($page) - 1) * $limitProduct;
         //find accessory with the searchkey condition
         $accessoryCat = new productcat();
         $accessoryCat->where_in('id', $this->config->item('allAccessoriesId'));
         $accessoryCat->get_iterated();
         $accessoryChildCat = array();
         foreach ($accessoryCat as $row) {
             $accessoryChildCat = array_merge($accessoryChildCat, $this->getListId($row->getAllChildCat()));
         }
         //$this->firephp->log($accessoryChildCat);
         $accessoryProduct = new product();
         $accessoryProduct->distinct();
         $accessoryProduct->group_start();
         $accessoryProduct->like('name', $searchKey);
         $accessoryProduct->or_like('searchKey', $searchKey);
         $accessoryProduct->group_end();
         $accessoryProduct->where_in_related_productcat('id', $accessoryChildCat);
         $accessoryProduct->where('active', 1);
         $accessoryProduct->group_by('id');
         $accessoryProduct->order_by('id', 'desc');
         $accessoryProduct->get_paged_iterated($offset, $limitProduct);
         $dis['accessoryProduct'] = $accessoryProduct;
         $dis['view'] = 'product/search_accessory';
         $url = "tim-kiem/" . $searchKeyEncode . '/phu-kien';
         $dis['url'] = $url;
         $config['base_url'] = site_url($url . "/trang-");
         $config['total_rows'] = $accessoryProduct->paged->total_rows;
         $config['per_page'] = $limitProduct;
         $config['use_page_numbers'] = TRUE;
         $config['uri_segment'] = 4;
         $config['num_links'] = 3;
         $config['full_tag_open'] = '<span class="pagin">';
         $config['full_tag_close'] = "</span>";
         $config['first_link'] = FALSE;
         $config['first_tag_open'] = '';
         $config['first_tag_close'] = '';
         $config['last_link'] = FALSE;
         $config['last_tag_open'] = '';
         $config['last_tag_close'] = '';
         $config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />';
         $config['next_tag_open'] = '';
         $config['next_tag_close'] = '';
         $config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /';
         $config['prev_tag_open'] = '';
         $config['prev_tag_close'] = '';
         $config['num_tag_open'] = '';
         $config['num_tag_close'] = '';
         $config['cur_tag_open'] = '<span class="active fl">';
         $config['cur_tag_close'] = '</span>';
         $this->pagination->initialize($config);
     }
     if ($viewType == "tin-tuc") {
         $resultStatus = true;
         //find dien thoai & mtb
         $phoneCat = new productcat($this->config->item('catPhoneId'));
         $phoneChildCat = $this->getListId($phoneCat->getAllChildCat());
         $tabletCat = new productcat($this->config->item('catTabletId'));
         $tabletChildCat = $this->getListId($tabletCat->getAllChildCat());
         $phoneTabletCat = array_merge($phoneChildCat, $tabletChildCat);
         $offset = ($this->getPageNumber($page) - 1) * $limitProduct;
         //find the new by keyword
         $newCat = array(58, 59, 60, 61, 62, 64);
         $newsResult = new article();
         $newsResult->where_in('newscatalogue_id', $newCat);
         $newsResult->like('title_vietnamese', $searchKey);
         $newsResult->where('active', 1);
         $newsResult->where('recycle', 0);
         $newsResult->order_by('id', 'desc');
         $newsResult->get_paged_iterated($offset, $limitNews);
         $dis['newsResult'] = $newsResult;
         $dis['view'] = 'product/search_news';
         $url = "tim-kiem/" . $searchKeyEncode . '/tin-tuc';
         $dis['url'] = $url;
         $config['base_url'] = site_url($url . "/trang-");
         $config['total_rows'] = $newsResult->paged->total_rows;
         $config['per_page'] = $limitNews;
         $config['use_page_numbers'] = TRUE;
         $config['uri_segment'] = 4;
         $config['num_links'] = 3;
         $config['full_tag_open'] = '<span class="pagin">';
         $config['full_tag_close'] = "</span>";
         $config['first_link'] = FALSE;
         $config['first_tag_open'] = '';
         $config['first_tag_close'] = '';
         $config['last_link'] = FALSE;
         $config['last_tag_open'] = '';
         $config['last_tag_close'] = '';
         $config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />';
         $config['next_tag_open'] = '';
         $config['next_tag_close'] = '';
         $config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /';
         $config['prev_tag_open'] = '';
         $config['prev_tag_close'] = '';
         $config['num_tag_open'] = '';
         $config['num_tag_close'] = '';
         $config['cur_tag_open'] = '<span class="active fl">';
         $config['cur_tag_close'] = '</span>';
         $this->pagination->initialize($config);
     }
     $dis['searchKey'] = $searchKey;
     $dis['base_url'] = base_url();
     $this->viewfront($dis);
 }
示例#2
0
 function edit($id = 0)
 {
     $productcat = new productcat($id);
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $this->load->library('file_lib');
         //get the object parameter
         $productcat->name_vietnamese = $this->input->post('name_vietnamese');
         $productcat->name_english = $this->input->post('name_english');
         $productcat->name_japanese = $this->input->post('name_japanese');
         $parentcat = new productcat(trim($this->input->post('productCategoryId')));
         $productcat->isShowInHot = $this->input->post('isShowInHot');
         $productcat->isShowInNew = $this->input->post('isShowInNew');
         $productcat->isShowInParentHot = $this->input->post('isShowInParentHot');
         $productcat->isHide = $this->input->post('isHide');
         $productcat->isShowLogo = $this->input->post('isShowLogo');
         $productcat->seo_title_vietnamese = $this->input->post('seo_title_vietnamese');
         $productcat->seo_keyword_vietnamese = $this->input->post('seo_keyword_vietnamese');
         $productcat->seo_description_vietnamese = $this->input->post('seo_description_vietnamese');
         $productcat->seo_title_english = $this->input->post('seo_title_english');
         $productcat->seo_keyword_english = $this->input->post('seo_keyword_english');
         $productcat->seo_description_english = $this->input->post('seo_description_english');
         $productcat->numProductHomepage = $this->input->post('numProductHomepage');
         $productcat->tag = $this->input->post('tag');
         if ($_FILES['logo']['name'] != "") {
             $dataupload = $this->file_lib->upload('logo', 'img/category/');
             if (is_array($dataupload)) {
                 $productcat->image = 'img/category/' . $dataupload['file_name'];
             } else {
                 flash_message('error', $dataupload);
             }
         }
         $this->load->helper('remove_vn_helper');
         if (!$productcat->exists()) {
             $productcat->url_vietnamese = remove_vn($productcat->name_vietnamese);
             $productcat->url_english = remove_vn($productcat->name_english);
         } else {
             $productcat->url_vietnamese = $this->input->post('url_vietnamese');
             $productcat->url_english = $this->input->post('url_english');
         }
         if ($productcat->save(array('parentcat' => $parentcat))) {
             flash_message('success', 'Thành công. Thao tác đã được thực hiện.');
             redirect($this->admin . 'productcats/edit/' . $productcat->id);
         }
     }
     $dis['base_url'] = base_url();
     $sitelanguage = new Sitelanguage();
     $sitelanguage->get()->all;
     $dis['sitelanguage'] = $sitelanguage;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}productcats/listAll/" . $productcat->parentcat->id, "onclick" => ""), array("type" => "add", "text" => "Thêm danh mục khác", "link" => "{$this->admin_url}productcats/edit/", "onclick" => ""));
     //load any resource if the product category is exist
     if ($productcat->exists()) {
         //title depend on category name
         $dis['title'] = $productcat->name;
         $dis['productcatspec'] = $productcat->getSpec();
         /*$dis['nav_menu'] = array_merge($dis['nav_menu'],array(
                    array(
         			"type"=>"add",
         			"text"=>"Thêm thông số",
         			"link"=>"javascript:void(0)",
         			"onclick"=>"addSpecDialog_show()"		
         		),
                    array(
         			"type"=>"edit",
         			"text"=>"Copy thông số",
         			"link"=>"javascript:void(0)",
         			"onclick"=>"copySpecDialog_show()"		
         		),
                    array(
         			"type"=>"edit",
         			"text"=>"Thêm sp homepage",
         			"link"=>"javascript:void(0)",
         			"onclick"=>"showProductMultiDialog(0)"		
         		)
                ));*/
         $productHome = new producthome();
         $productHome->where('productcat_id', $productcat->id);
         $productHome->order_by('position', 'asc');
         $productHome->get_iterated();
         $dis['productHome'] = $productHome;
     } else {
         $dis['title'] = "Thêm/ Sửa danh mục sản phẩm";
     }
     $dis['menu_active'] = "Danh mục sản phẩm";
     $dis['view'] = "productcats/edit";
     $dis['object'] = $productcat;
     //$dis['productspecification'] = $productspecifications;
     $this->viewadmin($dis);
 }
示例#3
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new productcat();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }