Add method and form for the report. #267
This commit is contained in:
parent
d8aa28d751
commit
2a81103773
5 changed files with 149 additions and 0 deletions
|
|
@ -292,6 +292,8 @@ access_keys:
|
||||||
label: Battery Conflict Report
|
label: Battery Conflict Report
|
||||||
- id: report.popapp.comparison
|
- id: report.popapp.comparison
|
||||||
label: Popapp Comparison Report
|
label: Popapp Comparison Report
|
||||||
|
- id: report.meh.customer
|
||||||
|
label: RESQ MEH Customer Report
|
||||||
|
|
||||||
- id: service
|
- id: service
|
||||||
label: Other Services
|
label: Other Services
|
||||||
|
|
|
||||||
|
|
@ -37,3 +37,13 @@ rep_popapp_export_csv:
|
||||||
path: /report/popapp_export
|
path: /report/popapp_export
|
||||||
controller: App\Controller\ReportController::popappExportCSV
|
controller: App\Controller\ReportController::popappExportCSV
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
rep_resq_meh_form:
|
||||||
|
path: /report/meh_customer
|
||||||
|
controller: App\Controller\ReportController::mehCustomerForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
rep_resq_meh_export_csv:
|
||||||
|
path: /report/meh_customer_export
|
||||||
|
controller: App\Controller\ReportController::mehCustomerExportCSV
|
||||||
|
methods: [POST]
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use App\Entity\JobOrder;
|
||||||
use App\Entity\Warranty;
|
use App\Entity\Warranty;
|
||||||
use App\Entity\CustomerVehicle;
|
use App\Entity\CustomerVehicle;
|
||||||
use App\Entity\MobileSession;
|
use App\Entity\MobileSession;
|
||||||
|
use App\Entity\Customer;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
|
@ -26,6 +27,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
|
||||||
use Catalyst\MenuBundle\Annotation\Menu;
|
use Catalyst\MenuBundle\Annotation\Menu;
|
||||||
|
|
||||||
|
|
@ -494,6 +496,55 @@ class ReportController extends Controller
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="outlet_list")
|
||||||
|
*/
|
||||||
|
public function mehCustomerForm()
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('report.meh.customer', null, 'No access.');
|
||||||
|
$params['mode'] = 'form';
|
||||||
|
|
||||||
|
return $this->render('report/meh/form.html.twig', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="outlet_list")
|
||||||
|
*/
|
||||||
|
public function mehCustomerExportCSV(Request $req, EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$data = getMEHCustomerData($em);
|
||||||
|
|
||||||
|
$resp = new StreamedResponse();
|
||||||
|
$resp->setCallback(function() use ($data) {
|
||||||
|
// csv output
|
||||||
|
$csv_handle = fopen('php://output', 'w+');
|
||||||
|
fputcsv($csv_handle, [
|
||||||
|
'Last Name',
|
||||||
|
'First Name',
|
||||||
|
'Mobile Number',
|
||||||
|
'Landline Number',
|
||||||
|
'Office Number',
|
||||||
|
'Fax Number',
|
||||||
|
'Date Mobile App Downloaded',
|
||||||
|
'Mobile Number Using Mobile App',
|
||||||
|
]);
|
||||||
|
foreach ($data as $row)
|
||||||
|
{
|
||||||
|
fputcsv($csv_handle, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($csv_handle);
|
||||||
|
});
|
||||||
|
|
||||||
|
$filename = 'resq_meh_customer_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)
|
protected function processPopappFile(UploadedFile $csv_file, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
// attempt to open file
|
// attempt to open file
|
||||||
|
|
@ -620,4 +671,32 @@ class ReportController extends Controller
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMEHCustomerData(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
//get the policy id for the mobile privacy policy from env
|
||||||
|
$dotenv = new Dotenv();
|
||||||
|
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||||
|
|
||||||
|
$policy_mobile_id = $_ENV['POLICY_MOBILE'];
|
||||||
|
|
||||||
|
// get all the customers with mobile privacy policy id
|
||||||
|
$customers = $em->getRepository(Customer::class)->findBy(['privpol_mobile_app' => $policy_mobile_id]):
|
||||||
|
|
||||||
|
foreach ($customers as $customer)
|
||||||
|
{
|
||||||
|
// get plate numbers
|
||||||
|
$plate_numbers = $customer->getPlateNumberList();
|
||||||
|
|
||||||
|
// using plate number, get all customer vehicles with the plate number and the job orders with the plate number
|
||||||
|
|
||||||
|
// get job orders of vehicles
|
||||||
|
|
||||||
|
// check if source is not null. If not null, add customer to results
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,14 @@
|
||||||
Popapp Comparison Report
|
Popapp Comparison Report
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{{ url('rep_resq_meh_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">
|
||||||
|
RESQ MEH Customer Report
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
50
templates/report/meh/form.html.twig
Normal file
50
templates/report/meh/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">
|
||||||
|
RESQ MEH Customer 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 Customer 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_resq_meh_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