Exemplo n.º 1
0
    redirect($nexturl);
} else if ($fromform = $mform->get_data()) {
    /* presence of data */
    if (isset($fromform->school_name)) {
        $schoolid = $fromform->school_name;
    }
    if (isset($fromform->schoolid)) {
        $schoolid = $fromform->schoolid;
    }
    if (isset($fromform->program_name1)) {
        $program = $fromform->program_name1;
    }
    if (isset($fromform->programid)) {
        $program = $fromform->programid;
    }
    $users = $requestpro->current_user();
    if ($fromform->field_select == 0) {
        $presentdata = $users->firstname . " " . $users->lastname;
        $subject = 1;
    }
    if ($fromform->field_select == 1) {
        $presentdata = $users->email;
        $subject = 2;
    }
    $fromform->programid = $program;
    $fromform->schoolid = $schoolid;
    $fromform->studentid = $USER->id;
    $fromform->subjectcode = $subject;
    $fromform->presentdata = $presentdata;
    $fromform->reason = $fromform->reason['text'];
    $fromform->requested_date = time();
Exemplo n.º 2
0
    function definition_after_data() {
        global $USER, $CFG, $DB, $PAGE;
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $requestpro = new requests();
        $school = $mform->getElementValue('school_name');
        $countvalue = $mform->getElementValue('count');
        $fields = $mform->getElementValue('field_select');
        $fid = $school[0];
        if ($countvalue == 1) {
            $pro_count = $mform->getElementValue('count_pros');
            if ($pro_count > 1) {
                // single school and more than one program assigned to a user
                $program1 = $mform->getElementValue('program_name1');
                $schoolid = $mform->getElementValue('schoolid');

                echo $pro_index = $program1[0];
                if ($pro_index > 0 && $pro_count > 1) {
                    $semesteres = $requestpro->semester($schoolid, $pro_index);
                    $serviceid = $requestpro->service($schoolid, $pro_index);

                    foreach ($semesteres as $s) {
                        $value2 = $s->fullname;
                    }
                    $ser_id = $mform->createElement('static', 'serviceid', get_string('student_id', 'local_request'), $serviceid->serviceid);
                    $mform->insertElementBefore($ser_id, 'name');
                    $sem_name = $mform->createElement('static', 'semester_name', get_string('semester', 'local_semesters'), $value2);
                    $mform->insertElementBefore($sem_name, 'addschool');
                }
            }
        }
        // more than one school assiged to a user
        if ($school[0] > 0 && isset($school) && $countvalue > 1) {

            $users = $requestpro->users($fid);
            $programses = $requestpro->program($fid);
            $mypro = array();
            $mypro[''] = '--Select--';
            foreach ($programses as $p) {
                $mypro[$p->id] = $p->fullname;
            }
            $service = $requestpro->service($fid, $p->id);
            $username = $mform->createElement('static', 'name', get_string('name', 'local_request'), $users->fullname);
            $mform->insertElementBefore($username, 'addschool');
            $emailid = $mform->createElement('static', 'email_id', get_string('email_id', 'local_request'), $users->email);
            $mform->insertElementBefore($emailid, 'addschool');

            $ser_id = $mform->createElement('static', 'serviceid', get_string('student_id', 'local_request'), $service->serviceid);
            $mform->insertElementBefore($ser_id, 'addschool');
            if (count($mypro) == 2) {
                // more than school and one program to user
                $pro_name = $mform->createElement('static', 'program_name', get_string('program', 'local_programs'), $mypro[$p->id]);
                $mform->insertElementBefore($pro_name, 'addschool');
                $pro_id = $mform->createElement('hidden', 'programid', $p->id);
                $mform->insertElementBefore($pro_id, 'addschool');
                $semesteres = $requestpro->semester($fid, $p->id);
                foreach ($semesteres as $s) {
                    $mysemvalue = $s->fullname;
                }
                $sems_name = $mform->createElement('static', 'semester_name', get_string('semester', 'local_semesters'), $mysemvalue);
                $mform->insertElementBefore($sems_name, 'addschool');
                $sem_id = $mform->createElement('hidden', 'semesterid', $s->id);
                $mform->insertElementBefore($sem_id, 'addschool');
            } else {
                // more than one program and school assined to user
                $pro_name = $mform->createElement('select', 'program_name', get_string('program', 'local_programs'), $mypro);
                $mform->insertElementBefore($pro_name, 'addschool');
            }
            $formatvalue3 = $mform->getElementValue('program_name');
            if ($formatvalue3[0] > 0) {
                $semesteres = $requestpro->semester($fid, $formatvalue3[0]);
                foreach ($semesteres as $s) {
                    $mysemvalue = $s->fullname;
                }
                $se_name = $mform->createElement('static', 'semester_name', get_string('semester', 'local_semesters'), $mysemvalue);
                $mform->insertElementBefore($se_name, 'addschool');
            }
        }
        if (isset($fields[0]) && $fields[0] != null) {
            if ($fields[0] == 0) {
                $result = $DB->get_record('local_request_profile_change', array('reg_approval' => 0, 'subjectcode' => 1, 'studentid' => $USER->id));
            }if ($fields[0] == 1) {
                $result = $DB->get_record('local_request_profile_change', array('reg_approval' => 0, 'subjectcode' => 2, 'studentid' => $USER->id));
            }
            if (!empty($result)) {
                if ($fields[0] == 0) {
                    $errormsg = $mform->createElement('html', '<div class="alert alert-danger">' . get_string('noteforname', 'local_request') . '</div>');
                    $mform->insertElementBefore($errormsg, 'fields');
                }if ($fields[0] == 1) {
                    $errormsg = $mform->createElement('html', '<div class="alert alert-danger">' . get_string('noteforemail', 'local_request') . '</div>');
                    $mform->insertElementBefore($errormsg, 'fields');
                }
            } else {
                $editheader = $mform->createElement('header', 'settingsheader', get_string('edit_settings', 'local_request'));
                $mform->insertElementBefore($editheader, 'fields');
                $users = $requestpro->current_user();
                $fullname = $users->firstname . " " . $users->lastname;
                if ($fields[0] == 0 && $fields[0] != null) {
                    $username = $mform->createElement('static', 'fullname', get_string('present_data', 'local_request'), $fullname);
                    $mform->insertElementBefore($username, 'fields');
                }
                if ($fields[0] == 1 && $fields[0] != null) {
                    $email_id = $mform->createElement('static', 'email_id', get_string('present_data', 'local_request'), $users->email);
                    $mform->insertElementBefore($email_id, 'fields');
                }
                $changeto = $mform->createElement('text', 'changeto', get_string("request_to_chage", "local_request"));
                $mform->insertElementBefore($changeto, 'fields');
                $mform->addRule('changeto', get_string('error_change_to', 'local_request'), 'required', null, 'client');

                $reason = $mform->createElement('editor', 'reason', get_string("reason_id", "local_request"));
                $mform->setType('reason', PARAM_RAW);
                $mform->insertElementBefore($reason, 'fields');

                $mform->addRule('reason', get_string('error_request_id', 'local_request'), 'required', null, 'client');
            }
        }
    }