public function table_content() { $filter = $this->input->post('filter'); $this->store_filter($filter); $participants = new Participant(); $participants->include_related('student', 'fullname'); $participants->include_related('student', 'email'); $participants->include_related('course', 'name'); $participants->include_related('course/period', 'name'); $participants->include_related('group', 'name'); if (isset($filter['student_fullname']) && trim($filter['student_fullname']) != '') { $participants->like_related('student', 'fullname', trim($filter['student_fullname'])); } if (isset($filter['course']) && intval($filter['course']) > 0) { $participants->where_related('course', 'id', intval($filter['course'])); } if (isset($filter['group']) && intval($filter['group']) > 0) { $participants->where_related('group', 'id', intval($filter['group'])); } if (isset($filter['group_set'])) { if ($filter['group_set'] == 'none') { $participants->where('group_id', NULL); } else { if ($filter['group_set'] == 'assigned') { $participants->group_start(' NOT', 'AND'); $participants->where('group_id', NULL); $participants->group_end(); } } } $order_by_direction = $filter['order_by_direction'] == 'desc' ? 'desc' : 'asc'; if ($filter['order_by_field'] == 'student') { $participants->order_by_related_as_fullname('student', 'fullname', $order_by_direction); $participants->order_by_related('student', 'email', $order_by_direction); } elseif ($filter['order_by_field'] == 'course') { $participants->order_by_related('course/period', 'sorting', $order_by_direction); $participants->order_by_related_with_constant('course', 'name', $order_by_direction); } elseif ($filter['order_by_field'] == 'group') { $participants->order_by_related_with_constant('group', 'name', $order_by_direction); } elseif ($filter['order_by_field'] == 'status') { $participants->order_by('allowed', $order_by_direction); } $participants->get_paged_iterated(isset($filter['page']) ? intval($filter['page']) : 1, isset($filter['rows_per_page']) ? intval($filter['rows_per_page']) : 25); $this->parser->parse('backend/participants/table_content.tpl', array('participants' => $participants)); }
public function mail_to_course($course_id) { $course = new Course(); $course->include_related('period', 'name'); $course->get_by_id((int) $course_id); if ($course->exists()) { $groups = new Group(); $groups->where_related_course('id', $course->id); $groups->order_by_with_constant('name', 'asc'); $groups->get_iterated(); $groups_students = array(); foreach ($groups as $group) { $groups_students[$group->id] = array('name' => $group->name, 'students' => array()); } $groups_students[0] = array('name' => 'lang:admin_courses_mail_to_course_group_name_unassigned_students', 'students' => array()); $participants = new Participant(); $participants->where('allowed', 1); $participants->include_related('student'); $participants->where_related_course('id', $course->id); $participants->order_by_related_as_fullname('student', 'fullname', 'asc'); $participants->get_iterated(); foreach ($participants as $participant) { $groups_students[(int) $participant->group_id]['students'][(int) $participant->student_id] = array('fullname' => $participant->student_fullname, 'email' => $participant->student_email); } $this->parser->assign('groups_students', $groups_students); } $this->_add_tinymce4(); $this->parser->add_js_file('admin_courses/mail_form.js'); $this->parser->add_css_file('admin_courses.css'); $this->parser->parse('backend/courses/mail_to_course.tpl', array('course' => $course)); }