Merge branch '270-final-cmb-fixes' of gitlab.com:jankstudio/resq into 330-entity-logging-service-bundle
This commit is contained in:
commit
28ae096a87
13 changed files with 139 additions and 23 deletions
|
|
@ -46,3 +46,13 @@ rider_active_jo:
|
|||
path: /riders/{id}/activejo/{jo_id}
|
||||
controller: App\Controller\RiderController::riderActiveJO
|
||||
methods: [GET]
|
||||
|
||||
rider_priority_up_jo:
|
||||
path: /riders/{id}/priority_up/{jo_id}
|
||||
controller: App\Controller\RiderController::priorityUpJO
|
||||
methods: [GET]
|
||||
|
||||
rider_priority_down_jo:
|
||||
path: /riders/{id}/priority_down/{jo_id}
|
||||
controller: App\Controller\RiderController::priorityDownJO
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -277,13 +277,13 @@ class JobOrderController extends Controller
|
|||
$rows[$key]['meta']['reassign_hub_url'] = $this->generateUrl('jo_open_hub_form', ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['reassign_rider_url'] = $this->generateUrl('jo_open_rider_form', ['id' => $jo_id]);
|
||||
// $rows[$key]['meta']['edit_url'] = $this->generateUrl('jo_open_edit_form', ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['edit_url'] = $this->generateUrl($jo_handler->getEditRoute($jo_id), ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['edit_url'] = $this->generateUrl($jo_handler->getEditRoute($jo_id, $tier_params['edit_route']), ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// $rows[$key]['meta']['update_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['update_url'] = $this->generateUrl($jo_handler->getEditRoute($jo_id), ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['update_url'] = $this->generateUrl($jo_handler->getEditRoute($jo_id, $tier_params['edit_route']), ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]);
|
||||
$rows[$key]['meta']['pdf_url'] = $this->generateUrl('jo_pdf_form', ['id' => $jo_id]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -534,6 +534,66 @@ class RiderController extends Controller
|
|||
$mclient->sendRiderEvent($jo, $payload);
|
||||
|
||||
|
||||
return $this->redirecttoRoute('rider_update', ['id' => $rider->getID()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ParamConverter("rider", class="App\Entity\Rider")
|
||||
* @ParamConverter("jo", class="App\Entity\JobOrder", options={"id": "jo_id"})
|
||||
*/
|
||||
public function priorityUpJO(EntityManagerInterface $em, Rider $rider, JobOrder $jo)
|
||||
{
|
||||
$jos = $rider->getOpenJobOrders();
|
||||
|
||||
// set new priority
|
||||
$old_prio = $jo->getPriority();
|
||||
$new_prio = $old_prio - 1;
|
||||
$jo->setPriority($new_prio);
|
||||
|
||||
// go through all rider open JOs and set priority when needed
|
||||
foreach ($jos as $rider_jo)
|
||||
{
|
||||
// check if it's the same
|
||||
if ($rider_jo->getID() == $jo->getID())
|
||||
continue;
|
||||
|
||||
// if priority is the same as old priority, move it down
|
||||
if ($new_prio == $rider_jo->getPriority())
|
||||
$rider_jo->setPriority($rider_jo->getPriority() + 1);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
return $this->redirecttoRoute('rider_update', ['id' => $rider->getID()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ParamConverter("rider", class="App\Entity\Rider")
|
||||
* @ParamConverter("jo", class="App\Entity\JobOrder", options={"id": "jo_id"})
|
||||
*/
|
||||
public function priorityDownJO(EntityManagerInterface $em, Rider $rider, JobOrder $jo)
|
||||
{
|
||||
$jos = $rider->getOpenJobOrders();
|
||||
|
||||
// set new priority
|
||||
$old_prio = $jo->getPriority();
|
||||
$new_prio = $old_prio + 1;
|
||||
$jo->setPriority($new_prio);
|
||||
|
||||
// go through all rider open JOs and set priority when needed
|
||||
foreach ($jos as $rider_jo)
|
||||
{
|
||||
// check if it's the same
|
||||
if ($rider_jo->getID() == $jo->getID())
|
||||
continue;
|
||||
|
||||
// if priority is the same as old priority, move it down
|
||||
if ($new_prio == $rider_jo->getPriority())
|
||||
$rider_jo->setPriority($rider_jo->getPriority() - 1);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
return $this->redirecttoRoute('rider_update', ['id' => $rider->getID()]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,6 +280,14 @@ class JobOrder
|
|||
*/
|
||||
protected $hub_rejections;
|
||||
|
||||
// priority order for riders
|
||||
// NOTE: this is a workaround since changeing rider to jo rider assignment with details requires
|
||||
// too many changes and may break too many things.
|
||||
/**
|
||||
* @ORM\Column(type="integer", options={"default": 0}))
|
||||
*/
|
||||
protected $priority;
|
||||
|
||||
// meta
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
|
|
@ -304,6 +312,7 @@ class JobOrder
|
|||
$this->flag_rider_rating = false;
|
||||
$this->flag_coolant = false;
|
||||
|
||||
$this->priority = 0;
|
||||
$this->meta = [];
|
||||
}
|
||||
|
||||
|
|
@ -811,6 +820,17 @@ class JobOrder
|
|||
return $this->hub_rejections;
|
||||
}
|
||||
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
public function addMeta($id, $value)
|
||||
{
|
||||
$this->meta[$id] = $value;
|
||||
|
|
@ -825,5 +845,4 @@ class JobOrder
|
|||
|
||||
return $this->meta[$id];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class Rider
|
|||
// job orders that the rider has done
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="rider")
|
||||
* @ORM\OrderBy({"priority" = "ASC"})
|
||||
*/
|
||||
protected $job_orders;
|
||||
|
||||
|
|
|
|||
|
|
@ -518,6 +518,19 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
// set priority based on rider's existing open job orders
|
||||
$rider_jos = $rider->getOpenJobOrders();
|
||||
|
||||
// get maximum priority then add 1
|
||||
// NOTE: this can be a bit buggy due to concurrency issues
|
||||
// ideally have to lock jo table, but that isn't feasible right now
|
||||
$priority = 0;
|
||||
foreach ($rider_jos as $rider_jo)
|
||||
{
|
||||
if ($priority < $rider_jo->getPriority())
|
||||
$priority = $rider_jo->getPriority() + 1;
|
||||
}
|
||||
|
||||
// get discount and set to meta
|
||||
$discount = $req->request->get('invoice_discount', []);
|
||||
|
||||
|
|
@ -555,7 +568,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
->setModeOfPayment($req->request->get('mode_of_payment'))
|
||||
->setLandmark($req->request->get('landmark'))
|
||||
->setHub($hub)
|
||||
->setRider($rider);
|
||||
->setRider($rider)
|
||||
->setPriority($priority);
|
||||
|
||||
$jo->addMeta('discount', $discount);
|
||||
$jo->addMeta('service_charges', $service_charges);
|
||||
|
|
@ -2065,13 +2079,6 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
$pdf->Cell($label_width, $line_height, 'Plate Number:');
|
||||
$pdf->MultiCell($val_width, $line_height, $cv ? $cv->getPlateNumber() : '', 0, 'L');
|
||||
|
||||
// get Y after left cell
|
||||
$y1 = $pdf->GetY();
|
||||
|
||||
$pdf->SetXY($col2_x, $y);
|
||||
$pdf->Cell($label_width, $line_height, 'Vehicle Color:');
|
||||
$pdf->MultiCell(0, $line_height, $cv ? $cv->getColor() : '', 0, 'L');
|
||||
|
||||
// get Y after right cell
|
||||
$y2 = $pdf->GetY();
|
||||
|
||||
|
|
@ -2993,7 +3000,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
public function getEditRoute($jo_id)
|
||||
public function getEditRoute($jo_id, $tier = null)
|
||||
{
|
||||
$jo = $this->em->getRepository(JobOrder::class)->find($jo_id);
|
||||
if (empty($jo))
|
||||
|
|
|
|||
|
|
@ -310,6 +310,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: check status before saving since JO might already
|
||||
// have a status that needs to be retained
|
||||
|
||||
if (empty($error_array)) {
|
||||
// get current user
|
||||
$user = $this->security->getUser();
|
||||
|
|
@ -2585,7 +2588,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
public function getEditRoute()
|
||||
public function getEditRoute($jo_id, $tier)
|
||||
{
|
||||
if (empty($tier))
|
||||
return 'jo_open_edit_form';
|
||||
|
||||
return $tier;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,4 +98,7 @@ interface JobOrderHandlerInterface
|
|||
|
||||
// check if service type is new battery
|
||||
public function checkIfNewBattery(JobOrder $jo);
|
||||
|
||||
// return the edit route, based on tier and form
|
||||
public function getEditRoute(int $jo_id, $tier);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,17 +206,17 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-3">
|
||||
<label data-field="current_battery">Current Battery</label>
|
||||
<input type="text" name="current_battery" id="current-battery" class="form-control m-input" value="{{ obj.getCustomerVehicle and obj.getCustomerVehicle.getCurrentBattery ? obj.getCustomerVehicle.getCurrentBattery.getManufacturer.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getModel.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getSize.getName ~ ' (' ~ obj.getCustomerVehicle.getCurrentBattery.getProductCode ~ ')' }}" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="current_battery" id="current-battery" class="form-control m-input battery_field" value="{{ obj.getCustomerVehicle and obj.getCustomerVehicle.getCurrentBattery ? obj.getCustomerVehicle.getCurrentBattery.getManufacturer.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getModel.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getSize.getName ~ ' (' ~ obj.getCustomerVehicle.getCurrentBattery.getProductCode ~ ')' }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="current_battery"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="warranty_code">Serial Number</label>
|
||||
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}">
|
||||
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input battery_field" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}">
|
||||
<div class="form-control-feedback hide" data-field="warranty_code"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="warranty_expiration">Warranty Expiration Date</label>
|
||||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input" value="{{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") : '' }}" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input battery_field" value="{{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") : '' }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="warranty_expiration"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1270,6 +1270,7 @@ $(function() {
|
|||
$('.cust_field').val('');
|
||||
$('.cv_field').val('');
|
||||
$('#cv-make').val('');
|
||||
$('.battery_field').val('');
|
||||
} else {
|
||||
$('.cust_field').prop('disabled', true);
|
||||
$('.cv_field').prop('disabled', true);
|
||||
|
|
|
|||
|
|
@ -206,17 +206,17 @@
|
|||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-3">
|
||||
<label data-field="current_battery">Current Battery</label>
|
||||
<input type="text" name="current_battery" id="current-battery" class="form-control m-input" value="{{ obj.getCustomerVehicle and obj.getCustomerVehicle.getCurrentBattery ? obj.getCustomerVehicle.getCurrentBattery.getManufacturer.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getModel.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getSize.getName ~ ' (' ~ obj.getCustomerVehicle.getCurrentBattery.getProductCode ~ ')' }}" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="current_battery" id="current-battery" class="form-control m-input battery_field" value="{{ obj.getCustomerVehicle and obj.getCustomerVehicle.getCurrentBattery ? obj.getCustomerVehicle.getCurrentBattery.getManufacturer.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getModel.getName ~ ' ' ~ obj.getCustomerVehicle.getCurrentBattery.getSize.getName ~ ' (' ~ obj.getCustomerVehicle.getCurrentBattery.getProductCode ~ ')' }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="current_battery"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="warranty_code">Serial Number</label>
|
||||
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}">
|
||||
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input battery_field" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}">
|
||||
<div class="form-control-feedback hide" data-field="warranty_code"></div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<label data-field="warranty_expiration">Warranty Expiration Date</label>
|
||||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input" value="{{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") : '' }}" data-vehicle-field="1" disabled>
|
||||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input battery_field" value="{{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") : '' }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="warranty_expiration"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -806,6 +806,7 @@ var vdata = false;
|
|||
$('.cust_field').val('');
|
||||
$('.cv_field').val('');
|
||||
$('#cv-make').val('');
|
||||
$('.battery_field').val('');
|
||||
} else {
|
||||
$('.cust_field').prop('disabled', true);
|
||||
$('.cv_field').prop('disabled', true);
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@
|
|||
sortable: false,
|
||||
overflow: 'visible',
|
||||
template: function (row, index, datatable) {
|
||||
var actions = '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View / Edit"><i class="la la-edit"></i></a>' + '<a href="' + row.meta.onestep_edit_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="One Step Edit"><i class="la la-edit"></i></a>';
|
||||
var actions = '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View / Edit"><i class="la la-edit"></i></a>';
|
||||
|
||||
return actions;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -148,9 +148,6 @@
|
|||
{% if is_granted('jo_open.edit') %}
|
||||
actions += '<a href="' + row.meta.edit_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-reassign-hub" title="Edit"><i class="fa fa-file"></i></a>';
|
||||
{% endif %}
|
||||
{% if is_granted('jo_onestep.edit') %}
|
||||
actions += '<a href="' + row.meta.onestep_edit_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-reassign-hub" title="One Step Edit"><i class="fa fa-file"></i></a>';
|
||||
{% endif %}
|
||||
|
||||
return actions;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -180,6 +180,16 @@
|
|||
<td>{{ jo.getDeliveryAddress|default('') }}</td>
|
||||
<td>{% if jo.getID == active_jo_id %}<span class="m-badge m-badge--success m-badge--wide">Active</span>{% endif %}</td>
|
||||
<td>
|
||||
<a href="{{ url('rider_priority_up_jo', {'id': obj.getID, 'jo_id': jo.getID}) }}" class="btn m-btn m-btn--icon">
|
||||
<span>
|
||||
<i class="fa fa-angle-up"></i>
|
||||
</span>
|
||||
</a>
|
||||
<a href="{{ url('rider_priority_down_jo', {'id': obj.getID, 'jo_id': jo.getID}) }}" class="btn m-btn m-btn--icon">
|
||||
<span>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</span>
|
||||
</a>
|
||||
{% if jo.getID != active_jo_id %}
|
||||
<!-- TODO: make this submit via ajax post -->
|
||||
<a href="{{ url('rider_active_jo', {'id': obj.getID, 'jo_id': jo.getID}) }}" class="btn btn-danger m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
|
||||
|
|
|
|||
Loading…
Reference in a new issue