Initial commit for assigning screens for job orders
This commit is contained in:
parent
3622315999
commit
c0ecc1114c
9 changed files with 497 additions and 97 deletions
|
|
@ -185,3 +185,5 @@ access_keys:
|
|||
label: Incoming
|
||||
- id: jo_proc.list
|
||||
label: Processing
|
||||
- id: jo_assign.list
|
||||
label: Assigning
|
||||
|
|
|
|||
|
|
@ -89,4 +89,8 @@ main_menu:
|
|||
acl: jo_proc.list
|
||||
label: Processing
|
||||
parent: joborder
|
||||
- id: jo_assign
|
||||
acl: jo_assign.list
|
||||
label: Assigning
|
||||
parent: joborder
|
||||
|
||||
|
|
|
|||
|
|
@ -3,21 +3,25 @@ jo_in:
|
|||
controller: App\Controller\JobOrderController::incomingForm
|
||||
methods: [GET]
|
||||
|
||||
jo_proc:
|
||||
path: /job-order/processing
|
||||
controller: App\Controller\JobOrderController::processingList
|
||||
methods: [GET]
|
||||
|
||||
jo_proc_rows:
|
||||
path: /job-order/processing-rows
|
||||
controller: App\Controller\JobOrderController::processingRows
|
||||
methods: [POST]
|
||||
|
||||
jo_in_submit:
|
||||
path: /job-order/incoming
|
||||
controller: App\Controller\JobOrderController::incomingSubmit
|
||||
methods: [POST]
|
||||
|
||||
jo_proc:
|
||||
path: /job-order/processing
|
||||
controller: App\Controller\JobOrderController::listRows
|
||||
methods: [GET]
|
||||
defaults:
|
||||
tier: "proc"
|
||||
|
||||
jo_proc_rows:
|
||||
path: /job-order/processing-rows
|
||||
controller: App\Controller\JobOrderController::getRows
|
||||
methods: [POST]
|
||||
defaults:
|
||||
tier: "proc"
|
||||
|
||||
jo_proc_form:
|
||||
path: /job-order/processing/{id}
|
||||
controller: App\Controller\JobOrderController::processingForm
|
||||
|
|
@ -27,3 +31,27 @@ jo_proc_submit:
|
|||
path: /job-order/processing/{id}
|
||||
controller: App\Controller\JobOrderController::processingSubmit
|
||||
methods: [POST]
|
||||
|
||||
jo_assign:
|
||||
path: /job-order/assigning
|
||||
controller: App\Controller\JobOrderController::listRows
|
||||
methods: [GET]
|
||||
defaults:
|
||||
tier: "assign"
|
||||
|
||||
jo_assign_rows:
|
||||
path: /job-order/assigning-rows
|
||||
controller: App\Controller\JobOrderController::getRows
|
||||
methods: [POST]
|
||||
defaults:
|
||||
tier: "assign"
|
||||
|
||||
jo_assign_form:
|
||||
path: /job-order/assigning/{id}
|
||||
controller: App\Controller\JobOrderController::assigningForm
|
||||
methods: [GET]
|
||||
|
||||
jo_assign_submit:
|
||||
path: /job-order/assigning/{id}
|
||||
controller: App\Controller\JobOrderController::assigningSubmit
|
||||
methods: [POST]
|
||||
|
|
@ -12,6 +12,19 @@ span.has-danger,
|
|||
border-color: #f4516c;
|
||||
}
|
||||
|
||||
.table-frame {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.table-frame.form-control-danger {
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.table-frame > .table {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none !important;
|
||||
}
|
||||
|
|
@ -104,6 +117,10 @@ span.has-danger,
|
|||
font-weight: 400;
|
||||
}
|
||||
|
||||
.table-vcenter td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.placeholder-row td {
|
||||
background-color: #fff !important;
|
||||
padding: 32px 0 !important;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ class JobOrderController extends BaseController
|
|||
$params = $this->initParameters('jo_in');
|
||||
$params['obj'] = new JobOrder();
|
||||
$params['mode'] = 'create';
|
||||
$params['submit_url'] = $this->generateUrl('jo_in_submit');
|
||||
$params['return_url'] = $this->generateUrl('jo_in');
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
|
|
@ -122,19 +124,60 @@ class JobOrderController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
public function processingList()
|
||||
protected function checkTier($tier)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
// check specified tier
|
||||
switch ($tier) {
|
||||
case 'proc':
|
||||
$tier_key = 'jo_proc';
|
||||
$tier_name = 'Processing';
|
||||
$rows_route = 'jo_proc_rows';
|
||||
$edit_route = 'jo_proc_form';
|
||||
$jo_status = JOStatus::PENDING;
|
||||
break;
|
||||
case 'assign':
|
||||
$tier_key = 'jo_assign';
|
||||
$tier_name = 'Assigning';
|
||||
$rows_route = 'jo_assign_rows';
|
||||
$edit_route = 'jo_assign_form';
|
||||
$jo_status = JOStatus::RIDER_ASSIGN;
|
||||
break;
|
||||
default:
|
||||
$exception = $this->createAccessDeniedException('No access.');
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$params = $this->initParameters('jo_proc');
|
||||
// check acl
|
||||
$this->denyAccessUnlessGranted($tier_key . '.list', null, 'No access.');
|
||||
|
||||
// return params if allowed access
|
||||
return [
|
||||
'key' => $tier_key,
|
||||
'name' => $tier_name,
|
||||
'rows_route' => $rows_route,
|
||||
'edit_route' => $edit_route,
|
||||
'jo_status' => $jo_status
|
||||
];
|
||||
}
|
||||
|
||||
public function listRows($tier)
|
||||
{
|
||||
// check which job order tier is being called for and confirm access
|
||||
$tier_params = $this->checkTier($tier);
|
||||
|
||||
$params = $this->initParameters($tier_params['key']);
|
||||
|
||||
$params['tier_name'] = $tier_params['name'];
|
||||
$params['rows_route'] = $tier_params['rows_route'];
|
||||
|
||||
// response
|
||||
return $this->render('job-order/list.html.twig', $params);
|
||||
}
|
||||
|
||||
public function processingRows(Request $req)
|
||||
public function getRows(Request $req, $tier)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
// check which job order tier is being called for and confirm access
|
||||
$tier_params = $this->checkTier($tier);
|
||||
|
||||
// get query builder
|
||||
$qb = $this->getDoctrine()
|
||||
|
|
@ -149,7 +192,7 @@ class JobOrderController extends BaseController
|
|||
->join('q.cus_vehicle', 'cv')
|
||||
->join('q.customer', 'c');
|
||||
|
||||
$this->setQueryFilters($datatable, $tquery, $qb);
|
||||
$this->setQueryFilters($datatable, $tquery, $qb, $tier_params['jo_status']);
|
||||
|
||||
$total = $tquery->getQuery()
|
||||
->getSingleScalarResult();
|
||||
|
|
@ -176,7 +219,7 @@ class JobOrderController extends BaseController
|
|||
->addSelect('c.first_name as customer_name')
|
||||
->addSelect('c.last_name as cust_last_name');
|
||||
|
||||
$this->setQueryFilters($datatable, $query, $qb);
|
||||
$this->setQueryFilters($datatable, $query, $qb, $tier_params['jo_status']);
|
||||
|
||||
// check if sorting is present, otherwise use default
|
||||
if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) {
|
||||
|
|
@ -222,7 +265,7 @@ class JobOrderController extends BaseController
|
|||
$row['flag_advance'] = $orow[0]->isAdvanceOrder();
|
||||
|
||||
// add crud urls
|
||||
$row['meta']['update_url'] = $this->generateUrl('jo_proc_form', ['id' => $row['id']]);
|
||||
$row['meta']['update_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $row['id']]);
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
|
@ -239,7 +282,7 @@ class JobOrderController extends BaseController
|
|||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
$params = $this->initParameters('jo_proc');
|
||||
$params['mode'] = 'update';
|
||||
$params['mode'] = 'update-processing';
|
||||
|
||||
// get row data
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
|
@ -252,8 +295,6 @@ class JobOrderController extends BaseController
|
|||
// get parent associations
|
||||
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
|
||||
$params['customers'] = $em->getRepository(Customer::class)->findAll();
|
||||
$params['outlet'] = $em->getRepository(Outlet::class)->findAll();
|
||||
$params['rider'] = $em->getRepository(Rider::class)->findAll();
|
||||
$params['service_types'] = ServiceType::getCollection();
|
||||
$params['statuses'] = JOStatus::getCollection();
|
||||
|
||||
|
|
@ -289,6 +330,8 @@ class JobOrderController extends BaseController
|
|||
}
|
||||
|
||||
$params['obj'] = $obj;
|
||||
$params['submit_url'] = $this->generateUrl('jo_proc_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_proc');
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
|
|
@ -296,7 +339,7 @@ class JobOrderController extends BaseController
|
|||
|
||||
public function processingSubmit(Request $req, ValidatorInterface $validator, $id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
// initialize error list
|
||||
$error_array = [];
|
||||
|
|
@ -309,8 +352,6 @@ class JobOrderController extends BaseController
|
|||
if (empty($obj))
|
||||
throw $this->createNotFoundException('The item does not exist');
|
||||
|
||||
error_log(print_r($req->request->all(), true));
|
||||
|
||||
// check if lat and lng are provided
|
||||
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
|
||||
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||
|
|
@ -371,12 +412,149 @@ class JobOrderController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
public function assigningForm(MapTools $map_tools, $id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_assign.list', null, 'No access.');
|
||||
|
||||
$params = $this->initParameters('jo_assign');
|
||||
$params['mode'] = 'update-assigning';
|
||||
|
||||
// get row data
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||
|
||||
// make sure this row exists
|
||||
if (empty($obj))
|
||||
throw $this->createNotFoundException('The item does not exist');
|
||||
|
||||
// get parent associations
|
||||
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
|
||||
$params['customers'] = $em->getRepository(Customer::class)->findAll();
|
||||
$params['service_types'] = ServiceType::getCollection();
|
||||
$params['statuses'] = JOStatus::getCollection();
|
||||
|
||||
// get closest outlets
|
||||
$outlets = $map_tools->getClosestOutlets($obj->getCoordinates(), 10, date("H:i:s"));
|
||||
|
||||
$params['outlets'] = [];
|
||||
|
||||
// format duration and distance into friendly time
|
||||
foreach ($outlets as $outlet) {
|
||||
// duration
|
||||
$seconds = $outlet['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" : '') : '');
|
||||
} else {
|
||||
$outlet['duration'] = false;
|
||||
}
|
||||
|
||||
// distance
|
||||
$meters = $outlet['distance'];
|
||||
|
||||
if (!empty($meters) && $meters > 0) {
|
||||
$outlet['distance'] = round($meters / 1000) . " km";
|
||||
} else {
|
||||
$outlet['distance'] = false;
|
||||
}
|
||||
|
||||
$params['outlets'][] = $outlet;
|
||||
}
|
||||
|
||||
$params['obj'] = $obj;
|
||||
$params['submit_url'] = $this->generateUrl('jo_assign_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_assign');
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
}
|
||||
|
||||
public function assigningSubmit(Request $req, ValidatorInterface $validator, $id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_assign.list', null, 'No access.');
|
||||
|
||||
// initialize error list
|
||||
$error_array = [];
|
||||
|
||||
// get object data
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||
|
||||
// make sure this object exists
|
||||
if (empty($obj))
|
||||
throw $this->createNotFoundException('The item does not exist');
|
||||
|
||||
// check if lat and lng are provided
|
||||
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
|
||||
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||
}
|
||||
|
||||
// check if rider is set
|
||||
if (empty($req->request->get('rider'))) {
|
||||
$error_array['rider'] = 'No rider selected.';
|
||||
} else {
|
||||
// get rider
|
||||
$rider = $em->getRepository(Rider::class)->find($req->request->get('rider'));
|
||||
|
||||
if (empty($rider)) {
|
||||
$error_array['rider'] = 'Invalid rider specified.';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error_array)) {
|
||||
// coordinates
|
||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||
|
||||
// set and save values
|
||||
$obj->setDateSchedule(DateTime::createFromFormat("d M Y h:i A", $req->request->get('date_schedule_date') . " " . $req->request->get('date_schedule_time')))
|
||||
->setCoordinates($point)
|
||||
->setAdvanceOrder($req->request->get('flag_advance') ?? false)
|
||||
->setServiceType($req->request->get('service_type'))
|
||||
->setSource('web')
|
||||
->setStatus($req->request->get('status'))
|
||||
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||
->setAgentNotes($req->request->get('agent_notes'))
|
||||
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||
->setRider($rider);
|
||||
|
||||
// validate
|
||||
$errors = $validator->validate($obj);
|
||||
|
||||
// add errors to list
|
||||
foreach ($errors as $error) {
|
||||
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// check if any errors were found
|
||||
if (!empty($error_array)) {
|
||||
// return validation failure response
|
||||
return $this->json([
|
||||
'success' => false,
|
||||
'errors' => $error_array
|
||||
], 422);
|
||||
}
|
||||
|
||||
// validated! save the entity
|
||||
$em->flush();
|
||||
|
||||
// return successful response
|
||||
return $this->json([
|
||||
'success' => 'Changes have been saved!'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 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) {
|
||||
protected function setQueryFilters($datatable, &$query, $qb, $status) {
|
||||
error_log($status);
|
||||
$query->where('q.status = :status')
|
||||
->setParameter('status', 'pending');
|
||||
->setParameter('status', $status);
|
||||
|
||||
// get only pending rows
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class JobOrder
|
|||
|
||||
// status of the job order
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
* @ORM\Column(type="string", length=15)
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Ramcar;
|
|||
class JOStatus
|
||||
{
|
||||
const PENDING = 'pending';
|
||||
const RIDER_ASSIGN = 'rider_assign';
|
||||
const ASSIGNED = 'assigned';
|
||||
const IN_PROGRESS = 'in_progress';
|
||||
const CANCELLED = 'cancelled';
|
||||
|
|
@ -12,6 +13,7 @@ class JOStatus
|
|||
|
||||
const COLLECTION = [
|
||||
'pending' => 'Pending',
|
||||
'rider_assign' => 'For Rider Assignment',
|
||||
'assigned' => 'Assigned',
|
||||
'in_progress' => 'In Progress',
|
||||
'cancelled' => 'Cancelled',
|
||||
|
|
|
|||
|
|
@ -22,9 +22,12 @@
|
|||
<i class="flaticon-transport"></i>
|
||||
</span>
|
||||
<h3 class="m-portlet__head-text">
|
||||
{% if mode == 'update' %}
|
||||
{% if mode == 'update-processing' %}
|
||||
Processing
|
||||
<small>{{ obj.getID() }}</small>
|
||||
{% elseif mode == 'update-assigning' %}
|
||||
Assigning
|
||||
<small>{{ obj.getID() }}</small>
|
||||
{% else %}
|
||||
Incoming
|
||||
{% endif %}
|
||||
|
|
@ -32,7 +35,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ mode == 'update' ? url('jo_proc_submit', {'id': obj.getId()}) : url('jo_in_submit') }}">
|
||||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ submit_url }}">
|
||||
<div class="m-portlet__body">
|
||||
|
||||
{% if mode == 'create' %}
|
||||
|
|
@ -47,7 +50,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="m-form__section{{ mode == 'update' ? ' m-form__section--first' }}">
|
||||
<div class="m-form__section{{ mode != 'create' ? ' m-form__section--first' }}">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Customer Details
|
||||
|
|
@ -202,7 +205,7 @@
|
|||
<select class="form-control m-input" name="status">
|
||||
<!--<option value=""></option>-->
|
||||
{% for key, status in statuses %}
|
||||
<option value="{{ key }}"{{ obj.getStatus == status ? ' selected' }}>{{ status }}</option>
|
||||
<option value="{{ key }}"{{ obj.getStatus == key ? ' selected' }}>{{ status }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class="form-control-feedback hide" data-field="status"></div>
|
||||
|
|
@ -226,6 +229,7 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label name="coordinates" data-field="coordinates">Coordinates</label>
|
||||
<div class="form-control-feedback hide" data-field="coordinates"></div>
|
||||
<input type="hidden" id="map_lat" name="coord_lat" value="">
|
||||
<input type="hidden" id="map_lng" name="coord_lng" value="">
|
||||
<div class="input-group">
|
||||
|
|
@ -237,7 +241,6 @@
|
|||
</span>
|
||||
</div>
|
||||
<div id="m_gmap" style="height:600px;"></div>
|
||||
<div class="form-control-feedback hide" data-field="coordinates"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -320,7 +323,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% if mode == 'update' %}
|
||||
{% if mode == 'update-processing' %}
|
||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__heading">
|
||||
|
|
@ -330,57 +333,195 @@
|
|||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<table id="outlets-table" class="table table-compact table-hover table-clickable m-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>Numbers</th>
|
||||
<th>Opening</th>
|
||||
<th>Closing</th>
|
||||
<th class="text-right">Sales Count</th>
|
||||
<th class="text-right">Sales Amount</th>
|
||||
<th class="text-right">Service Count</th>
|
||||
<th class="text-right">Distance</th>
|
||||
<th class="text-right">Travel Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="placeholder-row{{ outlets|length > 0 ? ' hide' }}">
|
||||
<td colspan="10">
|
||||
No items to display.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% for outlet in outlets %}
|
||||
<tr 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.getAddress }}</td>
|
||||
<td>{{ outlet.outlet.getContactNumbers }}</td>
|
||||
<td>{{ outlet.outlet.getTimeOpen|date("g:i A") }}</td>
|
||||
<td>{{ outlet.outlet.getTimeClose|date("g:i A") }}</td>
|
||||
<td class="text-right">0.00</td>
|
||||
<td class="text-right">0.00</td>
|
||||
<td class="text-right">0</td>
|
||||
<td class="text-right">{{ outlet.distance ? outlet.distance : '-' }}</td>
|
||||
<td class="text-right">{{ outlet.duration ? outlet.duration : '-' }}</td>
|
||||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>Numbers</th>
|
||||
<th>Opening</th>
|
||||
<th>Closing</th>
|
||||
<th class="text-right">Sales Count</th>
|
||||
<th class="text-right">Sales Amount</th>
|
||||
<th class="text-right">Service Count</th>
|
||||
<th class="text-right">Distance</th>
|
||||
<th class="text-right">Travel Time</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="placeholder-row{{ outlets|length > 0 ? ' hide' }}">
|
||||
<td colspan="10">
|
||||
No items to display.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% for outlet in outlets %}
|
||||
<tr 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.getAddress }}</td>
|
||||
<td>{{ outlet.outlet.getContactNumbers }}</td>
|
||||
<td>{{ outlet.outlet.getTimeOpen|date("g:i A") }}</td>
|
||||
<td>{{ outlet.outlet.getTimeClose|date("g:i A") }}</td>
|
||||
<td class="text-right">0.00</td>
|
||||
<td class="text-right">0.00</td>
|
||||
<td class="text-right">0</td>
|
||||
<td class="text-right">{{ outlet.distance ? outlet.distance : '-' }}</td>
|
||||
<td class="text-right">{{ outlet.duration ? outlet.duration : '-' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outlet_map" style="height:600px;"></div>
|
||||
{% endif %}
|
||||
|
||||
{% if mode == 'update-assigning' %}
|
||||
<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">
|
||||
Hub Details
|
||||
</h3>
|
||||
</div>
|
||||
<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 ? obj.getOutlet.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 ? obj.getOutlet.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 ? obj.getOutlet.getHub.getTimeClose|date("g:i A") }}" disabled>
|
||||
<div class="form-control-feedback hide" data-field="hub_time_close"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-6">
|
||||
<label data-field="hub_address">
|
||||
Address
|
||||
</label>
|
||||
<textarea class="form-control m-input" id="hub-address" rows="4" name="hub_address" disabled>{{ obj.getOutlet ? obj.getOutlet.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 ? obj.getOutlet.getHub.getContactNumbers }}</textarea>
|
||||
<div class="form-control-feedback hide" data-field="hub_contact_nums"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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 ? 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 ? 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 ? 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 ? 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 ? 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">
|
||||
<h3 class="m-form__heading-title">
|
||||
Rider Assignment
|
||||
</h3>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label>Click on a row to select a rider</label>
|
||||
<div class="form-control-feedback hide" data-field="rider"></div>
|
||||
<div class="table-frame" data-name="rider">
|
||||
<table id="riders-table" class="table table-compact table-hover table-clickable table-vcenter m-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Contact No.</th>
|
||||
<th>Plate Number</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="placeholder-row{{ obj.getOutlet.getHub.getRiders|length > 0 ? ' hide' }}">
|
||||
<td colspan="6">
|
||||
No items to display.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% for rider in obj.getOutlet.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>
|
||||
</td>
|
||||
<td>{{ rider.getFirstName }}</td>
|
||||
<td>{{ rider.getLastName }}</td>
|
||||
<td>{{ rider.getContactNumber }}</td>
|
||||
<td>{{ rider.getPlateNumber }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
<a href="{{ url('jo_in') }}" class="btn btn-secondary">Cancel</a>
|
||||
{% if mode != 'create' %}
|
||||
<a href="{{ return_url }}" class="btn btn-secondary">Cancel</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -454,11 +595,11 @@ $(function() {
|
|||
}
|
||||
});
|
||||
|
||||
{% if mode == 'update' %}
|
||||
// check if we need to set map
|
||||
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||
selectPoint(map, latlng);
|
||||
// check if we need to set map
|
||||
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||
selectPoint(map, latlng);
|
||||
|
||||
{% if mode == 'update-processing' %}
|
||||
// display outlet map
|
||||
var omap = new GMaps({
|
||||
div: '#outlet_map',
|
||||
|
|
@ -499,11 +640,16 @@ $(function() {
|
|||
// add invoice items to data
|
||||
fields['invoice_items'] = invoiceItems;
|
||||
|
||||
{% if mode == 'update' %}
|
||||
{% if mode == 'update-processing' %}
|
||||
// add selected outlet to data
|
||||
fields['outlet'] = selectedOutlet;
|
||||
{% endif %}
|
||||
|
||||
{% if mode == 'update-assigning' %}
|
||||
// add selected rider to data
|
||||
fields['rider'] = selectedRider;
|
||||
{% endif %}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
|
|
@ -518,7 +664,7 @@ $(function() {
|
|||
text: 'Your changes have been saved!',
|
||||
type: 'success',
|
||||
onClose: function() {
|
||||
window.location.href = "{{ mode == 'create' ? url('jo_in') : url('jo_proc') }}";
|
||||
window.location.href = "{{ return_url }}";
|
||||
}
|
||||
});
|
||||
}).fail(function(response) {
|
||||
|
|
@ -530,7 +676,7 @@ $(function() {
|
|||
|
||||
// display errors contextually
|
||||
$.each(errors, function(field, msg) {
|
||||
var formfield = $("[name='" + field + "']");
|
||||
var formfield = $("[name='" + field + "'], [data-name='" + field + "']");
|
||||
var label = $("label[data-field='" + field + "']");
|
||||
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
|
||||
|
||||
|
|
@ -821,29 +967,52 @@ $(function() {
|
|||
}
|
||||
});
|
||||
|
||||
{% if mode == 'update' %}
|
||||
{% if mode == 'update-processing' %}
|
||||
var selectedOutlet = '{{ obj.getOutlet ? obj.getOutlet.getID : "" }}';
|
||||
|
||||
var selectedOutlet = '{{ obj.getOutlet ? obj.getOutlet.getID : "" }}';
|
||||
$("#outlets-table tbody tr").click(function() {
|
||||
var id = $(this).data('id');
|
||||
|
||||
$("#outlets-table tbody tr").click(function() {
|
||||
var id = $(this).data('id');
|
||||
if (id != selectedOutlet) {
|
||||
// highlight this row, set outlet value
|
||||
$("#outlets-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
||||
|
||||
if (id != selectedOutlet) {
|
||||
// highlight this row, set outlet value
|
||||
$("#outlets-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
|
||||
selectedOutlet = id;
|
||||
} else {
|
||||
// unhighlight this row
|
||||
$(this).removeClass('m-table__row--primary');
|
||||
|
||||
// set value
|
||||
selectedOutlet = id;
|
||||
} else {
|
||||
// unhighlight this row
|
||||
$(this).removeClass('m-table__row--primary');
|
||||
// remove id value
|
||||
selectedOutlet = '';
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
// remove id value
|
||||
selectedOutlet = '';
|
||||
}
|
||||
});
|
||||
{% if mode == 'update-assigning' %}
|
||||
var selectedRider = '{{ obj.getRider ? obj.getRider.getID : "" }}';
|
||||
|
||||
$("#riders-table tbody tr").click(function() {
|
||||
var id = $(this).data('id');
|
||||
|
||||
if (id != selectedRider) {
|
||||
// highlight this row, set outlet value
|
||||
$("#riders-table").find('.m-table__row--primary').removeClass('m-table__row--primary');
|
||||
|
||||
$(this).addClass('m-table__row--primary');
|
||||
|
||||
// set value
|
||||
selectedRider = id;
|
||||
} else {
|
||||
// unhighlight this row
|
||||
$(this).removeClass('m-table__row--primary');
|
||||
|
||||
// remove id value
|
||||
selectedRider = '';
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<div class="d-flex align-items-center">
|
||||
<div class="mr-auto">
|
||||
<h3 class="m-subheader__title">
|
||||
Job Orders (Processing)
|
||||
Job Orders ({{ tier_name|capitalize }})
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
type: 'remote',
|
||||
source: {
|
||||
read: {
|
||||
url: '{{ url("jo_proc_rows") }}',
|
||||
url: '{{ url(rows_route) }}',
|
||||
method: 'POST'
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue