public function dashboard() { $regCode = $this->session->userdata('lswdo_regioncode'); $dashboard_model = new dashboard_model(); $indicator_model = new indicator_model(); $provCode = 0; $lgu_PSWDO = 1; $lgu_CSWDO = 2; $lgu_MSWDO = 3; $getIndicator = $dashboard_model->getFunctionalityScore($regCode); $f = ''; $ff = ''; $pf = ''; $region = ''; foreach ($getIndicator as $item) { $f .= $item->Functional . ','; $ff .= $item->FullyFunctional . ','; $pf .= $item->PartiallyFunctional . ','; $region .= "'" . $item->region_name . "',"; } $region_format = substr($region, 0, -1); $ffscore_format = substr($ff, 0, -1); $fscore_format = substr($f, 0, -1); $pfscore_format = substr($pf, 0, -1); $this->validateAddForm(); if (!$this->form_validation->run()) { $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('dashboard', array('region_format' => $region_format, 'ffscore_format' => $ffscore_format, 'fscore_format' => $fscore_format, 'pfscore_format' => $pfscore_format, 'lguType' => 0)); $this->load->view('footer'); } else { $lguType = $this->input->post('LGUtype'); $getNoncompliance = $indicator_model->getScorePartarray1($regCode, $provCode, $lguType); $getCompliance = $indicator_model->getScorePartarray2($regCode, $provCode, $lguType); $unformat = ""; $unformat2 = ""; foreach ($getNoncompliance as $key => $value) { $unformat .= '"' . $value['indicator_name'] . '",'; $unformat2 .= "" . $value['TotalNonCompliance'] . ","; } $nonComplianceName = substr($unformat, 0, -1); $nonCompliance = substr($unformat2, 0, -1); $unformat3 = ""; $unformat4 = ""; foreach ($getCompliance as $key => $value) { $unformat3 .= '"' . $value['indicator_name'] . '",'; $unformat4 .= "" . $value['TotalCompliance'] . ","; } $complianceName = substr($unformat3, 0, -1); $compliance = substr($unformat4, 0, -1); $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('dashboard', array('region_format' => $region_format, 'ffscore_format' => $ffscore_format, 'fscore_format' => $fscore_format, 'pfscore_format' => $pfscore_format, 'lguType' => $lguType, 'nonComplianceName' => $nonComplianceName, 'nonCompliance' => $nonCompliance, 'complianceName' => $complianceName, 'compliance' => $compliance)); $this->load->view('footer'); } }
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 monitoring_add($profID) { if (!$this->session->userdata('user_id')) { redirect('/users/login', 'location'); } $validity_model = new Validity_model(); $visit_model = new Visit_model(); $monitoring_model = new Monitoring_Model(); $this->validateAddMonitoring(); if ($this->form_validation->run() == FALSE) { //if ($this->input->post('insert') <> "") { $form_message = ''; $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('monitoring_add', array('getVisitCount' => $visit_model->getVisitCount(), 'getValidity' => $validity_model->getValidity(), 'monitoring_model' => $monitoring_model, 'visit_model' => $visit_model, 'validity_model' => $validity_model, 'getStatus' => $monitoring_model->getStatus(), 'countVisits' => $monitoring_model->countVisits($profID))); $this->load->view('footer'); } else { //$certfication_model = new Certification_Model(); /*$validity_model = new Validity_model(); $visit_model = new Visit_model(); $monitoring_model = new Monitoring_Model();*/ //$profile_id ='9'; $profile_id = $this->input->post('profile_id'); //mglv $ref_cert_id = '0'; $visit_count = $this->input->post('visit_count'); $visit_status = $this->input->post('visit_status'); //date $strVisitDate = $this->input->post('visit_date'); $visitDateToDate = date_create($strVisitDate); $visit_date = date_format($visitDateToDate, "Y-m-d"); //date $remarks = $this->input->post('remarks'); $created_by = $this->session->userdata('user_id'); $date_created = 'NOW()'; $modified_by = $this->session->userdata('user_id'); $date_modified = '0000-00-00'; $deleted = '0'; $addResult = $monitoring_model->insertLswdoMonitoring($profile_id, $ref_cert_id, $visit_count, $visit_date, $visit_status, $remarks, $created_by, $date_created, $modified_by, $date_modified, $deleted); if ($addResult) { $indicator_model = new indicator_model(); /*$form_message = 'Add Success!'; $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('monitoring_list', array( 'getDataByProfileID' => $monitoring_model->getDataByProfileID(), 'getVisitCount' => $visit_model->getVisitCount(), 'getValidity' => $validity_model->getValidity(), 'monitoring_model' => $monitoring_model, 'visit_model' => $visit_model, 'validity_model' => $validity_model, )); $this->load->view('footer');*/ $form_message = ''; $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('indicator_add', array('firstMotherIndicator' => $indicator_model->getFirstMotherIndicator(), 'firstIndicators' => $indicator_model->getFirstIndicators())); $this->load->view('footer'); $this->redirectIndex($profile_id, $addResult); } } }
public function summaryLSWDO($regCode, $provCode, $cityCode, $lguType) { $indicator_model = new indicator_model(); $reports_model = new reports_model(); // Create new PHPExcel object $objPHPExcel = new PHPExcel(); $firstMotherIndicator = $indicator_model->getFirstMotherIndicator(); $secondMotherIndicator = $indicator_model->getSecondMotherIndicator(); $fourthMotherIndicator = $indicator_model->getFourthMotherIndicator(); $thirdMotherIndicator = $indicator_model->getThirdMotherIndicator(); $getScorePart1 = $indicator_model->getsummaryLSWDO($regCode, $provCode, $cityCode); $getPart1 = $indicator_model->getPart1($lguType); $getPart2 = $indicator_model->getPart2($lguType); $getPart3 = $indicator_model->getPart3($lguType); $getPart4 = $indicator_model->getPart4($lguType); $get_totalAssess = $reports_model->get_totalAssess($regCode, $provCode, $lguType); $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Compliance/Non Compliance Per indicator'); //autosize column $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFill()->getStartColor()->setRGB('FF0000'); // $objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(-1);a $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20); $objPHPExcel->getActiveSheet()->mergeCells('B1:E2'); //Center text merge columns $objPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->applyFromArray(array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER)); // $col = 'A'; // $row = 5; $objPHPExcel->getActiveSheet()->setCellValue('A3', 'Areas'); $objPHPExcel->getActiveSheet()->getStyle('A3')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->setCellValue('B3', 'Distribution of functional by Province -Sample title'); $objPHPExcel->getActiveSheet()->mergeCells('A3:A5'); $objPHPExcel->getActiveSheet()->mergeCells('B3:E3'); //Center text merge columns $objPHPExcel->getActiveSheet()->getStyle('B3')->getAlignment()->applyFromArray(array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER)); $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->applyFromArray(array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER)); $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objPHPExcel->getActiveSheet()->mergeCells('B6:e6'); $objPHPExcel->getActiveSheet()->freezePane('B6'); //Header $objPHPExcel->getActiveSheet()->setCellValue('B4', 'Indicators'); $objPHPExcel->getActiveSheet()->getStyle('B4')->getAlignment()->applyFromArray(array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER)); //Start Editing //Part1 $row2 = 7; $col2 = 'A'; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $firstMotherIndicator->indicator_name); $col2++; $row2++; foreach ($getPart1 as $firstPartIndicator) { if ($firstPartIndicator->indicator_checklist_id == 1) { $arr = explode("-", $firstPartIndicator->indicator_id); $indicatorID = $arr[0]; foreach ($getScorePart1 as $scorePart1) { if ($scorePart1->indicator_id == $firstPartIndicator->indicator_id) { $indicator_id = $firstPartIndicator->indicator_name; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $indicator_id); if ($col2 == 'B') { $col2 = 'B'; } $row2++; } } } } //Part2 $col2 = 'A'; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $secondMotherIndicator->indicator_name); $col2++; $row2++; foreach ($getPart2 as $secondPartIndicator) { if ($secondPartIndicator->indicator_checklist_id == 1) { $arr = explode("-", $secondPartIndicator->indicator_id); $indicatorID = $arr[0]; foreach ($getScorePart1 as $scorePart1) { if ($scorePart1->indicator_id == $secondPartIndicator->indicator_id) { $indicator_id = $secondPartIndicator->indicator_name; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $indicator_id); if ($col2 == 'B') { $col2 = 'B'; } $row2++; } } } } //Part3 $col2 = 'A'; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $thirdMotherIndicator->indicator_name); $col2++; $row2++; foreach ($getPart3 as $thirdPartIndicator) { if ($thirdPartIndicator->indicator_checklist_id == 1) { $arr = explode("-", $thirdPartIndicator->indicator_id); $indicatorID = $arr[0]; foreach ($getScorePart1 as $scorePart1) { if ($scorePart1->indicator_id == $thirdPartIndicator->indicator_id) { $indicator_id = $thirdPartIndicator->indicator_name; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $indicator_id); if ($col2 == 'B') { $col2 = 'B'; } $row2++; } } } } //Part4 $col2 = 'A'; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $fourthMotherIndicator->indicator_name); $col2++; $row2++; foreach ($getPart4 as $fourthPartIndicator) { if ($fourthPartIndicator->indicator_checklist_id == 1) { $arr = explode("-", $fourthPartIndicator->indicator_id); $indicatorID = $arr[0]; foreach ($getScorePart1 as $scorePart1) { if ($scorePart1->indicator_id == $fourthPartIndicator->indicator_id) { $indicator_id = $fourthPartIndicator->indicator_name; $objPHPExcel->getActiveSheet()->setCellValue($col2 . $row2, $indicator_id); if ($col2 == 'B') { $col2 = 'B'; } $row2++; } } } } //End Editing // //border $objPHPExcel->getActiveSheet()->getStyle('A1:' . $objPHPExcel->getActiveSheet()->getHighestColumn() . $objPHPExcel->getActiveSheet()->getHighestRow())->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); // Rename worksheet (worksheet, not filename) $objPHPExcel->setActiveSheetIndex(0)->setTitle('LSWDO-Summary'); // Add new sheet // Add some data // Set active sheet index to the first sheet, so Excel opens this as the first asheet $objPHPExcel->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Excel2007) //clean the output buffer ob_end_clean(); //this is the header given from PHPExcel examples. but the output seems somewhat corrupted in some cases. //header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); //so, we use this header instead. // $regionName = $this->reports_model->getRegionName($region); $filename = 'Summary.xlsx'; header('Content-type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename=' . $filename); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); }
public function indicatorDeletepart4($profID, $ref_id) { if (!$this->session->userdata('user_id')) { redirect('/users/login', 'location'); } $indicator_model = new indicator_model(); $lguTypes = $indicator_model->getLGUtype($profID); $updateResult = $indicator_model->deleteIndicatorpart4($profID, $ref_id); if ($updateResult) { $form_message = 'Add Success!'; $this->load->view('header'); $this->load->view('nav'); $this->load->view('sidebar'); $this->load->view('indicator_viewpart4'); $this->load->view('footer'); $this->redirectIndexAddPart4($profID, $ref_id); } }