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); } } }
public function indicatorAddpart4($profID, $ref_id) { if (!$this->session->userdata('user_id')) { redirect('/users/login', 'location'); } $date_today = date('Y-m-d'); $indicator_model = new indicator_model(); $updates_model = new updates_model(); $this->validateAddIndicatorpart4(); $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_addpart4', array('fourthMotherIndicator' => $indicator_model->getFourthMotherIndicator(), 'fourthIndicators' => $indicator_model->getFourthIndicators(), 'fourthCategory' => $indicator_model->getCategoriesFromFourthI(), 'LGUType' => $indicator_model->getLGUtype($profID), 'profileID' => $profID, 'refID' => $ref_id)); $this->load->view('footer'); } else { foreach ($indicator_model->getFourthIndicators() 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 != "") { $addResultBronze = $indicator_model->insertFirstIndicator($profile, $indicator, $complianceBronze, $findings, $ref_id); $updatesResultBronze = $updates_model->insertUpdates($indicator, $profile, $ref_id, $complianceBronze, $complianceBronze, $date_today, 0); } if ($complianceSilver != "") { $addResultSilver = $indicator_model->insertFirstIndicator($profile, $indicator, $complianceSilver, $findings, $ref_id); $updatesResultSilver = $updates_model->insertUpdates($indicator, $profile, $ref_id, $complianceSilver, $complianceSilver, $date_today, 0); } if ($complianceGold != "") { $addResultGold = $indicator_model->insertFirstIndicator($profile, $indicator, $complianceGold, $findings, $ref_id); $updatesResultGold = $updates_model->insertUpdates($indicator, $profile, $ref_id, $complianceGold, $complianceGold, $date_today, 0); } } else { continue; } } foreach ($indicator_model->getCategoriesFromFourthI() 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 = $this->input->post('profID'); $indicator = $secondCat->indicator_id; $findings = $this->input->post('textArea' . $secondCat->indicator_id); if ($complianceBronze != "") { $addResultBronze = $indicator_model->insertFirstIndicator($profile, $indicator, $complianceBronze, $findings, $ref_id); $updatesResultBronze = $updates_model->insertUpdates($indicator, $profile, $ref_id, $complianceBronze, $complianceBronze, $date_today, 0); } if ($complianceSilver != "") { $addResultSilver = $indicator_model->insertFirstIndicator($profile, $indicator, $complianceSilver, $findings, $ref_id); $updatesResultSilver = $updates_model->insertUpdates($indicator, $profile, $ref_id, $complianceSilver, $complianceSilver, $date_today, 0); } if ($complianceGold != "") { $addResultGold = $indicator_model->insertFirstIndicator($profile, $indicator, $complianceGold, $findings, $ref_id); $updatesResultGold = $updates_model->insertUpdates($indicator, $profile, $ref_id, $complianceGold, $complianceGold, $date_today, 0); } } else { continue; } } if ($addResultBronze || $addResultSilver || $addResultGold) { $form_message = 'Add Success!'; $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('indicator_view', array('fourthMotherIndicator' => $indicator_model->getFirstMotherIndicator(), 'fourthIndicators' => $indicator_model->getFirstIndicators(), 'fourthCategory' => $indicator_model->getCategoriesFromFourthI(), 'getFirstCategory' => $indicator_model->getCategoriesFromFI($lguTypes->lgu_type_id), 'getSecondCategory' => $indicator_model->getSecondCategoriesFromFI($lguTypes->lgu_type_id))); $this->load->view('footer'); $scoreProf = $indicator_model->getScorePerProf($profID, $ref_id); $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->updateFunctionalityProfOnly($profID, $level, $totalScore); $this->redirectIndexAddPart4($profID, $ref_id); // $this->redirectIndexViewAll($profID,$ref_id); } } }