public static function saveConsolidatedReport($_fields = array())
 {
     $report = new ConsolidatedReports();
     $report->report_id = $_fields['report_id'];
     $report->status = $_fields['status'];
     $report->generated_by = $_fields['generated_by'];
     $report->save();
     return $report;
 }
 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 =
 }