/** * Description: List of courses and all information related to courses in a table */ public function index($order = 1, $type = "asc", $match = '-', $page = 0) { //Secondary order parameter $order1 = $order; if ($order == NULL) { $order1 = 'course'; } //Setting default url $this->data['url'] = "/" . $order1 . '/' . $type . '/'; if (empty($match)) { //Search parameter $match = '-'; } /**---------------------- Creating header links --------------------------------------**/ //Total number of table columns $total_items = 10; //what is the position of the pagination parameter $pagination_segment = 8; //Specific url path $extended_url = "/admin/course/order/"; //User visible header names $header_list_name = array(0 => $this->lang->line('course_table_icon'), 1 => $this->lang->line('course_table_category'), 2 => $this->lang->line('course_table_course'), 3 => $this->lang->line('course_table_slug'), 4 => $this->lang->line('course_table_author'), 5 => $this->lang->line('course_table_description'), 6 => $this->lang->line('course_table_created'), 7 => $this->lang->line('active'), 8 => '', 9 => '', 10 => ''); //List of valid header slugs( False values are converted to non-clickable) $header_order_slug = array(0 => false, 1 => 'category', 2 => 'course', 3 => 'slug', 4 => 'author', 5 => 'description', 6 => 'date', 7 => 'active', 8 => false, 9 => false, 10 => false); //Calling and sending all data required to create header ordering links(Ordering value+type, Pagination and search result filtering) $this->data['links'] = $this->course_m->create_table_header($this->data['language'], $total_items, $extended_url, $header_list_name, $header_order_slug, $order, $type, $page, $pagination_segment, decodeseoUrl($match)); /**---------------------- Creating header links --------------------------------------**/ $this->data['type'] = $type; //defaulting the type of search if ($type != 'asc' and $type != 'desc') { $type = 'asc'; } if ($match != '-' or $match == NULL) { $field = array('title' => seoUrl($match), 'description' => seoUrl($match), 'category_name' => seoUrl($match), 'cat_slug' => seoUrl($match)); } else { $field = null; } //what columns are we searching in when the user wants to filter $search_haystack = array('1' => 'title', '2' => 'category_name', '3' => 'c_slug', '4' => 'courses.description', '5' => 'first_name', '5' => 'last_name'); //if we want to extend tables primary-secondery $multy = array('1' => 'courses-users', '2' => 'courses-category'); //Defaulting the order_by //$this->db->order_by('category_namea', $type); //-------------------- Configuring the Pagination ---------------------- $config = array(); $config["base_url"] = base_url() . $this->data['language'] . "/admin/course/order/" . $order . "/" . $type . '/' . $match; //Defaulting the match parameter if ($match == '-') { $match = NULL; } $config["total_rows"] = $this->course_m->count_pagination_records(null, $search_haystack, $match, $multy); $config['num_links'] = 3; $config["per_page"] = 10; $config["uri_segment"] = 8; // Configuring styles for pagination (Located in '/library/MY_PAgination') foreach ($this->my_pagination->set_style() as $key => $value) { $config[$key] = $value; } switch ($order) { case 'category': $this->db->order_by('category_name', $type); break; case 'course': $this->db->order_by('title', $type); break; case 'slug': $this->db->order_by('c_slug', $type); break; case 'author': $this->db->order_by('first_name', $type); break; case 'description': $this->db->order_by('course_description', $type); break; case 'date': $this->db->order_by('course_date', $type); break; case 'active': $this->db->order_by('course_approved', $type); break; default: $this->db->order_by('title', $type); break; } $this->pagination->initialize($config); $this->data["course_data"] = ' '; $page = $this->uri->segment(8) ? $this->uri->segment(8) : 0; $this->data['courses'] = $this->course_m->fetch_pagination_records($config["per_page"], $page, null, null, $search_haystack, decodeseoUrl($match), $multy); $this->data["page_links"] = $this->pagination->create_links(); //-------------------- Configuring the Pagination ---------------------- //Search options if ($this->input->post('match') != null) { //Redirecting to display the search results //$match=$this->input->post('match'); $match = seoUrl($this->input->post('match')); redirect($this->data['language'] . '/admin/course/order' . $this->data['url'] . $match, 'refresh'); } //$this->data['courses'] =$this->course_m->count_pagination_records(null , null ,$search_haystack, 'a', $multy); $this->data['url'] = "/" . $order1 . '/' . $type . '/'; // Getting information needed to display courses //$this->data['categories'] = $this->category_m->get(); // $this->data['courses']=$this->course_m->get(); //$this->data['users']=$this->user_m->get(); // Load views $this->data['subview'] = 'en/1-admin/components/views/main_course_index'; $this->load->view('en/1-admin/layout/_layout_main', $this->data); }
</label> </div> <div class="pull-left"> <?php $data = array('name' => 'checkbox_group[]', 'value' => '4', 'checked' => $checkbox_checking[4], 'class' => 'pull-left', 'style' => 'margin-left:15px; margin-right:3px;'); echo form_checkbox($data); ?> <label class="pull-left"> <?php echo $this->lang->line('user_search_lessons'); ?> </label> </div> </div> <?php $data = array('name' => 'search', 'id' => 'search', 'placeholder' => $this->lang->line('user_search_place'), 'value' => decodeseoUrl($this->uri->segment(5)), 'maxlength' => '50', 'type' => 'text', 'size' => '50', 'class' => 'col-lg-6 col-md-9 col-sm-9 col-xs-12', 'style' => 'margin-top:10px'); echo form_input($data); ?> <?php $data = array('name' => 'search_button', 'id' => 'search_button', 'value' => $this->lang->line('user_search_btn'), 'class' => 'btn btn-primary col-lg-2 col-lg-offset-1 col-md-2 col-md-offset-1 col-sm-2 col-sm-offset-1 col-sm-offset-4 col-xs-9 col-xs-offset-1 login-button pull-left', 'style' => 'margin-top:10px'); echo form_submit($data); ?> <?php echo form_close(); ?> </div> </div>
/** * All = all fields are filled * 1 = Author field is checked * 2 = Course field is checked * 3 = Author and Course field are checked * 4 = Lesson Field is checked * 5 = Lesson and Author fields are checked * 6 = Course and lesson fields are checked * Any other input = All fields selected */ public function index($match = '-', $fields = 'all', $page = null) { $this->data['main_view12'] = ''; if ($match == "-" or $match == NULL) { $this->data['did_we_search'] = false; } else { $this->data['did_we_search'] = true; } switch ($fields) { case "author": $this->data['checkbox_checking'][1] = true; $this->data['checkbox_checking'][2] = false; $this->data['checkbox_checking'][4] = false; break; case "course": $this->data['checkbox_checking'][1] = false; $this->data['checkbox_checking'][2] = true; $this->data['checkbox_checking'][4] = false; break; case "author-course": $this->data['checkbox_checking'][1] = true; $this->data['checkbox_checking'][2] = true; $this->data['checkbox_checking'][4] = false; break; case "lesson": $this->data['checkbox_checking'][1] = false; $this->data['checkbox_checking'][2] = false; $this->data['checkbox_checking'][4] = true; break; case "author-lesson": $this->data['checkbox_checking'][1] = true; $this->data['checkbox_checking'][2] = false; $this->data['checkbox_checking'][4] = true; break; case "course-lesson": $this->data['checkbox_checking'][1] = false; $this->data['checkbox_checking'][2] = true; $this->data['checkbox_checking'][4] = true; break; default: $this->data['checkbox_checking'][1] = true; $this->data['checkbox_checking'][2] = true; $this->data['checkbox_checking'][4] = true; break; } // end of fields if ($this->input->post('search_mini_button') == true) { $filter_slug = "all"; redirect($this->data['language'] . '/user/search/index/' . seoUrl($this->input->post('search')) . '/' . $filter_slug . '/' . $page, 'refresh'); } $property = $this->input->post('checkbox_group'); //$this->data['main_view12']=$property; $total = 0; $filter_slug = ''; if ($this->input->post('search')) { $this->data['did_we_search'] = true; $match = seoUrl($this->input->post('search')); if ($property) { foreach ($property as $value) { $total += $value; } } switch ($total) { case 1: $filter_slug = "author"; break; case 2: $filter_slug = "course"; break; case 3: $filter_slug = "author-course"; break; case 4: $filter_slug = "lesson"; break; case 5: $filter_slug = "author-lesson"; break; case 6: $filter_slug = "course-lesson"; break; default: $filter_slug = "all"; break; } redirect($this->data['language'] . '/user/search/index/' . seoUrl($this->input->post('search')) . '/' . $filter_slug . '/' . $page, 'refresh'); } //-------------------- Configuring the Pagination ---------------------- $config = array(); $config["base_url"] = base_url() . $this->data['language'] . "/user/search/index/" . $match . '/' . $fields; //Defaulting the match parameter if ($match == '-') { $match = NULL; } $this->data['main_view12'] = $config["total_rows"] = $this->course_m->search_count(decodeseoUrl($match), $fields); $config['num_links'] = 3; $config["per_page"] = 10; $config["uri_segment"] = 7; // Configuring styles for pagination (Located in '/library/MY_PAgination') foreach ($this->my_pagination->set_style() as $key => $value) { $config[$key] = $value; } $this->pagination->initialize($config); $this->data["course_data"] = ' '; $page = $this->uri->segment(7) ? $this->uri->segment(7) : 0; $this->data["course_data"] = $this->course_m->search_limit($config["per_page"], $page, decodeseoUrl($match), $fields); $this->data["page_links"] = $this->pagination->create_links(); //-------------------- Configuring the Pagination ---------------------- //Search options if ($this->input->post('match') != null) { //Redirecting to display the search results $match = $this->input->post('match'); $match = seoUrl($this->input->post('match')); redirect($this->data['language'] . '/user/search/index/' . $this->data['url'] . $match . '/' . $fields, 'refresh'); } $this->data['main_view12'] = decodeseoURL($match); $this->data['main_view'] = 'en/3-user/components/views/search/main_search_window'; $this->load->view('en/3-user/layout/_layout_notification', $this->data); }