function definition() { global $USER, $CFG, $DB, $PAGE; $mform = $this->_form; $requestid = new requests(); $schools = $requestid->school(); foreach ($schools as $school) { $value = $school->fullname; $key = $school->id; } $programs = $requestid->program($key); foreach ($programs as $pro) { $pro_val = $pro->fullname; $pro_key = $pro->id; } $semester = $requestid->previoussemsofuser($key, $pro_key); $cur_semester = $requestid->current_sem($key, $pro_key); $list = array(); $list[''] = get_string("select", "local_request"); foreach ($semester as $ses) { $key1 = $ses->id; $list[$key1] = $ses->fullname; } foreach ($cur_semester as $cus_ses) { global $sesid; $sesid = $cus_ses->id; } unset($list[$sesid]); $mform->addElement('select', 'semester_name', get_string('semester', 'local_semesters'), $list); $mform->addRule('semester_name', get_string('missingsemester', 'local_semesters'), 'required', null, 'server'); $mform->addElement('editor', 'reason', get_string("reason_id", "local_request")); $mform->addRule('reason', get_string('error_request_id', 'local_request'), 'required', null, 'client'); $this->add_action_buttons(true, get_string('submitbutton', 'local_request')); }
/* if click on cancel it redirects us to request_id.php file */ redirect($nexturl); } else if ($fromform = $mform->get_data()) { /* presence of data */ $check = $DB->get_record_sql("SELECT * FROM {local_request_transcript} WHERE studentid = {$USER->id} AND req_semester = {$fromform->semester_name}"); $schools = $requestid->school(); foreach ($schools as $school) { $value = $school->fullname; $key = $school->id; } $programs = $requestid->program($key); foreach ($programs as $pro) { $pro_val = $pro->fullname; $pro_key = $pro->id; } $cur_semester = $requestid->current_sem($key, $pro_key); foreach ($cur_semester as $cus_ses) { $sesid = $cus_ses->id; $fromform->semester = $sesid; } $fromform->studentid = $USER->id; $fromform->notification = '0'; $fromform->requested_date = time(); $fromform->req_semester = $fromform->semester_name; $fromform->reason = $fromform->reason['text']; $registrar = $DB->get_records_sql("select userid from {local_school_permissions} where roleid = 9 and schoolid = {$key} group by userid"); foreach ($registrar as $reg) { $registrarid = $reg->userid; }