From 34c22b01e296d27c1de6b33507b2aace9eaa1f6c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 12 Mar 2019 05:30:10 -0400 Subject: [PATCH 1/9] Add getters and setters for LegacyJobOrder. Create service that searches for plate number, name, and phone numbers in the legacy job orders, current job orders, and warranty. Create test command to test the search service. #182 --- src/Command/TestGeneralSearchCommand.php | 70 +++++ src/Entity/LegacyJobOrder.php | 341 +++++++++++++++++++++++ src/Service/GeneralSearch.php | 63 +++++ 3 files changed, 474 insertions(+) create mode 100644 src/Command/TestGeneralSearchCommand.php create mode 100644 src/Service/GeneralSearch.php diff --git a/src/Command/TestGeneralSearchCommand.php b/src/Command/TestGeneralSearchCommand.php new file mode 100644 index 00000000..0696fb86 --- /dev/null +++ b/src/Command/TestGeneralSearchCommand.php @@ -0,0 +1,70 @@ +setName('test:generalsearch') + ->setDescription('Test general search service.') + ->setHelp('Test the general search service.') + ->addArgument('search_term', InputArgument::REQUIRED, 'Search Terms'); + } + + public function __construct(GeneralSearch $search) + { + $this->search = $search; + + parent::__construct(); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $search_term = $input->getArgument('search_term'); + + $results = $this->search->search($search_term); + + echo "legacy job order results: " . count($results['legacy_job_orders']) . "\n"; + + foreach($results['legacy_job_orders'] as $legacy_job_order) + { + echo "Plate Number: " . $legacy_job_order->getPlateNumber() . "\n"; + echo "Mobile Number: " . $legacy_job_order->getCustMobile() . "\n"; + echo "Landline: " . $legacy_job_order->getCustLandline() . "\n"; + echo "Name: " . $legacy_job_order->getCustName() . "\n"; + echo "Last Name: " . $legacy_job_order->getCustLastName() . "\n"; + echo "First Name: " . $legacy_job_order->getCustFirstName() . "\n"; + echo "Middle Name: " . $legacy_job_order->getCustMiddleName() . "\n"; + } + + echo "job order results: " . count($results['job_orders']) . "\n"; + foreach($results['job_orders'] as $job_order) + { + echo "Plate Number: " . $job_order->getCustomerVehicle()->getPlateNumber() . "\n"; + echo "Mobile Number: " . $job_order->getCustomer()->getPhoneMobile() . "\n"; + echo "Landline: " . $job_order->getCustomer()->getPhoneLandline() . "\n"; + echo "Office: " . $job_order->getCustomer()->getPhoneOffice() . "\n"; + echo "Fax: " . $job_order->getCustomer()->getPhoneFax() . "\n"; + echo "Last Name: " . $job_order->getCustomer()->getLastName() . "\n"; + echo "First Name: " . $job_order->getCustomer()->getFirstName() . "\n"; + } + + echo "warranties results: " . count($results['warranties']) . "\n"; + + foreach($results['warranties'] as $warranty) + { + echo "Plate Number: " . $warranty->getPlateNumber() . "\n"; + echo "Mobile Number: " . $warranty->getMobileNumber() . "\n"; + echo "Last Name: " . $warranty->getLastName() . "\n"; + echo "First Name: " . $warranty->getFirstName() . "\n"; + } + } +} diff --git a/src/Entity/LegacyJobOrder.php b/src/Entity/LegacyJobOrder.php index 345fc724..fde4d7ff 100644 --- a/src/Entity/LegacyJobOrder.php +++ b/src/Entity/LegacyJobOrder.php @@ -355,4 +355,345 @@ class LegacyJobOrder { return $this->id; } + + public function setTransDate($trans_date) + { + $this->id = $trans_date; + return $this; + } + + public function getTransDate() + { + return $this->trans_date; + } + + public function setTransType($trans_type) + { + $this->trans_type = $trans_type; + return $this; + } + + public function getTransType() + { + return $this->trans_type; + } + + public function setOrigin($origin) + { + $this->origin = $origin; + return $this; + } + + public function getOrigin() + { + return $this->origin; + } + + public function setCarBrand($car_brand) + { + $this->car_brand = $car_brand; + return $this; + } + + public function getCarBrand() + { + return $this->car_brand; + } + + public function setCarMake($car_make) + { + $this->car_make = $car_make; + return $this; + } + + public function getCarMake() + { + return $this->car_make; + } + + public function setCarModel($car_model) + { + $this->car_model = $car_model; + return $this; + } + + public function getCarModel() + { + return $this->car_model; + } + + public function setCarColor($car_color) + { + $this->car_color = $car_color; + return $this; + } + + public function getCarColor() + { + return $this->car_color; + } + + public function setCustName($cust_name) + { + $this->cust_name = $cust_name; + return $this; + } + + public function getCustName() + { + return $this->cust_name; + } + + public function setCustFirstName($cust_first_name) + { + $this->cust_first_name = $cust_first_name; + return $this; + } + + public function getCustFirstName() + { + return $this->cust_first_name; + } + + public function setCustMiddleName($cust_middle_name) + { + $this->cust_middle_name = $cust_middle_name; + return $this; + } + + public function getCustMiddleName() + { + return $this->cust_middle_name; + } + + public function setCustLastName($cust_last_name) + { + $this->cust_last_name = $cust_last_name; + return $this; + } + + public function getCustLastName() + { + return $this->cust_last_name; + } + + public function setCustContact($cust_contact) + { + $this->cust_contact = $cust_contact; + return $this; + } + + public function getCustContact() + { + return $this->cust_contact; + } + + public function setCustMobile($cust_mobile) + { + $this->cust_mobile = $cust_mobile; + return $this; + } + + public function getCustMobile() + { + return $this->cust_mobile; + } + + public function setCustLandline($cust_landline) + { + $this->cust_landline = $cust_landline; + return $this; + } + + public function getCustLandline() + { + return $this->cust_landline; + } + + public function setDeliveryInstructions($delivery_instructions) + { + $this->delivery_instructions = $delivery_instructions; + return $this; + } + + public function getDeliveryInstructions() + { + return $this->delivery_instructions; + } + + public function setAgentNotes1($agent_notes_1) + { + $this->agent_notes_1 = $agent_notes_1; + return $this; + } + + public function getAgentNotes1() + { + return $this->agent_notes_1; + } + + public function setDeliveryDate($delivery_date) + { + $this->delivery_date = $delivery_date; + return $this; + } + + public function getDeliveryDate() + { + return $this->delivery_date; + } + + public function setDeliveryTime($delivery_time) + { + $this->delivery_time = $delivery_time; + return $this; + } + + public function getDeliveryTime() + { + return $this->delivery_time; + } + + public function setAdvanceOrder($advance_order) + { + $this->advance_order = $advance_order; + return $this; + } + + public function getAdvanceOrder() + { + return $this->advance_order; + } + + public function setStage($stage) + { + $this->stage = $stage; + return $this; + } + + public function getStage() + { + return $this->stage; + } + + public function setCancelReason($cancel_reason) + { + $this->cancel_reason = $cancel_reason; + return $this; + } + + public function getCancelReason() + { + return $this->cancel_reason; + } + + public function setCancelReasonSpecify($cancel_reason_specify) + { + $this->cancel_reason_specify = $cancel_reason_specify; + return $this; + } + + public function getCancelReasonSpecify() + { + return $this->cancel_reason_specify; + } + + public function setPaymentMethod($payment_method) + { + $this->payment_method = $payment_method; + return $this; + } + + public function getPaymentMethod() + { + return $this->payment_method; + } + + public function setPreparedBy($prepared_by) + { + $this->prepared_by = $prepared_by; + return $this; + } + + public function getPreparedBy() + { + return $this->prepared_by; + } + + public function setDispatchTime($dispatch_time) + { + $this->dispatch_time = $dispatch_time; + return $this; + } + + public function getDispatchTime() + { + return $this->dispatch_time; + } + + public function setDispatchDate($dispatch_date) + { + $this->dispatch_date = $dispatch_date; + return $this; + } + + public function getDispatchDate() + { + return $this->dispatch_date; + } + + public function setDispatchBy($dispatch_by) + { + $this->dispatch_by = $dispatch_by; + return $this; + } + + public function getDispatchBy() + { + return $this->dispatch_by; + } + + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + public function getAddress() + { + return $this->address; + } + + public function setLandmark($landmark) + { + $this->landmark = $landmark; + return $this; + } + + public function getLandmark() + { + return $this->landmark; + } + + public function setDatePurchase($date_purchase) + { + $this->date_purchase = $date_purchase; + return $this; + } + + public function getDatePurchase() + { + return $this->date_purchase; + } + + public function setPlateNumber($plate_number) + { + $this->plate_number = $plate_number; + return $this; + } + + public function getPlateNumber() + { + return $this->plate_number; + } } diff --git a/src/Service/GeneralSearch.php b/src/Service/GeneralSearch.php new file mode 100644 index 00000000..a6da2685 --- /dev/null +++ b/src/Service/GeneralSearch.php @@ -0,0 +1,63 @@ +em = $em; + } + + public function search($search_term) + { + // query legacy job orders for plate number, name (first, middle, last), phone number(mobile, landline) + $legacy_job_orders = $this->em->createQuery('SELECT l FROM App\Entity\LegacyJobOrder l + WHERE l.plate_number LIKE :search_term + OR l.cust_mobile LIKE :search_term + OR l.cust_landline LIKE :search_term + OR l.cust_name LIKE :search_term + OR l.cust_last_name LIKE :search_term + OR l.cust_middle_name LIKE :search_term + OR l.cust_first_name LIKE :search_term + OR l.cust_contact LIKE :search_term') + ->setParameter('search_term', "%" . $search_term . "%") + ->getResult(); + + // query current job orders for plate number, name(first, last), phone number(mobile, landline, office, fax) + // join with customervehicle for plate number. join with customer for name and number + $job_orders = $this->em->createQuery('SELECT jo FROM App\Entity\JobOrder jo + JOIN jo.cus_vehicle cv + JOIN jo.customer c + WHERE cv.plate_number LIKE :search_term + OR c.first_name LIKE :search_term + OR c.last_name LIKE :search_term + OR c.phone_mobile LIKE :search_term + OR c.phone_landline LIKE :search_term + OR c.phone_office LIKE :search_term + OR c.phone_fax LIKE :search_term') + ->setParameter('search_term', "%" . $search_term . "%") + ->getResult(); + + // query warranty for plate number, name(first, last), phone number(mobile) + $warranties = $this->em->createQuery('SELECT w FROM App\Entity\Warranty w + WHERE w.plate_number LIKE :search_term + OR w.first_name LIKE :search_term + OR w.last_name LIKE :search_term + OR w.mobile_number LIKE :search_term') + ->setParameter('search_term', "%" . $search_term . "%") + ->getResult(); + + $results = array('legacy_job_orders'=>$legacy_job_orders, 'job_orders'=>$job_orders, 'warranties'=>$warranties); + + return $results; + } +} From e447973bb0b7002051c8675cf5f34e9b55fe9480 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 12 Mar 2019 23:23:56 -0400 Subject: [PATCH 2/9] Add the search items to acl.yaml and menu.yaml #182 --- config/acl.yaml | 2 ++ config/menu.yaml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/config/acl.yaml b/config/acl.yaml index f50b9d33..a1152234 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -211,6 +211,8 @@ access_keys: acls: - id: support.menu label: Menu + - id: general.search + label: Search - id: ticket label: Ticket Access acls: diff --git a/config/menu.yaml b/config/menu.yaml index 9da352f9..fd870fea 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -118,3 +118,7 @@ main_menu: acl: ticket.list label: Tickets parent: support + - id: general_search + acl: general.search + label: Search + parent: support From dc842aab5e72eccb244efba5e89b4128dd48d1f7 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 13 Mar 2019 03:17:47 -0400 Subject: [PATCH 3/9] Create controller, route, and default page for search #182 --- config/routes/search.yaml | 3 ++ src/Controller/SearchController.php | 28 ++++++++++++++++ templates/search/list.html.twig | 51 +++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 config/routes/search.yaml create mode 100644 src/Controller/SearchController.php create mode 100644 templates/search/list.html.twig diff --git a/config/routes/search.yaml b/config/routes/search.yaml new file mode 100644 index 00000000..239392bc --- /dev/null +++ b/config/routes/search.yaml @@ -0,0 +1,3 @@ +general_search: + path: /search + controller: App\Controller\SearchController::index diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php new file mode 100644 index 00000000..d84e643c --- /dev/null +++ b/src/Controller/SearchController.php @@ -0,0 +1,28 @@ +acl_gen = $acl_gen; + parent::__construct($menu_gen); + } + + public function index() + { + $this->denyaccessUnlessGranted('general.search', null, 'No access.'); + $params = $this->initParameters('general_search'); + + // response + return $this->render('search/list.html.twig', $params); + } +} diff --git a/templates/search/list.html.twig b/templates/search/list.html.twig new file mode 100644 index 00000000..f2863436 --- /dev/null +++ b/templates/search/list.html.twig @@ -0,0 +1,51 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Search +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} + From bd1009dac914d60fb076be95cda5622cbad11538 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 14 Mar 2019 04:44:59 -0400 Subject: [PATCH 4/9] Implement the search feature from the controller #182 --- config/routes/search.yaml | 5 +++++ src/Controller/SearchController.php | 27 +++++++++++++++++++++++++++ templates/search/list.html.twig | 28 +++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/config/routes/search.yaml b/config/routes/search.yaml index 239392bc..b3a53477 100644 --- a/config/routes/search.yaml +++ b/config/routes/search.yaml @@ -1,3 +1,8 @@ general_search: path: /search controller: App\Controller\SearchController::index + +search_history: + path: /search/history + controller: App\Controller\SearchController::search + methods: [POST] diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index d84e643c..ea9e8425 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -3,6 +3,10 @@ namespace App\Controller; use App\Ramcar\BaseController; +use App\Service\GeneralSearch; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use App\Menu\Generator as MenuGenerator; use App\Access\Generator as ACLGenerator; @@ -25,4 +29,27 @@ class SearchController extends BaseController // response return $this->render('search/list.html.twig', $params); } + + public function search(Request $req, GeneralSearch $search) + { + $this->denyAccessUnlessGranted('general.search', null, 'No access.'); + + $search_term = $req->request->get('data-rows-search'); + $results = $search->search($search_term); + + // process rows + // this is not how to process the results. + // TODO: fix this asap + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow[0]->getID(); + + $rows[] = $row; + } + + return $this->json([ + 'data' => $rows + ]); + } } diff --git a/templates/search/list.html.twig b/templates/search/list.html.twig index f2863436..7c325483 100644 --- a/templates/search/list.html.twig +++ b/templates/search/list.html.twig @@ -23,12 +23,14 @@
+
- +
+
@@ -46,6 +48,30 @@ {% block scripts %} {% endblock %} From fc94bfbef19828ee501236a6e5f9e85670fe49c2 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 14 Mar 2019 07:31:44 -0400 Subject: [PATCH 5/9] Set a maximum number of results for the query. Fix the issue of the search word not sent to the controller. #182 --- src/Controller/SearchController.php | 31 +++++++++++++++++++++++----- src/Service/GeneralSearch.php | 5 +++++ templates/search/list.html.twig | 32 ++++++----------------------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index ea9e8425..fe99eb86 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -38,15 +38,36 @@ class SearchController extends BaseController $results = $search->search($search_term); // process rows - // this is not how to process the results. - // TODO: fix this asap $rows = []; - foreach ($obj_rows as $orow) { - // add row data - $row['id'] = $orow[0]->getID(); + // get the legacy job order results + foreach($results['legacy_job_orders'] as $lrow) + { + $row['id'] = $lrow->getID(); + $row['name'] = $lrow->getCustName(); + $row['plate_number'] = $lrow->getPlateNumber(); $rows[] = $row; } + + // get the job order results + foreach($results['job_orders'] as $jrow) + { + $row['id'] = $jrow->getID(); + $row['name'] = $jrow->getCustomer()->getFirstName() . " " . $jrow->getCustomer()->getLastName(); + $row['plate_number'] = $jrow->getCustomerVehicle()->getPlateNumber(); + + $rows[] = $row; + } + + // get the warranties results + foreach($results['warranties'] as $wrow) + { + $row['id'] = $wrow->getID(); + $row['name'] = $wrow->getFirstName() . " " . $wrow->getLastName(); + $row['plate_number'] = $wrow->getPlateNumber(); + + $rows[] = $row; + } return $this->json([ 'data' => $rows diff --git a/src/Service/GeneralSearch.php b/src/Service/GeneralSearch.php index a6da2685..5a5b47ed 100644 --- a/src/Service/GeneralSearch.php +++ b/src/Service/GeneralSearch.php @@ -8,6 +8,8 @@ use App\Entity\Warranty; use Doctrine\ORM\EntityManagerInterface; +define("SEARCH_MAX_RESULTS", "20"); + class GeneralSearch { protected $em; @@ -30,6 +32,7 @@ class GeneralSearch OR l.cust_first_name LIKE :search_term OR l.cust_contact LIKE :search_term') ->setParameter('search_term', "%" . $search_term . "%") + ->setMaxResults(SEARCH_MAX_RESULTS) ->getResult(); // query current job orders for plate number, name(first, last), phone number(mobile, landline, office, fax) @@ -45,6 +48,7 @@ class GeneralSearch OR c.phone_office LIKE :search_term OR c.phone_fax LIKE :search_term') ->setParameter('search_term', "%" . $search_term . "%") + ->setMaxResults(SEARCH_MAX_RESULTS) ->getResult(); // query warranty for plate number, name(first, last), phone number(mobile) @@ -54,6 +58,7 @@ class GeneralSearch OR w.last_name LIKE :search_term OR w.mobile_number LIKE :search_term') ->setParameter('search_term', "%" . $search_term . "%") + ->setMaxResults(SEARCH_MAX_RESULTS) ->getResult(); $results = array('legacy_job_orders'=>$legacy_job_orders, 'job_orders'=>$job_orders, 'warranties'=>$warranties); diff --git a/templates/search/list.html.twig b/templates/search/list.html.twig index 7c325483..2a16c22d 100644 --- a/templates/search/list.html.twig +++ b/templates/search/list.html.twig @@ -23,9 +23,9 @@
-
+
- + @@ -48,30 +48,10 @@ {% block scripts %} {% endblock %} From b021479d2ef791bd3da28c7074836cec07fdfa1c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 15 Mar 2019 05:16:22 -0400 Subject: [PATCH 6/9] Fix display issue for search results #182 --- config/routes/search.yaml | 2 +- src/Controller/SearchController.php | 10 ++--- templates/search/list.html.twig | 9 ++-- templates/search/results.html.twig | 68 +++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 templates/search/results.html.twig diff --git a/config/routes/search.yaml b/config/routes/search.yaml index b3a53477..54bebd51 100644 --- a/config/routes/search.yaml +++ b/config/routes/search.yaml @@ -5,4 +5,4 @@ general_search: search_history: path: /search/history controller: App\Controller\SearchController::search - methods: [POST] + methods: [GET] diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index fe99eb86..45a582cd 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -33,8 +33,9 @@ class SearchController extends BaseController public function search(Request $req, GeneralSearch $search) { $this->denyAccessUnlessGranted('general.search', null, 'No access.'); + $params = $this->initParameters('general_search'); - $search_term = $req->request->get('data-rows-search'); + $search_term = $req->query->get('search'); $results = $search->search($search_term); // process rows @@ -43,7 +44,7 @@ class SearchController extends BaseController foreach($results['legacy_job_orders'] as $lrow) { $row['id'] = $lrow->getID(); - $row['name'] = $lrow->getCustName(); + $row['name'] = $lrow->getCustFirstName() . " " . $lrow->getCustLastName(); $row['plate_number'] = $lrow->getPlateNumber(); $rows[] = $row; @@ -69,8 +70,7 @@ class SearchController extends BaseController $rows[] = $row; } - return $this->json([ - 'data' => $rows - ]); + $params['data'] = $rows; + return $this->render('search/results.html.twig', $params); } } diff --git a/templates/search/list.html.twig b/templates/search/list.html.twig index 2a16c22d..0d715c80 100644 --- a/templates/search/list.html.twig +++ b/templates/search/list.html.twig @@ -23,9 +23,9 @@
- +
- + @@ -37,7 +37,8 @@
-
+
+
@@ -52,6 +53,8 @@ { e.preventDefault(); } + {% endblock %} + diff --git a/templates/search/results.html.twig b/templates/search/results.html.twig new file mode 100644 index 00000000..4b03c86c --- /dev/null +++ b/templates/search/results.html.twig @@ -0,0 +1,68 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Search +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+ + + + +
+ +
+
+
+
+
+ +
+ + {% for result in data %} + + + + + + {% endfor %} +
{{ result.id }} {{ result.name }} {{ result.plate_number }}
+
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} + From 97570405d6caed04e5a25a8a8a3fd4c29b8c1e95 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 18 Mar 2019 03:20:22 -0400 Subject: [PATCH 7/9] Display the results into three separate tables #182 --- src/Controller/SearchController.php | 34 +---------------------------- templates/search/results.html.twig | 32 +++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index 45a582cd..1d73c4d7 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -38,39 +38,7 @@ class SearchController extends BaseController $search_term = $req->query->get('search'); $results = $search->search($search_term); - // process rows - $rows = []; - // get the legacy job order results - foreach($results['legacy_job_orders'] as $lrow) - { - $row['id'] = $lrow->getID(); - $row['name'] = $lrow->getCustFirstName() . " " . $lrow->getCustLastName(); - $row['plate_number'] = $lrow->getPlateNumber(); - - $rows[] = $row; - } - - // get the job order results - foreach($results['job_orders'] as $jrow) - { - $row['id'] = $jrow->getID(); - $row['name'] = $jrow->getCustomer()->getFirstName() . " " . $jrow->getCustomer()->getLastName(); - $row['plate_number'] = $jrow->getCustomerVehicle()->getPlateNumber(); - - $rows[] = $row; - } - - // get the warranties results - foreach($results['warranties'] as $wrow) - { - $row['id'] = $wrow->getID(); - $row['name'] = $wrow->getFirstName() . " " . $wrow->getLastName(); - $row['plate_number'] = $wrow->getPlateNumber(); - - $rows[] = $row; - } - - $params['data'] = $rows; + $params['data'] = $results; return $this->render('search/results.html.twig', $params); } } diff --git a/templates/search/results.html.twig b/templates/search/results.html.twig index 4b03c86c..268bc9c6 100644 --- a/templates/search/results.html.twig +++ b/templates/search/results.html.twig @@ -38,12 +38,36 @@
+

Legacy Job Orders

- {% for result in data %} + {% for key, result in data.legacy_job_orders %} - - - + + + + + + {% endfor %} +
{{ result.id }} {{ result.name }} {{ result.plate_number }} {{ result.getID() }} {{ result.getCustLastName() }} {{ result.getCustFirstName() }} {{ result.getPlateNumber() }}
+

Job Orders

+ + {% for result in data.job_orders %} + + + + + + + {% endfor %} +
{{ result.getID() }} {{ result.getCustomer().getLastName() }} {{ result.getCustomer().getFirstName() }} {{ result.getCustomerVehicle().getPlateNumber() }}
+

Warranties

+ + {% for result in data.warranties %} + + + + + {% endfor %}
{{ result.getID() }} {{ result.getLastName() }} {{ result.getFirstName() }} {{ result.getPlateNumber() }}
From 9e5b597d44404da5440237e1988f0cd46c197b83 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 18 Mar 2019 04:01:25 -0400 Subject: [PATCH 8/9] Add table headers to tables. Set default value to display if field is null for legacy job orders #182 --- templates/search/results.html.twig | 33 +++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/templates/search/results.html.twig b/templates/search/results.html.twig index 268bc9c6..9d1fa07a 100644 --- a/templates/search/results.html.twig +++ b/templates/search/results.html.twig @@ -40,34 +40,43 @@

Legacy Job Orders

+ + + {% for key, result in data.legacy_job_orders %} - - - - + + + + {% endfor %}
ID Last Name Plate Number
{{ result.getID() }} {{ result.getCustLastName() }} {{ result.getCustFirstName() }} {{ result.getPlateNumber() }} {{ result.getID }} {{ result.getCustLastName | default('') }} {{ result.getCustFirstNamei | default('') }} {{ result.getPlateNumber | default('') }}

Job Orders

+ + + {% for result in data.job_orders %} - - - - + + + + {% endfor %}
ID Last Name Plate Number
{{ result.getID() }} {{ result.getCustomer().getLastName() }} {{ result.getCustomer().getFirstName() }} {{ result.getCustomerVehicle().getPlateNumber() }} {{ result.getID }} {{ result.getCustomer.getLastName }} {{ result.getCustomer.getFirstName }} {{ result.getCustomerVehicle.getPlateNumber }}

Warranties

+ + + {% for result in data.warranties %} - - - - + + + + {% endfor %}
ID Last Name Plate Number
{{ result.getID() }} {{ result.getLastName() }} {{ result.getFirstName() }} {{ result.getPlateNumber() }} {{ result.getID }} {{ result.getLastName }} {{ result.getFirstName }} {{ result.getPlateNumber }}
From 179fbe3718df43a7602b1ac18c9b797a75a6b68c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 18 Mar 2019 06:07:28 -0400 Subject: [PATCH 9/9] Add checking if results are empty #182 --- templates/search/results.html.twig | 78 +++++++++++++++++------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/templates/search/results.html.twig b/templates/search/results.html.twig index 9d1fa07a..83d0ea93 100644 --- a/templates/search/results.html.twig +++ b/templates/search/results.html.twig @@ -40,45 +40,57 @@

Legacy Job Orders

- - - - {% for key, result in data.legacy_job_orders %} - - - - - - - {% endfor %} + {% if data.legacy_job_orders is empty %} + + {% else %} + + + + {% for key, result in data.legacy_job_orders %} + + + + + + + {% endfor %} + {% endif %}
ID Last Name Plate Number
{{ result.getID }} {{ result.getCustLastName | default('') }} {{ result.getCustFirstNamei | default('') }} {{ result.getPlateNumber | default('') }}
No records for legacy job orders ID Last Name Plate Number
{{ result.getID }} {{ result.getCustLastName | default('') }} {{ result.getCustFirstNamei | default('') }} {{ result.getPlateNumber | default('') }}

Job Orders

- - - - {% for result in data.job_orders %} - - - - - - - {% endfor %} + {% if data.job_orders is empty %} + + {% else %} + + + + {% for result in data.job_orders %} + + + + + + + {% endfor %} + {% endif %}
ID Last Name Plate Number
{{ result.getID }} {{ result.getCustomer.getLastName }} {{ result.getCustomer.getFirstName }} {{ result.getCustomerVehicle.getPlateNumber }}
No records for job orders ID Last Name Plate Number
{{ result.getID }} {{ result.getCustomer.getLastName }} {{ result.getCustomer.getFirstName }} {{ result.getCustomerVehicle.getPlateNumber }}

Warranties

- - - - {% for result in data.warranties %} - - - - - - - {% endfor %} + {% if data.warranties is empty %} + + {% else %} + + + + {% for result in data.warranties %} + + + + + + + {% endfor %} + {% endif %}
ID Last Name Plate Number
{{ result.getID }} {{ result.getLastName }} {{ result.getFirstName }} {{ result.getPlateNumber }}
No records for warranties ID Last Name Plate Number
{{ result.getID }} {{ result.getLastName }} {{ result.getFirstName }} {{ result.getPlateNumber }}