Merge branch '453-resq-july-30-release' of gitlab.com:jankstudio/resq into 461-resq-get-only-compatible-batteries-after-customer-vehicle-is-selected
This commit is contained in:
commit
54c20f5218
16 changed files with 444 additions and 61 deletions
|
|
@ -74,3 +74,6 @@ MAPTILER_API_KEY=map_tiler_api_key
|
||||||
|
|
||||||
# API version
|
# API version
|
||||||
API_VERSION=insert_api_version_here
|
API_VERSION=insert_api_version_here
|
||||||
|
|
||||||
|
#SSL_ENABLE for websockets
|
||||||
|
SSL_ENABLE=set_to_true_or_false
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,8 @@ access_keys:
|
||||||
label: Autoassign Test
|
label: Autoassign Test
|
||||||
- id: jo_hub.list
|
- id: jo_hub.list
|
||||||
label: Hub View
|
label: Hub View
|
||||||
|
- id: jo_cancel.fulfill
|
||||||
|
label: Fulfill Cancelled JO
|
||||||
|
|
||||||
- id: support
|
- id: support
|
||||||
label: Customer Support Access
|
label: Customer Support Access
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,4 @@ twig:
|
||||||
mqtt_host: "%env(MQTT_WS_HOST)%"
|
mqtt_host: "%env(MQTT_WS_HOST)%"
|
||||||
mqtt_port: "%env(MQTT_WS_PORT)%"
|
mqtt_port: "%env(MQTT_WS_PORT)%"
|
||||||
dashboard_enable: "%env(DASHBOARD_ENABLE)%"
|
dashboard_enable: "%env(DASHBOARD_ENABLE)%"
|
||||||
|
ssl_enable: "%env(SSL_ENABLE)%"
|
||||||
|
|
|
||||||
|
|
@ -253,3 +253,12 @@ jo_hub_view_form:
|
||||||
controller: App\Controller\JobOrderController::hubViewForm
|
controller: App\Controller\JobOrderController::hubViewForm
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
class MapEventHandler {
|
class MapEventHandler {
|
||||||
constructor(options, dashmap) {
|
constructor(options, dashmap, ssl) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.dashmap = dashmap;
|
this.dashmap = dashmap;
|
||||||
|
this.ssl = ssl;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(user_id, host, port) {
|
connect(user_id, host, port) {
|
||||||
|
|
@ -11,7 +12,7 @@ class MapEventHandler {
|
||||||
|
|
||||||
this.mqtt = new Paho.MQTT.Client(host, port, client_id);
|
this.mqtt = new Paho.MQTT.Client(host, port, client_id);
|
||||||
var options = {
|
var options = {
|
||||||
// useSSL: true,
|
useSSL: this.ssl,
|
||||||
timeout: 3,
|
timeout: 3,
|
||||||
invocationContext: this,
|
invocationContext: this,
|
||||||
onSuccess: this.onConnect.bind(this),
|
onSuccess: this.onConnect.bind(this),
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -631,7 +632,6 @@ class JobOrderController extends Controller
|
||||||
$params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll();
|
$params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll();
|
||||||
$params['vmakes'] = $em->getRepository(Vehicle::class)->findAll();
|
$params['vmakes'] = $em->getRepository(Vehicle::class)->findAll();
|
||||||
$params['return_url'] = $this->generateUrl('jo_all');
|
$params['return_url'] = $this->generateUrl('jo_all');
|
||||||
$params['submit_url'] = '';
|
|
||||||
$params['map_js_file'] = $gis->getJSJOFile();
|
$params['map_js_file'] = $gis->getJSJOFile();
|
||||||
|
|
||||||
$template = $params['template'];
|
$template = $params['template'];
|
||||||
|
|
@ -1153,6 +1153,38 @@ class JobOrderController extends Controller
|
||||||
return $this->render($template, $params);
|
return $this->render($template, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fulfillCancelSubmit(Request $req, JobOrderHandlerInterface $jo_handler, $id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('jo_cancel.fulfill', null, 'No access.');
|
||||||
|
|
||||||
|
// TODO: make the service function to fulfill the cancelled JO
|
||||||
|
$error_array = [];
|
||||||
|
$result = $jo_handler->fulfillCancelledJobOrder($req, $id);
|
||||||
|
|
||||||
|
$error_array = $result['error_array'];
|
||||||
|
|
||||||
|
// check if any errors were found
|
||||||
|
if (!empty($error_array)) {
|
||||||
|
// return validation failure response
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $error_array
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return successful response
|
||||||
|
return $this->json([
|
||||||
|
'success' => 'Changes have been saved!'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ajax call
|
||||||
|
public function cancelReasons()
|
||||||
|
{
|
||||||
|
return $this->json([
|
||||||
|
'cancel_reasons' => JOCancelReasons::getCollection(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="jo_autoassign")
|
* @Menu(selected="jo_autoassign")
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,18 @@ class JobOrder
|
||||||
*/
|
*/
|
||||||
protected $phone_mobile;
|
protected $phone_mobile;
|
||||||
|
|
||||||
|
// flag if customer is willing to wait
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $flag_will_wait;
|
||||||
|
|
||||||
|
// reason for not willing to wait
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=80, nullable=true)
|
||||||
|
*/
|
||||||
|
protected $reasons_not_waiting;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -356,6 +368,8 @@ class JobOrder
|
||||||
$this->meta = [];
|
$this->meta = [];
|
||||||
|
|
||||||
$this->phone_mobile = '';
|
$this->phone_mobile = '';
|
||||||
|
|
||||||
|
$this->flag_will_wait = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -962,5 +976,25 @@ class JobOrder
|
||||||
return $this->phone_mobile;
|
return $this->phone_mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setWillingToWait($flag = true)
|
||||||
|
{
|
||||||
|
$this->flag_will_wait = $flag;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isWillingToWait()
|
||||||
|
{
|
||||||
|
return $this->flag_will_wait;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReasonsNotWait($reasons)
|
||||||
|
{
|
||||||
|
$this->reasons_not_waiting = $reasons;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReasonsNotWait()
|
||||||
|
{
|
||||||
|
return $this->reasons_not_waiting;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/Ramcar/CustomerNotWaitReason.php
Normal file
16
src/Ramcar/CustomerNotWaitReason.php
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ramcar;
|
||||||
|
|
||||||
|
class CustomerNotWaitReason extends NameValue
|
||||||
|
{
|
||||||
|
const EMERGENCY = 'emergency';
|
||||||
|
const USE_VEHICLE_NOW = 'use_vehicle_now';
|
||||||
|
const WITH_APPOINTMENT = 'with_appointment';
|
||||||
|
|
||||||
|
const COLLECTION = [
|
||||||
|
'emergency' => 'Emergency',
|
||||||
|
'use_vehicle_now' => 'Need to Use Vehicle Now',
|
||||||
|
'with_appointment' => 'With Appointment',
|
||||||
|
];
|
||||||
|
}
|
||||||
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',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ class TransactionOrigin extends NameValue
|
||||||
const VIP = 'vip';
|
const VIP = 'vip';
|
||||||
const MOBILE_APP = 'mobile_app';
|
const MOBILE_APP = 'mobile_app';
|
||||||
const WALK_IN = 'walk_in';
|
const WALK_IN = 'walk_in';
|
||||||
|
const LAZADA = 'lazada';
|
||||||
|
|
||||||
// TODO: for now, resq also gets the walk-in option
|
// TODO: for now, resq also gets the walk-in option
|
||||||
const COLLECTION = [
|
const COLLECTION = [
|
||||||
|
|
@ -19,5 +20,6 @@ class TransactionOrigin extends NameValue
|
||||||
'vip' => 'VIP',
|
'vip' => 'VIP',
|
||||||
'mobile_app' => 'Mobile App',
|
'mobile_app' => 'Mobile App',
|
||||||
'walk_in' => 'Walk-in',
|
'walk_in' => 'Walk-in',
|
||||||
|
'lazada' => 'Lazada',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ use App\Ramcar\ModeOfPayment;
|
||||||
use App\Ramcar\TransactionOrigin;
|
use App\Ramcar\TransactionOrigin;
|
||||||
use App\Ramcar\FacilitatedType;
|
use App\Ramcar\FacilitatedType;
|
||||||
use App\Ramcar\JORejectionReason;
|
use App\Ramcar\JORejectionReason;
|
||||||
|
use App\Ramcar\CustomerNotWaitReason;
|
||||||
|
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\JobOrderHandlerInterface;
|
use App\Service\JobOrderHandlerInterface;
|
||||||
|
|
@ -183,6 +184,12 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
else
|
else
|
||||||
$row['assignor'] = $orow->getAssignedBy()->getFullName();
|
$row['assignor'] = $orow->getAssignedBy()->getFullName();
|
||||||
|
|
||||||
|
$hub_facilitated = $orow->getFacilitatedBy();
|
||||||
|
if ($hub_facilitated == null)
|
||||||
|
$row['hub_facilitated'] = '';
|
||||||
|
else
|
||||||
|
$row['hub_facilitated'] = $orow->getFacilitatedBy()->getName();
|
||||||
|
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -314,6 +321,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
// TODO: check status before saving since JO might already
|
// TODO: check status before saving since JO might already
|
||||||
// have a status that needs to be retained
|
// have a status that needs to be retained
|
||||||
|
|
||||||
|
|
@ -343,7 +361,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setORName($req->request->get('or_name'))
|
->setORName($req->request->get('or_name'))
|
||||||
->setPromoDetail($req->request->get('promo_detail'))
|
->setPromoDetail($req->request->get('promo_detail'))
|
||||||
->setModeOfPayment($req->request->get('mode_of_payment'))
|
->setModeOfPayment($req->request->get('mode_of_payment'))
|
||||||
->setLandmark($req->request->get('landmark'));
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
// check if user is null, meaning call to create came from API
|
// check if user is null, meaning call to create came from API
|
||||||
if ($user != null)
|
if ($user != null)
|
||||||
|
|
@ -434,6 +454,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
if (empty($error_array))
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
// get current user
|
// get current user
|
||||||
|
|
@ -458,7 +489,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setORName($req->request->get('or_name'))
|
->setORName($req->request->get('or_name'))
|
||||||
->setPromoDetail($req->request->get('promo_detail'))
|
->setPromoDetail($req->request->get('promo_detail'))
|
||||||
->setModeOfPayment($req->request->get('mode_of_payment'))
|
->setModeOfPayment($req->request->get('mode_of_payment'))
|
||||||
->setLandmark($req->request->get('landmark'));
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
// did they change invoice?
|
// did they change invoice?
|
||||||
$invoice_items = $req->request->get('invoice_items', []);
|
$invoice_items = $req->request->get('invoice_items', []);
|
||||||
|
|
@ -492,6 +525,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setTypeID(JOEventType::OPEN_EDIT)
|
->setTypeID(JOEventType::OPEN_EDIT)
|
||||||
->setJobOrder($obj);
|
->setJobOrder($obj);
|
||||||
|
|
||||||
|
error_log('open edit?');
|
||||||
|
|
||||||
if ($user != null)
|
if ($user != null)
|
||||||
{
|
{
|
||||||
$event->setUser($user);
|
$event->setUser($user);
|
||||||
|
|
@ -587,6 +622,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$fac_by = null;
|
$fac_by = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
if (empty($error_array))
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
// coordinates
|
// coordinates
|
||||||
|
|
@ -606,7 +652,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
->setFacilitatedType($fac_type)
|
->setFacilitatedType($fac_type)
|
||||||
->setFacilitatedBy($fac_by)
|
->setFacilitatedBy($fac_by)
|
||||||
->setHub($hub);
|
->setHub($hub)
|
||||||
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $this->validator->validate($obj);
|
$errors = $this->validator->validate($obj);
|
||||||
|
|
@ -680,6 +729,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
// get current user
|
// get current user
|
||||||
$user = $this->security->getUser();
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
|
|
@ -700,7 +760,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setTier2Notes($req->request->get('tier2_notes'))
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
->setDateAssign(new DateTime())
|
->setDateAssign(new DateTime())
|
||||||
->setRider($rider);
|
->setRider($rider)
|
||||||
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
if ($user != null)
|
if ($user != null)
|
||||||
{
|
{
|
||||||
|
|
@ -763,6 +826,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
if (empty($error_array)) {
|
if (empty($error_array)) {
|
||||||
// coordinates
|
// coordinates
|
||||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||||
|
|
@ -777,7 +851,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||||
->setTier1Notes($req->request->get('tier1_notes'))
|
->setTier1Notes($req->request->get('tier1_notes'))
|
||||||
->setTier2Notes($req->request->get('tier2_notes'))
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'));
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $this->validator->validate($obj);
|
$errors = $this->validator->validate($obj);
|
||||||
|
|
@ -883,6 +960,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
|
||||||
|
|
@ -947,6 +1025,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
if (empty($error_array))
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
// rider mqtt event
|
// rider mqtt event
|
||||||
|
|
@ -974,7 +1063,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setTier2Notes($req->request->get('tier2_notes'))
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
->setHub($hub)
|
->setHub($hub)
|
||||||
->clearRider();
|
->clearRider()
|
||||||
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
if ($user != null)
|
if ($user != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1148,6 +1240,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if landmark is set
|
||||||
|
if (empty($req->request->get('landmark')))
|
||||||
|
$error_array['landmark'] = 'Landmark is required.';
|
||||||
|
|
||||||
|
// check if customer is not willing to wait
|
||||||
|
$will_wait = $req->request->get('flag_will_wait');
|
||||||
|
if ($will_wait)
|
||||||
|
$reason = '';
|
||||||
|
else
|
||||||
|
$reason = $req->request->get('no_wait_reason');
|
||||||
|
|
||||||
if (empty($error_array)) {
|
if (empty($error_array)) {
|
||||||
// rider mqtt event
|
// rider mqtt event
|
||||||
// NOTE: need to send this before saving because rider will be cleared
|
// NOTE: need to send this before saving because rider will be cleared
|
||||||
|
|
@ -1174,7 +1277,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setTier2Notes($req->request->get('tier2_notes'))
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
->setDateAssign(new DateTime())
|
->setDateAssign(new DateTime())
|
||||||
->setRider($rider);
|
->setRider($rider)
|
||||||
|
->setLandmark($req->request->get('landmark'))
|
||||||
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
|
->setReasonsNotWait($reason);
|
||||||
|
|
||||||
if ($user != null)
|
if ($user != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1562,6 +1668,18 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->fillDropdownParameters($params);
|
$this->fillDropdownParameters($params);
|
||||||
$this->fillFormTags($params);
|
$this->fillFormTags($params);
|
||||||
|
|
||||||
|
// check JO status to determine the mode and submit_url to return
|
||||||
|
if ($obj->getStatus() == JOStatus::CANCELLED)
|
||||||
|
{
|
||||||
|
$params['mode'] = 'fulfill-cancel';
|
||||||
|
$params['submit_url'] = 'jo_fulfill_cancel_submit';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$params['mode'] = 'update-all';
|
||||||
|
$params['submit_url'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
// get template to display
|
// get template to display
|
||||||
$params['template'] = $this->getTwigTemplate('jo_all_form');
|
$params['template'] = $this->getTwigTemplate('jo_all_form');
|
||||||
|
|
||||||
|
|
@ -2434,6 +2552,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$params['facilitated_types'] = FacilitatedType::getCollection();
|
$params['facilitated_types'] = FacilitatedType::getCollection();
|
||||||
$params['facilitated_hubs'] = $fac_hubs;
|
$params['facilitated_hubs'] = $fac_hubs;
|
||||||
$params['sources'] = TransactionOrigin::getCollection();
|
$params['sources'] = TransactionOrigin::getCollection();
|
||||||
|
$params['no_wait_reasons'] = CustomerNotWaitReason::getCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initFormTags(&$params)
|
protected function initFormTags(&$params)
|
||||||
|
|
@ -2765,20 +2884,35 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->andWhere('h.flag_hub_view = :flag_hub_view')
|
->andWhere('h.flag_hub_view = :flag_hub_view')
|
||||||
->setParameter('flag_hub_view', true);
|
->setParameter('flag_hub_view', true);
|
||||||
}
|
}
|
||||||
|
if (isset($datatable['query']['schedule_date']))
|
||||||
|
{
|
||||||
|
$start = $datatable['query']['schedule_date'][0] . ' ' . '00:00:00';
|
||||||
|
$end = $datatable['query']['schedule_date'][1] . ' ' . '23:59:00';
|
||||||
|
|
||||||
|
$date_start = DateTime::createFromFormat('m/d/Y H:i:s', $start);
|
||||||
|
$date_end = DateTime::createFromFormat('m/d/Y H:i:s', $end);
|
||||||
|
|
||||||
|
$query->andWhere('q.date_schedule >= :date_start')
|
||||||
|
->andWhere('q.date_schedule <= :date_end')
|
||||||
|
->setParameter('date_start', $date_start)
|
||||||
|
->setParameter('date_end', $date_end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$c_date = new DateTime();
|
||||||
|
$start_curr_date = $c_date->format('Y-m-d') . ' ' . '00:00:00';
|
||||||
|
$end_curr_date = $c_date->format('Y-m-d') . ' ' . '23:59:00';
|
||||||
|
|
||||||
$c_date = new DateTime();
|
$start_current_date = DateTime::createFromFormat('Y-m-d H:i:s', $start_curr_date);
|
||||||
$start_curr_date = $c_date->format('Y-m-d') . ' ' . '00:00:00';
|
$end_current_date = DateTime::createFromFormat('Y-m-d H:i:s', $end_curr_date);
|
||||||
$end_curr_date = $c_date->format('Y-m-d') . ' ' . '23:59:00';
|
|
||||||
|
|
||||||
$start_current_date = DateTime::createFromFormat('Y-m-d H:i:s', $start_curr_date);
|
$query->andWhere('q.date_schedule >= :start_current_date')
|
||||||
$end_current_date = DateTime::createFromFormat('Y-m-d H:i:s', $end_curr_date);
|
->andWhere('q.date_schedule <= :end_current_date')
|
||||||
|
->andWhere('q.status IN (:statuses)')
|
||||||
$query->andWhere('q.date_schedule >= :start_current_date')
|
->setParameter('start_current_date', $start_current_date)
|
||||||
->andWhere('q.date_schedule <= :end_current_date')
|
->setParameter('end_current_date', $end_current_date)
|
||||||
->andWhere('q.status IN (:statuses)')
|
->setParameter('statuses', $status, Connection::PARAM_STR_ARRAY);
|
||||||
->setParameter('start_current_date', $start_current_date)
|
}
|
||||||
->setParameter('end_current_date', $end_current_date)
|
|
||||||
->setParameter('statuses', $status, Connection::PARAM_STR_ARRAY);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$query->where('q.status = :status')
|
$query->where('q.status = :status')
|
||||||
|
|
@ -2954,4 +3088,37 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fulfillCancelledJobOrder(Request $req, $id)
|
||||||
|
{
|
||||||
|
// initialize error list
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// get object data
|
||||||
|
$em = $this->em;
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this object exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw new NotFoundHttpException('The item does not exist');
|
||||||
|
|
||||||
|
$obj->fulfill();
|
||||||
|
|
||||||
|
// the event
|
||||||
|
$event = new JOEvent();
|
||||||
|
$event->setDateHappen(new DateTime())
|
||||||
|
->setTypeID(JOEventType::FULFILL)
|
||||||
|
->setJobOrder($obj);
|
||||||
|
|
||||||
|
// get current user
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
if ($user != null)
|
||||||
|
{
|
||||||
|
$event->setUser($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
$event->setUser($user);
|
||||||
|
$em->persist($event);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ function initMap(r_markers, c_markers, icons) {
|
||||||
return dashmap;
|
return dashmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initEventHandler(dashmap) {
|
function initEventHandler(dashmap, icons, ssl) {
|
||||||
var options = {
|
var options = {
|
||||||
'track_jo': true,
|
'track_jo': true,
|
||||||
'track_rider': true,
|
'track_rider': true,
|
||||||
|
|
@ -58,7 +58,7 @@ function initEventHandler(dashmap) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var event_handler = new MapEventHandler(options, dashmap);
|
var event_handler = new MapEventHandler(options, dashmap, ssl);
|
||||||
event_handler.connect('{{ app.user.getID }}', '{{ mqtt_host }}', {{ mqtt_port }});
|
event_handler.connect('{{ app.user.getID }}', '{{ mqtt_host }}', {{ mqtt_port }});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,8 +94,13 @@ var icons = {
|
||||||
var r_markers = {};
|
var r_markers = {};
|
||||||
var c_markers = {};
|
var c_markers = {};
|
||||||
|
|
||||||
|
var ssl = false;
|
||||||
|
{% if ssl_enable == 'true' %}
|
||||||
|
ssl = true;
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
var dashmap = initMap(r_markers, c_markers, icons);
|
var dashmap = initMap(r_markers, c_markers, icons);
|
||||||
initEventHandler(dashmap, icons);
|
initEventHandler(dashmap, icons, ssl);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,22 @@
|
||||||
<div class="form-control-feedback hide" data-field="date_schedule_time"></div>
|
<div class="form-control-feedback hide" data-field="date_schedule_time"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<input type="checkbox" name="flag_will_wait" id="flag-will-wait" value="1"{{ obj.isWillingToWait ? ' checked' }} >
|
||||||
|
<label class="switch-label">Willing to Wait</label>
|
||||||
|
<div class="form-control-feedback hide" data-field="flag_will_wait"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<label data-field="no_wait_reason">Reason Why Not Willing to Wait</label>
|
||||||
|
<select class="form-control m-input" id="no-wait-reason" name="no_wait_reason">
|
||||||
|
{% for key, class in no_wait_reasons %}
|
||||||
|
<option value="{{ key }}"{{ obj.getReasonsNotWait == key ? ' selected' }}>{{ class }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="no_wait_reason"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="tier1_notes">Tier 1 Notes</label>
|
<label data-field="tier1_notes">Tier 1 Notes</label>
|
||||||
|
|
@ -848,7 +864,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
{% if mode != 'update-all' %}
|
{% if mode != 'update-all' %}
|
||||||
|
{% if mode == 'fulfill-cancel' and is_granted('jo_cancel.fulfill') %}
|
||||||
|
<a href="{{ url('jo_fulfill_cancel_submit', {'id': obj.getID}) }}" class="btn btn-success btn-fulfill-cancel-job-order">Fulfill</a>
|
||||||
|
{% else %}
|
||||||
<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 %}
|
{% endif %}
|
||||||
{% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %}
|
{% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %}
|
||||||
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</a>
|
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</a>
|
||||||
|
|
@ -1730,44 +1750,74 @@ $(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
|
||||||
|
$(".btn-fulfill-cancel-job-order").click(function(e) {
|
||||||
|
var url = $(this).prop('href');
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: url,
|
||||||
|
}).done(function(response) {
|
||||||
|
swal({
|
||||||
|
title: 'Done!',
|
||||||
|
text: response.success,
|
||||||
|
type: 'success',
|
||||||
|
onClose: function() {
|
||||||
|
window.location.href = "{{ return_url }}";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,10 @@
|
||||||
field: 'delivery_address',
|
field: 'delivery_address',
|
||||||
title: 'Customer Area'
|
title: 'Customer Area'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'hub_facilitated',
|
||||||
|
title: 'Battery Facilitated By'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'type',
|
field: 'type',
|
||||||
title: 'Schedule'
|
title: 'Schedule'
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="m-input-icon m-input-icon--left">
|
||||||
|
<div class="input-daterange input-group" id="date-range">
|
||||||
|
<input role="presentation" type="text" class="form-control m-input" id="date_start" name="date_start" placeholder="Start date" />
|
||||||
|
<div class="input-group-append">
|
||||||
|
<span class="input-group-text"><i class="la la-ellipsis-h"></i></span>
|
||||||
|
</div>
|
||||||
|
<input role="presentation" type="text" class="form-control" id="date_end" name="date_end" placeholder="End date" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -59,6 +70,10 @@
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
$("#date-range").datepicker({
|
||||||
|
orientation: "bottom"
|
||||||
|
});
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
data: {
|
data: {
|
||||||
type: 'remote',
|
type: 'remote',
|
||||||
|
|
@ -147,6 +162,22 @@
|
||||||
$("#hub_list").on("change", function() {
|
$("#hub_list").on("change", function() {
|
||||||
table.search($(this).val(), "hub");
|
table.search($(this).val(), "hub");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#date_start").on("change", function() {
|
||||||
|
var date_start = $(this).val();
|
||||||
|
var date_end = $("[name='date_end']").val();
|
||||||
|
var date_array = [date_start, date_end];
|
||||||
|
|
||||||
|
table.search(date_array, "schedule_date");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#date_end").on("change", function() {
|
||||||
|
var date_end = $(this).val();
|
||||||
|
var date_start = $("[name='date_start']").val();
|
||||||
|
var date_array = [date_start, date_end];
|
||||||
|
|
||||||
|
table.search(date_array, "schedule_date");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue