Merge branch '184-rejection-report' into 'master'
Resolve "Rejection report" Closes #184 See merge request jankstudio/resq!220
This commit is contained in:
commit
61d4ad0764
7 changed files with 338 additions and 36 deletions
|
|
@ -238,3 +238,11 @@ access_keys:
|
|||
label: Update
|
||||
- id: promo.delete
|
||||
label: Delete
|
||||
|
||||
- id: report
|
||||
label: Reports
|
||||
acls:
|
||||
- id: report.menu
|
||||
label: Menu
|
||||
- id: report.reject
|
||||
label: Rejection Report
|
||||
|
|
|
|||
9
config/routes/report.yaml
Normal file
9
config/routes/report.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
rep_reject_form:
|
||||
path: /report/rejection
|
||||
controller: App\Controller\ReportController::rejectForm
|
||||
methods: [GET]
|
||||
|
||||
rep_reject_submit:
|
||||
path: /report/rejection
|
||||
controller: App\Controller\ReportController::rejectSubmit
|
||||
methods: [POST]
|
||||
|
|
@ -196,6 +196,81 @@ span.has-danger,
|
|||
top: -0.45rem;
|
||||
}
|
||||
|
||||
.input-group .form-control:first-child:not(:last-child):not(:focus):not(.focus) {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.input-group .input-group-append + .form-control:not(:focus):not(.focus) {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.input-group > .form-control:not(:first-child) {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.input-group > .form-control:not(:last-child) {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.input-group .input-group-append > .input-group-text {
|
||||
border-color: #ebedf2;
|
||||
background-color: #f4f5f8;
|
||||
color: #575962;
|
||||
}
|
||||
|
||||
.input-group > .input-group-append > .input-group-text {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.input-group > .input-group-append:not(:last-child) > .input-group-text {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.input-group-text {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
padding: .85rem 1.15rem;
|
||||
margin-bottom: 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.25;
|
||||
color: #495057;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
background-color: #e9ecef;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: .25rem;
|
||||
}
|
||||
|
||||
.input-daterange input:last-child {
|
||||
border-radius: 0 3px 3px 0;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
position: relative;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-wrap: wrap;
|
||||
flex-wrap: wrap;
|
||||
-webkit-box-align: stretch;
|
||||
-ms-flex-align: stretch;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-daterange {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 995px) {
|
||||
.modal-lg {
|
||||
max-width: 1024px;
|
||||
|
|
|
|||
150
src/Controller/ReportController.php
Normal file
150
src/Controller/ReportController.php
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Ramcar\BaseController;
|
||||
use App\Ramcar\JORejectionReason;
|
||||
|
||||
use App\Entity\JORejection;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||
use DateTime;
|
||||
|
||||
class ReportController extends BaseController
|
||||
{
|
||||
public function rejectForm()
|
||||
{
|
||||
$this->denyAccessUnlessGranted('report.reject', null, 'No access.');
|
||||
|
||||
$params = $this->initParameters('outlet_list');
|
||||
|
||||
return $this->render('report/rejection/form.html.twig', $params);
|
||||
}
|
||||
|
||||
public function rejectSubmit(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();
|
||||
|
||||
if (!isset($counter[$hub_id]))
|
||||
$counter[$hub_id] = [
|
||||
'reasons' => [],
|
||||
'name' => $hub_name,
|
||||
];
|
||||
|
||||
if (!isset($counter[$hub_id][$reason]))
|
||||
{
|
||||
$counter[$hub_id]['reasons'][$reason]['name'] = JORejectionReason::getName($reason);
|
||||
$counter[$hub_id]['reasons'][$reason]['counter'] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$counter[$hub_id]['reasons'][$reason]['counter'] += 1;
|
||||
}
|
||||
|
||||
$res[] = [
|
||||
'jo_id' => $jo->getID(),
|
||||
'jo_date_time' => $jo->getDateSchedule(),
|
||||
'jor_date_create' => $jo->getDateCreate(),
|
||||
'hub' => $hub->getName() . ' - ' . $hub->getBranch(),
|
||||
'reason' => JORejectionReason::getName($jor->getReason()),
|
||||
'contact' => $jor->getContactPerson(),
|
||||
'remarks' => $jor->getRemarks(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// response
|
||||
$resp = new StreamedResponse();
|
||||
$resp->setCallback(function() use ($counter) {
|
||||
// csv output
|
||||
$csv_handle = fopen('php://output', 'w+');
|
||||
fputcsv($csv_handle, ['Enrollee', 'Reason', 'Count']);
|
||||
foreach ($counter as $centry)
|
||||
{
|
||||
$first = true;
|
||||
foreach ($centry['reasons'] as $creason)
|
||||
{
|
||||
// first line has hub name
|
||||
if ($first)
|
||||
{
|
||||
fputcsv($csv_handle, [
|
||||
$centry['name'],
|
||||
$creason['name'],
|
||||
$creason['counter'],
|
||||
]);
|
||||
$first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fputcsv($csv_handle, [
|
||||
'',
|
||||
$creason['name'],
|
||||
$creason['counter'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,9 @@ class JORejectionReason extends NameValue
|
|||
const NO_RIDER_AVAILABLE = 'no_rider_available';
|
||||
const NO_RIDER_IN_TRANSIT = 'no_rider_in_transit';
|
||||
const REFUSAL = 'refusal';
|
||||
const STORE_CLOSED = 'store_closed';
|
||||
const NO_CREDIT_CARD = 'no_credit_card';
|
||||
const DISCOUNT = 'discount';
|
||||
|
||||
const COLLECTION = [
|
||||
'administrative' => 'ADMINISTRATIVE',
|
||||
|
|
@ -22,5 +25,8 @@ class JORejectionReason extends NameValue
|
|||
'no_rider_available' => 'NO RIDER - AVAILABLE',
|
||||
'no_rider_in_transit' => 'NO RIDER - IN TRANSIT',
|
||||
'refusal' => 'REFUSAL',
|
||||
'store_closed' => 'STORE CLOSED',
|
||||
'no_credit_card' => 'NO CREDIT CARD PAYMENT / NO TERMINAL',
|
||||
'discount' => 'DISCOUNT',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,53 +103,24 @@
|
|||
<li class="m-menu__item">
|
||||
<h3 class="m-menu__heading m-menu__toggle">
|
||||
<span class="m-menu__link-text">
|
||||
Finance Reports
|
||||
Job Order Reports
|
||||
</span>
|
||||
<i class="m-menu__ver-arrow la la-angle-right"></i>
|
||||
</h3>
|
||||
<ul class="m-menu__inner">
|
||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||
<a href="header/actions.html" class="m-menu__link">
|
||||
<i class="m-menu__link-icon flaticon-map"></i>
|
||||
<a href="{{ url('rep_reject_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">
|
||||
Annual Reports
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||
<a href="header/actions.html" class="m-menu__link">
|
||||
<i class="m-menu__link-icon flaticon-user"></i>
|
||||
<span class="m-menu__link-text">
|
||||
HR Reports
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||
<a href="header/actions.html" class="m-menu__link">
|
||||
<i class="m-menu__link-icon flaticon-clipboard"></i>
|
||||
<span class="m-menu__link-text">
|
||||
IPO Reports
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||
<a href="header/actions.html" class="m-menu__link">
|
||||
<i class="m-menu__link-icon flaticon-graphic-1"></i>
|
||||
<span class="m-menu__link-text">
|
||||
Finance Margins
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||
<a href="header/actions.html" class="m-menu__link">
|
||||
<i class="m-menu__link-icon flaticon-graphic-2"></i>
|
||||
<span class="m-menu__link-text">
|
||||
Revenue Reports
|
||||
Rejection Report
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<!--
|
||||
<li class="m-menu__item">
|
||||
<h3 class="m-menu__heading m-menu__toggle">
|
||||
<span class="m-menu__link-text">
|
||||
|
|
@ -342,6 +313,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
-->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
82
templates/report/rejection/form.html.twig
Normal file
82
templates/report/rejection/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">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_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