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)); }
public function change_group($participant_id) { $group_id = $this->input->post('group_id'); $this->_transaction_isolation(); $this->db->trans_begin(); $participant = new Participant(); $participant->get_by_id($participant_id); $group = new Group(); $group->get_by_id($group_id); $course = $participant->course->get(); if ($group->exists()) { if ($group->is_related_to($course)) { $participant->save($group); } } else { $current_group = $participant->group->get(); $participant->delete($current_group); } $is_ok = TRUE; if ($group->exists()) { if ($participant->allowed == 1) { $group_for_test = new Group(); $rooms = $group_for_test->room; $rooms->select_min('capacity'); $rooms->where('group_id', '${parent}.id', FALSE); $group_for_test->select_subquery($rooms, 'group_capacity'); $group_for_test->include_related_count('participant'); $group_for_test->where_related_participant('allowed', 1); $group_for_test->get_by_id(intval($participant->group_id)); if ($group_for_test->exists()) { if (intval($group_for_test->participant_count) > intval($group_for_test->group_capacity)) { $is_ok = FALSE; } } } } if ($is_ok && $this->db->trans_status()) { $this->db->trans_commit(); $this->_action_success(); $this->output->set_internal_value('student_id', $participant->student_id); $this->output->set_internal_value('course_id', $participant->course_id); } else { $this->db->trans_rollback(); } $participant->include_related('group', 'name'); $participant->get_by_id($participant_id); $this->parser->parse('backend/participants/group_column.tpl', array('participant' => $participant)); }