Fix job order form to use hubs instead of outlets #17
This commit is contained in:
parent
d4cc431bac
commit
e124b0cebd
3 changed files with 53 additions and 85 deletions
|
|
@ -558,6 +558,14 @@ class JobOrderController extends BaseController
|
||||||
throw $this->createNotFoundException('The job order does not have an assigning status');
|
throw $this->createNotFoundException('The job order does not have an assigning status');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if hub is assigned to current user
|
||||||
|
$user_hubs = $this->getUser()->getHubs();
|
||||||
|
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
||||||
|
{
|
||||||
|
$em->getConnection()->rollback();
|
||||||
|
throw $this->createNotFoundException('The job order is not on a hub assigned to this user');
|
||||||
|
}
|
||||||
|
|
||||||
// check if we are the assignor
|
// check if we are the assignor
|
||||||
$assignor = $obj->getAssignedBy();
|
$assignor = $obj->getAssignedBy();
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class MapTools
|
||||||
public function getClosestHubs(Point $point, $limit, $time = false)
|
public function getClosestHubs(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
|
||||||
$query = $this->em->createQuery('SELECT h, st_distance(o.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Hub h' . ($time ? ' WHERE :time BETWEEN h.time_open AND h.time_close' : '') . ' ORDER BY dist')
|
$query = $this->em->createQuery('SELECT h, st_distance(h.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Hub h' . ($time ? ' WHERE :time BETWEEN h.time_open AND h.time_close' : '') . ' ORDER BY dist')
|
||||||
->setParameter('lat', $point->getLatitude())
|
->setParameter('lat', $point->getLatitude())
|
||||||
->setParameter('lng', $point->getLongitude());
|
->setParameter('lng', $point->getLongitude());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,18 +379,18 @@
|
||||||
<div class="m-form__section m-form__section--last">
|
<div class="m-form__section m-form__section--last">
|
||||||
<div class="m-form__heading">
|
<div class="m-form__heading">
|
||||||
<h3 class="m-form__heading-title">
|
<h3 class="m-form__heading-title">
|
||||||
Nearest Outlets
|
Nearest Hubs
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<label>Click on a row to select an outlet</label>
|
<label>Click on a row to select a hub</label>
|
||||||
<div class="form-control-feedback hide" data-field="outlet"></div>
|
<div class="form-control-feedback hide" data-field="hub"></div>
|
||||||
<div class="table-frame" data-name="outlet">
|
<div class="table-frame" data-name="hub">
|
||||||
<table id="outlets-table" class="table table-compact table-hover table-clickable m-table">
|
<table id="hubs-table" class="table table-compact table-hover table-clickable m-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Outlet</th>
|
<th>Hub</th>
|
||||||
<th>Branch</th>
|
<th>Branch</th>
|
||||||
<th class="text-right">Distance</th>
|
<th class="text-right">Distance</th>
|
||||||
<th class="text-right">Travel Time</th>
|
<th class="text-right">Travel Time</th>
|
||||||
|
|
@ -399,21 +399,21 @@
|
||||||
<th>Contact Numbers</th> </tr>
|
<th>Contact Numbers</th> </tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="placeholder-row{{ outlets|length > 0 ? ' hide' }}">
|
<tr class="placeholder-row{{ hubs|length > 0 ? ' hide' }}">
|
||||||
<td colspan="7">
|
<td colspan="7">
|
||||||
No items to display.
|
No items to display.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for outlet in outlets %}
|
{% for hub in hubs %}
|
||||||
<tr data-lat="{{ outlet.outlet.getCoordinates.getLatitude }}" data-lng="{{ outlet.outlet.getCoordinates.getLongitude }}" data-id="{{ outlet.outlet.getID }}"{{ obj.getOutlet and obj.getOutlet.getID == outlet.outlet.getID ? ' class="m-table__row--primary"' }}>
|
<tr data-lat="{{ hub.hub.getCoordinates.getLatitude }}" data-lng="{{ hub.hub.getCoordinates.getLongitude }}" data-id="{{ hub.hub.getID }}"{{ obj.getHub and obj.getHub.getID == hub.hub.getID ? ' class="m-table__row--primary"' }}>
|
||||||
<td>{{ outlet.outlet.getName }}</td>
|
<td>{{ hub.hub.getName }}</td>
|
||||||
<td>{{ outlet.outlet.getBranch }}</td>
|
<td>{{ hub.hub.getBranch }}</td>
|
||||||
<td class="text-right">{{ outlet.distance ? outlet.distance : '-' }}</td>
|
<td class="text-right">{{ hub.distance ? hub.distance : '-' }}</td>
|
||||||
<td class="text-right">{{ outlet.duration ? outlet.duration : '-' }}</td>
|
<td class="text-right">{{ hub.duration ? hub.duration : '-' }}</td>
|
||||||
<td class="text-right">0</td>
|
<td class="text-right">0</td>
|
||||||
<td class="text-right">0</td>
|
<td class="text-right">0</td>
|
||||||
<td>{{ outlet.outlet.getContactNumbers }}</td>
|
<td>{{ hub.hub.getContactNumbers }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -422,12 +422,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="outlet_map" style="height:600px;"></div>
|
<div id="hub_map" style="height:600px;"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if mode == 'update-assigning' %}
|
{% if mode == 'update-assigning' %}
|
||||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||||
{% if obj.getOutlet.getHub %}
|
{% if obj.getHub %}
|
||||||
<div class="m-form__section">
|
<div class="m-form__section">
|
||||||
<div class="m-form__heading">
|
<div class="m-form__heading">
|
||||||
<h3 class="m-form__heading-title">
|
<h3 class="m-form__heading-title">
|
||||||
|
|
@ -437,17 +437,17 @@
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="hub_name">Name</label>
|
<label data-field="hub_name">Name</label>
|
||||||
<input type="text" name="hub_name" id="hub-name" class="form-control m-input" value="{{ obj.getOutlet.getHub.getName }}" disabled>
|
<input type="text" name="hub_name" id="hub-name" class="form-control m-input" value="{{ obj.getHub.getName }}" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="hub_name"></div>
|
<div class="form-control-feedback hide" data-field="hub_name"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<label data-field="hub_time_open">Time Open</label>
|
<label data-field="hub_time_open">Time Open</label>
|
||||||
<input type="text" name="hub_time_open" id="hub-time-open" class="form-control m-input" value="{{obj.getOutlet.getHub.getTimeOpen|date("g:i A") }}" disabled>
|
<input type="text" name="hub_time_open" id="hub-time-open" class="form-control m-input" value="{{obj.getHub.getTimeOpen|date("g:i A") }}" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="hub_time_open"></div>
|
<div class="form-control-feedback hide" data-field="hub_time_open"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<label data-field="hub_time_close">Time Close</label>
|
<label data-field="hub_time_close">Time Close</label>
|
||||||
<input type="text" name="hub_time_close" id="hub-time-close" class="form-control m-input" value="{{ obj.getOutlet.getHub.getTimeClose|date("g:i A") }}" disabled>
|
<input type="text" name="hub_time_close" id="hub-time-close" class="form-control m-input" value="{{ obj.getHub.getTimeClose|date("g:i A") }}" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="hub_time_close"></div>
|
<div class="form-control-feedback hide" data-field="hub_time_close"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -456,59 +456,19 @@
|
||||||
<label data-field="hub_address">
|
<label data-field="hub_address">
|
||||||
Address
|
Address
|
||||||
</label>
|
</label>
|
||||||
<textarea class="form-control m-input" id="hub-address" rows="4" name="hub_address" disabled>{{ obj.getOutlet.getHub.getAddress }}</textarea>
|
<textarea class="form-control m-input" id="hub-address" rows="4" name="hub_address" disabled>{{ obj.getHub.getAddress }}</textarea>
|
||||||
<div class="form-control-feedback hide" data-field="hub_address"></div>
|
<div class="form-control-feedback hide" data-field="hub_address"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="contact_nums">
|
<label data-field="contact_nums">
|
||||||
Contact Numbers
|
Contact Numbers
|
||||||
</label>
|
</label>
|
||||||
<textarea class="form-control m-input" id="hub-contact-nums" rows="4" name="hub_contact_nums" disabled>{{ obj.getOutlet.getHub.getContactNumbers }}</textarea>
|
<textarea class="form-control m-input" id="hub-contact-nums" rows="4" name="hub_contact_nums" disabled>{{ obj.getHub.getContactNumbers }}</textarea>
|
||||||
<div class="form-control-feedback hide" data-field="hub_contact_nums"></div>
|
<div class="form-control-feedback hide" data-field="hub_contact_nums"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="m-form__section">
|
|
||||||
<div class="m-form__heading">
|
|
||||||
<h3 class="m-form__heading-title">
|
|
||||||
Outlet Details
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<label data-field="outlet_name">Name</label>
|
|
||||||
<input type="text" name="outlet_name" id="outlet-name" class="form-control m-input" value="{{ obj.getOutlet.getName }}" disabled>
|
|
||||||
<div class="form-control-feedback hide" data-field="outlet_name"></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-3">
|
|
||||||
<label data-field="outlet_time_open">Time Open</label>
|
|
||||||
<input type="text" name="outlet_time_open" id="outlet-time-open" class="form-control m-input" value="{{ obj.getOutlet.getTimeOpen|date("g:i A") }}" disabled>
|
|
||||||
<div class="form-control-feedback hide" data-field="outlet_time_open"></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-3">
|
|
||||||
<label data-field="outlet_time_close">Time Close</label>
|
|
||||||
<input type="text" name="outlet_time_close" id="outlet-time-close" class="form-control m-input" value="{{ obj.getOutlet.getTimeClose|date("g:i A") }}" disabled>
|
|
||||||
<div class="form-control-feedback hide" data-field="outlet_time_close"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<label data-field="outlet_address">
|
|
||||||
Address
|
|
||||||
</label>
|
|
||||||
<textarea class="form-control m-input" id="outlet-address" rows="4" name="outlet_address" disabled>{{ obj.getOutlet.getAddress }}</textarea>
|
|
||||||
<div class="form-control-feedback hide" data-field="outlet_address"></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<label data-field="contact_nums">
|
|
||||||
Contact Numbers
|
|
||||||
</label>
|
|
||||||
<textarea class="form-control m-input" id="outlet-contact-nums" rows="4" name="hub_contact_nums" disabled>{{ obj.getOutlet.getContactNumbers }}</textarea>
|
|
||||||
<div class="form-control-feedback hide" data-field="hub_contact_nums"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||||
<div class="m-form__section m-form__section--last">
|
<div class="m-form__section m-form__section--last">
|
||||||
<div class="m-form__heading">
|
<div class="m-form__heading">
|
||||||
|
|
@ -533,14 +493,14 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="placeholder-row{{ obj.getOutlet.getHub and obj.getOutlet.getHub.getRiders|length > 0 ? ' hide' }}">
|
<tr class="placeholder-row{{ obj.getHub and obj.getHub.getRiders|length > 0 ? ' hide' }}">
|
||||||
<td colspan="6">
|
<td colspan="6">
|
||||||
No items to display.
|
No items to display.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% if obj.getOutlet.getHub %}
|
{% if obj.getHub %}
|
||||||
{% for rider in obj.getOutlet.getHub.getRiders %}
|
{% for rider in obj.getHub.getRiders %}
|
||||||
<tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}>
|
<tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}>
|
||||||
<td>
|
<td>
|
||||||
<div class="user-portrait-sm" style="background-image: url('{{ rider.getImageFile ? "/uploads/" ~ rider.getImageFile : "/assets/images/user.gif" }}');"></div>
|
<div class="user-portrait-sm" style="background-image: url('{{ rider.getImageFile ? "/uploads/" ~ rider.getImageFile : "/assets/images/user.gif" }}');"></div>
|
||||||
|
|
@ -653,14 +613,14 @@ $(function() {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if mode == 'update-processing' %}
|
{% if mode == 'update-processing' %}
|
||||||
// display outlet map
|
// display hub map
|
||||||
var omap = new GMaps({
|
var hmap = new GMaps({
|
||||||
div: '#outlet_map',
|
div: '#hub_map',
|
||||||
lat: {{ obj.getCoordinates.getLatitude }},
|
lat: {{ obj.getCoordinates.getLatitude }},
|
||||||
lng: {{ obj.getCoordinates.getLongitude }}
|
lng: {{ obj.getCoordinates.getLongitude }}
|
||||||
});
|
});
|
||||||
|
|
||||||
omap.addMarker({
|
hmap.addMarker({
|
||||||
lat: {{ obj.getCoordinates.getLatitude }},
|
lat: {{ obj.getCoordinates.getLatitude }},
|
||||||
lng: {{ obj.getCoordinates.getLongitude }},
|
lng: {{ obj.getCoordinates.getLongitude }},
|
||||||
icon: '/assets/images/icon-destination.png',
|
icon: '/assets/images/icon-destination.png',
|
||||||
|
|
@ -668,12 +628,12 @@ $(function() {
|
||||||
content: "Destination"
|
content: "Destination"
|
||||||
});
|
});
|
||||||
|
|
||||||
{% for outlet in outlets %}
|
{% for hub in hubs %}
|
||||||
omap.addMarker({
|
hmap.addMarker({
|
||||||
lat: {{ outlet.outlet.getCoordinates.getLatitude }},
|
lat: {{ hub.hub.getCoordinates.getLatitude }},
|
||||||
lng: {{ outlet.outlet.getCoordinates.getLongitude }},
|
lng: {{ hub.hub.getCoordinates.getLongitude }},
|
||||||
title: "{{ outlet.outlet.getName }}",
|
title: "{{ hub.hub.getName }}",
|
||||||
content: "{{ outlet.outlet.getName }}",
|
content: "{{ hub.hub.getName }}",
|
||||||
icon: '/assets/images/icon-outlet.png'
|
icon: '/assets/images/icon-outlet.png'
|
||||||
});
|
});
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
@ -695,8 +655,8 @@ $(function() {
|
||||||
fields['invoice_items'] = invoiceItems;
|
fields['invoice_items'] = invoiceItems;
|
||||||
|
|
||||||
{% if mode == 'update-processing' %}
|
{% if mode == 'update-processing' %}
|
||||||
// add selected outlet to data
|
// add selected hub to data
|
||||||
fields['outlet'] = selectedOutlet;
|
fields['hub'] = selectedHub;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if mode == 'update-assigning' %}
|
{% if mode == 'update-assigning' %}
|
||||||
|
|
@ -1049,21 +1009,21 @@ $(function() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{% if mode == 'update-processing' %}
|
{% if mode == 'update-processing' %}
|
||||||
var selectedOutlet = '{{ obj.getOutlet ? obj.getOutlet.getID : "" }}';
|
var selectedHub = '{{ obj.getHub ? obj.getHub.getID : "" }}';
|
||||||
|
|
||||||
$("#outlets-table tbody tr").click(function() {
|
$("#hubs-table tbody tr").click(function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
var lat = $(this).data('lat');
|
var lat = $(this).data('lat');
|
||||||
var lng = $(this).data('lng');
|
var lng = $(this).data('lng');
|
||||||
|
|
||||||
if (id != selectedOutlet) {
|
if (id != selectedHub) {
|
||||||
// highlight this row, set outlet value
|
// highlight this row, set hub value
|
||||||
$("#outlets-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
$("#hubs-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
||||||
|
|
||||||
$(this).addClass('m-table__row--primary');
|
$(this).addClass('m-table__row--primary');
|
||||||
|
|
||||||
// set value
|
// set value
|
||||||
selectedOutlet = id;
|
selectedHub = id;
|
||||||
|
|
||||||
// center the map
|
// center the map
|
||||||
omap.setCenter(lat, lng);
|
omap.setCenter(lat, lng);
|
||||||
|
|
@ -1072,7 +1032,7 @@ $(function() {
|
||||||
$(this).removeClass('m-table__row--primary');
|
$(this).removeClass('m-table__row--primary');
|
||||||
|
|
||||||
// remove id value
|
// remove id value
|
||||||
selectedOutlet = '';
|
selectedHub = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -1084,7 +1044,7 @@ $(function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
|
|
||||||
if (id != selectedRider) {
|
if (id != selectedRider) {
|
||||||
// highlight this row, set outlet value
|
// highlight this row, set hub value
|
||||||
$("#riders-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
$("#riders-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
||||||
|
|
||||||
$(this).addClass('m-table__row--primary');
|
$(this).addClass('m-table__row--primary');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue