From 51850d023027484032c941c492b38f9cc9b98f7d Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 18 Dec 2019 04:06:45 +0800 Subject: [PATCH] Add one step job order process form #270 --- config/acl.yaml | 2 + config/menu.yaml | 4 + config/routes/hub.yaml | 4 + config/routes/job_order.yaml | 10 + public/assets/css/style.css | 37 + src/Controller/HubController.php | 33 + src/Controller/JobOrderController.php | 24 +- .../JobOrderHandler/ResqJobOrderHandler.php | 20 + templates/home.html.twig | 37 - templates/job-order/form.onestep.html.twig | 1548 +++++++++++++++++ templates/map/initOpenStreetMap.js | 6 +- 11 files changed, 1681 insertions(+), 44 deletions(-) create mode 100644 templates/job-order/form.onestep.html.twig diff --git a/config/acl.yaml b/config/acl.yaml index f48850f6..4699dc85 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -242,6 +242,8 @@ access_keys: label: Edit - id: joborder.cancel label: Cancel + - id: jo_onestep.form + label: One-step Process - id: support label: Customer Support Access diff --git a/config/menu.yaml b/config/menu.yaml index 92b29c2d..cd3f40b9 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -98,6 +98,10 @@ main_menu: acl: joborder.menu label: Job Order icon: flaticon-calendar-3 + - id: jo_onestep_form + acl: jo_onestep.form + label: One-step Process + parent: joborder - id: jo_in acl: jo_in.list label: Incoming diff --git a/config/routes/hub.yaml b/config/routes/hub.yaml index 1634e7d7..cad33e2b 100644 --- a/config/routes/hub.yaml +++ b/config/routes/hub.yaml @@ -34,3 +34,7 @@ hub_delete: controller: App\Controller\HubController::destroy methods: [DELETE] +hub_nearest: + path: /ajax/nearest_hubs + controller: App\Controller\HubController::nearest + methods: [GET] diff --git a/config/routes/job_order.yaml b/config/routes/job_order.yaml index 05cb08c8..e1bd3f34 100644 --- a/config/routes/job_order.yaml +++ b/config/routes/job_order.yaml @@ -175,3 +175,13 @@ jo_reject_hub: path: /job-order/{id}/reject-hub controller: App\Controller\JobOrderController::rejectHubSubmit methods: [POST] + +jo_onestep_form: + path: /job-order/onestep + controller: App\Controller\JobOrderController::oneStepForm + methods: [GET] + +jo_onestep_submit: + path: /job-order/onestep + controller: App\Controller\JobOrderController::oneStepSubmit + methods: [POST] diff --git a/public/assets/css/style.css b/public/assets/css/style.css index f8e6318d..051d2143 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -295,3 +295,40 @@ span.has-danger, .btn-icon { margin-right: .5em; } + +.marker-pin { + width: 30px; + height: 30px; + border-radius: 50% 50% 50% 0; + background: #c30b82; + position: absolute; + transform: rotate(-45deg); + left: 50%; + top: 50%; + margin: -15px 0 0 -15px; +} + +.marker-pin::after { + content: ''; + width: 24px; + height: 24px; + margin: 3px 0 0 3px; + background: #fff; + position: absolute; + border-radius: 50%; + } + +.map-div-icon i { + position: absolute; + width: 22px; + font-size: 22px; + left: 0; + right: 0; + margin: 10px auto; + text-align: center; +} + +.map-div-icon i.awesome { + margin: 12px auto; + font-size: 17px; + diff --git a/src/Controller/HubController.php b/src/Controller/HubController.php index eb1faa73..77c07f3b 100644 --- a/src/Controller/HubController.php +++ b/src/Controller/HubController.php @@ -17,6 +17,8 @@ use DateTime; use Catalyst\MenuBundle\Annotation\Menu; +use App\Service\MapTools; + class HubController extends Controller { /** @@ -287,4 +289,35 @@ class HubController extends Controller $response->setStatusCode(Response::HTTP_OK); $response->send(); } + + public function nearest(MapTools $map_tools, Request $req) + { + // get lat / long + $lat = $req->query->get('lat'); + $long = $req->query->get('long'); + + // get nearest hubs according to position + $point = new Point($long, $lat); + $result = $map_tools->getClosestHubs($point, 10, date("H:i:s")); + + $hubs = []; + foreach ($result as $hub_res) + { + $hub = $hub_res['hub']; + $coords = $hub->getCoordinates(); + $hubs[] = [ + 'id' => $hub->getID(), + 'long' => $coords->getLongitude(), + 'lat' => $coords->getLatitude(), + 'label' => $hub->getFullName(), + 'name' => $hub->getName(), + 'branch' => $hub->getBranch(), + 'cnum' => $hub->getContactNumbers(), + ]; + } + + return $this->json([ + 'hubs' => $hubs, + ]); + } } diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index 3fb6de92..3567db8e 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -66,8 +66,7 @@ class JobOrderController extends Controller /** * @Menu(selected="jo_in") */ - public function openEditForm($id, JobOrderHandlerInterface $jo_handler, - GISManagerInterface $gis) + public function openEditForm($id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_open.edit', null, 'No access.'); @@ -287,8 +286,7 @@ class JobOrderController extends Controller /** * @Menu(selected="jo_proc") */ - public function processingForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler, - GISManagerInterface $gis) + public function processingForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); @@ -822,4 +820,22 @@ class JobOrderController extends Controller 'request' => $req->request->all() ]); } + + /** + * @Menu(selected="jo_onestep_form") + */ + public function oneStepForm(JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) + { + $this->denyAccessUnlessGranted('jo_onestep.form', null, 'No access.'); + + $params = $jo_handler->initializeOneStepForm(); + $params['submit_url'] = $this->generateUrl('jo_onestep_submit'); + $params['return_url'] = $this->generateUrl('jo_onestep_form'); + $params['map_js_file'] = $gis->getJSJOFile(); + + $template = $params['template']; + + // response + return $this->render($template, $params); + } } diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 0ee76a90..91ffb073 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -1103,6 +1103,21 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface return $params; } + public function initializeOneStepForm() + { + $params['obj'] = new JobOrder(); + $params['mode'] = 'onestep'; + + $this->fillDropdownParameters($params); + $this->fillFormTags($params); + + // get template to display + $params['template'] = $this->getTwigTemplate('jo_onestep'); + + // return params + return $params; + } + // initialize open edit job order form public function initializeOpenEditForm($id) { @@ -2022,6 +2037,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $this->template_hash = []; // add all twig templates for job order to hash + // TODO: put this in an array declaration + // $this->template_hash = [ + // 'blah' => 'blah', + // ]; $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'; @@ -2036,6 +2055,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $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'; + $this->template_hash['jo_onestep'] = 'job-order/form.onestep.html.twig'; } protected function checkTier($tier) diff --git a/templates/home.html.twig b/templates/home.html.twig index bdbcd9ca..c6b95597 100644 --- a/templates/home.html.twig +++ b/templates/home.html.twig @@ -2,43 +2,6 @@ {% block stylesheets %} - {% endblock %} {% block body %} diff --git a/templates/job-order/form.onestep.html.twig b/templates/job-order/form.onestep.html.twig new file mode 100644 index 00000000..b91f8b55 --- /dev/null +++ b/templates/job-order/form.onestep.html.twig @@ -0,0 +1,1548 @@ +{% extends 'base.html.twig' %} + +{% block body %} + + + +
+ +
+
+
+
+
+
+ + + +

+ One-step Job Order +

+
+
+
+
+ +
+
+
+
+ + + +
+ +
+
+ {% if obj.getReferenceJO %} +
+
+
+ + + +
+
+
+ {% endif %} + +
+
+

+ Customer Details +

+
+
+
+ + + +
+
+ + + +
+
+
+
+ +
+ +63 + + +
+
+
+ +
+ +63 + + +
+
+
+
+
+ +
+ +63 + + +
+
+
+ +
+ +63 + + +
+
+
+
+
+ + + +
+
+
+
+
+

+ Vehicle Details +

+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+
+
+
+

+ Battery Details +

+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+

+ Transaction Details +

+ + + +
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+
+
+ + + +
+
+ + + +
+
+
+
+
+ + + +
+
+
+ + +
+
+
+
+ + + +
+
+
+ + + +
+
+
+ + + +
+
+
+ +
+
+
+
+

+ Location +

+
+
+
+ + + +
+
+ + + +
+
+
+
+ + + + +
+ + + + +
+
+
+
+
+ +
+
+

+ Nearest Hubs +

+
+
+
+ + +
+ + + + + + + + + + + + +
HubBranchContact NumbersAction
+
+
+
+
+ +
+
+
+

+ Invoice +

+
+
+
+ + + +
+
+ + + +
+
+
+
+ + {% if ftags.invoice_edit %} + + + {% else %} + + {% endif %} +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + + + + + + + + + + {% if not obj.getInvoice or (obj.getInvoice and obj.getInvoice.getItems|length == 0) %} + + + + {% else %} + {% for item in obj.getInvoice.getItems %} + + + + + + + {% endfor %} + {% endif %} + +
ItemQuantityUnit PriceAmount
+ No items to display. +
{{ item.getTitle }}{{ item.getQuantity|number_format }}{{ item.getPrice|number_format(2) }}{{ (item.getPrice * item.getQuantity)|number_format(2) }}
+
+
+ {% if ftags.invoice_edit %} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + +
+
+ {% endif %} +
+ + {% if mode in ['update-assigning', 'update-fulfillment', 'update-reassign-rider', 'update-all'] %} +
+ {% if obj.getHub %} +
+
+

+ Hub Details +

+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+
+ {% endif %} + +
+ + {% if mode in ['update-assigning', 'update-reassign-rider'] %} +
+
+

+ Rider Assignment +

+
+
+
+ + +
+ + + + + + + + + + + + + {% set avail_riders = obj.getHub.getAvailableRiders|default([]) %} + + + + + {% if obj.getHub %} + {% for rider in avail_riders %} + + + + + + + + + {% endfor %} + {% endif %} + +
First NameLast NameContact No.Plate NumberStatus
+ No riders available. +
+
+
{{ rider.getFirstName }}{{ rider.getLastName }}{{ rider.getContactNumber }}{{ rider.getPlateNumber }}
+
+
+
+
+ {% endif %} + + {% if mode in ['update-fulfillment', 'update-all'] %} + {% if obj.getRider %} +
+
+

+ Rider Details +

+
+
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+
+
+ +
+
+
+
+ {% endif %} + {% endif %} + {% endif %} + + {% if mode == 'update-all' %} +
+ +
+
+

+ Timeline +

+
+
+
+
+
+ {% for event in obj.getEvents %} +
+ + {{ event.getDateHappen|date("M j, Y") }} +
{{ event.getDateHappen|date("h:i:s a") }}
+
+
+ +
+
+ {{ event.getTypeName }} by {{ event.getUser.getFullName|default('Application') }} {% if event.getRider %} - Rider - {{ event.getRider.getFullName }}{% endif %} +
+
+ {% endfor %} +
+
+
+
+
+ {% endif %} + +
+
+
+
+
+ + Back +
+
+
+
+
+
+
+
+
+ + {% if mode in ['update-processing', 'update-reassign-hub'] %} + + + {% endif %} +{% endblock %} + +{% block scripts %} +{{ include('map/' ~ map_js_file) }} + + + + +{% endblock %} + diff --git a/templates/map/initOpenStreetMap.js b/templates/map/initOpenStreetMap.js index 2198c61b..59a8ebcf 100644 --- a/templates/map/initOpenStreetMap.js +++ b/templates/map/initOpenStreetMap.js @@ -33,19 +33,19 @@ function mapCreate(div_id, center_lat, center_lng, map_type, zoom) { // create icons var icon_rider_active_jo = L.divIcon({ - className: 'custom-div-icon', + className: 'map-div-icon', html: "
", iconSize: [39, 42], iconAnchor: [15, 42] }); var icon_rider_available = L.divIcon({ - className: 'custom-div-icon', + className: 'map-div-icon', html: "
", iconSize: [39, 42], iconAnchor: [15, 42] }); var icon_customer = L.divIcon({ - className: 'custom-div-icon', + className: 'map-div-icon', html: "
", iconSize: [39, 42], iconAnchor: [15, 42]