Merge branch '377-resq-bug-fixes' into 'master'
Resolve "Resq - bug fixes" Closes #377 See merge request jankstudio/resq!422
This commit is contained in:
commit
555d0dd3e7
12 changed files with 165 additions and 27 deletions
|
|
@ -66,3 +66,6 @@ INVENTORY_API_AUTH_TOKEN=insert_auth_token_here
|
||||||
|
|
||||||
# API logging
|
# API logging
|
||||||
API_LOGGING=set_to_true_or_false
|
API_LOGGING=set_to_true_or_false
|
||||||
|
|
||||||
|
# customer distance limit in km
|
||||||
|
CUST_DISTANCE_LIMIT=set_to_number
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$em: "@doctrine.orm.entity_manager"
|
$em: "@doctrine.orm.entity_manager"
|
||||||
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
|
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
|
||||||
|
$cust_dist_limit: "%env(CUST_DISTANCE_LIMIT)%"
|
||||||
|
|
||||||
App\Service\RisingTideGateway:
|
App\Service\RisingTideGateway:
|
||||||
arguments:
|
arguments:
|
||||||
|
|
@ -227,3 +228,8 @@ services:
|
||||||
$redis_prov: "@App\\Service\\RedisClientProvider"
|
$redis_prov: "@App\\Service\\RedisClientProvider"
|
||||||
$loc_key: "%env(LOCATION_RIDER_ACTIVE_KEY)%"
|
$loc_key: "%env(LOCATION_RIDER_ACTIVE_KEY)%"
|
||||||
$status_key: "%env(STATUS_RIDER_KEY)%"
|
$status_key: "%env(STATUS_RIDER_KEY)%"
|
||||||
|
|
||||||
|
# API logging
|
||||||
|
App\EventSubscriber\LogSubscriber:
|
||||||
|
arguments:
|
||||||
|
$api_log_flag: "%env(API_LOGGING)%"
|
||||||
|
|
|
||||||
|
|
@ -122,10 +122,6 @@ main_menu:
|
||||||
acl: jo_all.list
|
acl: jo_all.list
|
||||||
label: View All
|
label: View All
|
||||||
parent: joborder
|
parent: joborder
|
||||||
- id: jo_autoassign
|
|
||||||
acl: jo_autoassign.test
|
|
||||||
label: Autoassign Test
|
|
||||||
parent: joborder
|
|
||||||
|
|
||||||
- id: support
|
- id: support
|
||||||
acl: support.menu
|
acl: support.menu
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$em: "@doctrine.orm.entity_manager"
|
$em: "@doctrine.orm.entity_manager"
|
||||||
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
|
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
|
||||||
|
$cust_dist_limit: "%env(CUST_DISTANCE_LIMIT)%"
|
||||||
|
|
||||||
App\Service\RisingTideGateway:
|
App\Service\RisingTideGateway:
|
||||||
arguments:
|
arguments:
|
||||||
|
|
@ -233,4 +234,9 @@ services:
|
||||||
$api_url: "%env(INVENTORY_API_URL)%"
|
$api_url: "%env(INVENTORY_API_URL)%"
|
||||||
$api_ocp_key: "%env(INVENTORY_API_OCP)%"
|
$api_ocp_key: "%env(INVENTORY_API_OCP)%"
|
||||||
$api_auth_prefix: "%env(INVENTORY_API_AUTH_TOKEN_PREFIX)%"
|
$api_auth_prefix: "%env(INVENTORY_API_AUTH_TOKEN_PREFIX)%"
|
||||||
$api_auth_token: "%env(INVENTORY_API_AUTH_TOKEN)%"
|
$api_auth_token: "%env(INVENTORY_API_AUTH_TOKEN)%"
|
||||||
|
|
||||||
|
# API logging
|
||||||
|
App\EventSubscriber\LogSubscriber:
|
||||||
|
arguments:
|
||||||
|
$api_log_flag: "%env(API_LOGGING)%"
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$em: "@doctrine.orm.entity_manager"
|
$em: "@doctrine.orm.entity_manager"
|
||||||
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
|
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
|
||||||
|
$cust_dist_limit: "%env(CUST_DISTANCE_LIMIT)%"
|
||||||
|
|
||||||
App\Service\RisingTideGateway:
|
App\Service\RisingTideGateway:
|
||||||
arguments:
|
arguments:
|
||||||
|
|
@ -231,7 +232,7 @@ services:
|
||||||
App\Service\InventoryManager:
|
App\Service\InventoryManager:
|
||||||
arguments:
|
arguments:
|
||||||
$api_url: "%env(INVENTORY_API_URL)%"
|
$api_url: "%env(INVENTORY_API_URL)%"
|
||||||
$api_ocp_key: "%env(INVENTORY_API_OCP)%"
|
$api_ocp_key: "%env(INVENTORY_API_OCP)%"
|
||||||
$api_auth_prefix: "%env(INVENTORY_API_AUTH_TOKEN_PREFIX)%"
|
$api_auth_prefix: "%env(INVENTORY_API_AUTH_TOKEN_PREFIX)%"
|
||||||
$api_auth_token: "%env(INVENTORY_API_AUTH_TOKEN)%"
|
$api_auth_token: "%env(INVENTORY_API_AUTH_TOKEN)%"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,15 +181,13 @@ class CustomerController extends Controller
|
||||||
|
|
||||||
public function getCustomerVehicles(Request $req, CustomerHandlerInterface $cust_handler)
|
public function getCustomerVehicles(Request $req, CustomerHandlerInterface $cust_handler)
|
||||||
{
|
{
|
||||||
/*
|
if (!(($this->isGranted('jo_onestep.form')) ||
|
||||||
// TODO: fix
|
($this->isGranted('jo_walkin.form')) ||
|
||||||
if ((!$this->isGranted('jo_onestep.form')) ||
|
($this->isGranted('jo_in.list'))))
|
||||||
(!$this->isGranted('jo_walkin.form')) ||
|
{
|
||||||
(!$this->isGranted('jo_in.list'))) {
|
|
||||||
$exception = $this->createAccessDeniedException('No access.');
|
$exception = $this->createAccessDeniedException('No access.');
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
$results = $cust_handler->getCustomerVehicles($req);
|
$results = $cust_handler->getCustomerVehicles($req);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class JobOrderController extends Controller
|
||||||
$this->denyAccessUnlessGranted('jo_open.edit', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_open.edit', null, 'No access.');
|
||||||
|
|
||||||
$error_array = [];
|
$error_array = [];
|
||||||
$result = $jo_handler->generateJobOrder($req, $id);
|
$result = $jo_handler->openEditJobOrder($req, $id);
|
||||||
|
|
||||||
$error_array = $result['error_array'];
|
$error_array = $result['error_array'];
|
||||||
|
|
||||||
|
|
@ -939,12 +939,18 @@ class JobOrderController extends Controller
|
||||||
/**
|
/**
|
||||||
* @ParamConverter("jo", class="App\Entity\JobOrder")
|
* @ParamConverter("jo", class="App\Entity\JobOrder")
|
||||||
*/
|
*/
|
||||||
public function popupInfo(JobOrder $jo)
|
public function popupInfo(JobOrder $jo, JobOrderHandlerInterface $jo_handler)
|
||||||
{
|
{
|
||||||
if ($jo == null)
|
if ($jo == null)
|
||||||
return new Response('No job order data');
|
return new Response('No job order data');
|
||||||
|
|
||||||
return $this->render('job-order/popup.html.twig', [ 'jo' => $jo ]);
|
// get the right template
|
||||||
|
$template = $jo_handler->getTwigTemplate('jo_popup');
|
||||||
|
|
||||||
|
$params['jo'] = $jo;
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->render($template, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2842,6 +2842,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->template_hash['jo_onestep_edit_form'] = 'job-order/cmb.form.onestep.html.twig';
|
$this->template_hash['jo_onestep_edit_form'] = 'job-order/cmb.form.onestep.html.twig';
|
||||||
$this->template_hash['jo_walkin_form'] = 'job-order/cmb.form.walkin.html.twig';
|
$this->template_hash['jo_walkin_form'] = 'job-order/cmb.form.walkin.html.twig';
|
||||||
$this->template_hash['jo_walkin_edit_form'] = 'job-order/cmb.form.walkin.html.twig';
|
$this->template_hash['jo_walkin_edit_form'] = 'job-order/cmb.form.walkin.html.twig';
|
||||||
|
$this->template_hash['jo_popup'] = 'job-order/cmb.popup.html.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkTier($tier)
|
protected function checkTier($tier)
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates/updates job order
|
// creates job order
|
||||||
public function generateJobOrder(Request $req, $id)
|
public function generateJobOrder(Request $req, $id)
|
||||||
{
|
{
|
||||||
// initialize error list
|
// initialize error list
|
||||||
|
|
@ -415,6 +415,105 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// updates job order
|
||||||
|
public function openEditJobOrder(Request $req, $id)
|
||||||
|
{
|
||||||
|
$em = $this->em;
|
||||||
|
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
|
||||||
|
// initialize error list
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// make sure this object exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
|
// check if lat and lng are provided
|
||||||
|
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
|
||||||
|
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($error_array))
|
||||||
|
{
|
||||||
|
// get current user
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
|
// coordinates
|
||||||
|
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||||
|
|
||||||
|
$stype = $req->request->get('service_type');
|
||||||
|
|
||||||
|
// set and save values
|
||||||
|
$obj->setDateSchedule(DateTime::createFromFormat("d M Y h:i A", $req->request->get('date_schedule_date') . " " . $req->request->get('date_schedule_time')))
|
||||||
|
->setCoordinates($point)
|
||||||
|
->setAdvanceOrder($req->request->get('flag_advance') ?? false)
|
||||||
|
->setServiceType($stype)
|
||||||
|
->setWarrantyClass($req->request->get('warranty_class'))
|
||||||
|
->setSource($req->request->get('source'))
|
||||||
|
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||||
|
->setTier1Notes($req->request->get('tier1_notes'))
|
||||||
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
|
->setORName($req->request->get('or_name'))
|
||||||
|
->setPromoDetail($req->request->get('promo_detail'))
|
||||||
|
->setModeOfPayment($req->request->get('mode_of_payment'))
|
||||||
|
->setLandmark($req->request->get('landmark'));
|
||||||
|
|
||||||
|
// did they change invoice?
|
||||||
|
$invoice_items = $req->request->get('invoice_items', []);
|
||||||
|
$promo_id = $req->request->get('invoice_promo');
|
||||||
|
$invoice_change = $req->request->get('invoice_change', 0);
|
||||||
|
if ($invoice_change)
|
||||||
|
{
|
||||||
|
$this->ic->generateInvoiceCriteria($obj, $promo_id, $invoice_items, $error_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
$errors = $this->validator->validate($obj);
|
||||||
|
|
||||||
|
// add errors to list
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if any errors were found
|
||||||
|
if (!empty($error_array)) {
|
||||||
|
// return validation failure response
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $error_array
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
// the event
|
||||||
|
$event = new JOEvent();
|
||||||
|
$event->setDateHappen(new DateTime())
|
||||||
|
->setTypeID(JOEventType::OPEN_EDIT)
|
||||||
|
->setJobOrder($obj);
|
||||||
|
|
||||||
|
if ($user != null)
|
||||||
|
{
|
||||||
|
$event->setUser($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
$em->persist($event);
|
||||||
|
|
||||||
|
// validated! save the entity
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['error_array'] = $error_array;
|
||||||
|
|
||||||
|
if ($obj != null)
|
||||||
|
{
|
||||||
|
$data['job_order'] = $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// dispatch job order
|
// dispatch job order
|
||||||
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient)
|
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient)
|
||||||
{
|
{
|
||||||
|
|
@ -2404,8 +2503,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->template_hash['jo_list_fulfillment'] = 'job-order/list.fulfillment.html.twig';
|
$this->template_hash['jo_list_fulfillment'] = 'job-order/list.fulfillment.html.twig';
|
||||||
$this->template_hash['jo_list_open'] = 'job-order/list.open.html.twig';
|
$this->template_hash['jo_list_open'] = 'job-order/list.open.html.twig';
|
||||||
$this->template_hash['jo_list_all'] = 'job-order/list.all.html.twig';
|
$this->template_hash['jo_list_all'] = 'job-order/list.all.html.twig';
|
||||||
$this->template_hash['jo_onestep'] = 'job-order/form.onestep.html.twig';
|
$this->template_hash['jo_popup'] = 'job-order/popup.html.twig';
|
||||||
$this->template_hash['jo_onestep_edit_form'] = 'job-order/form.onestep.html.twig';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkTier($tier)
|
protected function checkTier($tier)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,15 @@ class MapTools
|
||||||
// google maps api key
|
// google maps api key
|
||||||
protected $gmaps_api_key;
|
protected $gmaps_api_key;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, $gmaps_api_key)
|
// customer distance limit
|
||||||
|
protected $cust_dist_limit;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em, $gmaps_api_key,
|
||||||
|
$cust_dist_limit)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->gmaps_api_key = $gmaps_api_key;
|
$this->gmaps_api_key = $gmaps_api_key;
|
||||||
|
$this->cust_dist_limit = $cust_dist_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mapGetDistances(Point $point, $hubs)
|
protected function mapGetDistances(Point $point, $hubs)
|
||||||
|
|
@ -148,7 +153,8 @@ class MapTools
|
||||||
return $final_data;
|
return $final_data;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: only the API calls this
|
||||||
public function getClosestOpenHubs(Point $point, $limit, $time = false)
|
public function getClosestOpenHubs(Point $point, $limit, $time = false)
|
||||||
{
|
{
|
||||||
// get closest hubs based on st_distance function from db
|
// get closest hubs based on st_distance function from db
|
||||||
|
|
@ -184,14 +190,18 @@ class MapTools
|
||||||
// get distance in kilometers from customer point to hub point
|
// get distance in kilometers from customer point to hub point
|
||||||
$dist = $this->distance($cust_lat, $cust_lng, $hub_lat, $hub_lng);
|
$dist = $this->distance($cust_lat, $cust_lng, $hub_lat, $hub_lng);
|
||||||
|
|
||||||
$final_data[] = [
|
if ($dist < $this->cust_dist_limit)
|
||||||
'hub' => $row[0],
|
{
|
||||||
'db_distance' => $row['dist'],
|
$final_data[] = [
|
||||||
'distance' => $dist,
|
'hub' => $row[0],
|
||||||
'duration' => 0,
|
'db_distance' => $row['dist'],
|
||||||
];
|
'distance' => $dist,
|
||||||
|
'duration' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_log('nearest open hubs count: ' . count($final_data));
|
||||||
return $final_data;
|
return $final_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
templates/job-order/cmb.popup.html.twig
Normal file
13
templates/job-order/cmb.popup.html.twig
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{% set cust = jo.getCustomer %}
|
||||||
|
{% set cv = jo.getCustomerVehicle %}
|
||||||
|
<strong>{{ cust.getNameDisplay }}</strong><br>
|
||||||
|
{{ cv.getPlateNumber }}<br>
|
||||||
|
<a href="{{ url('jo_onestep_edit_form', {'id': jo.getID}) }}">Job Order #{{ jo.getID }}</a><br>
|
||||||
|
{{ jo.getServiceTypeName }}<br>
|
||||||
|
{{ jo.getStatusText }}
|
||||||
|
{% if jo.getRider != null %}
|
||||||
|
<br><br>
|
||||||
|
{% set rider = jo.getRider %}
|
||||||
|
{{ rider.getFullName }}<br>
|
||||||
|
{{ rider.getPlateNumber }}
|
||||||
|
{% endif %}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{% set cv = jo.getCustomerVehicle %}
|
{% set cv = jo.getCustomerVehicle %}
|
||||||
<strong>{{ cust.getNameDisplay }}</strong><br>
|
<strong>{{ cust.getNameDisplay }}</strong><br>
|
||||||
{{ cv.getPlateNumber }}<br>
|
{{ cv.getPlateNumber }}<br>
|
||||||
<a href="{{ url('jo_onestep_edit_form', {'id': jo.getID}) }}">Job Order #{{ jo.getID }}</a><br>
|
<a href="{{ url('jo_open_edit_form', {'id': jo.getID}) }}">Job Order #{{ jo.getID }}</a><br>
|
||||||
{{ jo.getServiceTypeName }}<br>
|
{{ jo.getServiceTypeName }}<br>
|
||||||
{{ jo.getStatusText }}
|
{{ jo.getStatusText }}
|
||||||
{% if jo.getRider != null %}
|
{% if jo.getRider != null %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue