示例#1
0
 public function index()
 {
     !$this->session->userdata('user_id') ? redirect('user') : null;
     $identifier = $this->session->userdata('user_indicator');
     // get user_id
     $user_id = $this->session->userdata('user_id');
     //get last log in
     $lastlogin = user::get_last_login($user_id);
     //pass data to view
     $data['lastlogin'] = date("l, jS F Y g:i a", strtotime($lastlogin));
     //exit;
     switch ($identifier) {
         case 'moh':
             $view = 'shared_files/template/dashboard_template_v';
             break;
         case 'facility_admin':
         case 'facility':
             //check if password is default
             //get last order
             $lastorder = user::get_last_order($user_id);
             //pass data to view
             if (!empty($lastorder)) {
                 $data['lastorder'] = date("l, jS F Y ", strtotime($lastorder['last_order']));
                 $data['order_no'] = $lastorder['order_no'];
                 $data['commodity_name'] = $lastorder['commodity_name'];
                 $data['quantity_ordered_pack'] = $lastorder['quantity_ordered_pack'];
                 $data['quantity_ordered_unit'] = $lastorder['quantity_ordered_unit'];
                 $data['order_total'] = $lastorder['order_total'];
             } else {
                 $data['no_order'] = "N/A";
             }
             $lastissue = user::get_last_issue($user_id);
             if (!empty($lastissue)) {
                 $data['last_issue'] = date("l, jS F Y ", strtotime($lastissue['last_issue']));
                 $data['commodity_name'] = $lastissue['commodity_name'];
                 $data['qty_issued'] = $lastissue['qty_issued'];
                 $data['issued_to'] = $lastissue['issued_to'];
             } else {
                 $data['no_issue'] = "N/A";
             }
             $username = $this->session->userdata('user_email');
             $facility_id = $this->session->userdata('facility_id');
             $reply = User::getPass($username);
             $user_data = $reply->toArray();
             $token = $user_data["password"];
             $default = '123456';
             $data['identifier'] = $identifier;
             $salt = '#*seCrEt!@-*%';
             $password = md5($salt . $default);
             if ($token == "{$password}") {
                 //$data['content_view'] = "shared_files/activation";
                 //$this -> session -> set_flashdata('system_success_message', "This is a security measure.Please Change Your Password to Proceed.");
                 $view = 'shared_files/enforce_change';
                 //$this -> load -> view('shared_files/activation');
             } else {
                 $last_synced = Facilities::get_days_from_last_sync($facility_id);
                 // $last_synced = 10;
                 if ($last_synced > 7) {
                     $view = "shared_files/template/template";
                     $data['last_synced'] = $last_synced;
                     $data['content_view'] = "shared_files/synchronize_now";
                 } else {
                     $view = 'shared_files/template/template';
                     $data['content_view'] = "facility/facility_home_v";
                     $data['facility_dashboard_notifications'] = $this->get_facility_dashboard_notifications_graph_data();
                 }
                 // echo "<pre>"; print_r($last_synced); echo "</pre>"; exit;
             }
             break;
         case 'recovery':
             $facility = $this->session->userdata('facility_id');
             $view = 'shared_files/template/template';
             $data['title'] = "User Management";
             $data['banner_text'] = "User Management";
             $data['current_user_id'] = $this->session->userdata('user_id');
             $data['content_view'] = "shared_files/user_recovery_v";
             $data['listing'] = Users::get_user_list_facility($facility);
             break;
         case 'district':
             $data['content_view'] = "subcounty/subcounty_home_v";
             $view = 'shared_files/template/template';
             break;
         case 'moh_user':
             $view = '';
             break;
         case 'scmlt':
         case 'rtk_county_admin':
         case 'allocation_committee':
         case 'rtk_partner_admin':
         case 'rtk_manager':
         case 'rtk_partner_admin':
         case 'rtk_partner_super':
             redirect('http://41.89.6.223/HCMP/user');
             //redirect('http://192.168.133.23/HCMP/user');
             break;
         case 'super_admin':
             $view = 'shared_files/template/dashboard_v';
             $data['content_view'] = "shared_files/template/super_admin_template";
             break;
             // case 'allocation_committee':
             // $view = '';
             break;
         case 'county':
             $view = 'shared_files/template/template';
             $data['content_view'] = "subcounty/subcounty_home_v";
             break;
     }
     $data['title'] = "System Home";
     $data['banner_text'] = "Home";
     $this->load->view($view, $data);
 }