From 5187b106907f5cceac6751ae70c3ff48e3e1a7a3 Mon Sep 17 00:00:00 2001 From: Ken Chapple Date: Tue, 10 Dec 2019 09:46:16 -0500 Subject: [PATCH] file name download should include MD5 from the contents of getCode #48 --- .../Zermelo/Http/Controllers/TabularApiController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CareSet/Zermelo/Http/Controllers/TabularApiController.php b/src/CareSet/Zermelo/Http/Controllers/TabularApiController.php index dfd7227..42a8efb 100644 --- a/src/CareSet/Zermelo/Http/Controllers/TabularApiController.php +++ b/src/CareSet/Zermelo/Http/Controllers/TabularApiController.php @@ -47,6 +47,13 @@ public function download( ZermeloRequest $request ) $reportGenerator = new ReportGenerator( $cache ); $collection = $reportGenerator->getCollection(); + // File name download should include MD5 from the contents of getCode #48 + if ($report->getCode()) { + $filename = $report->GetReportName() . '-'.$report->getCode().'.csv'; + } else { + $filename = $report->GetReportName() . '.csv'; + } + $response = new StreamedResponse( function() use ( $header, $collection ) { // Open output stream $handle = fopen('php://output', 'w'); @@ -65,7 +72,7 @@ public function download( ZermeloRequest $request ) }, 200, [ 'Content-Description' => 'File Transfer', 'Content-Type' => 'text/csv', - 'Content-Disposition' => 'attachment; filename="'.$report->GetReportName().'.csv"', + 'Content-Disposition' => 'attachment; filename="'.$filename.'"', 'Content-Type' => 'application/octet-stream', 'Expires' => '0', 'Cache-Control' => 'must-revalidate',