Add initial job order prioritization features #360
This commit is contained in:
parent
ebc9b77eda
commit
07753274c3
4 changed files with 66 additions and 0 deletions
|
|
@ -46,3 +46,13 @@ rider_active_jo:
|
||||||
path: /riders/{id}/activejo/{jo_id}
|
path: /riders/{id}/activejo/{jo_id}
|
||||||
controller: App\Controller\RiderController::riderActiveJO
|
controller: App\Controller\RiderController::riderActiveJO
|
||||||
methods: [GET]
|
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]
|
||||||
|
|
|
||||||
|
|
@ -534,6 +534,51 @@ class RiderController extends Controller
|
||||||
$mclient->sendRiderEvent($jo, $payload);
|
$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)
|
||||||
|
{
|
||||||
|
error_log("HERE");
|
||||||
|
error_log($rider->getID());
|
||||||
|
error_log($jo->getID());
|
||||||
|
|
||||||
|
$jos = $rider->getOpenJobOrders();
|
||||||
|
|
||||||
|
$old_prio = $jo->getPriority();
|
||||||
|
$new_prio = $old_prio - 1;
|
||||||
|
$jo->setPriority($new_prio);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
error_log("HERE");
|
||||||
|
error_log($rider->getID());
|
||||||
|
error_log($jo->getID());
|
||||||
|
|
||||||
return $this->redirecttoRoute('rider_update', ['id' => $rider->getID()]);
|
return $this->redirecttoRoute('rider_update', ['id' => $rider->getID()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ class Rider
|
||||||
// job orders that the rider has done
|
// job orders that the rider has done
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="rider")
|
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="rider")
|
||||||
|
* @ORM\OrderBy({"priority" = "ASC"})
|
||||||
*/
|
*/
|
||||||
protected $job_orders;
|
protected $job_orders;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,16 @@
|
||||||
<td>{{ jo.getDeliveryAddress|default('') }}</td>
|
<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>{% if jo.getID == active_jo_id %}<span class="m-badge m-badge--success m-badge--wide">Active</span>{% endif %}</td>
|
||||||
<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 %}
|
{% if jo.getID != active_jo_id %}
|
||||||
<!-- TODO: make this submit via ajax post -->
|
<!-- 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">
|
<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