diff --git a/src/Controller/WarrantyController.php b/src/Controller/WarrantyController.php index 2923de92..c3e6f284 100644 --- a/src/Controller/WarrantyController.php +++ b/src/Controller/WarrantyController.php @@ -40,17 +40,20 @@ class WarrantyController extends Controller // find the warranty $qb = $this->getDoctrine() ->getRepository(Warranty::class) - ->createQueryBuilder('q'); + ->createQueryBuilder('w'); - $query = $qb->select('w') - ->where('w.serial = :serial') + $query = $qb->where('w.serial = :serial') ->andWhere('w.plate_number = :platenum') ->setParameter('serial', $serial) - ->setParameter('plate_num', $plate_num); - $results = $query->getQuery()->execute(); + ->setParameter('platenum', $plate_num); + $results = $query->getQuery()->getResult(); - $params['data'] = $results; - $params['battery_serial'] = $battery_serial; + $res = []; + foreach ($results as $result) { + $res[] = $result; + } + $params['data'] = $res; + $params['battery_serial'] = $serial; $params['owner_name'] = $name; $params['plate_num'] = $plate_num; $params['mode'] = "results"; diff --git a/templates/warranty-search/form.html.twig b/templates/warranty-search/form.html.twig index f72c8ecc..371ee1ea 100644 --- a/templates/warranty-search/form.html.twig +++ b/templates/warranty-search/form.html.twig @@ -36,9 +36,9 @@
-

+

+
@@ -68,6 +68,71 @@
{% if mode == 'results' %} +
+
+
+
+
+
+

+ Warranty Information +

+
+
+
+
+ {% if data is empty %} + + {% else %} + + + + + + + + + {% for key, result in data %} + + + + + + + + + + + + + + + + + + + + + + + + + {% endfor %} + +
Battery Serial Number{{ result.getSerial|default("") }}
Owner Name{{ result.getFirstName|default("") ~ ' ' ~ result.getLastName|default("") }}
Vehicle Plate Number{{ result.getPlateNumber|default("") }}
Purchase Date{{ result.getDatePurchase|date("d M Y") }}
Battery{{ result.getBatteryModel.getName|default("") ~ ' - ' ~ result.getBatterySize.getName|default("") }}
End of Warranty{{ result.getDateExpire|date("d M Y") }}
+ {% endif %} +
+
+
+
{% endif %}
{% endblock %}