Add twig files for the battery conflict report. Add link to the battery conflict report in base twig. Add controller functions to query for the report. #197
This commit is contained in:
parent
a22816d18a
commit
c720be1c2d
3 changed files with 164 additions and 2 deletions
|
|
@ -5,8 +5,11 @@ namespace App\Controller;
|
||||||
use App\Ramcar\BaseController;
|
use App\Ramcar\BaseController;
|
||||||
use App\Ramcar\JORejectionReason;
|
use App\Ramcar\JORejectionReason;
|
||||||
use App\Ramcar\ServiceType;
|
use App\Ramcar\ServiceType;
|
||||||
|
use App\Ramcar\JOStatus;
|
||||||
|
|
||||||
use App\Entity\JORejection;
|
use App\Entity\JORejection;
|
||||||
|
use App\Entity\Battery;
|
||||||
|
use App\Entity\JobOrder;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
|
@ -265,8 +268,75 @@ class ReportController extends BaseController
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('report.battery.conflict', null, 'No access.');
|
$this->denyAccessUnlessGranted('report.battery.conflict', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters();
|
$params = $this->initParameters('outlet_list');
|
||||||
|
|
||||||
|
return $this->render('report/battery/batt_conflict_form.html.twig', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batteryConflictSubmit(Request $req)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('report.battery.conflict', null, 'No access.');
|
||||||
|
|
||||||
|
// get battery query builder
|
||||||
|
$batt_qb = $this->getDoctrine()
|
||||||
|
->getRepository(Battery::class)
|
||||||
|
->createQueryBuilder('batt');
|
||||||
|
|
||||||
|
// get job order query builder
|
||||||
|
$job_qb = $this->getDoctrine()
|
||||||
|
->getRepository(JobOrder::class)
|
||||||
|
->createQueryBuilder('jo');
|
||||||
|
|
||||||
|
// get dates
|
||||||
|
$raw_date_start = $req->request->get('date_start');
|
||||||
|
$raw_date_end = $req->request->get('date_end');
|
||||||
|
|
||||||
|
$date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start);
|
||||||
|
$date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end);
|
||||||
|
|
||||||
|
// build query for battery
|
||||||
|
$batt_query = $batt_qb->getQuery();
|
||||||
|
|
||||||
|
// build query for job order
|
||||||
|
$jo_query = $job_qb->where('jo.date_create >= :start')
|
||||||
|
->andWhere('jo.date_create <= :end')
|
||||||
|
->andWhere('jo.status != :status')
|
||||||
|
->setParameter('start', $date_start->format('Y-m-d') . ' 00:00:00')
|
||||||
|
->setParameter('end', $date_end->format('Y-m-d') . ' 23:59:59')
|
||||||
|
->setParameter('status', JOStatus::CANCELLED)
|
||||||
|
->getQuery();
|
||||||
|
|
||||||
|
// run queries
|
||||||
|
$batts = $batt_query->getResult();
|
||||||
|
$jos = $jo_query->getResult();
|
||||||
|
|
||||||
|
$battcomp = [];
|
||||||
|
// get battery results and store in array
|
||||||
|
foreach ($batts as $batt)
|
||||||
|
{
|
||||||
|
$batt_id = $batt->getID();
|
||||||
|
|
||||||
|
$comp_vehicles = $batt->getVehicles();
|
||||||
|
// go through compatible vehicle list and add to array
|
||||||
|
foreach ($comp_vehicles as $vehicle)
|
||||||
|
{
|
||||||
|
$battcomp[$batt_id] = [
|
||||||
|
'manufacturer' => $vehicle->getManufacturer(),
|
||||||
|
'make' => $vehicle->getMake(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get results
|
||||||
|
foreach ($jos as $jo)
|
||||||
|
{
|
||||||
|
$vehicle = $jo->getCustomerVehicle()->getVehicle();
|
||||||
|
$vmanufacturer = $vehicle->getManufacturer();
|
||||||
|
$vmake = $vehicle->getMake();
|
||||||
|
|
||||||
|
$invoice_items = $jo->getInvoice()->getItems();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('', $params);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,16 @@
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||||
|
<a href= "{{ url('rep_battery_conflict_form') }}" class="m-menu__link">
|
||||||
|
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
|
||||||
|
<span></span>
|
||||||
|
</i>
|
||||||
|
<span class="m-menu__link-text">
|
||||||
|
Battery Conflict Report
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<!--
|
<!--
|
||||||
|
|
|
||||||
82
templates/report/battery/batt_conflict_form.html.twig
Normal file
82
templates/report/battery/batt_conflict_form.html.twig
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
{% 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">Battery Conflict Report</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-calendar"></i>
|
||||||
|
</span>
|
||||||
|
<h3 class="m-portlet__head-text">
|
||||||
|
Select a date range
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form id="row-form" autocomplete="off" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('rep_battery_conflict_submit') }}">
|
||||||
|
<div class="m-portlet__body">
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="input-daterange input-group" id="date-range">
|
||||||
|
<input role="presentation" type="text" class="form-control m-input" name="date_start" placeholder="Start date" />
|
||||||
|
<div class="input-group-append">
|
||||||
|
<span class="input-group-text"><i class="la la-ellipsis-h"></i></span>
|
||||||
|
</div>
|
||||||
|
<input role="presentation" type="text" class="form-control" name="date_end" placeholder="End date" />
|
||||||
|
</div>
|
||||||
|
</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">Submit</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
$("#date-range").datepicker({
|
||||||
|
orientation: "bottom"
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#row-form").submit(function(e) {
|
||||||
|
var form = $(this);
|
||||||
|
|
||||||
|
if (!$("[name='date_start']").val() || !$("[name='date_end']").val()) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
swal({
|
||||||
|
title: 'Whoops!',
|
||||||
|
text: 'Please fill in both date fields.',
|
||||||
|
type: 'warning'
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Reference in a new issue