Ejemplo n.º 1
0
 public function curriculum_settings_add_classtype()
 {
     if ($this->input->post(sha1("addclasstype"))) {
         $this->form_validation->set_rules("classtypeCode", "Class type Code", "trim|required|xss_xlean");
         $this->form_validation->set_rules("classtypeAlias", "Class type Alias", "trim|required|xss_xlean");
         $this->form_validation->set_rules("classtypeDescription", "Class type Description", "trim|required|xss_xlean");
         if ($this->form_validation->run() == false) {
             if (form_error("classtypeCode")) {
                 set_has_error("classtypeCode", true);
                 set_message("classtypeCode", form_error("classtypeCode", " ", " "));
             }
             if (form_error("classtypeAlias")) {
                 set_has_error("classtypeAlias", true);
                 set_message("classtypeAlias", form_error("classtypeAlias", " ", " "));
             }
             if (form_error("classtypeDescription")) {
                 set_has_error("classtypeDescription", true);
                 set_message("classtypeDescription", form_error("classtypeDescription", " ", " "));
             }
         } else {
             $new_classtype_code = $this->input->post("classtypeCode");
             $new_classtype_alias = $this->input->post("classtypeAlias");
             $new_classtype_description = $this->input->post("classtypeDescription");
             if (is_class_type_exist(false, $new_classtype_code)) {
                 set_has_error("classtypeCode", true);
                 set_message("classtypeCode", "Class type code already exists.");
             } else {
                 $newclasstypeinfo = new Class_Type_Model();
                 $newclasstypeinfo->setClasstypecode($new_classtype_code);
                 $newclasstypeinfo->setClasstypealias($new_classtype_alias);
                 $newclasstypeinfo->setClasstypedescription($new_classtype_description);
                 if ($newclasstypeinfo->saveAsnew()) {
                     redirect("dashboard/curriculums/settings/classtypes");
                 }
             }
         }
     }
     $this->load->view("management/dashboard/curriculums/settings/classtypes/add/view", $this->data);
 }