fix file name adding more information

This commit is contained in:
Marco Cavalli 2023-10-12 16:37:45 +02:00
parent 01bbae8d54
commit 784c620012
1 changed files with 6 additions and 7 deletions

View File

@ -77,7 +77,6 @@ class GiteaApiController extends Controller
header('Content-Type: text/csv'); header('Content-Type: text/csv');
// tell the browser we want to save it instead of displaying it // tell the browser we want to save it instead of displaying it
header('Content-Disposition: attachment; filename="' . $file_name . '.csv";'); header('Content-Disposition: attachment; filename="' . $file_name . '.csv";');
exit();
} }
private function date_to_datetime(string $date) private function date_to_datetime(string $date)
@ -103,13 +102,12 @@ class GiteaApiController extends Controller
} }
} }
if (count($data) > 0 && $data[0]['Chiuso_il'] != '') { if (count($data) > 0) {
$file_name = date('Y_F', strtotime(explode(' ', $data[0]['Chiuso_il'])[0])); $file_name = $issues_params['state']."_issues_from_".$from_date."_to_".$to_date;
$this->create_csv($file_name, $data); $this->create_csv($file_name, $data);
return true; return true;
} else {
return false;
} }
return false;
} }
public function export_closed_issues(Request $req) public function export_closed_issues(Request $req)
@ -119,9 +117,10 @@ class GiteaApiController extends Controller
} }
$from = $req->input('from_year') . '-' . $req->input('from_month') . '-01'; $from = $req->input('from_year') . '-' . $req->input('from_month') . '-01';
$to = $req->input('to_year') . '-' . $req->input('to_month') . '-31'; $to = $req->input('to_year') . '-' . $req->input('to_month') . '-31';
$this->export_issues($from, $to, ['state' => $req->input('issues_type')]); $res = $this->export_issues($from, $to, ['state' => $req->input('issues_type')]);
return view('backend', [ return view('backend', [
'token' => getenv('GITEA_TOKEN') 'token' => getenv('GITEA_TOKEN'),
'download' => $res
]); ]);
} }
} }