Merge branch '476-resq-success-message-for-warranty-upload' into '480-resq-august-28-release'
Modified contents of the csv file when no invalid warranties are found. #476 See merge request jankstudio/resq!564
This commit is contained in:
commit
e6dd08d6d0
1 changed files with 46 additions and 31 deletions
|
|
@ -386,6 +386,9 @@ class WarrantyController extends Controller
|
||||||
$inv_entries = $this->processWarrantyFile($file, $em, $wh);
|
$inv_entries = $this->processWarrantyFile($file, $em, $wh);
|
||||||
|
|
||||||
$resp = new StreamedResponse();
|
$resp = new StreamedResponse();
|
||||||
|
|
||||||
|
if (count($inv_entries) > 0)
|
||||||
|
{
|
||||||
$resp->setCallback(function() use($inv_entries) {
|
$resp->setCallback(function() use($inv_entries) {
|
||||||
// csv output
|
// csv output
|
||||||
$csv_handle = fopen('php://output', 'w+');
|
$csv_handle = fopen('php://output', 'w+');
|
||||||
|
|
@ -418,11 +421,23 @@ class WarrantyController extends Controller
|
||||||
fclose($csv_handle);
|
fclose($csv_handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$resp->setCallback(function() {
|
||||||
|
// csv output
|
||||||
|
$csv_handle = fopen('php://output', 'w+');
|
||||||
|
fputcsv($csv_handle, ['No Invalid Warranties']);
|
||||||
|
|
||||||
|
fclose($csv_handle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$filename = 'invalid_warranties' . '.csv';
|
$filename = 'invalid_warranties' . '.csv';
|
||||||
|
|
||||||
$resp->setStatusCode(200);
|
|
||||||
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||||
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||||
|
$resp->setStatusCode(200);
|
||||||
|
|
||||||
return $resp;
|
return $resp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue