Beispiel #1
0
 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');
 }
Beispiel #2
0
 public function indicatorEditpart4($profID, $ref_id)
 {
     if (!$this->session->userdata('user_id')) {
         redirect('/users/login', 'location');
     }
     $indicator_model = new indicator_model();
     $this->validateAddIndicatorpart3();
     $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_editpart4', array('fourthMotherIndicator' => $indicator_model->getFourthMotherIndicator(), 'fourthIndicators' => $indicator_model->getFourthIndicators(), 'fourthCategory' => $indicator_model->getCategoriesFromFourthI(), 'getLSWDO' => $indicator_model->getLSWDOdata($profID, $ref_id), 'profileID' => $profID, 'refID' => $ref_id));
         $this->load->view('footer');
     } else {
         foreach ($indicator_model->getCategoriesFromTI($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->getSecondCategoriesFromTI($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 = $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('thirdMotherIndicator' => $indicator_model->getThirdMotherIndicator(), 'thirdIndicators' => $indicator_model->getThirdIndicators(), 'getFirstCategory' => $indicator_model->getCategoriesFromTI($lguTypes->lgu_type_id), 'getSecondCategory' => $indicator_model->getSecondCategoriesFromTI($lguTypes->lgu_type_id)));
             $this->load->view('footer');
             $this->redirectIndexAddPart2($profID, $ref_id);
         }
     }
 }