Merge branch '449-resq-dropdown-for-cancellation-reasons' into '453-resq-july-30-release'

Resolve "Resq - dropdown for cancellation reasons"

See merge request jankstudio/resq!528
This commit is contained in:
Korina Cordero 2020-08-04 02:30:36 +00:00
commit cf6793a323
5 changed files with 84 additions and 36 deletions

View file

@ -257,3 +257,8 @@ jo_fulfill_cancel_submit:
path: /job-order/fulfillcancel/{id} path: /job-order/fulfillcancel/{id}
controller: App\Controller\JobOrderController::fulfillCancelSubmit controller: App\Controller\JobOrderController::fulfillCancelSubmit
methods: [POST] methods: [POST]
jo_cancel_reasons:
path: /ajax/jo_cancel_reasons
controller: App\Controller\JobOrderController::cancelReasons
methods: [GET]

View file

@ -6,6 +6,7 @@ use App\Ramcar\JOStatus;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
use App\Ramcar\CMBServiceType; use App\Ramcar\CMBServiceType;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
use App\Ramcar\JOCancelReasons;
use App\Entity\CustomerVehicle; use App\Entity\CustomerVehicle;
use App\Entity\Promo; use App\Entity\Promo;
@ -1177,6 +1178,13 @@ class JobOrderController extends Controller
]); ]);
} }
// ajax call
public function cancelReasons()
{
return $this->json([
'cancel_reasons' => JOCancelReasons::getCollection(),
]);
}
/** /**
* @Menu(selected="jo_autoassign") * @Menu(selected="jo_autoassign")

View file

@ -0,0 +1,26 @@
<?php
namespace App\Ramcar;
class JOCancelReasons extends NameValue
{
const WRONG_BATTERY = 'wrong_battery';
const CUSTOMER_NO_SHOW = 'customer_no_show';
const RESCHEDULE = 'reschedule';
const LOCATION_CHANGE = 'location_change';
const WORKING_BATTERY = 'battery_working';
const LATE_DELIVERY = 'late_delivery';
const CUSTOMER_BOUGHT_NEW_BATTERY = 'customer_bought_new_battery';
const BATTERY_NO_STOCK = 'battery_no_stock';
const COLLECTION = [
'wrong_battery' => 'Wrong Battery',
'customer_no_show' => 'Customer No Show',
'reschedule' => 'Reschedule',
'location_change' => 'Change Location',
'battery_working' => 'Battery is Already Working',
'late_delivery' => 'Late Delivery',
'customer_bought_new_battery' => 'Customer Already Bought New Battery from Nearby Outlet',
'battery_no_stock' => 'No Stock of Battery',
];
}

View file

@ -954,6 +954,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
throw new NotFoundHttpException('The item does not exist'); throw new NotFoundHttpException('The item does not exist');
$cancel_reason = $req->request->get('cancel_reason'); $cancel_reason = $req->request->get('cancel_reason');
error_log($cancel_reason);
$obj->cancel($cancel_reason); $obj->cancel($cancel_reason);
// the event // the event

View file

@ -1746,44 +1746,52 @@ $(function() {
// cancel job order // cancel job order
$(".btn-cancel-job-order").click(function(e) { $(".btn-cancel-job-order").click(function(e) {
var url = $(this).prop('href'); var url = $(this).prop('href');
e.preventDefault(); e.preventDefault();
swal({ var inputOptionsPromise = new Promise(function(resolve) {
title: 'Cancel Job Order', // get your data and pass it to resolve()
html: 'Please enter the reason for cancellation of this job order:', $.getJSON("{{ url('jo_cancel_reasons') }}", function(data) {
input: 'textarea', resolve(data.cancel_reasons)
inputClass: 'form-control', });
type: 'warning', });
showCancelButton: true,
width: '40rem', swal({
preConfirm: (reason) => { title: 'Cancel Job Order',
if (!reason) { html: 'Please select the reason for cancellation of this job order:',
swal.showValidationError( input: 'select',
'Reason for cancellation is required.' inputOptions: inputOptionsPromise,
) type: 'warning',
} showCancelButton: true,
} closeOnCancel: true,
}).then((reason) => { width: '40rem',
$.ajax({ inputValidator: (value) => {
method: "DELETE", return new Promise((resolve) => {
url: url, resolve()
data: { })
'cancel_reason': reason.value }
} }).then((result) => {
}).done(function(response) { if (result.value) {
swal({ $.ajax({
title: 'Done!', method: "DELETE",
text: response.success, url: url,
type: 'success', data: {
onClose: function() { 'cancel_reason': result.value
window.location.href = "{{ return_url }}"; }
} }).done(function(response) {
}); swal({
}); title: 'Done!',
}); text: response.success,
}); type: 'success',
onClose: function() {
window.location.href = "{{ return_url }}";
}
});
});
}
});
});
// fulfill cancelled job order // fulfill cancelled job order
$(".btn-fulfill-cancel-job-order").click(function(e) { $(".btn-fulfill-cancel-job-order").click(function(e) {