function department_list($id = null) { if ($id) { $dept = new Department($id); $list = new Department(); $list->where('parent_id', $id); $list->order_by('orders', 'asc'); $list->get(); child_personnel(0, $id, $dept->title); foreach ($list as $key_tmp => $tmp) { department_list($tmp->id); } } }
public function index($offset = 0) { $this->filter_access('Departement', 'roled_select', base_url()); $dept_list = new Department(); switch ($this->input->get('c')) { case "1": $data['col'] = "dept_name"; break; case "2": $data['col'] = "dept_id"; break; default: $data['col'] = "dept_id"; } if ($this->input->get('d') == "1") { $data['dir'] = "DESC"; } else { $data['dir'] = "ASC"; } $data['title'] = "Departments"; $data['btn_add'] = anchor('departments/add', 'Add New', array("class" => "btn btn-primary")); $data['btn_home'] = anchor(base_url(), 'Home'); $uri_segment = 3; $offset = $this->uri->segment($uri_segment); if ($this->input->get('search_by')) { $total_rows = $dept_list->like($_GET['search_by'], $_GET['q'])->count(); $dept_list->like($_GET['search_by'], $_GET['q'])->order_by($data['col'], $data['dir']); } else { $total_rows = $dept_list->count(); $dept_list->order_by($data['col'], $data['dir']); } $data['dept_list'] = $dept_list->get($this->limit, $offset)->all; $config['base_url'] = site_url("departments/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('departments/index', $data); }