コード例 #1
0
ファイル: reports.php プロジェクト: titojaymz/lswdo
 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');
 }
コード例 #2
0
ファイル: monitoring.php プロジェクト: titojaymz/lswdo
 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);
         }
     }
 }
コード例 #3
0
ファイル: indicator.php プロジェクト: titojaymz/lswdo
 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);
         }
     }
 }