public function home()
 {
     //
     $rights = User_Right::getRights($this->session->userdata('access_level'));
     $menu_data = array();
     $menus = array();
     $counter = 0;
     foreach ($rights as $right) {
         $menu_data['menus'][$right->Menu] = $right->Access_Type;
         $menus['menu_items'][$counter]['url'] = $right->Menu_Item->Menu_Url;
         $menus['menu_items'][$counter]['text'] = $right->Menu_Item->Menu_Text;
         $counter++;
     }
     $this->session->set_userdata($menu_data);
     $this->session->set_userdata($menus);
     //Check if the user is a pharmacist. If so, update his/her local envirinment with current values
     if ($this->session->userdata('user_indicator') == "pharmacist") {
         $facility_code = $this->session->userdata('facility');
         //Retrieve the Totals of the records in the master database that have clones in the clients!
         $today = date('m/d/Y');
         $timestamp = strtotime($today);
         $data['scheduled_patients'] = Patient_Appointment::getAllScheduled($timestamp);
     }
     $data['title'] = "System Home";
     $data['content_view'] = "home_v";
     $data['banner_text'] = "System Home";
     $data['link'] = "home";
     $this->load->view("template", $data);
 }
 function dave()
 {
     $year = $_POST['year'];
     $disease = $_POST['disease'];
     $province = $_POST['province'];
     $epiweek = $_POST['epiweek'];
     $values = array($year, $disease, $province, $epiweek);
     $currentyear = date('Y');
     $rights = User_Right::getRights($this->session->userdata('access_level'));
     $menu_data = array();
     $menus = array();
     $counter = 0;
     foreach ($rights as $right) {
         $menu_data['menus'][$right->Menu] = $right->Access_Type;
         $menus['menu_items'][$counter]['url'] = $right->Menu_Item->Menu_Url;
         $menus['menu_items'][$counter]['text'] = $right->Menu_Item->Menu_Text;
         $counter++;
     }
     $this->session->set_userdata($menu_data);
     $this->session->set_userdata($menus);
     $provinces = Province::getAll();
     $epiweeks = Surveillance::getEpiweek();
     $years = Surveillance::getYears();
     $diseases = Diseases::getAllObjects();
     $this->load->database();
     $sql = 'select Districts.name as District, Lmcase,Gmcase,Lfcase,Gfcase from Surveillance,Districts,Diseases where Epiweek = ? and Disease = ? and Reporting_Year = ? and abs(Lmcase) != 0 and abs(Gmcase) != 0 and abs(Lfcase) != 0 and ABS(Gfcase) != 0  and surveillance.disease=diseases.id and surveillance.district=districts.id';
     $query = $this->db->query($sql, array($epiweek, $disease, $year));
     $data['epidemiks'] = $query->result_array();
     $data['epiweeks'] = $epiweeks;
     $data['provinces'] = $provinces;
     $data['years'] = $years;
     $data['diseases'] = $diseases;
     $data['values'] = $values;
     $data['scripts'] = array("FusionCharts/FusionCharts.js");
     $data['title'] = "System Home";
     $data['content_view'] = "home_v";
     $data['banner_text'] = "System Home";
     $data['link'] = "home";
     $this->load->view("template", $data);
 }
示例#3
0
 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");
 }