Add availability flag for rider entity #UAT
This commit is contained in:
parent
ecd9ee0dcf
commit
dc3774a835
3 changed files with 35 additions and 5 deletions
|
|
@ -3,8 +3,11 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Ramcar\Location;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
use DateTime;
|
||||
|
|
@ -53,6 +56,14 @@ class Hub
|
|||
return $this->riders;
|
||||
}
|
||||
|
||||
public function getAvailableRiders()
|
||||
{
|
||||
$crit = Criteria::create();
|
||||
$crit->where(Criteria::expr()->eq('flag_available', true));
|
||||
|
||||
return $this->riders->matching($crit);
|
||||
}
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
return $this->users;
|
||||
|
|
|
|||
|
|
@ -80,11 +80,18 @@ class Rider
|
|||
*/
|
||||
protected $schedules;
|
||||
|
||||
// is the rider available or not
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $flag_available;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->job_orders = new ArrayCollection();
|
||||
$this->schedules = new ArrayCollection();
|
||||
$this->curr_rating = 0;
|
||||
$this->flag_available = false;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -211,4 +218,15 @@ class Rider
|
|||
|
||||
return $this->schedules->matching($criteria)[0];
|
||||
}
|
||||
|
||||
public function setAvailable($avail = true)
|
||||
{
|
||||
$this->flag_available = $avail;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return $this->flag_available;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -532,8 +532,8 @@
|
|||
<th>Branch</th>
|
||||
<th class="text-right">Distance</th>
|
||||
<th class="text-right">Travel Time</th>
|
||||
<th class="text-right">Sales (Day)</th>
|
||||
<th class="text-right">Services (Day)</th>
|
||||
<th class="text-right">Riders Available</th>
|
||||
<th class="text-right">Job Backlog</th>
|
||||
<th>Contact Numbers</th> </tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -638,14 +638,15 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="placeholder-row{{ obj.getHub and obj.getHub.getRiders|length > 0 ? ' hide' }}">
|
||||
{% set avail_riders = obj.getHub.getAvailableRiders|default([]) %}
|
||||
<tr class="placeholder-row{{ obj.getHub and avail_riders|length > 0 ? ' hide' }}">
|
||||
<td colspan="6">
|
||||
No items to display.
|
||||
No riders available.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% if obj.getHub %}
|
||||
{% for rider in obj.getHub.getRiders %}
|
||||
{% for rider in avail_riders %}
|
||||
<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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue