Add Per Rider Volume Report to reports. #292
This commit is contained in:
parent
3546268c88
commit
10906b9e8a
6 changed files with 148 additions and 0 deletions
|
|
@ -300,6 +300,8 @@ access_keys:
|
|||
label: Warranty Class Report
|
||||
- id: report.call.volume
|
||||
label: Call Volume Report
|
||||
- id: report.rider.volume
|
||||
label: Per Rider Volume Report
|
||||
|
||||
- id: service
|
||||
label: Other Services
|
||||
|
|
|
|||
|
|
@ -67,3 +67,13 @@ rep_call_volume_export_csv:
|
|||
path: /report/call_volume_report
|
||||
controller: App\Controller\ReportController::callVolumeExportCSV
|
||||
methods: [POST]
|
||||
|
||||
rep_per_rider_volume_form:
|
||||
path: /report/per_rider_volume_report
|
||||
controller: App\Controller\ReportController::perRiderVolumeForm
|
||||
methods: [GET]
|
||||
|
||||
rep_per_rider_volume_export_csv:
|
||||
path: /report/per_rider_volume_report
|
||||
controller: App\Controller\ReportController::perRiderVolumeExportCSV
|
||||
methods: [POST]
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use App\Entity\Warranty;
|
|||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\MobileSession;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Rider;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
|
@ -664,6 +665,48 @@ class ReportController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Menu(selected="outlet_list")
|
||||
*/
|
||||
public function perRiderVolumeForm()
|
||||
{
|
||||
$this->denyAccessUnlessGranted('report.rider.volume', null, 'No access.');
|
||||
$params['mode'] = 'form';
|
||||
|
||||
return $this->render('report/per-rider-volume/form.html.twig', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Menu(selected="outlet_list")
|
||||
*/
|
||||
public function perRiderVolumeExportCSV(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
$data = $this->getPerRiderVolumeData($em);
|
||||
|
||||
$resp = new StreamedResponse();
|
||||
$resp->setCallback(function() use ($data) {
|
||||
// csv output
|
||||
$csv_handle = fopen('php://output', 'w+');
|
||||
fputcsv($csv_handle, [
|
||||
]);
|
||||
foreach ($data as $row)
|
||||
{
|
||||
fputcsv($csv_handle, $row);
|
||||
}
|
||||
|
||||
fclose($csv_handle);
|
||||
});
|
||||
|
||||
$filename = 'per_rider_volume_report' . '.csv';
|
||||
|
||||
$resp->setStatusCode(200);
|
||||
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
|
||||
return $resp;
|
||||
|
||||
}
|
||||
|
||||
protected function processPopappFile(UploadedFile $csv_file, EntityManagerInterface $em)
|
||||
{
|
||||
// attempt to open file
|
||||
|
|
@ -1053,4 +1096,34 @@ class ReportController extends Controller
|
|||
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function getPerRiderVolumeData(EntityManagerInterface $em)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
// get riders
|
||||
$riders = $em->getRepository(Rider::class)->findAll();
|
||||
|
||||
foreach($riders as $rider)
|
||||
{
|
||||
error_log('Processing rider ' . $rider->getID());
|
||||
// get rider information
|
||||
$last_name = $rider->getLastName();
|
||||
$first_name = $rider->getFirstName();
|
||||
|
||||
// get rider's job orders
|
||||
$rider_jos = $rider->getJobOrders();
|
||||
|
||||
foreach($rider_jos as $jo)
|
||||
{
|
||||
error_log('Processing job order ' . $jo->getID());
|
||||
|
||||
// TODO: process report data for per rider volume
|
||||
}
|
||||
|
||||
$em->clear();
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,4 +319,9 @@ class Rider
|
|||
{
|
||||
return $this->sessions;
|
||||
}
|
||||
|
||||
public function getJobOrders()
|
||||
{
|
||||
return $this->job_orders;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,6 +181,14 @@
|
|||
Call Volume Report
|
||||
</span>
|
||||
</a>
|
||||
<a href="{{ url('rep_per_rider_volume_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">
|
||||
Per Rider Volume Report
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
|||
50
templates/report/per-rider-volume/form.html.twig
Normal file
50
templates/report/per-rider-volume/form.html.twig
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{% 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">
|
||||
Per Rider Volume 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-upload"></i>
|
||||
</span>
|
||||
<h3 class="m-portlet__head-text">
|
||||
Generate Per Rider Volume CSV File
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="upload_form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('rep_per_rider_volume_export_csv') }}" enctype="multipart/form-data">
|
||||
<div class="m-portlet__body">
|
||||
<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">Export to CSV</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
Loading…
Reference in a new issue