Ejemplo n.º 1
0
 function get_all_curriculums()
 {
     $curriculums = false;
     $CI =& get_instance();
     $CI->load->model("curriculum_model");
     $curriculuminfo = new Curriculum_Model();
     $query = $CI->db->select("*")->from($curriculuminfo->table_name)->get();
     if ($query && $query->num_rows() > 0) {
         $curriculums = array();
         foreach ($query->result() as $rwi => $rw) {
             $curriculuminfo = new Curriculum_Model();
             $curriculuminfo->setCurriculumid($rw->curriculum_id);
             $curriculuminfo->setCourseid($rw->course_id);
             $curriculuminfo->setMajorid($rw->major_id);
             $curriculuminfo->setCurriculumtypeid($rw->curriculum_type_id);
             $curriculuminfo->setDescription($rw->description);
             $curriculuminfo->setYear($rw->year);
             $curriculuminfo->setSchoolyearstart($rw->schoolyear_start);
             $curriculuminfo->setCreatedon($rw->created_on);
             $curriculuminfo->setLastupdate($rw->last_update);
             $curriculums[] = $curriculuminfo;
         }
     }
     return $curriculums;
 }
Ejemplo n.º 2
0
 private function createCurriculum()
 {
     $return = false;
     $this->form_validation->set_rules("curriculumType", "Curriculum type", "trim|required|xss_clean");
     $this->form_validation->set_rules("curriculumCourse", "Curriculum course", "trim|required|xss_clean");
     $this->form_validation->set_rules("curriculumMajor", "Curriculum major", "trim|xss_clean");
     $this->form_validation->set_rules("curriculumDescription", "Curriculum description", "trim|xss_clean");
     $this->form_validation->set_rules("curriculumYear", "Curriculum year", "trim|xss_clean");
     if ($this->form_validation->run() == FALSE) {
         if (form_error("curriculumType")) {
             set_has_error("curriculumType", true);
             set_message("curriculumType", form_error("curriculumType", " ", " "));
         }
         if (form_error("curriculumCourse")) {
             set_has_error("curriculumCourse", true);
             set_message("curriculumCourse", form_error("curriculumCourse", " ", " "));
         }
         if (form_error("curriculumMajor")) {
             set_has_error("curriculumMajor", true);
             set_message("curriculumMajor", form_error("curriculumMajor", " ", " "));
         }
         if (form_error("curriculumDescription")) {
             set_has_error("curriculumDescription", true);
             set_message("curriculumDescription", form_error("curriculumDescription", " ", " "));
         }
         if (form_error("curriculumYear")) {
             set_has_error("curriculumYear", true);
             set_message("curriculumYear", form_error("curriculumYear", " ", " "));
         }
     } else {
         $newcurriculuminfo = new Curriculum_Model();
         $ctype = $this->input->post("curriculumType");
         $ccourse = $this->input->post("curriculumCourse");
         $cmajor = $this->input->post("curriculumMajor");
         $cdesc = $this->input->post("curriculumDescription");
         $cyear = $this->input->post("curriculumYear");
         if ($ctype && is_curriculum_type_exist($ctype)) {
             $newcurriculuminfo->setCurriculumtypeid($ctype);
             if ($ccourse && (int) $ccourse > 0 && is_course_exist($ccourse)) {
                 $errorz = 0;
                 $newcurriculuminfo->setCourseid($ccourse);
                 if ($cmajor) {
                     if ((int) $cmajor > 0 && is_major_exist($cmajor)) {
                         $newcurriculuminfo->setMajorid($cmajor);
                     } else {
                         set_has_error("curriculumMajor", true);
                         set_message("curriculumMajor", "Invalid major selected.");
                     }
                 }
                 if ($cdesc) {
                     $newcurriculuminfo->setDescription($cdesc);
                 }
                 if ($cyear) {
                     $ystart = 1970;
                     $now = mdate("%Y", now());
                     $yend = $now + 10;
                     if ((int) $cyear >= $ystart && (int) $cyear <= $yend) {
                         $newcurriculuminfo->setYear($cyear);
                     } else {
                         $errorz++;
                         set_has_error("curriculumYear", true);
                         set_message("curriculumYear", "Invalid Year.");
                     }
                 }
                 if ($errorz == 0) {
                     $return = $newcurriculuminfo->saveasnew();
                 }
             } else {
                 set_has_error("curriculumCourse", true);
                 set_message("curriculumCourse", "Invalid course selected.");
             }
         } else {
             set_has_error("curriculumType", true);
             set_message("curriculumType", "Invalid type selected.");
         }
     }
     return $return;
 }