コード例 #1
0
ファイル: updates.php プロジェクト: titojaymz/lswdo
 public function updateAdd($profID, $refID)
 {
     if (!$this->session->userdata('user_id')) {
         redirect('/users/login', 'location');
     }
     $date_today = date('Y-m-d');
     $updates_model = new updates_model();
     $indicator_model = new indicator_model();
     $this->validateUpdatesIndicator();
     if (!$this->form_validation->run()) {
         $form_message = '';
         $this->load->view('header');
         $this->load->view('nav');
         $this->load->view('sidebar');
         $this->load->view('updates_add', array('getDetail' => $updates_model->getDetails($profID, $refID), 'getMotherIndicator' => $updates_model->getMotherIndicator()));
         $this->load->view('footer');
     } else {
         $date_today = date('Y-m-d');
         $indicatorID = $this->input->post('indicatorID');
         $compliance = $this->input->post('compliance');
         $getIndicatorUpdate = $updates_model->getIndicatorUpdate($indicatorID);
         $count = count($getIndicatorUpdate);
         if ($count > 0) {
             $updatesResultBronze = $updates_model->updateUpdates($indicatorID, $profID, $refID, $compliance, $date_today);
         } else {
             $updatesResultBronze = $updates_model->insertUpdates($indicatorID, $profID, $refID, $compliance, $compliance, $date_today, 1);
         }
         if ($updatesResultBronze) {
             $form_message = 'Add Success!';
             $this->load->view('header');
             $this->load->view('nav');
             $this->load->view('sidebar');
             $this->load->view('updates_add', array('getDetail' => $updates_model->getDetails($profID, $refID), 'getMotherIndicator' => $updates_model->getMotherIndicator()));
             $this->load->view('footer');
             $scoreProf = $indicator_model->getScorePerProf($profID, $refID);
             $getPerc = $scoreProf->FinalScore;
             $totalScore = $scoreProf->TotalScore;
             if ($getPerc == 100) {
                 $level = 'Fully Functional';
             } elseif ($getPerc > 50 && $getPerc < 100) {
                 $level = 'Functional';
             } elseif ($getPerc < 51) {
                 $level = 'Partially Functional';
             }
             $addFunction = $indicator_model->updateFunctionality($profID, $refID, $level, $totalScore);
             $this->redirectIndex($profID, $refID);
         }
     }
 }