Resolve "Job Order Assignment Fix" #824
9 changed files with 229 additions and 145 deletions
|
|
@ -14,7 +14,8 @@ use App\Entity\JobOrder;
|
|||
use App\Entity\BatteryManufacturer;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\Outlet;
|
||||
//use App\Entity\Outlet;
|
||||
use App\Entity\Hub;
|
||||
use App\Entity\Promo;
|
||||
use App\Entity\Rider;
|
||||
use App\Entity\Battery;
|
||||
|
|
@ -23,6 +24,7 @@ use App\Service\InvoiceCreator;
|
|||
use App\Service\MapTools;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\LockMode;
|
||||
use Doctrine\ORM\PessimisticLockException;
|
||||
|
||||
|
|
@ -239,6 +241,10 @@ class JobOrderController extends BaseController
|
|||
// check which job order tier is being called for and confirm access
|
||||
$tier_params = $this->checkTier($tier);
|
||||
|
||||
// get current user
|
||||
$user = $this->getUser();
|
||||
$hubs = $user->getHubs();
|
||||
|
||||
// get query builder
|
||||
$qb = $this->getDoctrine()
|
||||
->getRepository(JobOrder::class)
|
||||
|
|
@ -250,7 +256,7 @@ class JobOrderController extends BaseController
|
|||
// count total records
|
||||
$tquery = $qb->select('COUNT(q)');
|
||||
|
||||
$this->setQueryFilters($datatable, $tquery, $qb, $tier_params['jo_status']);
|
||||
$this->setQueryFilters($datatable, $tquery, $qb, $hubs, $tier, $tier_params['jo_status']);
|
||||
|
||||
$total = $tquery->getQuery()
|
||||
->getSingleScalarResult();
|
||||
|
|
@ -274,7 +280,7 @@ class JobOrderController extends BaseController
|
|||
// build query
|
||||
$query = $qb->select('q');
|
||||
|
||||
$this->setQueryFilters($datatable, $query, $qb, $tier_params['jo_status']);
|
||||
$this->setQueryFilters($datatable, $query, $qb, $hubs, $tier, $tier_params['jo_status']);
|
||||
|
||||
// check if sorting is present, otherwise use default
|
||||
if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) {
|
||||
|
|
@ -396,35 +402,35 @@ class JobOrderController extends BaseController
|
|||
$params['discount_apply'] = DiscountApply::getCollection();
|
||||
$params['trade_in_types'] = TradeInType::getCollection();
|
||||
|
||||
// get closest outlets
|
||||
$outlets = $map_tools->getClosestOutlets($obj->getCoordinates(), 10, date("H:i:s"));
|
||||
// get closest hubs
|
||||
$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 10, date("H:i:s"));
|
||||
|
||||
$params['outlets'] = [];
|
||||
$params['hubs'] = [];
|
||||
|
||||
// format duration and distance into friendly time
|
||||
foreach ($outlets as $outlet) {
|
||||
foreach ($hubs as $hub) {
|
||||
// duration
|
||||
$seconds = $outlet['duration'];
|
||||
$seconds = $hub['duration'];
|
||||
|
||||
if (!empty($seconds) && $seconds > 0) {
|
||||
$hours = floor($seconds / 3600);
|
||||
$minutes = ceil(($seconds / 60) % 60);
|
||||
|
||||
$outlet['duration'] = ($hours > 0 ? number_format($hours) . " hr" . ($hours > 1 ? "s" : '') . ($minutes > 0 ? ", " : '') : '') . ($minutes > 0 ? number_format($minutes) . " min" . ($minutes > 1 ? "s" : '') : '');
|
||||
$hub['duration'] = ($hours > 0 ? number_format($hours) . " hr" . ($hours > 1 ? "s" : '') . ($minutes > 0 ? ", " : '') : '') . ($minutes > 0 ? number_format($minutes) . " min" . ($minutes > 1 ? "s" : '') : '');
|
||||
} else {
|
||||
$outlet['duration'] = false;
|
||||
$hub['duration'] = false;
|
||||
}
|
||||
|
||||
// distance
|
||||
$meters = $outlet['distance'];
|
||||
$meters = $hub['distance'];
|
||||
|
||||
if (!empty($meters) && $meters > 0) {
|
||||
$outlet['distance'] = round($meters / 1000) . " km";
|
||||
$hub['distance'] = round($meters / 1000) . " km";
|
||||
} else {
|
||||
$outlet['distance'] = false;
|
||||
$hub['distance'] = false;
|
||||
}
|
||||
|
||||
$params['outlets'][] = $outlet;
|
||||
$params['hubs'][] = $hub;
|
||||
}
|
||||
|
||||
$params['obj'] = $obj;
|
||||
|
|
@ -465,15 +471,15 @@ class JobOrderController extends BaseController
|
|||
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||
}
|
||||
|
||||
// check if outlet is set
|
||||
if (empty($req->request->get('outlet'))) {
|
||||
$error_array['outlet'] = 'No outlet selected.';
|
||||
// check if hub is set
|
||||
if (empty($req->request->get('hub'))) {
|
||||
$error_array['hub'] = 'No hub selected.';
|
||||
} else {
|
||||
// get outlet
|
||||
$outlet = $em->getRepository(Outlet::class)->find($req->request->get('outlet'));
|
||||
// get hub
|
||||
$hub = $em->getRepository(Hub::class)->find($req->request->get('hub'));
|
||||
|
||||
if (empty($outlet)) {
|
||||
$error_array['outlet'] = 'Invalid outlet specified.';
|
||||
if (empty($hub)) {
|
||||
$error_array['hub'] = 'Invalid hub specified.';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -492,7 +498,7 @@ class JobOrderController extends BaseController
|
|||
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||
->setAgentNotes($req->request->get('agent_notes'))
|
||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||
->setOutlet($outlet);
|
||||
->setHub($hub);
|
||||
|
||||
// validate
|
||||
$errors = $validator->validate($obj);
|
||||
|
|
@ -552,6 +558,14 @@ class JobOrderController extends BaseController
|
|||
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
|
||||
$assignor = $obj->getAssignedBy();
|
||||
$user = $this->getUser();
|
||||
|
|
@ -583,35 +597,35 @@ class JobOrderController extends BaseController
|
|||
$params['discount_apply'] = DiscountApply::getCollection();
|
||||
$params['trade_in_types'] = TradeInType::getCollection();
|
||||
|
||||
// get closest outlets
|
||||
$outlets = $map_tools->getClosestOutlets($obj->getCoordinates(), 10, date("H:i:s"));
|
||||
// get closest hubs
|
||||
$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 10, date("H:i:s"));
|
||||
|
||||
$params['outlets'] = [];
|
||||
$params['hubs'] = [];
|
||||
|
||||
// format duration and distance into friendly time
|
||||
foreach ($outlets as $outlet) {
|
||||
foreach ($hubs as $hub) {
|
||||
// duration
|
||||
$seconds = $outlet['duration'];
|
||||
$seconds = $hub['duration'];
|
||||
|
||||
if (!empty($seconds) && $seconds > 0) {
|
||||
$hours = floor($seconds / 3600);
|
||||
$minutes = ceil(($seconds / 60) % 60);
|
||||
|
||||
$outlet['duration'] = ($hours > 0 ? number_format($hours) . " hr" . ($hours > 1 ? "s" : '') . ($minutes > 0 ? ", " : '') : '') . ($minutes > 0 ? number_format($minutes) . " min" . ($minutes > 1 ? "s" : '') : '');
|
||||
$hub['duration'] = ($hours > 0 ? number_format($hours) . " hr" . ($hours > 1 ? "s" : '') . ($minutes > 0 ? ", " : '') : '') . ($minutes > 0 ? number_format($minutes) . " min" . ($minutes > 1 ? "s" : '') : '');
|
||||
} else {
|
||||
$outlet['duration'] = false;
|
||||
$hub['duration'] = false;
|
||||
}
|
||||
|
||||
// distance
|
||||
$meters = $outlet['distance'];
|
||||
$meters = $hub['distance'];
|
||||
|
||||
if (!empty($meters) && $meters > 0) {
|
||||
$outlet['distance'] = round($meters / 1000) . " km";
|
||||
$hub['distance'] = round($meters / 1000) . " km";
|
||||
} else {
|
||||
$outlet['distance'] = false;
|
||||
$hub['distance'] = false;
|
||||
}
|
||||
|
||||
$params['outlets'][] = $outlet;
|
||||
$params['hubs'][] = $hub;
|
||||
}
|
||||
|
||||
$params['obj'] = $obj;
|
||||
|
|
@ -704,11 +718,18 @@ class JobOrderController extends BaseController
|
|||
// TODO: re-enable search, figure out how to group the orWhere filters into one, so can execute that plus the pending filter
|
||||
|
||||
// check if datatable filter is present and append to query
|
||||
protected function setQueryFilters($datatable, &$query, $qb, $status)
|
||||
protected function setQueryFilters($datatable, &$query, $qb, $hubs, $tier, $status)
|
||||
{
|
||||
$query->where('q.status = :status')
|
||||
->setParameter('status', $status);
|
||||
|
||||
// on assigning, filter by assigned hub
|
||||
if ($tier == 'assign')
|
||||
{
|
||||
$query->andWhere('q.hub IN (:hubs)')
|
||||
->setParameter('hubs', $hubs, Connection::PARAM_STR_ARRAY);
|
||||
}
|
||||
|
||||
// get only pending rows
|
||||
/*
|
||||
$query->where($qb->expr()->orX(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
|||
use App\Ramcar\BaseController;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Role;
|
||||
use App\Entity\Hub;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
@ -133,6 +134,7 @@ class UserController extends BaseController
|
|||
// get roles
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$params['roles'] = $em->getRepository(Role::class)->findAll();
|
||||
$params['hubs'] = $em->getRepository(Hub::class)->findAll();
|
||||
|
||||
// response
|
||||
return $this->render('user/form.html.twig', $params);
|
||||
|
|
@ -153,7 +155,8 @@ class UserController extends BaseController
|
|||
->setEmail($req->request->get('email'))
|
||||
->setContactNumber($req->request->get('contact_no'))
|
||||
->setEnabled($req->request->get('enabled') ? true : false)
|
||||
->clearRoles();
|
||||
->clearRoles()
|
||||
->clearHubs();
|
||||
|
||||
// set roles
|
||||
$roles = $req->request->get('roles');
|
||||
|
|
@ -173,6 +176,19 @@ class UserController extends BaseController
|
|||
}
|
||||
}
|
||||
|
||||
// set hubs
|
||||
$hubs = $req->request->get('hubs');
|
||||
|
||||
if (!empty($hubs)) {
|
||||
foreach ($hubs as $hub_id) {
|
||||
// check if hub exists
|
||||
$hub = $em->getRepository(Hub::class)->find($hub_id);
|
||||
|
||||
if (!empty($hub))
|
||||
$obj->addHub($hub);
|
||||
}
|
||||
}
|
||||
|
||||
// validate
|
||||
$errors = $validator->validate($obj);
|
||||
|
||||
|
|
@ -238,6 +254,7 @@ class UserController extends BaseController
|
|||
|
||||
// get roles
|
||||
$params['roles'] = $em->getRepository(Role::class)->findAll();
|
||||
$params['hubs'] = $em->getRepository(Hub::class)->findAll();
|
||||
|
||||
$params['obj'] = $obj;
|
||||
|
||||
|
|
@ -264,7 +281,8 @@ class UserController extends BaseController
|
|||
->setEmail($req->request->get('email'))
|
||||
->setContactNumber($req->request->get('contact_no'))
|
||||
->setEnabled($req->request->get('enabled') ? true : false)
|
||||
->clearRoles();
|
||||
->clearRoles()
|
||||
->clearHubs();
|
||||
|
||||
// set roles
|
||||
$roles = $req->request->get('roles');
|
||||
|
|
@ -279,6 +297,19 @@ class UserController extends BaseController
|
|||
}
|
||||
}
|
||||
|
||||
// set hubs
|
||||
$hubs = $req->request->get('hubs');
|
||||
|
||||
if (!empty($hubs)) {
|
||||
foreach ($hubs as $hub_id) {
|
||||
// check if hub exists
|
||||
$hub = $em->getRepository(Hub::class)->find($hub_id);
|
||||
|
||||
if (!empty($hub))
|
||||
$obj->addHub($hub);
|
||||
}
|
||||
}
|
||||
|
||||
// validate
|
||||
$errors = $validator->validate($obj);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,16 @@ class Hub
|
|||
*/
|
||||
protected $riders;
|
||||
|
||||
// outlets under this hub
|
||||
// job orders assigned to hub
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Outlet", mappedBy="hub")
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="hub")
|
||||
*/
|
||||
protected $outlets;
|
||||
protected $job_orders;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="User", mappedBy="hubs", fetch="EXTRA_LAZY")
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -42,8 +47,18 @@ class Hub
|
|||
return $this->riders;
|
||||
}
|
||||
|
||||
public function getOutlets()
|
||||
public function getUsers()
|
||||
{
|
||||
return $this->outlets;
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
public function getUsersCount()
|
||||
{
|
||||
return $this->users->count();
|
||||
}
|
||||
|
||||
public function getJobOrders()
|
||||
{
|
||||
return $this->job_orders;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,12 +116,12 @@ class JobOrder
|
|||
*/
|
||||
protected $cus_vehicle;
|
||||
|
||||
// assigned outlet
|
||||
// assigned hub
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Outlet", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="outlet_id", referencedColumnName="id")
|
||||
* @ORM\ManyToOne(targetEntity="Hub", inversedBy="job_orders")
|
||||
* @ORM\JoinColumn(name="hub_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $outlet;
|
||||
protected $hub;
|
||||
|
||||
// assigned rider
|
||||
/**
|
||||
|
|
@ -324,15 +324,15 @@ class JobOrder
|
|||
return $this->cus_vehicle;
|
||||
}
|
||||
|
||||
public function setOutlet(Outlet $outlet)
|
||||
public function setHub(Hub $hub)
|
||||
{
|
||||
$this->outlet = $outlet;
|
||||
$this->hub = $hub;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOutlet()
|
||||
public function getHub()
|
||||
{
|
||||
return $this->outlet;
|
||||
return $this->hub;
|
||||
}
|
||||
|
||||
public function setRider(Rider $rider)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ class User implements AdvancedUserInterface, Serializable
|
|||
*/
|
||||
protected $roles;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Hub", inversedBy="users")
|
||||
* @ORM\JoinTable(name="user_hubs")
|
||||
*/
|
||||
protected $hubs;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
|
|
@ -100,6 +106,7 @@ class User implements AdvancedUserInterface, Serializable
|
|||
public function __construct()
|
||||
{
|
||||
$this->roles = new ArrayCollection();
|
||||
$this->hubs = new ArrayCollection();
|
||||
$this->job_orders_created = new ArrayCollection();
|
||||
$this->job_orders_assigned = new ArrayCollection();
|
||||
$this->tickets = new ArrayCollection();
|
||||
|
|
@ -171,6 +178,32 @@ class User implements AdvancedUserInterface, Serializable
|
|||
return $this->roles;
|
||||
}
|
||||
|
||||
public function addHub(Hub $hub)
|
||||
{
|
||||
$this->hubs->add($hub);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearHubs()
|
||||
{
|
||||
$this->hubs->clear();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHubs()
|
||||
{
|
||||
$str_hubs = [];
|
||||
foreach ($this->hubs as $hub)
|
||||
$str_hubs[] = $hub->getID();
|
||||
|
||||
return $str_hubs;
|
||||
}
|
||||
|
||||
public function getHubObjects()
|
||||
{
|
||||
return $this->hubs;
|
||||
}
|
||||
|
||||
public function eraseCredentials()
|
||||
{
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ trait Location
|
|||
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->name . ' ' . $this->branch;
|
||||
return $this->name . ($this->branch ? ' - ' . $this->branch : '');
|
||||
}
|
||||
|
||||
public function setAddress($address)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class MapTools
|
|||
$this->gmaps_api_key = $gmaps_api_key;
|
||||
}
|
||||
|
||||
protected function mapGetDistances(Point $point, $outlets)
|
||||
protected function mapGetDistances(Point $point, $hubs)
|
||||
{
|
||||
$client = new GuzzleClient();
|
||||
|
||||
|
|
@ -32,9 +32,9 @@ class MapTools
|
|||
|
||||
// destinations
|
||||
$dests = [];
|
||||
foreach ($outlets as $outlet)
|
||||
foreach ($hubs as $hub)
|
||||
{
|
||||
$coord = $outlet->getCoordinates();
|
||||
$coord = $hub->getCoordinates();
|
||||
$dests[] = round($coord->getLatitude(),5) . ',' . round($point->getLongitude(), 5);
|
||||
}
|
||||
$dests_value = implode('|', $dests);
|
||||
|
|
@ -57,10 +57,10 @@ class MapTools
|
|||
return $res->getBody();
|
||||
}
|
||||
|
||||
public function getClosestOutlets(Point $point, $limit, $time = false)
|
||||
public function getClosestHubs(Point $point, $limit, $time = false)
|
||||
{
|
||||
// get closest outlets based on st_distance function from db
|
||||
$query = $this->em->createQuery('SELECT o, st_distance(o.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Outlet o' . ($time ? ' WHERE :time BETWEEN o.time_open AND o.time_close' : '') . ' ORDER BY dist')
|
||||
// get closest hubs based on st_distance function from db
|
||||
$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('lng', $point->getLongitude());
|
||||
|
||||
|
|
@ -73,14 +73,14 @@ class MapTools
|
|||
// error_log($query->getSql());
|
||||
$result = $query->getResult();
|
||||
|
||||
$outlets = [];
|
||||
$hubs = [];
|
||||
$final_data = [];
|
||||
foreach ($result as $row)
|
||||
{
|
||||
//error_log($row[0]->getName() . ' - ' . $row['dist']);
|
||||
$outlets[] = $row[0];
|
||||
$hubs[] = $row[0];
|
||||
$final_data[] = [
|
||||
'outlet' => $row[0],
|
||||
'hub' => $row[0],
|
||||
'db_distance' => $row['dist'],
|
||||
'distance' => 0,
|
||||
'duration' => 0,
|
||||
|
|
@ -88,7 +88,7 @@ class MapTools
|
|||
}
|
||||
|
||||
// get actual distance details with eta from google maps api
|
||||
$raw_res = $this->mapGetDistances($point, $outlets);
|
||||
$raw_res = $this->mapGetDistances($point, $hubs);
|
||||
$res = json_decode($raw_res, true);
|
||||
//error_log(print_r($res, true));
|
||||
|
||||
|
|
|
|||
|
|
@ -379,18 +379,18 @@
|
|||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Nearest Outlets
|
||||
Nearest Hubs
|
||||
</h3>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label>Click on a row to select an outlet</label>
|
||||
<div class="form-control-feedback hide" data-field="outlet"></div>
|
||||
<div class="table-frame" data-name="outlet">
|
||||
<table id="outlets-table" class="table table-compact table-hover table-clickable m-table">
|
||||
<label>Click on a row to select a hub</label>
|
||||
<div class="form-control-feedback hide" data-field="hub"></div>
|
||||
<div class="table-frame" data-name="hub">
|
||||
<table id="hubs-table" class="table table-compact table-hover table-clickable m-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Outlet</th>
|
||||
<th>Hub</th>
|
||||
<th>Branch</th>
|
||||
<th class="text-right">Distance</th>
|
||||
<th class="text-right">Travel Time</th>
|
||||
|
|
@ -399,21 +399,21 @@
|
|||
<th>Contact Numbers</th> </tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="placeholder-row{{ outlets|length > 0 ? ' hide' }}">
|
||||
<tr class="placeholder-row{{ hubs|length > 0 ? ' hide' }}">
|
||||
<td colspan="7">
|
||||
No items to display.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% for outlet in outlets %}
|
||||
<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"' }}>
|
||||
<td>{{ outlet.outlet.getName }}</td>
|
||||
<td>{{ outlet.outlet.getBranch }}</td>
|
||||
<td class="text-right">{{ outlet.distance ? outlet.distance : '-' }}</td>
|
||||
<td class="text-right">{{ outlet.duration ? outlet.duration : '-' }}</td>
|
||||
{% for hub in hubs %}
|
||||
<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>{{ hub.hub.getName }}</td>
|
||||
<td>{{ hub.hub.getBranch }}</td>
|
||||
<td class="text-right">{{ hub.distance ? hub.distance : '-' }}</td>
|
||||
<td class="text-right">{{ hub.duration ? hub.duration : '-' }}</td>
|
||||
<td class="text-right">0</td>
|
||||
<td class="text-right">0</td>
|
||||
<td>{{ outlet.outlet.getContactNumbers }}</td>
|
||||
<td>{{ hub.hub.getContactNumbers }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
@ -422,12 +422,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outlet_map" style="height:600px;"></div>
|
||||
<div id="hub_map" style="height:600px;"></div>
|
||||
{% endif %}
|
||||
|
||||
{% if mode == 'update-assigning' %}
|
||||
<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__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
|
|
@ -437,17 +437,17 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<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>
|
||||
<div class="col-lg-3">
|
||||
<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>
|
||||
<div class="col-lg-3">
|
||||
<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>
|
||||
</div>
|
||||
|
|
@ -456,59 +456,19 @@
|
|||
<label data-field="hub_address">
|
||||
Address
|
||||
</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>
|
||||
<div class="col-lg-6">
|
||||
<label data-field="contact_nums">
|
||||
Contact Numbers
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
{% 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__section m-form__section--last">
|
||||
<div class="m-form__heading">
|
||||
|
|
@ -533,14 +493,14 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<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">
|
||||
No items to display.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% if obj.getOutlet.getHub %}
|
||||
{% for rider in obj.getOutlet.getHub.getRiders %}
|
||||
{% if obj.getHub %}
|
||||
{% for rider in obj.getHub.getRiders %}
|
||||
<tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}>
|
||||
<td>
|
||||
<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 %}
|
||||
|
||||
{% if mode == 'update-processing' %}
|
||||
// display outlet map
|
||||
var omap = new GMaps({
|
||||
div: '#outlet_map',
|
||||
// display hub map
|
||||
var hmap = new GMaps({
|
||||
div: '#hub_map',
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }}
|
||||
});
|
||||
|
||||
omap.addMarker({
|
||||
hmap.addMarker({
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }},
|
||||
icon: '/assets/images/icon-destination.png',
|
||||
|
|
@ -668,12 +628,12 @@ $(function() {
|
|||
content: "Destination"
|
||||
});
|
||||
|
||||
{% for outlet in outlets %}
|
||||
omap.addMarker({
|
||||
lat: {{ outlet.outlet.getCoordinates.getLatitude }},
|
||||
lng: {{ outlet.outlet.getCoordinates.getLongitude }},
|
||||
title: "{{ outlet.outlet.getName }}",
|
||||
content: "{{ outlet.outlet.getName }}",
|
||||
{% for hub in hubs %}
|
||||
hmap.addMarker({
|
||||
lat: {{ hub.hub.getCoordinates.getLatitude }},
|
||||
lng: {{ hub.hub.getCoordinates.getLongitude }},
|
||||
title: "{{ hub.hub.getName }}",
|
||||
content: "{{ hub.hub.getName }}",
|
||||
icon: '/assets/images/icon-outlet.png'
|
||||
});
|
||||
{% endfor %}
|
||||
|
|
@ -695,8 +655,8 @@ $(function() {
|
|||
fields['invoice_items'] = invoiceItems;
|
||||
|
||||
{% if mode == 'update-processing' %}
|
||||
// add selected outlet to data
|
||||
fields['outlet'] = selectedOutlet;
|
||||
// add selected hub to data
|
||||
fields['hub'] = selectedHub;
|
||||
{% endif %}
|
||||
|
||||
{% if mode == 'update-assigning' %}
|
||||
|
|
@ -1049,21 +1009,21 @@ $(function() {
|
|||
*/
|
||||
|
||||
{% 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 lat = $(this).data('lat');
|
||||
var lng = $(this).data('lng');
|
||||
|
||||
if (id != selectedOutlet) {
|
||||
// highlight this row, set outlet value
|
||||
$("#outlets-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
||||
if (id != selectedHub) {
|
||||
// highlight this row, set hub value
|
||||
$("#hubs-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
||||
|
||||
$(this).addClass('m-table__row--primary');
|
||||
|
||||
// set value
|
||||
selectedOutlet = id;
|
||||
selectedHub = id;
|
||||
|
||||
// center the map
|
||||
omap.setCenter(lat, lng);
|
||||
|
|
@ -1072,7 +1032,7 @@ $(function() {
|
|||
$(this).removeClass('m-table__row--primary');
|
||||
|
||||
// remove id value
|
||||
selectedOutlet = '';
|
||||
selectedHub = '';
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
|
|
@ -1084,7 +1044,7 @@ $(function() {
|
|||
var id = $(this).data('id');
|
||||
|
||||
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');
|
||||
|
||||
$(this).addClass('m-table__row--primary');
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
{% if mode != 'profile' %}
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
<div class="m-form__section">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Roles
|
||||
|
|
@ -138,6 +139,29 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Hub Assignment
|
||||
</h3>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<div class="m-checkbox-list">
|
||||
{% for hub in hubs %}
|
||||
<label class="m-checkbox">
|
||||
<input type="checkbox" name="hubs[]" value="{{ hub.getID() }}"{{ hub.getID() in obj.getHubs() ? ' checked' : '' }}>
|
||||
{{ hub.getFullName() }}
|
||||
<span></span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="form-control-feedback hide" data-field="hubs"></div>
|
||||
<span class="m-form__help">Check all hubs assigned to this user</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
|
|
|
|||
Loading…
Reference in a new issue