function list_all($offset = 0, $limit = 5) { $productstatus = new Productstatu(); $productstatus->order_by('position', 'asc'); $productstatus->get_paged($offset, $limit, TRUE); setPagination($this->admin . 'productstatus/list_all/', $productstatus->paged->total_rows, $limit, 4); $dis['base_url'] = base_url(); $dis['view'] = 'productstatus/list'; $dis['productstatus'] = $productstatus; $dis['menu_active'] = "Trạng thái sản phẩm"; $dis['title_table'] = "Trang hiện tại:" . $productstatus->paged->current_page . '/' . $productstatus->paged->total_pages; $dis['title'] = "Danh sách trạng thái sản phẩm"; $dis['nav_menu'] = array(array("type" => "add", "text" => "Thêm", "link" => "{$this->admin_url}productstatus/edit", "onclick" => "")); $this->viewadmin($dis); }
function edit($id = 0, $productCatId = 0) { $product = new Product($id); if (!$product->exists()) { $product->isAutoGenerateUrl = 1; $product->active = 1; } /** * get list store */ $stores = new Store(); $stores->order_by('position', 'asc'); $stores->get_iterated(); $dis['stores'] = $stores; if ($_SERVER['REQUEST_METHOD'] == "POST") { $this->load->library('file_lib'); //save any param $product->productCode = $this->input->post('productCode'); $product->name_vietnamese = $this->input->post('productName_vietnamese'); $product->name_english = $this->input->post('productName_english'); $product->name_japanese = $this->input->post('productName_japanese'); $product->des_vietnamese = $this->input->post('des_vietnamese'); $product->des_english = $this->input->post('des_english'); $product->des_japanese = $this->input->post('des_japanese'); $product->productstatu_id = $this->input->post('productstatu_id'); $product->productmanufacture_id = $this->input->post('productManufactureId'); $product->isSale = $this->input->post('isSale'); $product->saleOffPrice = $this->input->post('saleOffPrice'); $product->saleOffPriceText = $this->input->post('saleOffPriceText'); $product->price = $this->input->post('price'); $product->priceText = $this->input->post('priceText'); $product->isUsed = $this->input->post('isUsed'); $product->isGift = $this->input->post('isGift'); $product->isHot = $this->input->post('isHot'); $product->isNew = $this->input->post('isNew'); $product->seo_title = $this->input->post('seo_title'); $product->seo_description = $this->input->post('seo_description'); $product->seo_keyword = $this->input->post('seo_keyword'); $product->searchKey = $this->input->post('searchKey'); $product->txtDescription_vietnamese = $this->input->post('txtDescription_vietnamese'); $product->txtDescription_english = $this->input->post('txtDescription_english'); $product->txtGift = $this->input->post('txtGift'); $product->txtSumary = $this->input->post('txtSumary'); $product->txtVideo = $this->input->post('txtVideo'); $product->url_vietnamese = $this->input->post('url_vietnamese'); $product->url_english = $this->input->post('url_english'); $product->origin = $this->input->post('origin'); $product->warranty = $this->input->post('warranty'); $product->active = $this->input->post('isActive'); $product->promotion = $this->input->post('promotion'); $product->status = $this->input->post('productstatus'); $product->inBox = $this->input->post('inBox'); $product->isLinePrice = $this->input->post('isLinePrice'); $product->isLinePriceSaleOff = $this->input->post('isLinePriceSaleOff'); $product->isHighlightPriceSaleOff = $this->input->post('isHighlightPriceSaleOff'); $product->priceColor = $this->input->post('priceColor'); $product->saleOffPriceColor = $this->input->post('saleOffPriceColor'); $product->color = $this->input->post('color'); $product->weight = $this->input->post('weight'); $product->materials = $this->input->post('materials'); $product->size = $this->input->post('size'); $product->style = $this->input->post('style'); $product->productcat_id = $this->input->post('productcat_id'); if (trim($product->saleOffPrice) == "") { $product->finalPrice = $product->price; } else { $product->finalPrice = $product->saleOffPrice; } if ($product->exists()) { $product->updator = $this->logged_in_user->username; } else { $product->creator = $this->logged_in_user->username; } //check product representive image is available inside post request if ($_FILES['logo']['name'] != "") { $dataupload = $this->file_lib->upload('logo', 'img/products/'); if (is_array($dataupload)) { $product->image = 'img/products/' . $dataupload['file_name']; } else { flash_message('error', $dataupload); } } //first save if ($product->save()) { } } //create list product status $productstatus = new Productstatu(); $productstatus->order_by('id', 'asc'); $productstatus->get()->all; //create list productcomment. /*$productcomments = new Productcomment(); $productcomments->order_by('id', 'desc'); $productcomments->where('product_id', $id); $productcomments->get()->all;*/ //create list productphotos $productphotos = new Productphoto(); $productphotos->where('product_id', $id); $productphotos->order_by('position', 'asc'); $productphotos->order_by('id', 'desc'); $productphotos->get_iterated(); $accessories = $product->accessory; $dis['accessories'] = $accessories; $productSpec = new productspec(); $productSpec->where('product_id', $product->id); $productSpec->order_by('position', 'asc'); $productSpec->get_iterated(); $productCat = $product->productcat; $allSpec = new productspec(); if ($product->exists()) { $allSpec->where('product_id', $product->id); } else { $allSpec->where('product_id', 0); } $allSpec->order_by('position', 'asc'); $allSpec->get_iterated(); //if create new product with productcat if (!$product->exists()) { if ($productCatId != 0) { $productCat = new Productcat($productCatId); $productSpec = $productCat->getSpec(); $allSpec = $productCat->getSpec(); } } $sitelanguage = new Sitelanguage(); $sitelanguage->order_by('position', 'asc'); $sitelanguage->get(); $dis['sitelanguage'] = $sitelanguage; $productCat = new Productcat(); $productCat->order_by('position', 'asc'); $productCat->get_iterated(); $dis['productSpec'] = $productSpec; $dis['productCat'] = $productCat; $dis['allSpec'] = $allSpec; //setPagination($this->admin.'productphoto/listAll/',$productphotos->paged->total_rows,$limit,4); $dis['title_table'] = "Trang hiện tại:"; $dis['productphotos'] = $productphotos; $dis['base_url'] = base_url(); $dis['object'] = $product; $dis['productcomments'] = $productcomments; $dis['productstatus'] = $productstatus; $dis['title'] = "Thêm/ Sửa sản phẩm"; $dis['menu_active'] = "Sản phẩm"; $dis['view'] = "products/edit"; $dis['nav_menu'] = array(array("type" => "add", "text" => "Thêm sp khác", "link" => "{$this->admin_url}products/edit", "onclick" => "")); if ($product->exists()) { array_push($dis['nav_menu'], array("type" => "add", "text" => "Thêm hình ảnh", "link" => "{$this->admin_url}productphotos/edit/" . $product->id, "onclick" => "")); } else { $product->isAutoGenerateUrl = 1; $product->isActive = 1; } $this->viewadmin($dis); }