diff --git a/src/Entity/Hub.php b/src/Entity/Hub.php index 53200b80..53845ccc 100644 --- a/src/Entity/Hub.php +++ b/src/Entity/Hub.php @@ -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; diff --git a/src/Entity/Rider.php b/src/Entity/Rider.php index d6bdb173..d3b6cc71 100644 --- a/src/Entity/Rider.php +++ b/src/Entity/Rider.php @@ -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; + } } diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index fb5c7438..3f4ef386 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -532,8 +532,8 @@ Branch Distance Travel Time - Sales (Day) - Services (Day) + Riders Available + Job Backlog Contact Numbers @@ -638,14 +638,15 @@ - + {% set avail_riders = obj.getHub.getAvailableRiders|default([]) %} + - No items to display. + No riders available. {% if obj.getHub %} - {% for rider in obj.getHub.getRiders %} + {% for rider in avail_riders %}