public function save($table = "")
 {
     if ($table == "counties") {
         $county_name = $this->input->post("name");
         $new_county = new Counties();
         $new_county->county = $county_name;
         $new_county->save();
         $this->session->set_userdata('msg_success', 'County: ' . $county_name . ' was Added');
         $this->session->set_userdata('default_link', 'addCounty');
     } else {
         if ($table == "facilities") {
             $satellite_code = $this->input->post("facility");
             if ($satellite_code) {
                 $central_code = $this->session->userdata("facility");
                 $sql = "update facilities set parent='{$central_code}' where facilitycode='{$satellite_code}'";
                 $this->db->query($sql);
                 $this->session->set_userdata('msg_success', 'Facility No: ' . $satellite_code . ' was Added as a Satellite');
             }
             $this->session->set_userdata('default_link', 'addSatellite');
         } else {
             if ($table == "district") {
                 $disrict_name = $this->input->post("name");
                 $new_district = new District();
                 $new_district->Name = $disrict_name;
                 $new_district->save();
                 $this->session->set_userdata('msg_success', 'District: ' . $disrict_name . ' was Added');
                 $this->session->set_userdata('default_link', 'addDistrict');
             } else {
                 if ($table == "menu") {
                     $menu_name = $this->input->post("menu_name");
                     $menu_url = $this->input->post("menu_url");
                     $menu_desc = $this->input->post("menu_description");
                     $new_menu = new Menu();
                     $new_menu->Menu_Text = $menu_name;
                     $new_menu->Menu_Url = $menu_url;
                     $new_menu->Description = $menu_desc;
                     $new_menu->save();
                     $this->session->set_userdata('msg_success', 'Menu: ' . $menu_name . ' was Added');
                     $this->session->set_userdata('default_link', 'addMenu');
                 } else {
                     if ($table == "faq") {
                         $faq_module = $this->input->post("faq_module");
                         $faq_question = $this->input->post("faq_question");
                         $faq_answer = $this->input->post("faq_answer");
                         $new_faq = new Faq();
                         $new_faq->modules = $faq_module;
                         $new_faq->questions = $faq_question;
                         $new_faq->answers = $faq_answer;
                         $new_faq->save();
                         $this->session->set_userdata('msg_success', 'FAQ was Added');
                         $this->session->set_userdata('default_link', 'addFAQ');
                     } else {
                         if ($table == "users") {
                             //default password
                             $default_password = '******';
                             $user_data = array('Name' => $this->input->post('fullname', TRUE), 'Username' => $this->input->post('username', TRUE), 'Password' => md5($this->encrypt->get_key() . $default_password), 'Access_Level' => $this->input->post('access_level', TRUE), 'Facility_Code' => $this->input->post('facility', TRUE), 'Created_By' => $this->session->userdata('user_id'), 'Time_Created' => date('Y-m-d,h:i:s A'), 'Phone_Number' => $this->input->post('phone', TRUE), 'Email_Address' => $this->input->post('email', TRUE), 'Active' => 1, 'Signature' => 1);
                             $this->db->insert("users", $user_data);
                             $this->session->set_userdata('msg_success', 'User: '******'fullname', TRUE) . ' was Added');
                             $this->session->set_userdata('default_link', 'addUsers');
                         } else {
                             if ($table == "user_right") {
                                 $access_level = $this->input->post("access_level");
                                 $menu = $this->input->post("menus");
                                 if ($menu) {
                                     $new_right = new User_Right();
                                     $new_right->Access_Level = $access_level;
                                     $new_right->Menu = $menu;
                                     $new_right->Access_Type = "4";
                                     $new_right->save();
                                     $this->session->set_userdata('msg_success', 'User Right was Added');
                                     $this->session->set_userdata('default_link', 'assignRights');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     redirect("home_controller/home");
 }