function search() { $this->check_action_permission('search'); $search = $this->input->post('search'); $offset = $this->input->post('offset') ? $this->input->post('offset') : 0; $order_col = $this->input->post('order_col') ? $this->input->post('order_col') : 'last_name'; $order_dir = $this->input->post('order_dir') ? $this->input->post('order_dir') : 'asc'; $loans_search_data = array('offset' => $offset, 'order_col' => $order_col, 'order_dir' => $order_dir, 'search' => $search); $this->session->set_userdata("loans_search_data", $loans_search_data); $per_page = $this->config->item('number_of_items_per_page') ? (int) $this->config->item('number_of_items_per_page') : 20; $search_data = $this->Loan->search($search, $per_page, $offset, $order_col, $order_dir); $config['base_url'] = site_url('loans/search'); $config['total_rows'] = $this->Loan->search_count_all($search); $config['per_page'] = $per_page; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $data['total_rows'] = $this->Loan->search_count_all($search); $data['manage_table'] = get_loans_manage_table_data_rows($search_data, $this); echo json_encode(array('manage_table' => $data['manage_table'], 'pagination' => $data['pagination'])); }
function get_loans_manage_table($people, $controller) { $CI =& get_instance(); $table = '<table class="tablesorter table table-bordered table-hover" id="sortable_table">'; $controller_name = strtolower(get_class($CI)); if ($controller_name == 'loans') { $headers = array('<input type="checkbox" id="select_all" />', lang('common_person_id'), lang('common_fullname'), lang('common_phone_number'), lang('loans_amount'), lang('loans_rate'), lang('loans_duration'), lang('loans_borrow_date'), lang('loans_option')); } $table .= '<thead><tr>'; $count = 0; foreach ($headers as $header) { $count++; if ($count == 1) { $table .= "<th class='leftmost'>{$header}</th>"; } elseif ($count == count($headers)) { $table .= "<th class='rightmost'>{$header}</th>"; } else { $table .= "<th>{$header}</th>"; } } $table .= '</tr></thead><tbody>'; $table .= get_loans_manage_table_data_rows($people, $controller); $table .= '</tbody></table>'; return $table; }