public function download_consolidated($id = 0) { $report = Reports::getAllReportRowsByReportId($id); //$this->print_this($report, '$report'); $report = ExcelExporter::formatFileArrays($report); //$this->print_this($report, '$report');exit; ExcelExporter::exportFileTest($report); //$reformattedReport = }
public function download($id = 0) { $currentReport = ConsolidatedReports::getById($id); $version = ConsolidatedReportsVersion::getById($id); # get table headers $originalReport = Reports::getReportById($currentReport->report_id); $reportFiles = ReportFile::getReportFilesById($originalReport->report_id); $reportColumns = array(); if (isset($reportFiles[0])) { $currentOriginalFile = $reportFiles[0]; $currentFileVersion = ReportFileVersion::getCurrentVersion($currentOriginalFile->file_id); // get sheets $reportColumns = ReportFileSheets::getFirstSheetByVersionId($currentFileVersion->version_id); $reportColumns = json_decode($reportColumns); $reportColumns = json_decode($reportColumns->data_table_columns); } # get table data $dataTable = json_decode($version->table_data); $report = ExcelExporter::formatFileArrays($dataTable); # combine headers and data $finalDataTable = array_merge($reportColumns, $report); # file name here $filename = "{$originalReport->incident_name} - Incident Number {$originalReport->incident_number}"; ExcelExporter::exportFileTest($finalDataTable, $filename); //$reformattedReport = }