Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
- class Aggregated extends CI_Controller
- {
- function __construct()
- {
- parent::__construct();
- $this->load->library('asec_giz_api_library');
- }
- function index()
- {
- render('apps/aggregated/index', [], 'main-layout');
- }
- function records($type = '')
- {
- $this->load->model('ProjectTr');
- $get = $_GET;
- if (isset($get['page'])) {
- $get['page'] = (!is_numeric($get['page'])) ? 0 : $get['page'];
- }
- // $get['alias']['search_type_of_pillars_code'] = 'a.type_of_pillars_code';
- if (isGroup("DO")) {
- $get['where'] = "struc_org_id_assign = " . id_user('id_struc_org');
- }
- // $get['debug_query'] = 1;
- // debug_api();
- $data_result = $this->ProjectTr->fetchAllReport(null, $get);
- $data['data'] = ($type == 'excel') ? $data_result : set_nomor_urut($data_result, isset($get['page']) ? $get['page'] : 0);
- foreach ($data['data'] as $key => $value)
- {
- $data['data'][$key]['remarks'] = !empty($value['remarks']) ? $value['remarks'] : '-';
- $data['data'][$key]['main_pillar'] = !empty($value['main_pillar']) ? $value['main_pillar'] : 'Data empty';
- $data['data'][$key]['review_position'] = !empty($value['review_position']) ? $value['review_position'] : '-';
- $data['data'][$key]['id'] = isset($value['type_of_pillars_id']) ? $value['type_of_pillars_id'] : '';
- $data['data'][$key]['create_date'] = dateDbToUser($value['create_date']);
- $data['data'][$key]['modify_date'] = isset($value['modify_date']) ? dateDbToUser($value['modify_date']) : '';
- $data['data'][$key]['programme_txt'] = empty($value['is_programme']) ? 'No' : 'Yes';
- $data['data'][$key]['total_funding'] = number_format($value['propose_total_funding'],2,".",",");
- $data['data'][$key]['email'] = !empty($value['email']) ? $value['email'] : '-';
- $data['data'][$key]['proposal_submission_date'] = date('Y-m-d', strtotime($value['proposal_submission_date']));
- }
- $get['is_num_rows'] = 1;
- $total_rows = (int)$this->ProjectTr->fetchAllReport(null, $get);
- $data['paging'] = ($type == 'excel') ? [] : paging_grid($total_rows, 3);
- if ($type == 'excel') {
- $this->load->helper('excel');
- $this->excel = new Spreadsheet();
- $excel = $this->excel->setActiveSheetIndex(0);
- excelCellValue("A1", 'aggregated as of ' . date('d/m/Y') , array(
- 'fontSize' => 20,
- 'bold' => 1
- ));
- excelHeaderTable("A3:S3", 'CCCCCC');
- excelCellValue("A3", 'No');
- excelCellValue("B3", 'ID');
- excelCellValue("C3", 'Temp-Proposal-ID');
- excelCellValue("D3", 'Project Title');
- excelCellValue("E3", 'Date of Proposal Input');
- excelCellValue("F3", 'Funding Source');
- excelCellValue("G3", 'Category Funding Source');
- excelCellValue("H3", 'Total Funds (USD)');
- excelCellValue("I3", 'Proponent');
- excelCellValue("J3", 'Proponent Country');
- excelCellValue("K3", 'Assign DO Division');
- excelCellValue("L3", 'Main Pillar');
- excelCellValue("M3", 'Review Position');
- excelCellValue("N3", 'Status Action');
- excelCellValue("O3", 'Last Update');
- excelCellValue("P3", 'Remarks');
- excelCellValue("Q3", 'Is Programme');
- excelCellValue("R3", 'Created By');
- excelCellValue("S3", 'Submission Date');
- $row = 4;
- $n = 0;
- foreach ($data['data'] as $key => $value) {
- excelCellValue("A$row", ++$n);
- excelCellValue("B$row", $value['proposal_id']);
- excelCellValue("C$row", $value['proposal_temp_id']);
- excelCellValue("D$row", $value['project_tr_title'], array(
- 'wrap' => 1
- ));
- excelCellValue("E$row", $value['create_date']);
- excelCellValue("F$row", $value['funding_source'], array(
- 'wrap' => 1
- ));
- excelCellValue("G$row", $value['funding_source_parent']);
- excelCellValue("H$row", $value['total_funding']);
- excelCellValue("I$row", $value['proponent'], array(
- 'wrap' => 1
- ));
- excelCellValue("J$row", $value['proponent_country'], array(
- 'wrap' => 1
- ));
- excelCellValue("K$row", str_replace('&', '&', $value['do_division']) , array(
- 'wrap' => 1
- ));
- excelCellValue("L$row", $value['main_pillar'], array(
- 'wrap' => 1
- ));
- excelCellValue("M$row", $value['review_position']);
- excelCellValue("N$row", $value['review_status']);
- excelCellValue("O$row", $value['modify_date']);
- excelCellValue("P$row", $value['remarks']);
- excelCellValue("Q$row", $value['programme_txt']);
- excelCellValue("R$row", $value['email']);
- excelCellValue("S$row", $value['proposal_submission_date']);
- ++$row;
- }
- excelBorder("A3:Q$row");
- // excelAutoWidth();
- excelWidth('A', 10);
- excelWidth('B', 40);
- excelWidth('C', 15);
- excelWidth('D', 70);
- excelWidth('E', 17);
- excelWidth('F', 30);
- excelWidth('G', 30);
- excelWidth('H', 12);
- excelWidth('I', 60);
- excelWidth('J', 35);
- excelWidth('K', 35);
- excelWidth('L', 35);
- excelWidth('O', 17);
- excelWidth('Q', 13);
- excelExport('aggregated-' . date('Ymd'));
- } else {
- render('apps/aggregated/records', $data, 'blank');
- }
- }
- }
- /* End of file Aggregated.php */
- /* Location: ./application/controllers/Aggregated.php */
Advertisement
Add Comment
Please, Sign In to add comment