Merge branch '312-cmb-highlight-selected-hub-and-rider-in-onestep-edit' of gitlab.com:jankstudio/resq into 311-cmb-refactor-rapicontroller-into-a-service
This commit is contained in:
commit
ce9a1abd6e
5 changed files with 267 additions and 129 deletions
|
|
@ -28,6 +28,8 @@ RT_SHORTCODE=1234
|
||||||
MQTT_IP_ADDRESS=localhost
|
MQTT_IP_ADDRESS=localhost
|
||||||
MQTT_PORT=8883
|
MQTT_PORT=8883
|
||||||
MQTT_CERT=/location/of/cert/file.crt
|
MQTT_CERT=/location/of/cert/file.crt
|
||||||
|
MQTT_WS_HOST=insertiphere
|
||||||
|
MQTT_WS_PORT=8083
|
||||||
|
|
||||||
# redis client
|
# redis client
|
||||||
REDIS_CLIENT_SCHEME=tcp
|
REDIS_CLIENT_SCHEME=tcp
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,19 @@ use App\Ramcar\APIResult;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
use App\Ramcar\CMBServiceType;
|
use App\Ramcar\CMBServiceType;
|
||||||
|
use App\Ramcar\ServiceType;
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\APIRiderStatus;
|
use App\Ramcar\APIRiderStatus;
|
||||||
use App\Ramcar\TransactionOrigin;
|
use App\Ramcar\TransactionOrigin;
|
||||||
use App\Ramcar\CMBTradeInType;
|
use App\Ramcar\CMBTradeInType;
|
||||||
|
use App\Ramcar\TradeInType;
|
||||||
use App\Ramcar\InvoiceStatus;
|
use App\Ramcar\InvoiceStatus;
|
||||||
use App\Ramcar\ModeOfPayment;
|
use App\Ramcar\ModeOfPayment;
|
||||||
use App\Ramcar\JOEventType;
|
use App\Ramcar\JOEventType;
|
||||||
|
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\RedisClientProvider;
|
use App\Service\RedisClientProvider;
|
||||||
|
|
||||||
use App\Entity\RiderSession;
|
use App\Entity\RiderSession;
|
||||||
|
|
@ -49,6 +52,7 @@ use DateTime;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
// Rider API controller
|
// Rider API controller
|
||||||
|
// TODO: Need to refactor this into a service
|
||||||
class RAPIController extends Controller
|
class RAPIController extends Controller
|
||||||
{
|
{
|
||||||
protected $session;
|
protected $session;
|
||||||
|
|
@ -606,7 +610,7 @@ class RAPIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment(Request $req, MQTTClient $mclient)
|
public function payment(Request $req, MQTTClient $mclient, WarrantyHandler $wh)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
@ -634,9 +638,50 @@ class RAPIController extends Controller
|
||||||
|
|
||||||
// TODO: tag rider as unavailable
|
// TODO: tag rider as unavailable
|
||||||
|
|
||||||
|
// save to customer vehicle battery record
|
||||||
|
// TODO: this has to move to JOHandler
|
||||||
|
$this->updateVehicleBattery($jo);
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// send mqtt event (fulfilled)
|
// create warranty
|
||||||
|
if (($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW) ||
|
||||||
|
($jo->getServiceType() == CMBServiceType::BATTERY_REPLACEMENT_NEW))
|
||||||
|
{
|
||||||
|
$serial = null;
|
||||||
|
$warranty_class = $jo->getWarrantyClass();
|
||||||
|
$first_name = $jo->getCustomer()->getFirstName();
|
||||||
|
$last_name = $jo->getCustomer()->getLastName();
|
||||||
|
$mobile_number = $jo->getCustomer()->getPhoneMobile();
|
||||||
|
|
||||||
|
// check if date fulfilled is null
|
||||||
|
if ($jo->getDateFulfill() == null)
|
||||||
|
$date_purchase = $jo->getDateCreate();
|
||||||
|
else
|
||||||
|
$date_purchase = $jo->getDateFulfill();
|
||||||
|
|
||||||
|
$plate_number = $wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
||||||
|
|
||||||
|
$batt_list = array();
|
||||||
|
$invoice = $jo->getInvoice();
|
||||||
|
if (!empty($invoice))
|
||||||
|
{
|
||||||
|
// get battery
|
||||||
|
$invoice_items = $invoice->getItems();
|
||||||
|
foreach ($invoice_items as $item)
|
||||||
|
{
|
||||||
|
$battery = $item->getBattery();
|
||||||
|
if ($battery != null)
|
||||||
|
{
|
||||||
|
$batt_list[] = $item->getBattery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send mqtt event (fulfilled)
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
$image_url = $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/assets/images/user.gif';
|
$image_url = $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/assets/images/user.gif';
|
||||||
if ($rider->getImageFile() != null)
|
if ($rider->getImageFile() != null)
|
||||||
|
|
@ -650,12 +695,6 @@ class RAPIController extends Controller
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
// create the warranty if new battery only
|
|
||||||
if ($jo->getServiceType () == CMBServiceType::BATTERY_REPLACEMENT_NEW)
|
|
||||||
{
|
|
||||||
$this->createWarranty($jo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -774,7 +813,8 @@ class RAPIController extends Controller
|
||||||
|
|
||||||
// check service type
|
// check service type
|
||||||
$stype_id = $req->request->get('stype_id');
|
$stype_id = $req->request->get('stype_id');
|
||||||
if (!CMBServiceType::validate($stype_id))
|
if ((!CMBServiceType::validate($stype_id)) ||
|
||||||
|
(!ServiceType::validate($stype_id)))
|
||||||
{
|
{
|
||||||
$res->setError(true)
|
$res->setError(true)
|
||||||
->setErrorMessage('Invalid service type - ' . $stype_id);
|
->setErrorMessage('Invalid service type - ' . $stype_id);
|
||||||
|
|
@ -836,7 +876,8 @@ class RAPIController extends Controller
|
||||||
|
|
||||||
// check trade in
|
// check trade in
|
||||||
$trade_in = $req->request->get('trade_in');
|
$trade_in = $req->request->get('trade_in');
|
||||||
if (!CMBTradeInType::validate($trade_in))
|
if ((!CMBTradeInType::validate($trade_in)) ||
|
||||||
|
(!TradeInType::validate($trade_in)))
|
||||||
$trade_in = null;
|
$trade_in = null;
|
||||||
|
|
||||||
// check mode of payment
|
// check mode of payment
|
||||||
|
|
@ -890,79 +931,59 @@ class RAPIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createWarranty($jo)
|
protected function updateVehicleBattery(JobOrder $jo)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
// check if new battery
|
||||||
$warranty = new Warranty();
|
if (($jo->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW) ||
|
||||||
|
($jo->getServiceType() != CMBServiceType::BATTERY_REPLACEMENT_NEW))
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
$warranty_class = $jo->getWarrantyClass();
|
// customer vehicle
|
||||||
$first_name = $jo->getCustomer()->getFirstName();
|
$cv = $jo->getCustomerVehicle();
|
||||||
$last_name = $jo->getCustomer()->getLastName();
|
if ($cv == null)
|
||||||
$mobile_number = $jo->getCustomer()->getPhoneMobile();
|
return;
|
||||||
|
|
||||||
// check if date fulfilled is null
|
// invoice
|
||||||
if ($jo->getDateFulfill() == null)
|
$invoice = $jo->getInvoice();
|
||||||
$date_create = $jo->getDateCreate();
|
if ($invoice == null)
|
||||||
else
|
return;
|
||||||
$date_create = $jo->getDateFulfill();
|
|
||||||
|
|
||||||
// normalize the plate number
|
// invoice items
|
||||||
$plate_number = $this->normalizePlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
$items = $invoice->getItems();
|
||||||
|
if (count($items) <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// get battery and its warranty periods
|
// get first battery from invoice
|
||||||
$warranty_period = 0;
|
$battery = null;
|
||||||
$invoice_items = $jo->getInvoice()->getItems();
|
foreach ($items as $item)
|
||||||
foreach ($invoice_items as $item)
|
|
||||||
{
|
{
|
||||||
if ($item->getBattery() != null)
|
$battery = $item->getBattery();
|
||||||
{
|
if ($battery != null)
|
||||||
$battery = $item->getBattery();
|
break;
|
||||||
$warranty->setBatteryModel($battery->getModel());
|
|
||||||
$warranty->setBatterySize($battery->getSize());
|
|
||||||
|
|
||||||
if ($warranty_class == WarrantyClass::WTY_PRIVATE)
|
|
||||||
$warranty_period = $battery->getWarrantyPrivate();
|
|
||||||
else if ($warranty_class == WarrantyClass::WTY_COMMERCIAL)
|
|
||||||
$warranty_period = $battery->getWarrantyCommercial();
|
|
||||||
else if ($warranty_class == WarrantyClass::WTY_TNV)
|
|
||||||
$warranty_period = $battery->getWarrantyTnv();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute expiry date
|
// no battery in order
|
||||||
$expiry_date = $this->computeDateExpire($date_create, $warranty_period);
|
if ($battery == null)
|
||||||
|
return;
|
||||||
|
|
||||||
$warranty->setWarrantyClass($warranty_class)
|
// warranty expiration
|
||||||
->setFirstName($first_name)
|
$warr_months = 0;
|
||||||
->setLastName($last_name)
|
$warr = $jo->getWarrantyClass();
|
||||||
->setMobileNumber($mobile_number)
|
if ($warr == WarrantyClass::WTY_PRIVATE)
|
||||||
->setDatePurchase($date_create)
|
$warr_months = $battery->getWarrantyPrivate();
|
||||||
->setDateExpire($expiry_date)
|
else if ($warr == WarrantyClass::WTY_COMMERCIAL)
|
||||||
->setPlateNumber($plate_number);
|
$warr_months = $battery->getWarrantyCommercial();
|
||||||
|
else if ($warr == WarrantyClass::WTY_TNV)
|
||||||
|
$warr_months = 12;
|
||||||
|
|
||||||
$em->persist($warranty);
|
$warr_date = new DateTime();
|
||||||
$em->flush();
|
$warr_date->add(new DateInterval('P' . $warr_months . 'M'));
|
||||||
|
|
||||||
|
// update customer vehicle battery
|
||||||
|
$cv->setCurrentBattery($battery)
|
||||||
|
->setHasMotoliteBattery(true)
|
||||||
|
->setWarrantyExpiration($warr_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function normalizePlateNumber($plate_number)
|
|
||||||
{
|
|
||||||
// make it upper case
|
|
||||||
$plate_number = trim(strtoupper($plate_number));
|
|
||||||
|
|
||||||
// remove special characters and spaces
|
|
||||||
$plate_number = preg_replace('/[^A-Za-z0-9]/', '', $plate_number);
|
|
||||||
|
|
||||||
//error_log('plate number ' . $plate_number);
|
|
||||||
|
|
||||||
return $plate_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function computeDateExpire($date_create, $warranty_period)
|
|
||||||
{
|
|
||||||
$expire_date = clone $date_create;
|
|
||||||
$expire_date->add(new DateInterval('P'.$warranty_period.'M'));
|
|
||||||
return $expire_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -104,7 +104,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_landline">Landline</label>
|
<label data-field="customer_phone_landline">Landline</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_office">Office Phone</label>
|
<label data-field="customer_phone_office">Office Phone</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_fax">Fax</label>
|
<label data-field="customer_phone_fax">Fax</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -380,17 +380,19 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Hub</th>
|
<th>Hub</th>
|
||||||
<th>Branch</th>
|
<th>Branch</th>
|
||||||
<!--
|
|
||||||
<th class="text-right">Distance</th>
|
|
||||||
<th class="text-right">Travel Time</th>
|
|
||||||
<th class="text-right">Available Riders</th>
|
|
||||||
<th class="text-right">Jobs For Assignment</th>
|
|
||||||
-->
|
|
||||||
<th>Contact Numbers</th>
|
<th>Contact Numbers</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="nearest_hubs">
|
<tbody id="nearest_hubs">
|
||||||
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
{% for hub in hubs %}
|
||||||
|
<tr data-id="{{ hub.hub.getID }}"{{ obj.getHub and obj.getHub.getID == hub.hub.getID ? ' class="m-table__row--primary"' }}>
|
||||||
|
<td>{{ hub.hub.getName }}</td>
|
||||||
|
<td>{{ hub.hub.getBranch }}</td>
|
||||||
|
<td>{{ hub.hub.getContactNumbers }}</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -422,6 +424,24 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="riders">
|
<tbody id="riders">
|
||||||
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
{% set avail_riders = obj.getHub.getAvailableRiders|default([]) %}
|
||||||
|
<tr class="placeholder-row{{ obj.getHub and avail_riders|length > 0 ? ' hide' }}">
|
||||||
|
<td colspan="5">
|
||||||
|
No riders available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% if obj.getHub %}
|
||||||
|
{% for rider in avail_riders %}
|
||||||
|
<tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}">
|
||||||
|
<td>{{ rider.getFirstName }}</td>
|
||||||
|
<td>{{ rider.getLastName }}</td>
|
||||||
|
<td>{{ rider.getContactNumber }}</td>
|
||||||
|
<td>{{ rider.getPlateNumber }}</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -584,6 +604,8 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var form_in_process = false;
|
var form_in_process = false;
|
||||||
|
var selected_hub = '';
|
||||||
|
var selected_rider = '';
|
||||||
|
|
||||||
// openstreet maps stuff
|
// openstreet maps stuff
|
||||||
// TODO: move this to a service
|
// TODO: move this to a service
|
||||||
|
|
@ -623,25 +645,40 @@ $(function() {
|
||||||
|
|
||||||
var marker = L.marker([lat, lng], { icon: icon_customer });
|
var marker = L.marker([lat, lng], { icon: icon_customer });
|
||||||
|
|
||||||
// get nearest hubs ajax
|
{% if mode in ['onestep'] %}
|
||||||
var hub_table = '';
|
// get nearest hubs ajax
|
||||||
$.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) {
|
var hub_table = '';
|
||||||
var hubs = data['hubs'];
|
$.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) {
|
||||||
for (i in hubs) {
|
var hubs = data['hubs'];
|
||||||
var hub = hubs[i];
|
for (i in hubs) {
|
||||||
var hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub });
|
var hub = hubs[i];
|
||||||
hubLayerGroup.addLayer(hub_marker);
|
var hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub });
|
||||||
|
hubLayerGroup.addLayer(hub_marker);
|
||||||
|
|
||||||
hub_table += '<tr data-id=' + hub['id'] + '>';
|
hub_table += '<tr data-id=' + hub['id'] + '>';
|
||||||
hub_table += '<td>' + hub['name'] + '</td>';
|
hub_table += '<td>' + hub['name'] + '</td>';
|
||||||
hub_table += '<td>' + hub['branch'] + '</td>';
|
hub_table += '<td>' + hub['branch'] + '</td>';
|
||||||
hub_table += '<td>' + hub['cnum'] + '</td>';
|
hub_table += '<td>' + hub['cnum'] + '</td>';
|
||||||
hub_table += '<td></td>';
|
hub_table += '<td></td>';
|
||||||
hub_table += '</tr>';
|
hub_table += '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#nearest_hubs').html(hub_table);
|
$('#nearest_hubs').html(hub_table);
|
||||||
});
|
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
// get nearest hubs ajax
|
||||||
|
$.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) {
|
||||||
|
var hubs = data['hubs'];
|
||||||
|
for (i in hubs) {
|
||||||
|
var hub = hubs[i];
|
||||||
|
var hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub });
|
||||||
|
hubLayerGroup.addLayer(hub_marker);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
// add marker to layer group
|
// add marker to layer group
|
||||||
markerLayerGroup.addLayer(marker);
|
markerLayerGroup.addLayer(marker);
|
||||||
|
|
@ -706,7 +743,14 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var selected_hub = "";
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
selected_hub = '{{ obj.getHub ? obj.getHub.getID: "" }}';
|
||||||
|
$('#hub-field').val(selected_hub);
|
||||||
|
{% endif %}
|
||||||
|
{% if mode in ['onestep'] %}
|
||||||
|
selected_hub = '';
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
$('#hubs-table').on('click', 'tr', function() {
|
$('#hubs-table').on('click', 'tr', function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
|
|
||||||
|
|
@ -723,6 +767,10 @@ $(function() {
|
||||||
selected_hub = id;
|
selected_hub = id;
|
||||||
$('#hub-field').val(selected_hub);
|
$('#hub-field').val(selected_hub);
|
||||||
|
|
||||||
|
// clear rider field
|
||||||
|
$('#rider-field').val('');
|
||||||
|
selected_rider = '';
|
||||||
|
|
||||||
// get riders of hub
|
// get riders of hub
|
||||||
// get hub riders ajax
|
// get hub riders ajax
|
||||||
// TODO: add latitude and longitude of delivery location to ajax request
|
// TODO: add latitude and longitude of delivery location to ajax request
|
||||||
|
|
@ -758,7 +806,13 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var selected_rider = '';
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
selected_rider = '{{ obj.getRider ? obj.getRider.getID: "" }}';
|
||||||
|
$('#rider-field').val(selected_rider);
|
||||||
|
{% endif %}
|
||||||
|
{% if mode in ['onestep'] %}
|
||||||
|
selected_rider = '';
|
||||||
|
{% endif %}
|
||||||
$('#rider-table').on('click', 'tr', function() {
|
$('#rider-table').on('click', 'tr', function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
|
|
||||||
|
|
@ -776,6 +830,8 @@ $(function() {
|
||||||
{% if mode in ['onestep-edit'] %}
|
{% if mode in ['onestep-edit'] %}
|
||||||
var lat = {{ obj.getCoordinates.getLatitude }};
|
var lat = {{ obj.getCoordinates.getLatitude }};
|
||||||
var lng = {{ obj.getCoordinates.getLongitude }};
|
var lng = {{ obj.getCoordinates.getLongitude }};
|
||||||
|
var hub = {{ obj.getHub.getID }};
|
||||||
|
var rider = {{ obj.getRider.getID }};
|
||||||
|
|
||||||
selectPoint(lat, lng);
|
selectPoint(lat, lng);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -118,7 +118,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_landline">Landline</label>
|
<label data-field="customer_phone_landline">Landline</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -128,7 +128,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_office">Office Phone</label>
|
<label data-field="customer_phone_office">Office Phone</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -136,7 +136,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_fax">Fax</label>
|
<label data-field="customer_phone_fax">Fax</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -102,7 +102,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_landline">Landline</label>
|
<label data-field="customer_phone_landline">Landline</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_office">Office Phone</label>
|
<label data-field="customer_phone_office">Office Phone</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -120,7 +120,7 @@
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_phone_fax">Fax</label>
|
<label data-field="customer_phone_fax">Fax</label>
|
||||||
<div class="input-group m-input-group">
|
<div class="input-group m-input-group">
|
||||||
<span class="input-group-addon">+63</span>
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" data-vehicle-field="1" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -383,6 +383,14 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="nearest_hubs">
|
<tbody id="nearest_hubs">
|
||||||
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
{% for hub in hubs %}
|
||||||
|
<tr data-id="{{ hub.hub.getID }}"{{ obj.getHub and obj.getHub.getID == hub.hub.getID ? ' class="m-table__row--primary"' }}>
|
||||||
|
<td>{{ hub.hub.getName }}</td>
|
||||||
|
<td>{{ hub.hub.getBranch }}</td>
|
||||||
|
<td>{{ hub.hub.getContactNumbers }}</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -412,6 +420,24 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="riders">
|
<tbody id="riders">
|
||||||
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
{% set avail_riders = obj.getHub.getAvailableRiders|default([]) %}
|
||||||
|
<tr class="placeholder-row{{ obj.getHub and avail_riders|length > 0 ? ' hide' }}">
|
||||||
|
<td colspan="5">
|
||||||
|
No riders available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% if obj.getHub %}
|
||||||
|
{% for rider in avail_riders %}
|
||||||
|
<tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}">
|
||||||
|
<td>{{ rider.getFirstName }}</td>
|
||||||
|
<td>{{ rider.getLastName }}</td>
|
||||||
|
<td>{{ rider.getContactNumber }}</td>
|
||||||
|
<td>{{ rider.getPlateNumber }}</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -574,6 +600,8 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var form_in_process = false;
|
var form_in_process = false;
|
||||||
|
var selected_hub = '';
|
||||||
|
var selected_rider = '';
|
||||||
|
|
||||||
// openstreet maps stuff
|
// openstreet maps stuff
|
||||||
// TODO: move this to a service
|
// TODO: move this to a service
|
||||||
|
|
@ -613,25 +641,40 @@ $(function() {
|
||||||
|
|
||||||
var marker = L.marker([lat, lng], { icon: icon_customer });
|
var marker = L.marker([lat, lng], { icon: icon_customer });
|
||||||
|
|
||||||
// get nearest hubs ajax
|
{% if mode in ['onestep'] %}
|
||||||
var hub_table = '';
|
// get nearest hubs ajax
|
||||||
$.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) {
|
var hub_table = '';
|
||||||
var hubs = data['hubs'];
|
$.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) {
|
||||||
for (i in hubs) {
|
var hubs = data['hubs'];
|
||||||
var hub = hubs[i];
|
for (i in hubs) {
|
||||||
var hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub });
|
var hub = hubs[i];
|
||||||
hubLayerGroup.addLayer(hub_marker);
|
var hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub });
|
||||||
|
hubLayerGroup.addLayer(hub_marker);
|
||||||
|
|
||||||
hub_table += '<tr data-id=' + hub['id'] + '>';
|
hub_table += '<tr data-id=' + hub['id'] + '>';
|
||||||
hub_table += '<td>' + hub['name'] + '</td>';
|
hub_table += '<td>' + hub['name'] + '</td>';
|
||||||
hub_table += '<td>' + hub['branch'] + '</td>';
|
hub_table += '<td>' + hub['branch'] + '</td>';
|
||||||
hub_table += '<td>' + hub['cnum'] + '</td>';
|
hub_table += '<td>' + hub['cnum'] + '</td>';
|
||||||
hub_table += '<td></td>';
|
hub_table += '<td></td>';
|
||||||
hub_table += '</tr>';
|
hub_table += '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#nearest_hubs').html(hub_table);
|
$('#nearest_hubs').html(hub_table);
|
||||||
});
|
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
// get nearest hubs ajax
|
||||||
|
$.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) {
|
||||||
|
var hubs = data['hubs'];
|
||||||
|
for (i in hubs) {
|
||||||
|
var hub = hubs[i];
|
||||||
|
var hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub });
|
||||||
|
hubLayerGroup.addLayer(hub_marker);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
// add marker to layer group
|
// add marker to layer group
|
||||||
markerLayerGroup.addLayer(marker);
|
markerLayerGroup.addLayer(marker);
|
||||||
|
|
@ -696,7 +739,13 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var selected_hub = "";
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
selected_hub = '{{ obj.getHub ? obj.getHub.getID: "" }}';
|
||||||
|
$('#hub-field').val(selected_hub);
|
||||||
|
{% endif %}
|
||||||
|
{% if mode in ['onestep'] %}
|
||||||
|
selected_hub = '';
|
||||||
|
{% endif %}
|
||||||
$('#hubs-table').on('click', 'tr', function() {
|
$('#hubs-table').on('click', 'tr', function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
|
|
||||||
|
|
@ -713,6 +762,10 @@ $(function() {
|
||||||
selected_hub = id;
|
selected_hub = id;
|
||||||
$('#hub-field').val(selected_hub);
|
$('#hub-field').val(selected_hub);
|
||||||
|
|
||||||
|
// clear rider field
|
||||||
|
$('#rider-field').val('');
|
||||||
|
selected_rider = '';
|
||||||
|
|
||||||
// get riders of hub
|
// get riders of hub
|
||||||
// get hub riders ajax
|
// get hub riders ajax
|
||||||
// TODO: add latitude and longitude of delivery location to ajax request
|
// TODO: add latitude and longitude of delivery location to ajax request
|
||||||
|
|
@ -748,7 +801,13 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var selected_rider = '';
|
{% if mode in ['onestep-edit'] %}
|
||||||
|
selected_rider = '{{ obj.getRider ? obj.getRider.getID: "" }}';
|
||||||
|
$('#rider-field').val(selected_rider);
|
||||||
|
{% endif %}
|
||||||
|
{% if mode in ['onestep'] %}
|
||||||
|
selected_rider = '';
|
||||||
|
{% endif %}
|
||||||
$('#rider-table').on('click', 'tr', function() {
|
$('#rider-table').on('click', 'tr', function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue