Add job order cancel functionality #13
This commit is contained in:
parent
d0d8bb07e0
commit
c3199d80c4
4 changed files with 57 additions and 7 deletions
|
|
@ -114,8 +114,8 @@ jo_open_rider_submit:
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
jo_cancel:
|
jo_cancel:
|
||||||
path: /job-order/{id}
|
path: /job-order/cancel/{id}
|
||||||
controller: App\Controller\JobOrderController::cancel
|
controller: App\Controller\JobOrderController::cancelJobOrder
|
||||||
methods: [DELETE]
|
methods: [DELETE]
|
||||||
|
|
||||||
jo_search:
|
jo_search:
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,10 @@ span.has-danger,
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-form__actions .btn + .btn {
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (min-width: 995px) {
|
@media (min-width: 995px) {
|
||||||
.modal-lg {
|
.modal-lg {
|
||||||
max-width: 1024px;
|
max-width: 1024px;
|
||||||
|
|
|
||||||
|
|
@ -1082,10 +1082,6 @@ class JobOrderController extends BaseController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function openRiderForm($id)
|
public function openRiderForm($id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||||
|
|
@ -1208,14 +1204,31 @@ class JobOrderController extends BaseController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cancelJobOrder(Request $req, $id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('joborder.cancel', null, 'No access.');
|
||||||
|
|
||||||
|
// get object data
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this object exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
|
// cancel job order
|
||||||
|
$obj->setStatus(JOStatus::CANCELLED);
|
||||||
|
|
||||||
|
// save
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// return successful response
|
||||||
|
return $this->json([
|
||||||
|
'success' => 'Job order has been cancelled!'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: re-enable search, figure out how to group the orWhere filters into one, so can execute that plus the pending filter
|
// TODO: re-enable search, figure out how to group the orWhere filters into one, so can execute that plus the pending filter
|
||||||
|
|
||||||
// check if datatable filter is present and append to query
|
// check if datatable filter is present and append to query
|
||||||
protected function setQueryFilters($datatable, &$query, $qb, $hubs, $tier, $status)
|
protected function setQueryFilters($datatable, &$query, $qb, $hubs, $tier, $status)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -622,6 +622,9 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<button type="submit" class="btn btn-success">{{ mode == 'update-fulfillment' ? 'Fulfill' : 'Submit' }}</button>
|
<button type="submit" class="btn btn-success">{{ mode == 'update-fulfillment' ? 'Fulfill' : 'Submit' }}</button>
|
||||||
|
{% if mode != 'create' and is_granted('joborder.cancel') %}
|
||||||
|
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</button>
|
||||||
|
{% endif %}
|
||||||
{% if mode != 'create' %}
|
{% if mode != 'create' %}
|
||||||
<a href="{{ return_url }}" class="btn btn-secondary">Back</a>
|
<a href="{{ return_url }}" class="btn btn-secondary">Back</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -1256,6 +1259,36 @@ $(function() {
|
||||||
|
|
||||||
var ticketTable = $("#data-tickets").mDatatable(ticketOptions);
|
var ticketTable = $("#data-tickets").mDatatable(ticketOptions);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
// cancel job order
|
||||||
|
$(".btn-cancel-job-order").click(function(e) {
|
||||||
|
var url = $(this).prop('href');
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
swal({
|
||||||
|
title: 'Confirmation',
|
||||||
|
html: 'Are you sure you want to cancel this job order?',
|
||||||
|
type: 'warning',
|
||||||
|
showCancelButton: true
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.value) {
|
||||||
|
$.ajax({
|
||||||
|
method: "DELETE",
|
||||||
|
url: url
|
||||||
|
}).done(function(response) {
|
||||||
|
swal({
|
||||||
|
title: 'Done!',
|
||||||
|
text: response.success,
|
||||||
|
type: 'success',
|
||||||
|
onClose: function() {
|
||||||
|
window.location.href = "{{ return_url }}";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue