コード例 #1
0
ファイル: branches.php プロジェクト: anggadjava/payroll
 public function index($offset = 0)
 {
     $this->filter_access('Branch', 'roled_select', base_url());
     $branch_list = new Branch();
     switch ($this->input->get('c')) {
         case "1":
             $data['col'] = "branch_name";
             break;
         case "2":
             $data['col'] = "branch_id";
             break;
         default:
             $data['col'] = "branch_id";
     }
     if ($this->input->get('d') == "1") {
         $data['dir'] = "DESC";
     } else {
         $data['dir'] = "ASC";
     }
     $data['title'] = "Branch";
     $data['btn_add'] = anchor('branches/add', 'Add New', "class='btn btn-primary'");
     $data['btn_home'] = anchor(base_url(), 'Home', "class='btn btn-home'");
     $uri_segment = 3;
     $offset = $this->uri->segment($uri_segment);
     if ($this->input->get('search_by')) {
         $total_rows = $branch_list->like($_GET['search_by'], $_GET['q'])->count();
         $branch_list->like($_GET['search_by'], $_GET['q'])->order_by($data['col'], $data['dir']);
     } else {
         $total_rows = $branch_list->count();
         $branch_list->order_by($data['col'], $data['dir']);
     }
     $data['branch_list'] = $branch_list->get($this->limit, $offset)->all;
     $config['base_url'] = site_url("branches/index");
     $config['total_rows'] = $total_rows;
     $config['per_page'] = $this->limit;
     $config['uri_segment'] = $uri_segment;
     $this->pagination->initialize($config);
     $data['pagination'] = $this->pagination->create_links();
     $this->load->view('branches/index', $data);
 }