Пример #1
0
 public function indicatorEdit($profID, $ref_id)
 {
     if (!$this->session->userdata('user_id')) {
         redirect('/users/login', 'location');
     }
     $indicator_model = new indicator_model();
     $this->validateAddIndicator();
     $lguTypes = $indicator_model->getLGUtype($profID);
     if (!$this->form_validation->run()) {
         $form_message = '';
         $this->load->view('header');
         $this->load->view('nav');
         $this->load->view('sidebar');
         $this->load->view('indicator_edit', array('firstMotherIndicator' => $indicator_model->getFirstMotherIndicator(), 'firstIndicators' => $indicator_model->getFirstIndicators(), 'getFirstCategory' => $indicator_model->getCategoriesFromFI($lguTypes->lgu_type_id), 'getSecondCategory' => $indicator_model->getSecondCategoriesFromFI($lguTypes->lgu_type_id), 'getLSWDO' => $indicator_model->getLSWDOdata($profID, $ref_id), 'profileID' => $profID, 'refID' => $ref_id));
         $this->load->view('footer');
     } else {
         foreach ($indicator_model->getCategoriesFromFI($lguTypes->lgu_type_id) as $firstCatBronze) {
             if ($firstCatBronze->indicator_checklist_id != '0') {
                 $complianceBronze = $this->input->post('compliance' . $firstCatBronze->indicator_id . 'Bronze');
                 $complianceSilver = $this->input->post('compliance' . $firstCatBronze->indicator_id . 'Silver');
                 $complianceGold = $this->input->post('compliance' . $firstCatBronze->indicator_id . 'Gold');
                 $profile = $this->input->post('profID');
                 $indicator = $firstCatBronze->indicator_id;
                 $findings = $this->input->post('textArea' . $firstCatBronze->indicator_id);
                 if ($complianceBronze != "") {
                     $updateResultBronze = $indicator_model->updateIndicator($profile, $indicator, $complianceBronze, $findings, $ref_id);
                 }
                 if ($complianceSilver != "") {
                     $updateResultSilver = $indicator_model->updateIndicator($profile, $indicator, $complianceSilver, $findings, $ref_id);
                 }
                 if ($complianceGold != "") {
                     $updateResultGold = $indicator_model->updateIndicator($profile, $indicator, $complianceGold, $findings, $ref_id);
                 }
             } else {
                 continue;
             }
         }
         foreach ($indicator_model->getSecondCategoriesFromFI($lguTypes->lgu_type_id) as $secondCat) {
             if ($secondCat->indicator_checklist_id != '0') {
                 $complianceBronze = $this->input->post('compliance' . $secondCat->indicator_id . 'Bronze');
                 $complianceSilver = $this->input->post('compliance' . $secondCat->indicator_id . 'Silver');
                 $complianceGold = $this->input->post('compliance' . $secondCat->indicator_id . 'Gold');
                 $profile = $profile = $this->input->post('profID');
                 $indicator = $secondCat->indicator_id;
                 $findings = $this->input->post('textArea' . $secondCat->indicator_id);
                 if ($complianceBronze != "") {
                     $updateResultBronze = $indicator_model->updateIndicator($profile, $indicator, $complianceBronze, $findings, $ref_id);
                 }
                 if ($complianceSilver != "") {
                     $updateResultSilver = $indicator_model->updateIndicator($profile, $indicator, $complianceSilver, $findings, $ref_id);
                 }
                 if ($complianceGold != "") {
                     $updateResultGold = $indicator_model->updateIndicator($profile, $indicator, $complianceGold, $findings, $ref_id);
                 }
             } else {
                 continue;
             }
         }
         if ($updateResultBronze || $updateResultSilver || $updateResultGold) {
             $form_message = 'Add Success!';
             $this->load->view('header');
             $this->load->view('nav');
             $this->load->view('sidebar');
             $this->load->view('indicator_view', array('firstMotherIndicator' => $indicator_model->getFirstMotherIndicator(), 'firstIndicators' => $indicator_model->getFirstIndicators(), 'getFirstCategory' => $indicator_model->getCategoriesFromFI($lguTypes->lgu_type_id), 'getSecondCategory' => $indicator_model->getSecondCategoriesFromFI($lguTypes->lgu_type_id)));
             $this->load->view('footer');
             $this->redirectIndex($profID, $ref_id);
         }
     }
 }