Exemplo n.º 1
0
 function get_all_subjects()
 {
     $CI =& get_instance();
     $CI->load->model("Subject_Model");
     $subjects = false;
     $subjectinfo = new Subject_Model();
     $query = $CI->db->select("*")->from($subjectinfo->table_name)->get();
     if ($query && $query->num_rows() > 0) {
         $subjects = array();
         foreach ($query->result() as $rwi => $rw) {
             $subjectinfo = new Subject_Model();
             $subjectinfo->setSubjectid($rw->subject_id);
             $subjectinfo->setSubjectcode($rw->subject_code);
             $subjectinfo->setSubjectdescription($rw->subject_description);
             $subjectinfo->setCreatedon($rw->created_on);
             $subjectinfo->setLastupdate($rw->last_update);
             $subjects[] = $subjectinfo;
         }
     }
     return $subjects;
 }
Exemplo n.º 2
0
 public function curriculum_settings_add_subject()
 {
     if ($this->input->post(sha1("addsubject"))) {
         $this->form_validation->set_rules("subjectCode", "Subject Code", "trim|required|xss_xlean");
         $this->form_validation->set_rules("subjectDescription", "Subject Description", "trim|required|xss_xlean");
         if ($this->form_validation->run() == false) {
             if (form_error("subjectCode")) {
                 set_has_error("subjectCode", true);
                 set_message("subjectCode", form_error("subjectCode", " ", " "));
             }
             if (form_error("subjectDescription")) {
                 set_has_error("subjectDescription", true);
                 set_message("subjectDescription", form_error("subjectDescription", " ", " "));
             }
         } else {
             $new_subject_code = $this->input->post("subjectCode");
             $new_subject_description = $this->input->post("subjectDescription");
             if (is_subject_exist(false, $new_subject_code)) {
                 set_has_error("subjectCode", true);
                 set_message("subjectCode", "subject code already exists.");
             } else {
                 $new_subjectinfo = new Subject_Model();
                 $new_subjectinfo->setSubjectcode($new_subject_code);
                 $new_subjectinfo->setSubjectdescription($new_subject_description);
                 if ($new_subjectinfo->saveAsnew()) {
                     redirect("dashboard/curriculums/settings/subjects");
                 }
             }
         }
     }
     $this->load->view("management/dashboard/curriculums/settings/subjects/add/view", $this->data);
 }