Fix query for warranty. Display result of query. #223
This commit is contained in:
parent
749c3a75c8
commit
63e751528d
2 changed files with 77 additions and 9 deletions
|
|
@ -40,17 +40,20 @@ class WarrantyController extends Controller
|
||||||
// find the warranty
|
// find the warranty
|
||||||
$qb = $this->getDoctrine()
|
$qb = $this->getDoctrine()
|
||||||
->getRepository(Warranty::class)
|
->getRepository(Warranty::class)
|
||||||
->createQueryBuilder('q');
|
->createQueryBuilder('w');
|
||||||
|
|
||||||
$query = $qb->select('w')
|
$query = $qb->where('w.serial = :serial')
|
||||||
->where('w.serial = :serial')
|
|
||||||
->andWhere('w.plate_number = :platenum')
|
->andWhere('w.plate_number = :platenum')
|
||||||
->setParameter('serial', $serial)
|
->setParameter('serial', $serial)
|
||||||
->setParameter('plate_num', $plate_num);
|
->setParameter('platenum', $plate_num);
|
||||||
$results = $query->getQuery()->execute();
|
$results = $query->getQuery()->getResult();
|
||||||
|
|
||||||
$params['data'] = $results;
|
$res = [];
|
||||||
$params['battery_serial'] = $battery_serial;
|
foreach ($results as $result) {
|
||||||
|
$res[] = $result;
|
||||||
|
}
|
||||||
|
$params['data'] = $res;
|
||||||
|
$params['battery_serial'] = $serial;
|
||||||
$params['owner_name'] = $name;
|
$params['owner_name'] = $name;
|
||||||
$params['plate_num'] = $plate_num;
|
$params['plate_num'] = $plate_num;
|
||||||
$params['mode'] = "results";
|
$params['mode'] = "results";
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@
|
||||||
<form id="warranty-search-form" autocomplete="off" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="get" action="{{ url('search_warranty') }}">
|
<form id="warranty-search-form" autocomplete="off" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="get" action="{{ url('search_warranty') }}">
|
||||||
<div class="m-portlet__body">
|
<div class="m-portlet__body">
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<h4 class="m-portlet__head-text">
|
<label>
|
||||||
Please fill up at least two (2) of the fields below to view battery's warranty status.
|
Please fill up at least two (2) of the fields below to view battery's warranty status.
|
||||||
</h4>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<label data-field="battery_serial">Battery Serial Number</label>
|
<label data-field="battery_serial">Battery Serial Number</label>
|
||||||
|
|
@ -68,6 +68,71 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if mode == 'results' %}
|
{% if mode == 'results' %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="m-portlet m-portlet--mobile">
|
||||||
|
<div class="m-portlet__head">
|
||||||
|
<div class="m-portlet__head-caption">
|
||||||
|
<div class="m-portlet__head-title">
|
||||||
|
<h3 class="m-portlet__head-text">
|
||||||
|
Warranty Information
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="m-portlet__body">
|
||||||
|
{% if data is empty %}
|
||||||
|
<div class="m-alert m-alert--icon m-alert--icon-solid m-alert--outline alert alert-brand" role="alert">
|
||||||
|
<div class="m-alert__icon">
|
||||||
|
<i class="flaticon-exclamation-2"></i>
|
||||||
|
<span></span>
|
||||||
|
</div>
|
||||||
|
<div class="m-alert__text">
|
||||||
|
No warranty found.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<table class="table table-striped m-table">
|
||||||
|
<thead>
|
||||||
|
<tr class="m-table__row--brand">
|
||||||
|
<th> </th>
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for key, result in data %}
|
||||||
|
<tr>
|
||||||
|
<td>Battery Serial Number</td>
|
||||||
|
<td>{{ result.getSerial|default("") }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Owner Name</td>
|
||||||
|
<td>{{ result.getFirstName|default("") ~ ' ' ~ result.getLastName|default("") }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Vehicle Plate Number</td>
|
||||||
|
<td>{{ result.getPlateNumber|default("") }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Purchase Date</td>
|
||||||
|
<td>{{ result.getDatePurchase|date("d M Y") }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Battery</td>
|
||||||
|
<td>{{ result.getBatteryModel.getName|default("") ~ ' - ' ~ result.getBatterySize.getName|default("") }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>End of Warranty</td>
|
||||||
|
<td>{{ result.getDateExpire|date("d M Y") }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue