Merge branch 'master' of gitlab.com:jankstudio/resq into origin/265-cmb-project
This commit is contained in:
commit
7f973fd10a
6 changed files with 179 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,56 @@ 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 = $this->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',
|
||||||
|
'Plate 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 +672,53 @@ class ReportController extends Controller
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMEHCustomerData(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
$conn = $em->getConnection();
|
||||||
|
$sql = 'SELECT c.id, c.last_name, c.first_name, c.phone_mobile, c.phone_landline,
|
||||||
|
c.phone_office, c.phone_fax,
|
||||||
|
cv.plate_number, jo.source
|
||||||
|
FROM job_order jo, customer_vehicle cv, customer c
|
||||||
|
WHERE c.id = cv.customer_id
|
||||||
|
AND jo.cvehicle_id = cv.id
|
||||||
|
AND c.policy_mobile_app_id IS NOT NULL
|
||||||
|
AND jo.source != :source';
|
||||||
|
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute(array('source' => 'mobile_app'));
|
||||||
|
|
||||||
|
$query_results = $stmt->fetchAll();
|
||||||
|
|
||||||
|
foreach($query_results as $row)
|
||||||
|
{
|
||||||
|
$mobile_date = '';
|
||||||
|
$mobile_number = '';
|
||||||
|
|
||||||
|
$mobile_session = $em->getRepository(MobileSession::class)
|
||||||
|
->findOneBy(['customer' => $row['id']], ['date_generated' => 'ASC']);
|
||||||
|
if ($mobile_session != null)
|
||||||
|
{
|
||||||
|
$mobile_date = $mobile_session->getDateGenerated()->format("d M Y");
|
||||||
|
$mobile_number = $mobile_session->getPhoneNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'last_name' => $row['last_name'],
|
||||||
|
'first_name' => $row['first_name'],
|
||||||
|
'cust_mobile_number' => $row['phone_mobile'],
|
||||||
|
'landline_number' => $row['phone_landline'],
|
||||||
|
'office_number' => $row['phone_office'],
|
||||||
|
'fax_number' => $row['phone_fax'],
|
||||||
|
'plate_number' => $row['plate_number'],
|
||||||
|
'date_mobile' => $mobile_date,
|
||||||
|
'mobile_number' => $mobile_number,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
@ -119,6 +120,8 @@ class CustomerVehicle
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->flag_active = true;
|
$this->flag_active = true;
|
||||||
|
|
||||||
|
$this->job_orders = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -256,6 +259,11 @@ class CustomerVehicle
|
||||||
return $this->curr_battery;
|
return $this->curr_battery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getJobOrders()
|
||||||
|
{
|
||||||
|
return $this->job_orders;
|
||||||
|
}
|
||||||
|
|
||||||
public function setHasMotoliteBattery($flag_motolite_battery = true)
|
public function setHasMotoliteBattery($flag_motolite_battery = true)
|
||||||
{
|
{
|
||||||
$this->flag_motolite_battery = $flag_motolite_battery;
|
$this->flag_motolite_battery = $flag_motolite_battery;
|
||||||
|
|
|
||||||
|
|
@ -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