Add one step job order process form #270

This commit is contained in:
Kendrick Chan 2019-12-18 04:06:45 +08:00
parent a21d0509fd
commit 51850d0230
11 changed files with 1681 additions and 44 deletions

View file

@ -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

View file

@ -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

View file

@ -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]

View file

@ -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]

View file

@ -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;

View file

@ -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,
]);
}
}

View file

@ -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);
}
}

View file

@ -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)

View file

@ -2,43 +2,6 @@
{% block stylesheets %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
<style type="text/css">
.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%;
}
.custom-div-icon i {
position: absolute;
width: 22px;
font-size: 22px;
left: 0;
right: 0;
margin: 10px auto;
text-align: center;
}
.custom-div-icon i.awesome {
margin: 12px auto;
font-size: 17px;
</style>
{% endblock %}
{% block body %}

File diff suppressed because it is too large Load diff

View file

@ -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: "<div style='background-color:#FF0000;' class='marker-pin'></div><i class='fa fa-bolt awesome'>",
iconSize: [39, 42],
iconAnchor: [15, 42]
});
var icon_rider_available = L.divIcon({
className: 'custom-div-icon',
className: 'map-div-icon',
html: "<div style='background-color:#00FF00;' class='marker-pin'></div><i class='fa fa-bolt awesome'>",
iconSize: [39, 42],
iconAnchor: [15, 42]
});
var icon_customer = L.divIcon({
className: 'custom-div-icon',
className: 'map-div-icon',
html: "<div style='background-color:#0055FF;' class='marker-pin'></div><i class='fa fa-user awesome'>",
iconSize: [39, 42],
iconAnchor: [15, 42]