Separate and create detailed rejection report #190
This commit is contained in:
parent
61d4ad0764
commit
d791374b29
5 changed files with 299 additions and 11 deletions
|
|
@ -1,9 +1,19 @@
|
||||||
rep_reject_form:
|
rep_reject_summary_form:
|
||||||
path: /report/rejection
|
path: /report/rejection_summary
|
||||||
controller: App\Controller\ReportController::rejectForm
|
controller: App\Controller\ReportController::rejectSummaryForm
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
rep_reject_submit:
|
rep_reject_summary_submit:
|
||||||
path: /report/rejection
|
path: /report/rejection_summary
|
||||||
controller: App\Controller\ReportController::rejectSubmit
|
controller: App\Controller\ReportController::rejectSummarySubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
rep_reject_detail_form:
|
||||||
|
path: /report/rejection_detail
|
||||||
|
controller: App\Controller\ReportController::rejectDetailForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
rep_reject_detail_submit:
|
||||||
|
path: /report/rejection_detail
|
||||||
|
controller: App\Controller\ReportController::rejectDetailSubmit
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ 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\Entity\JORejection;
|
use App\Entity\JORejection;
|
||||||
|
|
||||||
|
|
@ -20,16 +21,16 @@ use DateTime;
|
||||||
|
|
||||||
class ReportController extends BaseController
|
class ReportController extends BaseController
|
||||||
{
|
{
|
||||||
public function rejectForm()
|
public function rejectSummaryForm()
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('outlet_list');
|
$params = $this->initParameters('outlet_list');
|
||||||
|
|
||||||
return $this->render('report/rejection/form.html.twig', $params);
|
return $this->render('report/rejection/summary_form.html.twig', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rejectSubmit(Request $req)
|
public function rejectSummarySubmit(Request $req)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
||||||
|
|
||||||
|
|
@ -147,4 +148,107 @@ class ReportController extends BaseController
|
||||||
]);
|
]);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function rejectDetailForm()
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
||||||
|
|
||||||
|
$params = $this->initParameters('outlet_list');
|
||||||
|
|
||||||
|
return $this->render('report/rejection/detail_form.html.twig', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rejectDetailSubmit(Request $req)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
||||||
|
|
||||||
|
// get query builder
|
||||||
|
$qb = $this->getDoctrine()
|
||||||
|
->getRepository(JORejection::class)
|
||||||
|
->createQueryBuilder('r');
|
||||||
|
|
||||||
|
// 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
|
||||||
|
$query = $qb->where('r.date_create >= :start')
|
||||||
|
->andWhere('r.date_create <= :end')
|
||||||
|
->setParameter('start', $date_start->format('Y-m-d') . ' 00:00:00')
|
||||||
|
->setParameter('end', $date_end->format('Y-m-d') . ' 23:59:59')
|
||||||
|
->getQuery();
|
||||||
|
|
||||||
|
|
||||||
|
// run query
|
||||||
|
$jors = $query->getResult();
|
||||||
|
|
||||||
|
// initialize counter
|
||||||
|
$counter = [];
|
||||||
|
|
||||||
|
// get results
|
||||||
|
$res = [];
|
||||||
|
foreach ($jors as $jor)
|
||||||
|
{
|
||||||
|
$jo = $jor->getJobOrder();
|
||||||
|
$hub = $jor->getHub();
|
||||||
|
$hub_id = $hub->getID();
|
||||||
|
$hub_name = $hub->getName() . ' - ' . $hub->getBranch();
|
||||||
|
|
||||||
|
$reason = $jor->getReason();
|
||||||
|
|
||||||
|
$res[] = [
|
||||||
|
$jo->getID(),
|
||||||
|
$jo->getDateSchedule()->format('m/d/Y H:i'),
|
||||||
|
$jor->getDateCreate()->format('m/d/Y H:i'),
|
||||||
|
$hub->getName() . ' - ' . $hub->getBranch(),
|
||||||
|
JORejectionReason::getName($jor->getReason()),
|
||||||
|
$jor->getContactPerson(),
|
||||||
|
$jor->getRemarks(),
|
||||||
|
$jo->getCreatedBy()->getFullName(),
|
||||||
|
ServiceType::getName($jo->getServiceType()),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// response
|
||||||
|
$resp = new StreamedResponse();
|
||||||
|
$resp->setCallback(function() use ($res) {
|
||||||
|
// csv output
|
||||||
|
$csv_handle = fopen('php://output', 'w+');
|
||||||
|
fputcsv($csv_handle, [
|
||||||
|
'Order #',
|
||||||
|
'Order Date and Time',
|
||||||
|
'Date and Time Rejected',
|
||||||
|
'Enrollee',
|
||||||
|
'Reason',
|
||||||
|
'Contact Person',
|
||||||
|
'Remarks',
|
||||||
|
'Dispatched By',
|
||||||
|
'Type of Service',
|
||||||
|
]);
|
||||||
|
foreach ($res as $row)
|
||||||
|
{
|
||||||
|
fputcsv($csv_handle, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($csv_handle);
|
||||||
|
});
|
||||||
|
|
||||||
|
$filename = 'reject_' . $date_start->format('Ymd') . '_' . $date_end->format('Ymd') . '.csv';
|
||||||
|
|
||||||
|
$resp->setStatusCode(200);
|
||||||
|
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||||
|
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||||
|
|
||||||
|
return $resp;
|
||||||
|
/*
|
||||||
|
return $this->json([
|
||||||
|
'result' => $res,
|
||||||
|
'counter' => $counter,
|
||||||
|
]);
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,12 +109,22 @@
|
||||||
</h3>
|
</h3>
|
||||||
<ul class="m-menu__inner">
|
<ul class="m-menu__inner">
|
||||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||||
<a href="{{ url('rep_reject_form') }}" class="m-menu__link">
|
<a href="{{ url('rep_reject_summary_form') }}" class="m-menu__link">
|
||||||
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
|
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
|
||||||
<span></span>
|
<span></span>
|
||||||
</i>
|
</i>
|
||||||
<span class="m-menu__link-text">
|
<span class="m-menu__link-text">
|
||||||
Rejection Report
|
Summary Rejection Report
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||||
|
<a href="{{ url('rep_reject_detail_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">
|
||||||
|
Detailed Rejection Report
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
82
templates/report/rejection/detail_form.html.twig
Normal file
82
templates/report/rejection/detail_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">Detailed Rejection 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_reject_detail_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 %}
|
||||||
82
templates/report/rejection/summary_form.html.twig
Normal file
82
templates/report/rejection/summary_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">Summary Rejection 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_reject_summary_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