From c695a1f9b2e5bf82b598c952954dd4f410d8caf3 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 8 Aug 2019 04:17:58 +0000 Subject: [PATCH 1/6] Add popapp comparison report link to Reports. Add route and access to report. #248 --- config/acl.yaml | 2 ++ config/routes/report.yaml | 5 +++++ templates/base.html.twig | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/config/acl.yaml b/config/acl.yaml index 9de80027..64b53ad1 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -290,6 +290,8 @@ access_keys: label: Rejection Report - id: report.battery.conflict label: Battery Conflict Report + - id: report.popapp.comparison + label: Popapp Comparison Report - id: service label: Other Services diff --git a/config/routes/report.yaml b/config/routes/report.yaml index c8560798..25d637c6 100644 --- a/config/routes/report.yaml +++ b/config/routes/report.yaml @@ -27,3 +27,8 @@ rep_battery_conflict_submit: path: /report/battery_conflict controller: App\Controller\ReportController::batteryConflictSubmit methods: [POST] + +rep_popapp_comp_form: + path: /report/popapp_comparison + controller: App\Controller\ReportController::popappComparisonForm + methods: [POST] diff --git a/templates/base.html.twig b/templates/base.html.twig index e61acf78..9052bb17 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -140,6 +140,26 @@ + +
+
+
+

Popapp Comparison Report

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ Upload Popapp CSV File +

+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} From 10d9800bda6df2d4b81c7c6fe3c96181ead81831 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 9 Aug 2019 07:40:32 +0000 Subject: [PATCH 3/6] Add static class to check if plate number is valid. #248 --- src/Ramcar/InvalidPlateNumber.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/Ramcar/InvalidPlateNumber.php diff --git a/src/Ramcar/InvalidPlateNumber.php b/src/Ramcar/InvalidPlateNumber.php new file mode 100644 index 00000000..43f3a736 --- /dev/null +++ b/src/Ramcar/InvalidPlateNumber.php @@ -0,0 +1,20 @@ + Date: Fri, 9 Aug 2019 07:42:18 +0000 Subject: [PATCH 4/6] Display customer and warranty information for serials from the uploaded CSV file. #248 --- src/Controller/ReportController.php | 64 ++++++++++++++++++++----- templates/report/popapp/form.html.twig | 66 ++++++++++++++++++++++++-- 2 files changed, 113 insertions(+), 17 deletions(-) diff --git a/src/Controller/ReportController.php b/src/Controller/ReportController.php index 0e66687e..224019d2 100644 --- a/src/Controller/ReportController.php +++ b/src/Controller/ReportController.php @@ -5,12 +5,14 @@ namespace App\Controller; use App\Ramcar\JORejectionReason; use App\Ramcar\ServiceType; use App\Ramcar\JOStatus; +use App\Ramcar\InvalidPlateNumber; use App\Entity\JORejection; use App\Entity\Battery; use App\Entity\JobOrder; use App\Entity\Warranty; use App\Entity\CustomerVehicle; +use App\Entity\MobileSession; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; @@ -410,22 +412,31 @@ class ReportController extends Controller public function popappComparisonForm() { $this->denyAccessUnlessGranted('report.popapp.comparison', null, 'No access.'); + $params['mode'] = 'form'; - return $this->render('report/popapp/form.html.twig'); + return $this->render('report/popapp/form.html.twig', $params); } + /** + * @Menu(selected="outlet_list") + */ public function popappComparisonSubmit(Request $req) { // retrieve temporary info for file $file = $req->files->get('csv_file'); // process the csv file - $this->processPopappFile($file); + $data = $this->processPopappFile($file); // return response - return $this->json([ - 'success' => true, - ]); + //return $this->json([ + // 'success' => true, + // 'data' => $data, + //]); + $params['mode'] = 'results'; + $params['data'] = $data; + + return $this->render('report/popapp/form.html.twig', $params); } protected function processPopappFile(UploadedFile $csv_file) @@ -456,24 +467,53 @@ class ReportController extends Controller } // get the warranty for serial - $qb = $this->getDoctrine() + $warr_qb = $this->getDoctrine() ->getRepository(Warranty::class) ->createQueryBuilder('q'); - $warranty_query = $qb->select('q') + $warranty_query = $warr_qb->select('q') ->where('q.serial IN(:serials)') ->setParameter('serials', $serial_numbers, Connection::PARAM_STR_ARRAY); $warr_results = $warranty_query->getQuery()->getResult(); // get the plate numbers - $plate_numbers = []; + $results = []; foreach ($warr_results as $warranty) { - $plate_numbers[] = $warranty->getPlateNumber(); - // what if plate number is 0000 or NONE? + //error_log($warranty->getPlateNumber()); + // validate the plate number + $isValid = InvalidPlateNumber::isInvalid($warranty->getPlateNumber()); + if ($isValid) + { + // get customer vehicle using plate number + $em = $this->getDoctrine()->getManager(); + $cust_vehicles = $em->getRepository(CustomerVehicle::class)->findBy(['plate_number' => $warranty->getPlateNumber()]); + foreach ($cust_vehicles as $cv) + { + // get customer info + // get mobile session of customer + //error_log($cv->getCustomer()->getLastName() . ' ' . $cv->getCustomer()->getFirstName()); + $has_mobile = false; + $mobile_session = $em->getRepository(MobileSession::class)->findBy(['customer' => $cv->getCustomer()->getID()]); + foreach ($mobile_session as $mobile) + { + error_log($mobile->getID()); + $has_mobile = true; + } + $results[] = [ + 'cust_id' => $cv->getCustomer()->getID(), + 'cust_lastname' => $cv->getCustomer()->getLastName(), + 'cust_firstname' => $cv->getCustomer()->getFirstName(), + 'plate_num' => $cv->getPlateNumber(), + 'serial' => $warranty->getSerial(), + 'warr_date_create' => $warranty->getDateCreate()->format("d M Y"), + 'has_mobile' => $has_mobile, + ]; + + } + } } - // search in customer vehicle using the plate numbers - + return $results; } } diff --git a/templates/report/popapp/form.html.twig b/templates/report/popapp/form.html.twig index bc176c63..1dad59a6 100644 --- a/templates/report/popapp/form.html.twig +++ b/templates/report/popapp/form.html.twig @@ -5,7 +5,9 @@
-

Popapp Comparison Report

+

+ Popapp Comparison Report +

@@ -46,10 +48,64 @@ + {% if mode == 'results' %} + +
+
+
+
+
+
+

+ Report Details +

+
+
+
+
+ {% if data is empty %} + + {% else %} + + + + + + + + + + + + + + {% for key, result in data %} + + + + + + + + + + {% endfor %} + +
Customer IDLast NameFirst NamePlate NumberSerialWarranty Create DateHas Mobile?
{{ result.cust_id|default("") }}{{ result.cust_lastname|default('') }}{{ result.cust_firstname|default('') }}{{ result.plate_num|default('') }}{{ result.serial|default('') }}{{ result.warr_date_create|default('') }}{{ result.has_mobile ? Yes : 'No' }}
+ {% endif %} +
+
+
+
+ {% endif %} {% endblock %} -{% block scripts %} - -{% endblock %} From ec17cd4c7735f4303f6dcad8e7c8b98c1004b651 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 9 Aug 2019 07:46:37 +0000 Subject: [PATCH 5/6] Modify 'Has Mobile?' to 'Has Mobile App?'. #248 --- templates/report/popapp/form.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/report/popapp/form.html.twig b/templates/report/popapp/form.html.twig index 1dad59a6..cd02cfd4 100644 --- a/templates/report/popapp/form.html.twig +++ b/templates/report/popapp/form.html.twig @@ -83,7 +83,7 @@ Plate Number Serial Warranty Create Date - Has Mobile? + Has Mobile App? From c11393b69e19ea869dcb2f6bdb03810602ec74ce Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 9 Aug 2019 08:01:23 +0000 Subject: [PATCH 6/6] Add Activation Status column to report. #248 --- src/Controller/ReportController.php | 1 + templates/report/popapp/form.html.twig | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Controller/ReportController.php b/src/Controller/ReportController.php index 224019d2..c92b071b 100644 --- a/src/Controller/ReportController.php +++ b/src/Controller/ReportController.php @@ -508,6 +508,7 @@ class ReportController extends Controller 'serial' => $warranty->getSerial(), 'warr_date_create' => $warranty->getDateCreate()->format("d M Y"), 'has_mobile' => $has_mobile, + 'warr_activation_status' => $warranty->isActivated(), ]; } diff --git a/templates/report/popapp/form.html.twig b/templates/report/popapp/form.html.twig index cd02cfd4..f48ada3d 100644 --- a/templates/report/popapp/form.html.twig +++ b/templates/report/popapp/form.html.twig @@ -83,6 +83,7 @@ Plate Number Serial Warranty Create Date + Activation Status Has Mobile App? @@ -95,7 +96,8 @@ {{ result.plate_num|default('') }} {{ result.serial|default('') }} {{ result.warr_date_create|default('') }} - {{ result.has_mobile ? Yes : 'No' }} + {{ result.warr_activation_status ? 'Active' : 'Inactive' }} + {{ result.has_mobile ? 'Yes' : 'No' }} {% endfor %}