Merge branch '258-upload-warranty-csv' into 'master'

Add reason for invalid warranty. #258

Closes #258

See merge request jankstudio/resq!320
This commit is contained in:
Korina Cordero 2019-11-18 04:43:50 +00:00
commit 4c5733f891

View file

@ -26,6 +26,11 @@ use Catalyst\MenuBundle\Annotation\Menu;
class WarrantyController extends Controller
{
const PURCHASE_DATE_EMPTY = 'Purchase date missing.';
const PLATE_NUM_EMPTY = 'Plate number missing.';
const SERIAL_EMPTY = 'Serial number missing.';
const PURCHASE_DATE_INVALID = 'Invalid purchase date.';
/**
* @Menu(selected="warranty_list")
*/
@ -398,6 +403,7 @@ class WarrantyController extends Controller
'Application Type ID',
'Battery ID',
'Ownership Type',
'Reason Warranty Not Added',
]);
foreach ($inv_entries as $row)
{
@ -477,6 +483,19 @@ class WarrantyController extends Controller
empty($serial) ||
($date_purchase == false))
{
$reason = '';
if (empty($plate_number))
$reason = $reason . self::PLATE_NUM_EMPTY . ' ';
if (empty($serial))
$reason = $reason . self::SERIAL_EMPTY . ' ';
if (empty($purchase_date))
$reason = $reason . self::PURCHASE_DATE_EMPTY . ' ';
else
{
if ($date_purchase == false)
$reason = $reason . self::PURCHASE_DATE_INVALID . ' ';
}
// add to invalid_entries
$invalid_entries[] = [
'owner_first_name' => $first_name,
@ -496,7 +515,8 @@ class WarrantyController extends Controller
'distributor_address' => trim($fields[14]),
'application_type_id' => trim($fields[15]),
'battery_id' => $battery_id,
'ownership_typ' => trim($fields[17]),
'ownership_type' => trim($fields[17]),
'reason' => $reason,
];
}
else