From b021479d2ef791bd3da28c7074836cec07fdfa1c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 15 Mar 2019 05:16:22 -0400 Subject: [PATCH] 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 %} +