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