Move the initialization of rider and hub forms and hub reassignment to the job order service. #270
This commit is contained in:
parent
a7b5341f0d
commit
12555f3452
4 changed files with 285 additions and 179 deletions
|
|
@ -134,76 +134,6 @@ class JobOrderController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fillDropdownParameters(&$params)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
// db loaded
|
|
||||||
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
|
|
||||||
// $params['customers'] = $em->getRepository(Customer::class)->findAll();
|
|
||||||
$params['promos'] = $em->getRepository(Promo::class)->findAll();
|
|
||||||
|
|
||||||
// list of hubs
|
|
||||||
$hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']);
|
|
||||||
$fac_hubs = [];
|
|
||||||
foreach ($hubs as $hub)
|
|
||||||
{
|
|
||||||
$fac_hubs[$hub->getID()] = $hub->getName() . ' - ' . $hub->getBranch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// name values
|
|
||||||
$params['service_types'] = ServiceType::getCollection();
|
|
||||||
$params['warranty_classes'] = WarrantyClass::getCollection();
|
|
||||||
$params['modes_of_payment'] = ModeOfPayment::getCollection();
|
|
||||||
$params['statuses'] = JOStatus::getCollection();
|
|
||||||
$params['discount_apply'] = DiscountApply::getCollection();
|
|
||||||
$params['trade_in_types'] = TradeInType::getCollection();
|
|
||||||
$params['facilitated_types'] = FacilitatedType::getCollection();
|
|
||||||
$params['facilitated_hubs'] = $fac_hubs;
|
|
||||||
$params['sources'] = TransactionOrigin::getCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function initFormTags(&$params)
|
|
||||||
{
|
|
||||||
// default to editing, as we have more forms editing than creating
|
|
||||||
$params['ftags'] = [
|
|
||||||
'title' => 'Job Order Form',
|
|
||||||
'vehicle_dropdown' => false,
|
|
||||||
'invoice_edit' => false,
|
|
||||||
'set_map_coordinate' => true,
|
|
||||||
'preset_vehicle' => false,
|
|
||||||
'ticket_table' => true,
|
|
||||||
'cancel_button' => true,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function fillFormTags(&$params)
|
|
||||||
{
|
|
||||||
$this->initFormTags($params);
|
|
||||||
|
|
||||||
switch ($params['mode'])
|
|
||||||
{
|
|
||||||
case 'create':
|
|
||||||
$params['ftags']['vehicle_dropdown'] = true;
|
|
||||||
$params['ftags']['set_map_coordinate'] = false;
|
|
||||||
$params['ftags']['invoice_edit'] = true;
|
|
||||||
$params['ftags']['ticket_table'] = false;
|
|
||||||
$params['ftags']['cancel_button'] = false;
|
|
||||||
break;
|
|
||||||
case 'create_vehicle':
|
|
||||||
$params['ftags']['set_map_coordinate'] = false;
|
|
||||||
$params['ftags']['invoice_edit'] = true;
|
|
||||||
$params['ftags']['preset_vehicle'] = true;
|
|
||||||
$params['ftags']['ticket_table'] = false;
|
|
||||||
$params['ftags']['cancel_button'] = false;
|
|
||||||
break;
|
|
||||||
case 'open_edit':
|
|
||||||
$params['ftags']['invoice_edit'] = true;
|
|
||||||
$params['ftags']['preset_vehicle'] = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="jo_in")
|
* @Menu(selected="jo_in")
|
||||||
*/
|
*/
|
||||||
|
|
@ -854,76 +784,17 @@ class JobOrderController extends Controller
|
||||||
return $this->render('job-order/form.html.twig', $params);
|
return $this->render('job-order/form.html.twig', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function openHubSubmit(Request $req, ValidatorInterface $validator, MQTTClient $mclient, $id)
|
public function openHubSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||||
|
|
||||||
// get object data
|
try
|
||||||
$em = $this->getDoctrine()->getManager();
|
{
|
||||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
$error_array = $jo_handler->setHub($req, $id, $mclient);
|
||||||
$user = $this->getUser();
|
|
||||||
|
|
||||||
// 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.';
|
|
||||||
}
|
}
|
||||||
|
catch (NotFoundHttpException $e)
|
||||||
// check if hub is set
|
{
|
||||||
if (empty($req->request->get('hub'))) {
|
throw $this->createNotFoundException($e->getMessage());
|
||||||
$error_array['hub'] = 'No hub selected.';
|
|
||||||
} else {
|
|
||||||
// get hub
|
|
||||||
$hub = $em->getRepository(Hub::class)->find($req->request->get('hub'));
|
|
||||||
|
|
||||||
if (empty($hub)) {
|
|
||||||
$error_array['hub'] = 'Invalid hub specified.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($error_array))
|
|
||||||
{
|
|
||||||
// rider mqtt event
|
|
||||||
// NOTE: need to send this before saving because rider will be cleared
|
|
||||||
$rider_payload = [
|
|
||||||
'event' => 'cancelled',
|
|
||||||
'reason' => 'Reassigned',
|
|
||||||
'jo_id' => $obj->getID(),
|
|
||||||
];
|
|
||||||
$mclient->sendRiderEvent($obj, $rider_payload);
|
|
||||||
|
|
||||||
// coordinates
|
|
||||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
|
||||||
|
|
||||||
// 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($req->request->get('service_type'))
|
|
||||||
->setWarrantyClass($req->request->get('warranty_class'))
|
|
||||||
->setSource($req->request->get('source'))
|
|
||||||
->setStatus(JOStatus::RIDER_ASSIGN)
|
|
||||||
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
|
||||||
->setTier1Notes($req->request->get('tier1_notes'))
|
|
||||||
->setTier2Notes($req->request->get('tier2_notes'))
|
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
|
||||||
->setHub($hub)
|
|
||||||
->setProcessedBy($this->getUser())
|
|
||||||
->clearRider();
|
|
||||||
|
|
||||||
// validate
|
|
||||||
$errors = $validator->validate($obj);
|
|
||||||
|
|
||||||
// add errors to list
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if any errors were found
|
// check if any errors were found
|
||||||
|
|
@ -935,23 +806,6 @@ class JobOrderController extends Controller
|
||||||
], 422);
|
], 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add event
|
|
||||||
$event = new JOEvent();
|
|
||||||
$event->setDateHappen(new DateTime())
|
|
||||||
->setTypeID(JOEventType::HUB_ASSIGN)
|
|
||||||
->setUser($this->getUser())
|
|
||||||
->setJobOrder($obj);
|
|
||||||
$em->persist($event);
|
|
||||||
|
|
||||||
// validated! save the entity
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
// user mqtt event
|
|
||||||
$payload = [
|
|
||||||
'event' => 'outlet_assign'
|
|
||||||
];
|
|
||||||
$mclient->sendEvent($obj, $payload);
|
|
||||||
|
|
||||||
// return successful response
|
// return successful response
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'success' => 'Changes have been saved!'
|
'success' => 'Changes have been saved!'
|
||||||
|
|
@ -961,37 +815,20 @@ class JobOrderController extends Controller
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="jo_open")
|
* @Menu(selected="jo_open")
|
||||||
*/
|
*/
|
||||||
public function openRiderForm($id)
|
public function openRiderForm($id, JobOrderHandlerInterface $jo_handler)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
try
|
||||||
|
|
||||||
$params['mode'] = 'update-reassign-rider';
|
|
||||||
|
|
||||||
// get row data
|
|
||||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
|
||||||
|
|
||||||
// make sure this row exists
|
|
||||||
if (empty($obj))
|
|
||||||
{
|
{
|
||||||
$em->getConnection()->rollback();
|
$params = $jo_handler->initializeRiderForm($id);
|
||||||
throw $this->createNotFoundException('The job order does not exist');
|
}
|
||||||
|
catch (NotFoundHttpException $e)
|
||||||
|
{
|
||||||
|
throw $this->createNotFoundException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// check status
|
$params['submit_url'] = $this->generateUrl('jo_open_rider_submit', ['id' => $id]);
|
||||||
if ($obj->getStatus() == JOStatus::PENDING)
|
|
||||||
{
|
|
||||||
$em->getConnection()->rollback();
|
|
||||||
throw $this->createNotFoundException('The job order does not have an assigned hub');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->fillDropdownParameters($params);
|
|
||||||
$this->fillFormTags($params);
|
|
||||||
|
|
||||||
$params['obj'] = $obj;
|
|
||||||
$params['status_cancelled'] = JOStatus::CANCELLED;
|
|
||||||
$params['submit_url'] = $this->generateUrl('jo_open_rider_submit', ['id' => $obj->getID()]);
|
|
||||||
$params['return_url'] = $this->generateUrl('jo_open');
|
$params['return_url'] = $this->generateUrl('jo_open');
|
||||||
|
|
||||||
// response
|
// response
|
||||||
|
|
|
||||||
|
|
@ -557,6 +557,103 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set hub for job order
|
||||||
|
public function setHub($req, $id, $mclient)
|
||||||
|
{
|
||||||
|
// get object data
|
||||||
|
$em = $this->em;
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
|
// initialize error list
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// make sure this object exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw new NotFoundHttpException('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.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if hub is set
|
||||||
|
if (empty($req->request->get('hub'))) {
|
||||||
|
$error_array['hub'] = 'No hub selected.';
|
||||||
|
} else {
|
||||||
|
// get hub
|
||||||
|
$hub = $em->getRepository(Hub::class)->find($req->request->get('hub'));
|
||||||
|
|
||||||
|
if (empty($hub)) {
|
||||||
|
$error_array['hub'] = 'Invalid hub specified.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($error_array))
|
||||||
|
{
|
||||||
|
// rider mqtt event
|
||||||
|
// NOTE: need to send this before saving because rider will be cleared
|
||||||
|
$rider_payload = [
|
||||||
|
'event' => 'cancelled',
|
||||||
|
'reason' => 'Reassigned',
|
||||||
|
'jo_id' => $obj->getID(),
|
||||||
|
];
|
||||||
|
$mclient->sendRiderEvent($obj, $rider_payload);
|
||||||
|
|
||||||
|
// coordinates
|
||||||
|
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||||
|
|
||||||
|
// 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($req->request->get('service_type'))
|
||||||
|
->setWarrantyClass($req->request->get('warranty_class'))
|
||||||
|
->setSource($req->request->get('source'))
|
||||||
|
->setStatus(JOStatus::RIDER_ASSIGN)
|
||||||
|
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||||
|
->setTier1Notes($req->request->get('tier1_notes'))
|
||||||
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
|
->setHub($hub)
|
||||||
|
->setProcessedBy($user)
|
||||||
|
->clearRider();
|
||||||
|
|
||||||
|
$em->persist($obj);
|
||||||
|
|
||||||
|
// 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)) {
|
||||||
|
|
||||||
|
// add event
|
||||||
|
$event = new JOEvent();
|
||||||
|
$event->setDateHappen(new DateTime())
|
||||||
|
->setTypeID(JOEventType::HUB_ASSIGN)
|
||||||
|
->setUser($user)
|
||||||
|
->setJobOrder($obj);
|
||||||
|
$em->persist($event);
|
||||||
|
|
||||||
|
// validated! save the entity
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// user mqtt event
|
||||||
|
$payload = [
|
||||||
|
'event' => 'outlet_assign'
|
||||||
|
];
|
||||||
|
$mclient->sendEvent($obj, $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $error_array;
|
||||||
|
}
|
||||||
|
|
||||||
// initialize incoming job order form
|
// initialize incoming job order form
|
||||||
public function initializeIncomingForm()
|
public function initializeIncomingForm()
|
||||||
{
|
{
|
||||||
|
|
@ -987,6 +1084,39 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize rider form
|
||||||
|
public function initializeRiderForm($id)
|
||||||
|
{
|
||||||
|
$em = $this->em;
|
||||||
|
|
||||||
|
$params['mode'] = 'update-reassign-rider';
|
||||||
|
|
||||||
|
// get row data
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this row exists
|
||||||
|
if (empty($obj))
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw new NotFoundHttpException('The job order does not exist');
|
||||||
|
}
|
||||||
|
|
||||||
|
// check status
|
||||||
|
if ($obj->getStatus() == JOStatus::PENDING)
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw new NotFoundHttpException('The job order does not have an assigned hub');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->fillDropdownParameters($params);
|
||||||
|
$this->fillFormTags($params);
|
||||||
|
|
||||||
|
$params['obj'] = $obj;
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
protected function fillDropdownParameters(&$params)
|
protected function fillDropdownParameters(&$params)
|
||||||
{
|
{
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
|
||||||
|
|
@ -557,6 +557,103 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set hub for job order
|
||||||
|
public function setHub($req, $id, $mclient)
|
||||||
|
{
|
||||||
|
// get object data
|
||||||
|
$em = $this->em;
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
|
// initialize error list
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// make sure this object exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw new NotFoundHttpException('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.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if hub is set
|
||||||
|
if (empty($req->request->get('hub'))) {
|
||||||
|
$error_array['hub'] = 'No hub selected.';
|
||||||
|
} else {
|
||||||
|
// get hub
|
||||||
|
$hub = $em->getRepository(Hub::class)->find($req->request->get('hub'));
|
||||||
|
|
||||||
|
if (empty($hub)) {
|
||||||
|
$error_array['hub'] = 'Invalid hub specified.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($error_array))
|
||||||
|
{
|
||||||
|
// rider mqtt event
|
||||||
|
// NOTE: need to send this before saving because rider will be cleared
|
||||||
|
$rider_payload = [
|
||||||
|
'event' => 'cancelled',
|
||||||
|
'reason' => 'Reassigned',
|
||||||
|
'jo_id' => $obj->getID(),
|
||||||
|
];
|
||||||
|
$mclient->sendRiderEvent($obj, $rider_payload);
|
||||||
|
|
||||||
|
// coordinates
|
||||||
|
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||||
|
|
||||||
|
// 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($req->request->get('service_type'))
|
||||||
|
->setWarrantyClass($req->request->get('warranty_class'))
|
||||||
|
->setSource($req->request->get('source'))
|
||||||
|
->setStatus(JOStatus::RIDER_ASSIGN)
|
||||||
|
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||||
|
->setTier1Notes($req->request->get('tier1_notes'))
|
||||||
|
->setTier2Notes($req->request->get('tier2_notes'))
|
||||||
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
|
->setHub($hub)
|
||||||
|
->setProcessedBy($user)
|
||||||
|
->clearRider();
|
||||||
|
|
||||||
|
$em->persist($obj);
|
||||||
|
|
||||||
|
// 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)) {
|
||||||
|
|
||||||
|
// add event
|
||||||
|
$event = new JOEvent();
|
||||||
|
$event->setDateHappen(new DateTime())
|
||||||
|
->setTypeID(JOEventType::HUB_ASSIGN)
|
||||||
|
->setUser($user)
|
||||||
|
->setJobOrder($obj);
|
||||||
|
$em->persist($event);
|
||||||
|
|
||||||
|
// validated! save the entity
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// user mqtt event
|
||||||
|
$payload = [
|
||||||
|
'event' => 'outlet_assign'
|
||||||
|
];
|
||||||
|
$mclient->sendEvent($obj, $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $error_array;
|
||||||
|
}
|
||||||
|
|
||||||
// initialize incoming job order form
|
// initialize incoming job order form
|
||||||
public function initializeIncomingForm()
|
public function initializeIncomingForm()
|
||||||
{
|
{
|
||||||
|
|
@ -889,8 +986,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
throw new NotFoundHttpException('The job order does not have a fulfillment status');
|
throw new NotFoundHttpException('The job order does not have a fulfillment status');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get current user
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
// check if hub is assigned to current user
|
// check if hub is assigned to current user
|
||||||
$user_hubs = $this->getUser()->getHubs();
|
$user_hubs = $user->getHubs();
|
||||||
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
||||||
{
|
{
|
||||||
throw new NotFoundHttpException('The job order is not on a hub assigned to this user');
|
throw new NotFoundHttpException('The job order is not on a hub assigned to this user');
|
||||||
|
|
@ -984,6 +1084,39 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize rider form
|
||||||
|
public function initializeRiderForm($id)
|
||||||
|
{
|
||||||
|
$em = $this->em;
|
||||||
|
|
||||||
|
$params['mode'] = 'update-reassign-rider';
|
||||||
|
|
||||||
|
// get row data
|
||||||
|
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this row exists
|
||||||
|
if (empty($obj))
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw new NotFoundHttpException('The job order does not exist');
|
||||||
|
}
|
||||||
|
|
||||||
|
// check status
|
||||||
|
if ($obj->getStatus() == JOStatus::PENDING)
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw new NotFoundHttpException('The job order does not have an assigned hub');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->fillDropdownParameters($params);
|
||||||
|
$this->fillFormTags($params);
|
||||||
|
|
||||||
|
$params['obj'] = $obj;
|
||||||
|
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
protected function fillDropdownParameters(&$params)
|
protected function fillDropdownParameters(&$params)
|
||||||
{
|
{
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ interface JobOrderHandlerInterface
|
||||||
// cancel job order
|
// cancel job order
|
||||||
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient);
|
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient);
|
||||||
|
|
||||||
|
// set hub for job order
|
||||||
|
public function setHub(Request $req, int $id, MQTTClient $mclient);
|
||||||
|
|
||||||
// initialize incoming job order form
|
// initialize incoming job order form
|
||||||
public function initializeIncomingForm();
|
public function initializeIncomingForm();
|
||||||
|
|
||||||
|
|
@ -48,4 +51,7 @@ interface JobOrderHandlerInterface
|
||||||
|
|
||||||
// initialize hub form
|
// initialize hub form
|
||||||
public function initializeHubForm(int $id, MapTools $map_tools);
|
public function initializeHubForm(int $id, MapTools $map_tools);
|
||||||
|
|
||||||
|
// initialize rider form
|
||||||
|
public function initializeRiderForm(int $id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue