Add search by plate number on customer list #100
This commit is contained in:
parent
4ac54bfe21
commit
7ff058864a
1 changed files with 9 additions and 3 deletions
|
|
@ -51,6 +51,10 @@ class CustomerController extends BaseController
|
||||||
$this->denyAccessUnlessGranted('customer.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('customer.list', null, 'No access.');
|
||||||
|
|
||||||
// build query
|
// build query
|
||||||
|
$tqb = $this->getDoctrine()
|
||||||
|
->getRepository(Customer::class)
|
||||||
|
->createQueryBuilder('q');
|
||||||
|
|
||||||
$qb = $this->getDoctrine()
|
$qb = $this->getDoctrine()
|
||||||
->getRepository(Customer::class)
|
->getRepository(Customer::class)
|
||||||
->createQueryBuilder('q');
|
->createQueryBuilder('q');
|
||||||
|
|
@ -59,7 +63,7 @@ class CustomerController extends BaseController
|
||||||
$datatable = $req->request->get('datatable');
|
$datatable = $req->request->get('datatable');
|
||||||
|
|
||||||
// count total records
|
// count total records
|
||||||
$tquery = $qb->select('COUNT(q)');
|
$tquery = $tqb->select('COUNT(q)');
|
||||||
|
|
||||||
// add filters to count query
|
// add filters to count query
|
||||||
$this->setQueryFilters($datatable, $tquery);
|
$this->setQueryFilters($datatable, $tquery);
|
||||||
|
|
@ -676,10 +680,12 @@ class CustomerController extends BaseController
|
||||||
// check if datatable filter is present and append to query
|
// check if datatable filter is present and append to query
|
||||||
protected function setQueryFilters($datatable, &$query) {
|
protected function setQueryFilters($datatable, &$query) {
|
||||||
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
||||||
$query->where('q.first_name LIKE :filter')
|
$query->join('q.vehicles', 'cv')
|
||||||
|
->where('q.first_name LIKE :filter')
|
||||||
->orWhere('q.last_name LIKE :filter')
|
->orWhere('q.last_name LIKE :filter')
|
||||||
->orWhere('q.customer_classification LIKE :filter')
|
->orWhere('q.customer_classification LIKE :filter')
|
||||||
->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%');
|
->orWhere('cv.plate_number LIKE :filter')
|
||||||
|
->setParameter('filter', $datatable['query']['data-rows-search'] . '%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue