job_orders = new ArrayCollection(); $this->schedules = new ArrayCollection(); $this->sessions = new ArrayCollection(); $this->curr_rating = 0; $this->flag_available = true; $this->flag_active = true; $this->username = null; $this->password = ''; } public function getID() { return $this->id; } public function setFirstName($first_name) { $this->first_name = $first_name; return $this; } public function getFirstName() { return $this->first_name; } public function setLastName($last_name) { $this->last_name = $last_name; return $this; } public function getLastName() { return $this->last_name; } public function getFullName() { return $this->first_name . ' ' . $this->last_name; } public function setPlateNumber($plate_number) { $this->plate_number = $plate_number; return $this; } public function getPlateNumber() { return $this->plate_number; } public function setContactNumber($num) { $this->contact_num = $num; return $this; } public function getContactNumber() { return $this->contact_num; } public function setHub(Hub $hub) { $this->hub = $hub; return $this; } public function getHub() { return $this->hub; } public function clearHub() { $this->hub = null; return $this; } public function setImageFile($image_file) { $this->image_file = $image_file; return $this; } public function getImageFile() { return $this->image_file; } public function setCurrentRating($rating) { $this->curr_rating = $rating; return $this; } public function getCurrentRating() { return $this->curr_rating; } public function addSchedule(RiderSchedule $schedule) { $this->schedules->add($schedule); return $this; } public function clearSchedules() { $this->schedules->clear(); return $this; } public function removeSchedule(RiderSchedule $schedule) { $this->schedules->removeElement($schedule); return $this; } public function getSchedules() { return $this->schedules; } public function getScheduleForDay($day_of_week) { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('day_of_week', $day_of_week)) ->getFirstResult(1); return $this->schedules->matching($criteria)[0]; } public function setAvailable($avail = true) { // only set to available if they are active // non-active riders cannot be available if ($this->isActive() && $avail) $this->flag_available = true; else $this->flag_available = false; return $this; } public function isAvailable() { return $this->flag_available; } public function setActive($flag = true) { $this->flag_active = $flag; return $this; } public function isActive() { return $this->flag_active; } public function setUsername($username) { $this->username = $username; return $this; } public function getUsername() { return $this->username; } public function setPassword($pass) { // they have to pass the encoded password $this->password = $pass; return $this; } public function getPassword() { return $this->password; } public function getActiveJobOrder() { $active_status = [ JOStatus::ASSIGNED, JOStatus::IN_TRANSIT, JOStatus::IN_PROGRESS, ]; $criteria = Criteria::create(); $criteria->where(Criteria::expr()->in('status', $active_status)) ->getFirstResult(1); return $this->job_orders->matching($criteria)[0]; } public function getSessions() { return $this->sessions; } public function getMapLabel() { $map_label = $this->first_name .' ' . $this->last_name; return $map_label; } }