Resolve "JO Cancel needs prompt for 'reason'" #845
2 changed files with 49 additions and 20 deletions
|
|
@ -573,6 +573,7 @@ class JobOrderController extends BaseController
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
$params['warranty_classes'] = WarrantyClass::getCollection();
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
$params['discount_apply'] = DiscountApply::getCollection();
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
$params['trade_in_types'] = TradeInType::getCollection();
|
||||||
|
|
@ -770,6 +771,7 @@ class JobOrderController extends BaseController
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
$params['warranty_classes'] = WarrantyClass::getCollection();
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
$params['discount_apply'] = DiscountApply::getCollection();
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
$params['trade_in_types'] = TradeInType::getCollection();
|
||||||
|
|
@ -899,6 +901,7 @@ class JobOrderController extends BaseController
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
$params['warranty_classes'] = WarrantyClass::getCollection();
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
$params['discount_apply'] = DiscountApply::getCollection();
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
$params['trade_in_types'] = TradeInType::getCollection();
|
||||||
|
|
@ -1000,6 +1003,7 @@ class JobOrderController extends BaseController
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
$params['warranty_classes'] = WarrantyClass::getCollection();
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
$params['discount_apply'] = DiscountApply::getCollection();
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
$params['trade_in_types'] = TradeInType::getCollection();
|
||||||
|
|
@ -1155,6 +1159,7 @@ class JobOrderController extends BaseController
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
$params['warranty_classes'] = WarrantyClass::getCollection();
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
$params['discount_apply'] = DiscountApply::getCollection();
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
$params['trade_in_types'] = TradeInType::getCollection();
|
||||||
|
|
@ -1269,6 +1274,7 @@ class JobOrderController extends BaseController
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
$params['warranty_classes'] = WarrantyClass::getCollection();
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
$params['discount_apply'] = DiscountApply::getCollection();
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
$params['trade_in_types'] = TradeInType::getCollection();
|
||||||
|
|
@ -1313,6 +1319,17 @@ class JobOrderController extends BaseController
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('joborder.cancel', null, 'No access.');
|
$this->denyAccessUnlessGranted('joborder.cancel', null, 'No access.');
|
||||||
|
|
||||||
|
$cancel_reason = $req->request->get('cancel_reason');
|
||||||
|
|
||||||
|
if (empty($cancel_reason))
|
||||||
|
{
|
||||||
|
// something happened
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'Reason for cancellation is required.'
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
|
@ -1322,7 +1339,8 @@ class JobOrderController extends BaseController
|
||||||
throw $this->createNotFoundException('The item does not exist');
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
// cancel job order
|
// cancel job order
|
||||||
$obj->setStatus(JOStatus::CANCELLED);
|
$obj->setStatus(JOStatus::CANCELLED)
|
||||||
|
->setCancelReason($cancel_reason);
|
||||||
|
|
||||||
// save
|
// save
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
|
||||||
|
|
@ -715,7 +715,7 @@
|
||||||
{% if mode != 'update-all' %}
|
{% if mode != 'update-all' %}
|
||||||
<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>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mode != 'create' and is_granted('joborder.cancel') %}
|
{% if mode != 'create' and is_granted('joborder.cancel') and obj.getStatus != status_cancelled %}
|
||||||
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</button>
|
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if mode != 'create' %}
|
{% if mode != 'create' %}
|
||||||
|
|
@ -1361,26 +1361,37 @@ $(function() {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
swal({
|
swal({
|
||||||
title: 'Confirmation',
|
title: 'Cancel Job Order',
|
||||||
html: 'Are you sure you want to cancel this job order?',
|
html: 'Please enter the reason for cancellation of this job order:',
|
||||||
|
input: 'textarea',
|
||||||
|
inputClass: 'form-control',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
showCancelButton: true
|
showCancelButton: true,
|
||||||
}).then((result) => {
|
width: '40rem',
|
||||||
if (result.value) {
|
preConfirm: (reason) => {
|
||||||
$.ajax({
|
if (!reason) {
|
||||||
method: "DELETE",
|
swal.showValidationError(
|
||||||
url: url
|
'Reason for cancellation is required.'
|
||||||
}).done(function(response) {
|
)
|
||||||
swal({
|
}
|
||||||
title: 'Done!',
|
|
||||||
text: response.success,
|
|
||||||
type: 'success',
|
|
||||||
onClose: function() {
|
|
||||||
window.location.href = "{{ return_url }}";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}).then((reason) => {
|
||||||
|
$.ajax({
|
||||||
|
method: "DELETE",
|
||||||
|
url: url,
|
||||||
|
data: {
|
||||||
|
'cancel_reason': reason.value
|
||||||
|
}
|
||||||
|
}).done(function(response) {
|
||||||
|
swal({
|
||||||
|
title: 'Done!',
|
||||||
|
text: response.success,
|
||||||
|
type: 'success',
|
||||||
|
onClose: function() {
|
||||||
|
window.location.href = "{{ return_url }}";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue