Make new page to view all Resq app job orders. #770

This commit is contained in:
Korina Cordero 2023-11-13 15:20:46 +08:00
parent fba077d4d3
commit 14d62d044f
6 changed files with 224 additions and 9 deletions

View file

@ -277,6 +277,8 @@ catalyst_auth:
label: Fulfill Cancelled JO
- id: jo_resq_proc.list
label: RESQ Dispatch
- id: jo_resq_all.list
label: RESQ All
- id: support
label: Customer Support Access

View file

@ -168,6 +168,10 @@ catalyst_menu:
acl: jo_hub.list
label: '[menu.joborder.hubview]'
parent: joborder
- id: jo_resq_all
acl: jo_resq_all.list
label: '[menu.joborder.resqall]'
parent: joborder
- id: support
acl: support.menu

View file

@ -7,3 +7,17 @@ jo_resq_proc_rows:
path: /resq-job-order/processing-rows
controller: App\Controller\ResqJobOrderController::datatableRows
methods: [POST]
defaults:
tier: "proc"
jo_resq_all:
path: /resq-job-order/all
controller: App\Controller\ResqJobOrderController::listAll
methods: [GET]
jo_resq_all_rows:
path: /resq-job-orer/all
controller: App\Controller\ResqJobOrderController::datatableRows
methods: [POST]
defaults:
tier: "all"

View file

@ -39,7 +39,7 @@ class ResqJobOrderController extends Controller
/**
* @IsGranted("jo_resq_proc.list")
*/
public function datatableRows(Request $req, JobOrderHandlerInterface $jo_handler)
public function datatableRows(Request $req, $tier, JobOrderHandlerInterface $jo_handler)
{
// get query builder
$qb = $this->getDoctrine()
@ -52,7 +52,14 @@ class ResqJobOrderController extends Controller
// count total records
$tquery = $qb->select('COUNT(q)');
// right now, tier is either proc or all
if ($tier == 'proc')
$this->setQueryFilters($datatable, $tquery, $qb, JOStatus::PENDING, TransactionOrigin::MOBILE_APP);
else
{
// default to all
$this->setQueryFilters($datatable, $tquery, $qb, null, TransactionOrigin::MOBILE_APP);
}
$total = $tquery->getQuery()
->getSingleScalarResult();
@ -76,7 +83,13 @@ class ResqJobOrderController extends Controller
// build query
$query = $qb->select('q');
$this->setQueryFilters($datatable, $query, $qb, JOStatus::PENDING, TransactionOrigin::MOBILE_APP);
if ($tier == 'proc')
$this->setQueryFilters($datatable, $tquery, $qb, JOStatus::PENDING, TransactionOrigin::MOBILE_APP);
else
{
// default to all
$this->setQueryFilters($datatable, $tquery, $qb, null, TransactionOrigin::MOBILE_APP);
}
// check if sorting is present, otherwise use default
if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) {
@ -135,8 +148,18 @@ class ResqJobOrderController extends Controller
// add the items for Actions
$jo_id = $orow->getID();
if ($tier == 'proc')
{
$row['meta']['update_url'] = $this->generateUrl('jo_proc_form', ['id' => $jo_id, 'origin' => 'resq']);
$row['meta']['unlock_url'] = $this->generateUrl('jo_proc_unlock', ['id' => $jo_id, 'origin' => 'resq']);
}
else
{
// default to all
$row['meta']['update_url'] = $this->generateUrl('jo_all_form', ['id' => $jo_id, 'origin' => 'resq']);
$row['meta']['pdf_url'] = $this->generateUrl('jo_pdf_form', ['id' => $jo_id, 'origin' => 'resq']);
$row['meta']['view_url'] = $this->generateUrl('jo_all_view_form',['id' => $jo_id, 'origin' => 'resq']);
}
$rows[] = $row;
}
@ -148,11 +171,31 @@ class ResqJobOrderController extends Controller
]);
}
/**
* @Menu(selected="jo_resq_all")
* @IsGranted("jo_resq_all.list")
*/
public function listAll()
{
$params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval');
return $this->render('resq-job-order/list.all.html.twig', $params);
}
protected function setQueryFilters($datatable, &$query, $qb, $status, $source)
{
if ($status != null)
{
$query->where('q.status = :status')
->andWhere('q.source = :source')
->setParameter('status', $status)
->setParameter('source', $source);
}
else
{
// get all resq app job orders
$query->where('q.source = :source')
->setParameter('source', $source);
}
}
}

View file

@ -0,0 +1,151 @@
{% 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 Job Orders (All)
</h3>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-12">
<div class="m-portlet m-portlet--mobile">
<div class="m-portlet__body">
<div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
<div class="row align-items-center">
<div class="col-xl-12">
<div class="form-group m-form__group row align-items-center">
<div class="col-md-4">
<div class="m-input-icon m-input-icon--left">
<input type="text" class="form-control m-input m-input--solid" placeholder="Search..." id="data-rows-search">
<span class="m-input-icon__icon m-input-icon__icon--left">
<span><i class="la la-search"></i></span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!--begin: Datatable -->
<div id="data-rows"></div>
<!--end: Datatable -->
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
var options = {
data: {
type: 'remote',
source: {
read: {
url: '{{ url('jo_resq_all_rows') }}',
method: 'POST'
}
},
saveState: {
cookie: false,
webstorage: false
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
rows: {
beforeTemplate: function (row, data, index) {
var attribute = getRowAttribute(data);
// check if we have to apply a background color for the row
if (attribute) {
var row_class = "m-table__row--" + attribute;
$(row).addClass(row_class);
}
}
},
columns: [
{
field: 'id',
title: 'JO Number'
},
{
field: 'delivery_address',
title: 'Customer Area'
},
{
field: 'type',
title: 'Schedule'
},
{
field: 'date_schedule',
title: 'Scheduled Date'
},
{
field: 'status',
title: 'Status'
},
{
field: 'processor',
title: 'Dispatcher'
},
{
field: 'Actions',
width: 110,
title: 'Actions',
sortable: false,
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="Edit"><i class="la la-edit"></i></a>';
actions += '<a href="' + row.meta.view_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View"><i class="la la-eye"></i></a>';
actions += '<a href="' + row.meta.pdf_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="PDF" target="_blank"><i class="la la-file-o"></i></a>';
return actions;
},
}
],
search: {
onEnter: false,
input: $('#data-rows-search'),
delay: 400
}
};
var table = $("#data-rows").mDatatable(options);
// auto refresh table
setInterval(function() {
table.reload();
}, {{ table_refresh_rate }});
});
function getRowAttribute(data) {
if (data.is_vip) {
return 'is_vip';
}
if (data.is_emergency) {
return 'is_emergency';
}
if (data.flag_advance) {
return 'danger';
}
if (data.is_mobile) {
return 'is_mobile';
}
return false;
};
</script>
{% endblock %}

View file

@ -126,6 +126,7 @@ menu.joborder.fulfillment: 'Fulfillment'
menu.joborder.open: 'Open'
menu.joborder.viewall: 'View All'
menu.joborder.hubview: 'Hub View'
menu.joborder.resqall: 'RESQ All'
menu.support: 'Support'
menu.support.customers: 'Customers'