public function validate_form_reschedule_course($form) { $semester = implode("|", $form->new_semester); $course = implode("|", $form->training); $academic_year = implode("|", $form->academic_year); $username = $this->getUser()->username; $training_institution = iHRIS_PageFormLecturer::fetch_institution($username); $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training", "style" => "equals", "data" => array("value" => $course)), 2 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution)))); $is_rescheduled = I2CE_FormStorage::search("reschedule_course", false, $where); if (count($is_rescheduled) > 0) { $form->setInvalidMessage("training", "This Course Already Rescheduled For This Semester In This Academic Year"); } $ff = I2CE_FormFactory::instance(); if (!($courseObj = $ff->createContainer($course)) instanceof iHRIS_Training) { return; } $courseObj->populate(); $crs_semester = $courseObj->getField("semester")->getDBValue(); if ($crs_semester == $semester) { $form->setInvalidMessage("new_semester", "This Course Is Currently Offered In This Semester"); return; } $sem = $form->new_semester[1]; $crs_semester = explode("|", $crs_semester); $crs_semester = $crs_semester[1]; if ($crs_semester > $sem or $sem - $crs_semester != 1) { $form->setInvalidMessage("new_semester", "A Course Must Be Rescheduled To A Next Semester"); } }
/** * Create and load data for the objects used for this form. * * Create the list object and if this is a form submission load * the data from the form data. It determines the type based on the * {@link $type} member variable. */ protected function loadObjects() { if (!$this->hasPermission("task(can_edit_reschedule_course)") or $this->getUser()->role == "admin") { $this->setRedirect("noaccess"); } if ($this->isPost()) { $primary = $this->factory->createContainer('reschedule_course'); $course = $this->post["form"]["reschedule_course"][0][0]["fields"]["training"]; $courseObj = $this->factory->createContainer($course); $courseObj->populate(); $prev_sem = $courseObj->getField("semester")->getDBValue(); $training_program = $courseObj->getField("training_program")->getDBValue(); $this->post["form"]["reschedule_course"][0][0]["fields"]["old_semester"] = $prev_sem; $this->post["form"]["reschedule_course"][0][0]["fields"]["training_program"] = $training_program; $username = $this->getUser()->username; $inst_id = iHRIS_PageFormLecturer::fetch_institution($username); $this->post["form"]["reschedule_course"][0][0]["fields"]["training_institution"] = $inst_id; $primary->load($this->post); } else { $primary = $this->factory->createContainer('reschedule_course|0'); } $username = $this->getUser()->username; $role = $this->getUser()->role; $this->applyLimits($primary, $inst_id, $role); $this->setObject($primary); return true; }
/** * Create and load data for the objects used for this form. * * Create the list object and if this is a form submission load * the data from the form data. */ protected function loadObjects() { $role = $this->getUser()->role; if ($role != "registrar") { $this->userMessage("Only Registrar Can Add Students"); $this->setRedirect("home"); } //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); $username = $this->getUser()->username; $inst_id = iHRIS_PageFormLecturer::fetch_institution($username); $factory = I2CE_FormFactory::instance(); if ($this->isPost()) { $person = $factory->createContainer("person"); $person->load($this->post); $regObj = $factory->createContainer("registration"); $regObj->load($this->post); $regObj->getField("training_institution")->setFromDB($inst_id); $regObj->getField("registration_status")->setFromDB("registration_status|ongoing"); $program = $regObj->getField("training_program")->getDBValue(); $st_reg_num = self::generateRegistrationNumber($program, $inst_id); $regObj->getField("registration_number")->setFromPost($st_reg_num); } else { if ($this->get_exists('id')) { $id = $this->get('id'); if (strpos($id, '|') === false) { I2CE::raiseError("Depcreated use of id variable"); $id = 'person|' . $id; } } else { $id = 'person|0'; } $person = $factory->createContainer($id); if ($this->get_exists('id')) { $person->populateChildren("registration"); foreach ($person->getChildren("registration") as $regObj) { } } else { $regObj = $this->factory->createContainer("registration|0"); } if (!$person instanceof iHRIS_Person) { I2CE::raiseError("Could not create valid person form from id:{$id}"); return; } $person->populate(); $person->load($this->request()); } $this->applyLimits($inst_id, $person, $regObj); $this->template->setForm($regObj); $this->template->setForm($person); }
protected function action() { $role = $this->getUser()->role; if ($role != "student") { $this->userMessage("Only A Student Can Enroll Into Courses"); $this->setRedirect("view?id=" . $this->Get("parent")); return false; } iHRIS_AcademicYear::ensureAcademicYear(); $this->person_id = $this->Get("parent"); $this->getProgramAndSemester(); ############Deny Course Registration For A Student Dropped Out Of Semester################### $persObj = I2CE_FormFactory::instance()->createContainer($this->person_id); $persObj->populateChildren("drop_semester"); foreach ($persObj->getChildren("drop_semester") as $dropSemObj) { //check to insure that this drop semester is the one that belongs to the current registration if ($dropSemObj->getField("registration")->getDBValue() != $this->student_registration["id"]) { continue; } $dropSemObj->populateChildren("resume_semester"); $resSemObj = $dropSemObj->getChildren("resume_semester"); if (count($resSemObj) == 0) { $this->userMessage("You Are Currently Dropped From A Semester,Course Enrollment Not Allowed"); $this->setRedirect("view?id=" . $this->person_id); return; } } ############End Of Denying Course Registration For A Student Dropped Out Of Semester################### ############checking if course enrollment closed################# $username = $this->getUser()->username; $this->training_institution = iHRIS_PageFormLecturer::fetch_institution($username); $where = array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $this->training_institution)); $fields = I2CE_FormStorage::listFields("schedule_course_enrollment", array("start_date", "end_date"), false, $where); foreach ($fields as $id => $field) { $start_date = $field["start_date"]; $end_date = $field["end_date"]; } if (count($fields) == 0) { $this->userMessage("Course Registration Closed"); $this->setRedirect("view?id=" . self::$person_id); return false; } else { $start_date = strtotime($start_date); $end_date = strtotime($end_date); $today = strtotime(date("Y-m-d")); if ($today > $end_date) { $this->userMessage("Course Registration Closed"); $this->setRedirect("view?id=" . self::$person_id); return false; } } ########### End checking of course enrollment deadline ##################### ########### Check if this student is not discontinued ##################### if ($this->check_discontinue($this->person_id)) { $this->userMessage("You have discontinued from this program!!!"); $this->setRedirect("view?id=" . $this->person_id); return false; } ########### End of checking if a student has discontinued ################# ########### If its a new semester then increment the semester and level ################ ######get total number of semesters###### list($prog_form, $prog_id) = array_pad(explode("|", $this->program, 2), 2, ""); $total_sems = I2CE_FormStorage::lookupField("training_program", $prog_id, array("total_semesters"), false); $total_semesters = $total_sems["total_semesters"]; ######end of getting total number of semesters###### ######get passing score###### list($inst_form, $inst_id) = array_pad(explode("|", $this->training_institution, 2), 2, ""); $pass_score = I2CE_FormStorage::lookupField("training_institution", $inst_id, array("passing_score"), false); $this->passing_score = $pass_score["passing_score"]; ######end of getting passing score###### $semester_name = self::getSemesterName($this->curr_semester); $where_GPA = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $this->person_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $this->curr_semester))), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $this->student_registration["id"]))); ######if GPA for current semester available then increment the semester###### $sem_GPA = I2CE_FormStorage::Search("semester_GPA", false, $where_GPA); if (count($sem_GPA) > 0 and $semester_name < $total_semesters) { $regObj = $this->factory->createContainer($this->student_registration["id"]); list($form, $level) = array_pad(explode("|", $this->curr_level, 2), 2, ""); $semester_name = ++$semester_name; if ($semester_name % 2 != 0) { $new_level = ++$level; } $new_semester = "semester|" . $semester_name; $user = new I2CE_User(); $regObj->populate(); $regObj->getField("semester")->setFromDB($new_semester); if ($semester_name % 2 != 0) { $regObj->getField("academic_level")->setFromDB("academic_level|" . $new_level); } $regObj->save($user); } ########### End of incrementing the semester and level ############ $this->getProgramCourses($this->curr_semester); $this->getElectiveCourses($this->curr_semester); $this->getPreviousSemesterCourses($this->curr_semester); if (count($this->subject_courses) == 0 and count($this->elective_courses) == 0) { $this->userMessage("No courses defined into the system,try later on!!!"); $this->setRedirect("view?id=" . $this->person_id); } $this->displayCourses($this->subject_courses, "subject", "Subject Courses"); if (count($this->elective_courses) > 0) { $this->displayCourses($this->elective_courses, "elective", "Elective Courses"); } //append hidden values to be used on the onload if (!($hidden = $this->template->getElementByID("hidden_values")) instanceof DOMNode) { return; } $input = $this->template->createElement("input", array("type" => "hidden", "name" => "person_id", "value" => $this->person_id)); $this->template->appendNode($input, $hidden); $input = $this->template->createElement("input", array("type" => "hidden", "name" => "curr_semester", "value" => $this->curr_semester)); $this->template->appendNode($input, $hidden); if (!($div = $this->template->getElementByID("button")) instanceof DOMNode) { return; } $input = $this->template->createElement("input", array("type" => "submit", "value" => "Save")); $this->template->appendNode($input, $div); }
protected function action() { if (!$this->hasPermission("task(can_add_students_results)" or $this->getUser()->role == "admin")) { $this->setRedirect("noaccess"); return; } $this->ff = I2CE_FormFactory::instance(); //update academic year iHRIS_AcademicYear::ensureAcademicYear(); //retrive the academic year $current_academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year); $academic_year_id = "academic_year|" . $academic_year_id; $this->course_id = $this->request("id"); $where_course_id = array("operator" => "AND", "operand" => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'training', 'style' => 'like', 'data' => array('value' => "%" . $this->course_id . "%")), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'academic_year', 'style' => 'equals', 'data' => array('value' => $academic_year_id)))); $parents = I2CE_FormStorage::listFields("enroll_course", array("parent", "training", "academic_year"), false, $where_course_id); if (!($listNode = $this->template->getElementByID("students_list")) instanceof DOMNode) { return; } if (!($hidden_data = $this->template->getElementByID("hidden_data")) instanceof DOMNode) { return; } if (count($parents) == 0) { $this->userMessage("No students enrolled for this course!!!"); $this->setRedirect("add_results_select_course"); } $input = $this->template->createElement("input", array("type" => "hidden", "name" => "course_id", "value" => $this->course_id)); $this->template->appendNode($input, $listNode); $table = $this->template->createElement("table", array("class" => "multiFormTable", "width" => "100%", "border" => "0", "cellpadding" => "0", "cellspacing" => "0")); $tr = $this->template->createElement("tr"); $th = $this->template->createElement("th", array("width" => "60%"), "Student Name"); $this->template->appendNode($th, $tr); $th = $this->template->createElement("th", "", "Registration Number"); $this->template->appendNode($th, $tr); $this->appendExamTypesHeaders($tr); $this->template->appendNode($tr, $table); //retrieving the max mark for each assessment foreach ($this->exam_types as $exam_type) { list($form, $id) = array_pad(explode("|", $exam_type, 2), 2, ''); list($form, $course_id) = array_pad(explode("|", $this->course_id, 2), 2, ''); $max_mark = I2CE_FormStorage::lookupField("training", $course_id, array($id), false); $max_mark = $max_mark[$id]; $input = $this->template->createElement("input", array("type" => "hidden", "name" => $id, "id" => $id, "value" => $max_mark)); $this->template->appendNode($input, $listNode); } //fecth lecturer institution to make sure can see students for his/her institution $username = $this->getUser()->username; $inst_id = iHRIS_PageFormLecturer::fetch_institution($username); foreach ($parents as $enroll_id => $parent) { $reg_details = STS_PageFormPerson::load_current_registration($person_id); ###drop students which are on different institution### if ($inst_id != $reg_details["training_institution"]) { continue; } $trainings = explode(",", $parent["training"]); $tr = $this->template->createElement("tr"); $person_id = $parent["parent"]; $reg_num = $this->getRegistrationNumber($person_id); $input = $this->template->createElement("input", array("type" => "hidden", "name" => "reg_num[" . $reg_num . "]", "value" => $reg_num)); $this->template->appendNode($input, $tr); list($form, $id) = array_pad(explode("|", $person_id, 2), 2, ''); $field_data = I2CE_FormStorage::lookupField("person", $id, array('firstname', 'surname'), false); if (is_array($field_data) && array_key_exists('surname', $field_data) && array_key_exists('firstname', $field_data)) { $fullname = $field_data['firstname'] . ' ' . $field_data['surname']; $aNode = $this->template->createElement("a", array("href" => "view?id=" . $person_id), $fullname); $td = $this->template->createElement("td"); $this->template->appendNode($aNode, $td); $this->template->appendNode($td, $tr); $td = $this->template->createElement("td", array("id" => $reg_num, "align" => "center")); $this->template->addTextNode($reg_num, $reg_num, $td); $this->template->appendNode($td, $tr); $this->appendExamTypesInput($tr, $reg_num, $person_id, $this->course_id, $parent["academic_year"], $enroll_id); } $this->template->appendNode($tr, $table); } $tr = $this->template->createElement("tr"); $td = $this->template->createElement("td", array("colspan" => "10", "align" => "right")); $input = $this->template->createElement("input", array("type" => "submit", "value" => "Save", "onclick" => "return verify()")); $this->template->appendNode($input, $td); $this->template->appendNode($td, $tr); $this->template->appendNode($tr, $table); $this->template->appendNode($table, $listNode); }
protected function save() { $username = $this->getUser()->username; $training_institution = iHRIS_PageFormLecturer::fetch_institution($username); $assign_course_trainer = $this->factory->createContainer("assign_course_trainer"); $assign_course_trainer->load($this->post); $assign_course_trainer->getField("training_institution")->setFromDB($training_institution); $lecturer = $assign_course_trainer->getField("lecturer")->getDBValue(); $training_courses = $assign_course_trainer->getField("training")->getDBValue(); $academic_year = $assign_course_trainer->getField("academic_year")->getDBValue(); $training_courses = explode(",", $training_courses); $lecturers = explode(",", $lecturer); foreach ($lecturers as $lecturer) { foreach ($training_courses as $training_course) { //check if this course has been assigned for this lecturer $academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($academic_year); $academic_year_id = "academic_year|" . $academic_year_id; $where_assigned = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training", "style" => "equals", "data" => array("value" => $training_course)), 2 => array("operator" => "FIELD_LIMIT", "field" => "lecturer", "style" => "equals", "data" => array("value" => $lecturer)), 3 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution)))); $is_assigned = I2CE_FormStorage::search("assign_course_trainer", false, $where_assigned); if (count($is_assigned) > 0) { continue; } $assign_course_trainer = $this->factory->createContainer("assign_course_trainer"); $assign_course_trainer->getField("lecturer")->setFromDB($lecturer); $assign_course_trainer->getField("academic_year")->setFromDB($academic_year_id); $assign_course_trainer->getField("training")->setFromDB($training_course); $assign_course_trainer->getField("training_institution")->setFromDB($training_institution); /***alert HOD***/ //get lecturer department $lectObj = $this->factory->createContainer($lecturer); $lectObj->populate(); $lect_dep_id = $lectObj->getField("department")->getDBValue(); //get course department $trainObj = $this->factory->createContainer($training_course); $trainObj->populate(); $program = $trainObj->getField("training_program")->getDBValue(); $progObj = $this->factory->createContainer($program); $progObj->populate(); $course_dep_id = $progObj->getField("department")->getDBValue(); $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution)), 1 => array("operator" => "OR", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "department", "style" => "equals", "data" => array("value" => $lect_dep_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "department", "style" => "equals", "data" => array("value" => $course_dep_id)))), 2 => array("operator" => "FIELD_LIMIT", "field" => "role", "style" => "equals", "data" => array("value" => "role|hod")))); $hods = I2CE_FormStorage::listFields("lecturer", array("identification_number"), false, $where); $module_factory = I2CE_ModuleFactory::instance(); $code = $trainObj->getField("code")->getDBValue(); $course_name = $trainObj->getField("name")->getDBValue(); $lect_fname = $lectObj->getField("first_name")->getDBValue(); $lect_sname = $lectObj->getField("surname")->getDBValue(); $lect_oname = $lectObj->getField("other_name")->getDBValue(); $lect_name = $lect_fname . " " . $lect_oname . " " . $lect_sname; $lect_name = trim($lect_name); foreach ($hods as $hod) { if ($module_factory->isEnabled("UserAlerts")) { $alerts = $module_factory->getClass("UserAlerts"); $alerts->sendUserAlert($hod["identification_number"], 'notice', $code . "-" . $course_name . " Has Been Assigned To " . $lect_name, 'CustomReports/show/lecturer_assigned_courses', 'Vew Course Assignment Report'); } else { I2CE::raiseError("Tried to send user alert, but the module isn't enabled."); } } /***End of alerting HOD***/ $assign_course_trainer->save($this->user); } } $this->userMessage("Course(s) Assigned To Trainer!!!"); $this->setRedirect("assign_course_trainer"); }