Limit the service types to 2 for POC. Have job order return which twig template to display. #270

This commit is contained in:
Korina Cordero 2019-10-07 07:16:03 +00:00
parent eb0e19d27f
commit a9ed02b0b2
4 changed files with 180 additions and 19 deletions

View file

@ -56,8 +56,10 @@ class JobOrderController extends Controller
$params['submit_url'] = $this->generateUrl('jo_in_submit');
$params['return_url'] = $this->generateUrl('jo_in');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
/**
@ -71,8 +73,10 @@ class JobOrderController extends Controller
$params['submit_url'] = $this->generateUrl('jo_open_edit_submit', ['id' => $id]);
$params['return_url'] = $this->generateUrl('jo_open');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function openEditSubmit(Request $req, JobOrderHandlerInterface $jo_handler, $id)
@ -113,12 +117,13 @@ class JobOrderController extends Controller
throw $this->createNotFoundException($e->getMessage());
}
$params['submit_url'] = $this->generateUrl('jo_in_submit');
$params['return_url'] = $this->generateUrl('jo_in');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function incomingSubmit(Request $req, JobOrderHandlerInterface $jo_handler)
@ -275,7 +280,7 @@ class JobOrderController extends Controller
try
{
$params = $jo_handler->initializeDispatchForm($id, $map_tools);
$params = $jo_handler->initializeProcessingForm($id, $map_tools);
}
catch (AccessDeniedHttpException $e)
{
@ -286,12 +291,13 @@ class JobOrderController extends Controller
throw $this->createNotFoundException($e->getMessage());
}
$params['submit_url'] = $this->generateUrl('jo_proc_submit', ['id' => $id]);
$params['return_url'] = $this->generateUrl('jo_proc');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function processingSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
@ -349,12 +355,14 @@ class JobOrderController extends Controller
throw $this->createNotFoundException($e->getMessage());
}
$params['submit_url'] = $this->generateUrl('jo_assign_submit', ['id' => $id]);
$params['return_url'] = $this->generateUrl('jo_assign');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function assigningSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTCLient $mclient, APNSClient $aclient, $id)
@ -407,8 +415,10 @@ class JobOrderController extends Controller
$params['submit_url'] = $this->generateUrl('jo_fulfill_submit', ['id' => $id]);
$params['return_url'] = $this->generateUrl('jo_fulfill');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function fulfillmentSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
@ -462,8 +472,10 @@ class JobOrderController extends Controller
$params['submit_url'] = $this->generateUrl('jo_open_hub_submit', ['id' => $id]);
$params['return_url'] = $this->generateUrl('jo_open');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function openHubSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
@ -516,8 +528,10 @@ class JobOrderController extends Controller
$params['submit_url'] = $this->generateUrl('jo_open_rider_submit', ['id' => $id]);
$params['return_url'] = $this->generateUrl('jo_open');
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}
public function openRiderSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
@ -567,12 +581,13 @@ class JobOrderController extends Controller
throw $this->createNotFoundException($e->getMessage());
}
$params['return_url'] = $this->generateUrl('jo_all');
$params['submit_url'] = '';
$template = $params['template'];
// response
return $this->render('job-order/form.html.twig', $params);
return $this->render($template, $params);
}

View file

@ -61,6 +61,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
protected $validator;
protected $translator;
protected $template_hash;
public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator)
@ -70,6 +72,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->security = $security;
$this->validator = $validator;
$this->translator = $translator;
$this->loadTemplates();
}
// get job order rows
@ -1092,6 +1096,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_incoming_form');
// return params
return $params;
}
@ -1110,6 +1117,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_open_edit_form');
return $params;
}
@ -1140,6 +1150,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_incoming_vehicle_form');
return $params;
}
@ -1160,6 +1173,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_all_form');
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
@ -1195,7 +1211,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
}
// initialize dispatch/processing job order form
public function initializeDispatchForm($id, $map_tools)
public function initializeProcessingForm($id, $map_tools)
{
$em = $this->em;
@ -1310,6 +1326,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
}
$params['obj'] = $obj;
// get template to display
$params['template'] = $this->getTwigTemplate('jo_processing_form');
return $params;
}
@ -1387,6 +1405,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_assigning_form');
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
@ -1428,6 +1448,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_fulfillment_form');
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
@ -1509,6 +1531,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
}
$params['obj'] = $obj;
// get template to display
$params['template'] = $this->getTwigTemplate('jo_open_hub_form');
return $params;
}
@ -1542,6 +1566,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
// get template to display
$params['template'] = $this->getTwigTemplate('jo_open_rider_form');
return $params;
}
@ -1927,8 +1953,24 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$fac_hubs[$hub->getID()] = $hub->getName() . ' - ' . $hub->getBranch();
}
// get the first two service types for POC
$scount = 0;
$selected_stypes = [];
$stypes = ServiceType::getCollection();
foreach ($stypes as $stype)
{
if ($scount < 2)
$selected_stypes[] = $stype;
else
break;
$scount++;
}
// name values
$params['service_types'] = ServiceType::getCollection();
// $params['service_types'] = ServiceType::getCollection();
$params['service_types'] = $selected_stypes;
$params['warranty_classes'] = WarrantyClass::getCollection();
$params['modes_of_payment'] = ModeOfPayment::getCollection();
$params['statuses'] = JOStatus::getCollection();
@ -1980,6 +2022,37 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
}
}
protected function loadTemplates()
{
$this->template_hash = [];
// add all twig templates for job order to hash
$this->template_hash['jo_incoming_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_open_edit_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_incoming_vehicle_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_processing_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_assigning_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_fulfillment_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_open_hub_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_open_rider_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_all_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_list_processing'] = 'job-order/list.processing.html.twig';
$this->template_hash['jo_list_assigning'] = 'job-order/list.assigning.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_all'] = 'job-order/list.all.html.twig';
}
protected function getTwigTemplate($id)
{
if (isset($this->template_hash[$id]))
{
return $this->template_hash[$id];
}
return null;
}
protected function checkTier($tier)
{
// check specified tier

View file

@ -61,6 +61,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
protected $validator;
protected $translator;
protected $template_hash;
public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator)
@ -70,6 +72,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->security = $security;
$this->validator = $validator;
$this->translator = $translator;
$this->loadTemplates();
}
// get job order rows
@ -1092,6 +1096,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_incoming_form');
// return params
return $params;
}
@ -1110,6 +1117,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_open_edit_form');
return $params;
}
@ -1140,6 +1150,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_incoming_vehicle_form');
return $params;
}
@ -1160,6 +1173,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_all_form');
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
@ -1195,7 +1211,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
}
// initialize dispatch/processing job order form
public function initializeDispatchForm($id, $map_tools)
public function initializeProcessingForm($id, $map_tools)
{
$em = $this->em;
@ -1310,6 +1326,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
}
$params['obj'] = $obj;
// get template to display
$params['template'] = $this->getTwigTemplate('jo_processing_form');
return $params;
}
@ -1387,6 +1405,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_assigning_form');
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
@ -1428,6 +1448,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params);
$this->fillFormTags($params);
// get template to display
$params['template'] = $this->getTwigTemplate('jo_fulfillment_form');
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
@ -1509,6 +1531,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
}
$params['obj'] = $obj;
// get template to display
$params['template'] = $this->getTwigTemplate('jo_open_hub_form');
return $params;
}
@ -1542,6 +1566,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED;
// get template to display
$params['template'] = $this->getTwigTemplate('jo_open_rider_form');
return $params;
}
@ -1927,8 +1953,24 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$fac_hubs[$hub->getID()] = $hub->getName() . ' - ' . $hub->getBranch();
}
// get the first two service types for POC
$scount = 0;
$selected_stypes = [];
$stypes = ServiceType::getCollection();
foreach ($stypes as $stype)
{
if ($scount < 2)
$selected_stypes[] = $stype;
else
break;
$scount++;
}
// name values
$params['service_types'] = ServiceType::getCollection();
// $params['service_types'] = ServiceType::getCollection();
$params['service_types'] = $selected_stypes;
$params['warranty_classes'] = WarrantyClass::getCollection();
$params['modes_of_payment'] = ModeOfPayment::getCollection();
$params['statuses'] = JOStatus::getCollection();
@ -1980,6 +2022,37 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
}
}
protected function loadTemplates()
{
$this->template_hash = [];
// add all twig templates for job order to hash
$this->template_hash['jo_incoming_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_open_edit_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_incoming_vehicle_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_processing_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_assigning_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_fulfillment_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_open_hub_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_open_rider_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_all_form'] = 'job-order/form.html.twig';
$this->template_hash['jo_list_processing'] = 'job-order/list.processing.html.twig';
$this->template_hash['jo_list_assigning'] = 'job-order/list.assigning.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_all'] = 'job-order/list.all.html.twig';
}
protected function getTwigTemplate($id)
{
if (isset($this->template_hash[$id]))
{
return $this->template_hash[$id];
}
return null;
}
protected function checkTier($tier)
{
// check specified tier

View file

@ -59,7 +59,7 @@ interface JobOrderHandlerInterface
public function initializeAllForm(int $id);
// initialize dispatch/processing job order form
public function initializeDispatchForm(int $id, MapTools $map_tools);
public function initializeProcessingForm(int $id, MapTools $map_tools);
// initialize assign job order form
public function initializeAssignForm(int $id);