From bc74339fbf711a71a601798b16dd4945b7d7e191 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 16 Dec 2019 06:18:37 +0000 Subject: [PATCH] Add checking if serial exists. #288 --- src/Controller/WarrantyController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Controller/WarrantyController.php b/src/Controller/WarrantyController.php index 1d23bc9b..4da828c6 100644 --- a/src/Controller/WarrantyController.php +++ b/src/Controller/WarrantyController.php @@ -531,6 +531,7 @@ class WarrantyController extends Controller foreach($warr_results as $warr) { // check if details are complete + //error_log('Updating warranty with serial number ' . $serial . ' and plate number ' . $plate_number); if (empty($warr->getFirstName())) { if (!empty($first_name)) @@ -604,7 +605,16 @@ class WarrantyController extends Controller } else { - // what if serial exists but plate number is different? + // TODO: what if serial exists but plate number is different? + // check if just the serial exists + // if warranty exists, ignore for now + $w_results = $em->getRepository(Warranty::class)->findBy(['serial' => $serial]); + if (!empty($w_results)) + { + continue; + } + + //error_log('Adding warranty with serial number ' . $serial . ' and plate number ' . $plate_number); // new warranty $warranty = new Warranty();