Exemple #1
0
 function list_all($searchKey = "%20", $cartStatus = 0, $offset = 0, $limit = 20)
 {
     $carts = new Cartitem();
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $searchKey = $this->input->post("search_name");
         $cartStatus = $this->input->post('cartStatus');
         redirect("admin/carts/list_all/" . urlencode(htmlentities($searchKey)) . "/" . $cartStatus);
     }
     $searchKey = html_entity_decode(urldecode($searchKey));
     if (trim($searchKey) != "") {
         $customers = new Customer();
         $customers->like("name", "%" . $searchKey . "%");
         $customers->or_like('username', "%" . $searchKey . "%");
         $customers->or_like('address', "%" . $searchKey . "%");
         $customers->or_like('homePhone', "%" . $searchKey . "%");
         $customers->or_like('mobilePhone', "%" . $searchKey . "%");
         $customers->or_like('email', "%" . $searchKey . "%");
         $customers->order_by('id', 'desc');
         $customers->get_iterated();
         $cusArr = array(0);
         foreach ($customers as $row) {
             array_push($cusArr, $row->id);
         }
         //$carts->like('code',"%".$searchKey."%");
         $carts->where_in('customer_id', $cusArr);
     }
     if ($cartStatus != 0) {
         $carts->where('status', $cartStatus);
     }
     $carts->order_by('id', 'desc');
     $carts->get_paged($offset, $limit, TRUE);
     setPagination($this->admin . 'carts/list_all/' . urlencode(htmlentities($searchKey)) . "/" . $cartStatus, $carts->paged->total_rows, $limit, 6);
     $dis['base_url'] = base_url();
     $dis['view'] = "cart/list";
     $dis['searchKey'] = $searchKey;
     $dis['cartStatus'] = $cartStatus;
     $dis['menu_active'] = 'Giỏ hàng';
     $dis['title'] = "Danh sách đơn hàng";
     $dis['title_table'] = "Tìm được " . $carts->paged->total_rows . " kết quả. Trang hiện tại:" . $carts->paged->current_page . '/' . $carts->paged->total_pages;
     $dis['carts'] = $carts;
     $this->viewadmin($dis);
 }