Remove checking of entries. #660

This commit is contained in:
Korina Cordero 2022-05-12 06:08:50 +00:00
parent 3a00a46b73
commit 9318b37077

View file

@ -454,60 +454,46 @@ class WarrantyController extends Controller
$file = $req->files->get('csv_file');
// process the csv file. Call the WarrantyBulkUploader service
$inv_entries = $warr_uploader->warrantyUpload($file);
$entries = $warr_uploader->warrantyUpload($file);
$resp = new StreamedResponse();
if (count($inv_entries) > 0)
{
$resp->setCallback(function() use($inv_entries) {
// csv output
$csv_handle = fopen('php://output', 'w+');
fputcsv($csv_handle, [
'Encoded By',
'Date of Encoded',
'Owner First Name',
'Owner Last Name',
'Owner Email',
'Owner Address',
'Owner Mobile',
'Owner Telephone',
'Vehicle Make',
'Vehicle Model',
'Vehicle Year',
'Vehicle Plate Number',
'Battery Serial Number',
'Battery Sales Invoice',
'Battery Date of Purchase',
'Distributor Name',
'Distributor Address',
'Application Type ID',
'Battery ID',
'Ownership Type',
'Status',
'Reason Warranty Not Added',
]);
foreach ($inv_entries as $row)
{
fputcsv($csv_handle, $row);
}
$resp->setCallback(function() use($entries) {
// csv output
$csv_handle = fopen('php://output', 'w+');
fputcsv($csv_handle, [
'Encoded By',
'Date of Encoded',
'Owner First Name',
'Owner Last Name',
'Owner Email',
'Owner Address',
'Owner Mobile',
'Owner Telephone',
'Vehicle Make',
'Vehicle Model',
'Vehicle Year',
'Vehicle Plate Number',
'Battery Serial Number',
'Battery Sales Invoice',
'Battery Date of Purchase',
'Distributor Name',
'Distributor Address',
'Application Type ID',
'Battery ID',
'Ownership Type',
'Status',
'Reason Warranty Not Added',
]);
foreach ($entries as $row)
{
fputcsv($csv_handle, $row);
}
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 = 'upload_warranty_results' . '.csv';
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');