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:
commit
cf6793a323
5 changed files with 84 additions and 36 deletions
|
|
@ -257,3 +257,8 @@ jo_fulfill_cancel_submit:
|
|||
path: /job-order/fulfillcancel/{id}
|
||||
controller: App\Controller\JobOrderController::fulfillCancelSubmit
|
||||
methods: [POST]
|
||||
|
||||
jo_cancel_reasons:
|
||||
path: /ajax/jo_cancel_reasons
|
||||
controller: App\Controller\JobOrderController::cancelReasons
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Ramcar\JOStatus;
|
|||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\CMBServiceType;
|
||||
use App\Ramcar\ServiceType;
|
||||
use App\Ramcar\JOCancelReasons;
|
||||
|
||||
use App\Entity\CustomerVehicle;
|
||||
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")
|
||||
|
|
|
|||
26
src/Ramcar/JOCancelReasons.php
Normal file
26
src/Ramcar/JOCancelReasons.php
Normal 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',
|
||||
];
|
||||
}
|
||||
|
|
@ -954,6 +954,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
throw new NotFoundHttpException('The item does not exist');
|
||||
|
||||
$cancel_reason = $req->request->get('cancel_reason');
|
||||
error_log($cancel_reason);
|
||||
$obj->cancel($cancel_reason);
|
||||
|
||||
// the event
|
||||
|
|
|
|||
|
|
@ -1750,27 +1750,34 @@ $(function() {
|
|||
|
||||
e.preventDefault();
|
||||
|
||||
var inputOptionsPromise = new Promise(function(resolve) {
|
||||
// get your data and pass it to resolve()
|
||||
$.getJSON("{{ url('jo_cancel_reasons') }}", function(data) {
|
||||
resolve(data.cancel_reasons)
|
||||
});
|
||||
});
|
||||
|
||||
swal({
|
||||
title: 'Cancel Job Order',
|
||||
html: 'Please enter the reason for cancellation of this job order:',
|
||||
input: 'textarea',
|
||||
inputClass: 'form-control',
|
||||
html: 'Please select the reason for cancellation of this job order:',
|
||||
input: 'select',
|
||||
inputOptions: inputOptionsPromise,
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
closeOnCancel: true,
|
||||
width: '40rem',
|
||||
preConfirm: (reason) => {
|
||||
if (!reason) {
|
||||
swal.showValidationError(
|
||||
'Reason for cancellation is required.'
|
||||
)
|
||||
inputValidator: (value) => {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}).then((reason) => {
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
method: "DELETE",
|
||||
url: url,
|
||||
data: {
|
||||
'cancel_reason': reason.value
|
||||
'cancel_reason': result.value
|
||||
}
|
||||
}).done(function(response) {
|
||||
swal({
|
||||
|
|
@ -1782,6 +1789,7 @@ $(function() {
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue