Add customer battery search to menu and acl. Add WarrantyController. Add twig file for customer battery search. #223
This commit is contained in:
parent
9a7f5ab81e
commit
749c3a75c8
5 changed files with 150 additions and 0 deletions
|
|
@ -250,6 +250,8 @@ access_keys:
|
|||
label: Menu
|
||||
- id: general.search
|
||||
label: Search
|
||||
- id: warranty.search
|
||||
label: Customer Battery Search
|
||||
- id: ticket
|
||||
label: Ticket Access
|
||||
acls:
|
||||
|
|
|
|||
|
|
@ -139,3 +139,7 @@ main_menu:
|
|||
acl: general.search
|
||||
label: Search
|
||||
parent: support
|
||||
- id: warranty_search
|
||||
acl: warranty.search
|
||||
label: Customer Battery Search
|
||||
parent: support
|
||||
|
|
|
|||
10
config/routes/warranty.yaml
Normal file
10
config/routes/warranty.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# warranty
|
||||
|
||||
warranty_search:
|
||||
path: /warranty_search
|
||||
controller: App\Controller\WarrantyController::index
|
||||
|
||||
search_warranty:
|
||||
path: /warranty_search/warranty
|
||||
controller: App\Controller\WarrantyController::search
|
||||
methods: [GET]
|
||||
61
src/Controller/WarrantyController.php
Normal file
61
src/Controller/WarrantyController.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Warranty;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
use Catalyst\MenuBundle\Annotation\Menu;
|
||||
|
||||
class WarrantyController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Menu(selected="warranty_search")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->denyaccessUnlessGranted('warranty.search', null, 'No access.');
|
||||
$params["mode"] = "form";
|
||||
|
||||
// response
|
||||
return $this->render('warranty-search/form.html.twig', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Menu(selected="warranty_search")
|
||||
*/
|
||||
public function search(Request $req)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('warranty.search', null, 'No access.');
|
||||
|
||||
$serial = $req->query->get('battery_serial');
|
||||
$name = $req->query->get('owner_name');
|
||||
$plate_num = $req->query->get('plate_num');
|
||||
|
||||
// find the warranty
|
||||
$qb = $this->getDoctrine()
|
||||
->getRepository(Warranty::class)
|
||||
->createQueryBuilder('q');
|
||||
|
||||
$query = $qb->select('w')
|
||||
->where('w.serial = :serial')
|
||||
->andWhere('w.plate_number = :platenum')
|
||||
->setParameter('serial', $serial)
|
||||
->setParameter('plate_num', $plate_num);
|
||||
$results = $query->getQuery()->execute();
|
||||
|
||||
$params['data'] = $results;
|
||||
$params['battery_serial'] = $battery_serial;
|
||||
$params['owner_name'] = $name;
|
||||
$params['plate_num'] = $plate_num;
|
||||
$params['mode'] = "results";
|
||||
|
||||
// response
|
||||
return $this->render('warranty-search/form.html.twig', $params);
|
||||
}
|
||||
}
|
||||
73
templates/warranty-search/form.html.twig
Normal file
73
templates/warranty-search/form.html.twig
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<!-- BEGIN: Subheader -->
|
||||
<div class="m-subheader">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="mr-auto">
|
||||
<h3 class="m-subheader__title">
|
||||
{% if mode == 'form' %}
|
||||
Search
|
||||
{% else %}
|
||||
Search results</span>"
|
||||
{% endif %}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END: Subheader -->
|
||||
<div class="m-content">
|
||||
<!--Begin::Section-->
|
||||
<div class="row">
|
||||
<div class="col-xl-6">
|
||||
<div class="m-portlet m-portlet--mobile">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<span class="m-portlet__head-icon">
|
||||
<i class="fa fa-search"></i>
|
||||
</span>
|
||||
<h3 class="m-portlet__head-text">
|
||||
Customer Battery Status Search
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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="form-group m-form__group row">
|
||||
<h4 class="m-portlet__head-text">
|
||||
Please fill up at least two (2) of the fields below to view battery's warranty status.
|
||||
</h4>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<label data-field="battery_serial">Battery Serial Number</label>
|
||||
<input name="battery_serial" type="search"class="form-control" placeholder="xxxxxxxxxxxx" value="{{ battery_serial|default("") }}">
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<label data-field="owner_name">Owner Name</label>
|
||||
<input name="owner_name" type="search" class="form-control" placeholder="i.e. Juan Dela Cruz" value="{{ owner_name|default("") }}">
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<label data-field="plate_num">Vehicle Plate Number</label>
|
||||
<input name="plate_num" type="search" class="form-control" placeholder="i.e. ABC 123" value="{{ plate_num|default("") }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<button type="submit" class="btn btn-success">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if mode == 'results' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
Reference in a new issue