Esempio n. 1
0
 protected function _list_process()
 {
     $this->load->library('pagination');
     $this->load->helper('convert');
     $this->load->helper('cookie');
     /* PROCESS PARAMS BEGIN */
     $filters = array();
     $page_state = $this->_get_page_state();
     $defaults = array();
     $defaults['col'] = !empty($this->default_col) ? $this->default_col : $this->display_field;
     $defaults['order'] = !empty($this->default_order) ? $this->default_order : NULL;
     $defaults['offset'] = 0;
     $defaults['limit'] = 25;
     $defaults['search_term'] = '';
     $defaults['view_type'] = 'list';
     $defaults['extra_filters'] = array();
     // custom module filters defaults
     foreach ($this->filters as $key => $val) {
         $defaults[$key] = isset($val['default']) ? $val['default'] : NULL;
     }
     $uri_params = uri_safe_batch_decode(fuel_uri_segment(4), '|', TRUE);
     $uri_params['offset'] = fuel_uri_segment(4) ? (int) fuel_uri_segment(4) : 0;
     $posted = array();
     if (!empty($_POST)) {
         $posted['search_term'] = $this->input->post('search_term');
         $posted_vars = array('col', 'order', 'limit', 'offset', 'view_type');
         foreach ($posted_vars as $val) {
             if ($this->input->post($val)) {
                 $posted[$val] = $this->input->post($val);
             }
         }
         // custom module filters
         $extra_filters = array();
         foreach ($this->filters as $key => $val) {
             if (isset($_POST[$key])) {
                 $posted[$key] = $this->input->post($key);
                 $this->filters[$key]['value'] = $this->input->post($key);
                 $extra_filters[$key] = $this->input->post($key);
             }
         }
         $posted['extra_filters'] = $extra_filters;
     }
     $params = array_merge($defaults, $page_state, $uri_params, $posted);
     if ($params['search_term'] == 'Search') {
         $params['search_term'] = null;
     }
     /* PROCESS PARAMS END */
     return $params;
 }
Esempio n. 2
0
 function activity()
 {
     $this->_validate_user('manage/activity');
     $this->load->module_model(FUEL_FOLDER, 'logs_model');
     $this->load->library('pagination');
     $this->load->library('data_table');
     $this->load->helper('convert');
     $this->nav_selected = 'manage/activity';
     $page_state = $this->_get_page_state();
     /* PROCESS PARAMS BEGIN */
     $filters = array();
     $defaults = array();
     $defaults['col'] = 'entry_date';
     $defaults['order'] = 'asc';
     $defaults['offset'] = 0;
     $defaults['limit'] = 25;
     $defaults['search_term'] = '';
     $defaults['precedence'] = NULL;
     $uri_params = uri_safe_batch_decode(fuel_uri_segment(4), '|', TRUE);
     $uri_params = array();
     if (fuel_uri_segment(4)) {
         $uri_params['offset'] = (int) fuel_uri_segment(4);
     }
     $posted = array();
     if (!empty($_POST)) {
         if ($this->input->post('col')) {
             $posted['col'] = $this->input->post('col');
         }
         if ($this->input->post('order')) {
             $posted['order'] = $this->input->post('order');
         }
         if ($this->input->post('limit')) {
             $posted['limit'] = $this->input->post('limit');
         }
         if ($this->input->post('limit')) {
             $posted['offset'] = (int) $this->input->post('offset');
         }
         $posted['search_term'] = $this->input->post('search_term');
     }
     //$params = array_merge($defaults, $uri_params, $posted);
     $params = array_merge($defaults, $page_state, $uri_params, $posted);
     if ($params['search_term'] == lang('label_search')) {
         $params['search_term'] = NULL;
     }
     /* PROCESS PARAMS END */
     $seg_params = $params;
     unset($seg_params['offset']);
     $seg_params = uri_safe_batch_encode($seg_params, '|', TRUE);
     // if (!is_ajax() AND !empty($_POST))
     // {
     // 	$uri = fuel_url('manage/activity/offset/'.$params['offset']);
     // 	redirect($uri);
     // }
     $filters['first_name'] = $params['search_term'];
     $filters['last_name'] = $params['search_term'];
     $filters['message'] = $params['search_term'];
     $filters['entry_date'] = $params['search_term'];
     $this->logs_model->add_filters($filters);
     // pagination
     $config['base_url'] = fuel_url('manage/activity/offset/');
     $config['total_rows'] = $this->logs_model->list_items_total();
     $config['uri_segment'] = fuel_uri_index(4);
     $config['per_page'] = $params['limit'];
     $config['page_query_string'] = FALSE;
     $config['num_links'] = 5;
     $config['prev_link'] = lang('pagination_prev_page');
     $config['next_link'] = lang('pagination_next_page');
     $config['first_link'] = lang('pagination_first_link');
     $config['last_link'] = lang('pagination_last_link');
     $this->pagination->initialize($config);
     $this->_save_page_state($params);
     // data table
     $vars['params'] = $params;
     $vars['table'] = '';
     if (is_ajax()) {
         $items = $this->logs_model->list_items($params['limit'], $params['offset'], $params['col'], $params['order']);
         $this->data_table->row_alt_class = 'alt';
         $this->data_table->id = 'activity_data_table';
         // change this so that it doesn't have clickable rows'
         $this->data_table->only_data_cols = array('id');
         $this->data_table->set_sorting($params['col'], $params['order']);
         $this->data_table->auto_sort = TRUE;
         $this->data_table->sort_js_func = 'page.sortList';
         $headers = array('entry_date' => lang('form_label_entry_date'), 'name' => lang('form_label_name'), 'message' => lang('form_label_message'));
         $this->data_table->assign_data($items, $headers);
         $vars['table'] = $this->data_table->render();
         $this->load->view('_blocks/module_list_table', $vars);
         return;
     } else {
         $this->load->library('form_builder');
         $this->js_controller_params['method'] = 'activity';
         $vars['table'] = $this->load->view('_blocks/module_list_table', $vars, TRUE);
         $vars['pagination'] = $this->pagination->create_links();
         // for extra module filters
         $field_values = array();
         $this->_render('manage/activity', $vars);
     }
 }
Esempio n. 3
0
 protected function _list_process()
 {
     $this->load->library('pagination');
     $this->load->helper('convert');
     $this->load->helper('cookie');
     /* PROCESS PARAMS BEGIN */
     $filters = array();
     $page_state = $this->_get_page_state($this->module_uri);
     $defaults = array();
     $defaults['col'] = !empty($this->default_col) ? $this->default_col : $this->display_field;
     $defaults['order'] = !empty($this->default_order) ? $this->default_order : 'asc';
     $defaults['offset'] = 0;
     $defaults['limit'] = 25;
     $defaults['search_term'] = '';
     $defaults['view_type'] = 'list';
     $defaults['extra_filters'] = array();
     $defaults['precedence'] = 0;
     // custom module filters defaults
     foreach ($this->filters as $key => $val) {
         $defaults[$key] = isset($val['default']) ? $val['default'] : NULL;
     }
     $mod_segs = explode('/', $this->module_uri);
     $mod_offset_index = count($mod_segs) + 3;
     $uri_params = uri_safe_batch_decode(fuel_uri_segment($mod_offset_index), '|', TRUE);
     $uri_params['offset'] = fuel_uri_segment($mod_offset_index) ? (int) fuel_uri_segment($mod_offset_index) : 0;
     $posted = array();
     if (!empty($_POST)) {
         $posted['search_term'] = $this->input->post('search_term');
         $posted_vars = array('col', 'order', 'limit', 'offset', 'precedence', 'view_type');
         foreach ($posted_vars as $val) {
             if ($this->input->post($val)) {
                 $posted[$val] = $this->input->post($val, TRUE);
             }
         }
         // custom module filters
         $extra_filters = array();
         foreach ($this->filters as $key => $val) {
             if (isset($_POST[$key])) {
                 $posted[$key] = $this->input->post($key, TRUE);
                 $this->filters[$key]['value'] = $posted[$key];
                 $extra_filters[$key] = $posted[$key];
             }
         }
         $posted['extra_filters'] = $extra_filters;
     }
     //$params = array_merge($defaults, $page_state, $uri_params, $posted);
     $params = array_merge($defaults, $page_state, $uri_params, $posted);
     // reset offset if you apply a filter (via POST and not ajax)
     if (!empty($_POST) and !is_ajax()) {
         $params['offset'] = 0;
     }
     if ($params['search_term'] == lang('label_search')) {
         $params['search_term'] = NULL;
     }
     /* PROCESS PARAMS END */
     return $params;
 }