<?php
namespace AdminBundle\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Area
*/
#[ORM\Table(name: 'ctlf_area')]
#[ORM\Entity(repositoryClass: \AdminBundle\Repository\AreaRepository::class)]
class Area extends BaseEntity
{
const AREA_TYPE_POLYLINE = 'polyline';
const AREA_TYPE_POLYGON = 'polygon';
const AREA_TYPE_RECTANGLE = 'rectangle';
const AREA_TYPE_CIRCLE = 'circle';
const AREA_TYPE_MARKER = 'marker';
const AREA_TYPE_POSTCODE = 'postcode';
const CATEGORY_AIRPORT = 1;
const CATEGORY_PORT = 2;
const CATEGORY_TRAIN = 3;
const QUEUE_STATUS_JOINED = 1;
const QUEUE_STATUS_FULL = 2;
const QUEUE_STATUS_AVAILABLE = 3;
public static $categories = [
self::CATEGORY_AIRPORT => 'Airport',
self::CATEGORY_PORT => 'Port',
self::CATEGORY_TRAIN => 'Train',
];
public static $googleMapsCategories = [
self::CATEGORY_AIRPORT => 'airport',
self::CATEGORY_PORT => 'port',
self::CATEGORY_TRAIN => 'train_station',
];
public static $queueStatuses = [
self::QUEUE_STATUS_JOINED => 'Joined',
self::QUEUE_STATUS_FULL => 'Full',
self::QUEUE_STATUS_AVAILABLE => 'Available',
];
const BONUS_QUEUE = 10;
const TIME_FOR_QUEUE = 60;
const MAX_QUEUE_DAY = 2;
const MAX_ALLOWED_DISTANCE = 5;
const BUFFER_TIME_AFTER_QUEUE = 240;
/**
* @var integer
*/
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
protected $id;
/**
* @var string
*/
#[ORM\Column(name: 'area_code', type: 'string', length: 64)]
protected $areaCode;
/**
* @var string
*/
#[ORM\Column(name: 'area_name', type: 'string', length: 64)]
protected $areaName;
/**
* @var string
*/
#[ORM\Column(name: 'area_post_code', type: 'string', length: 64)]
protected $areaPostCode;
/**
* @var string
*/
#[ORM\Column(name: 'area_color', type: 'string', length: 64)]
protected $areaColor;
/**
* @var string
*/
#[ORM\Column(name: 'area_coords', type: 'text')]
protected $areaCoords;
/**
* @var string
*/
#[ORM\Column(name: 'area_type', type: 'string', length: 32)]
protected $areaType;
/**
* @var integer
*/
#[ORM\Column(name: 'area_status', type: 'integer', nullable: true)]
protected $areaStatus;
/**
* @var integer
*/
#[ORM\Column(name: 'area_drop_off_charge', type: 'integer', nullable: true)]
protected $areaDropOffCharge;
/**
* @var integer
*/
#[ORM\Column(name: 'area_pickup_charge', type: 'integer', nullable: true)]
protected $areaPickupCharge;
/**
* @var integer
*/
#[ORM\Column(name: 'area_pass_on_charge', type: 'integer', nullable: true)]
protected $areaPassOnCharge;
/**
* @var integer
*/
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(name: 'area_priority', type: 'integer', nullable: true)]
protected $areaPriority;
/**
* @var integer
*/
#[ORM\Column(name: 'category', type: 'integer', nullable: true)]
protected $category;
/**
* @var string
*/
#[ORM\Column(name: 'description', type: 'text', nullable: true)]
protected $description;
/**
* @var float
*/
#[ORM\Column(name: 'pmg_cost', type: 'float', scale: 2, nullable: true)]
protected $pmgCost;
/**
* @var integer
*/
#[ORM\Column(name: 'bonus_queue', type: 'integer', nullable: false, options: ['default' => 10])]
protected $bonusQueue = self::BONUS_QUEUE;
/**
* @var integer
*/
#[ORM\Column(name: 'time_for_queue', type: 'integer', nullable: false, options: ['default' => 60])]
protected $timeForQueue = self::TIME_FOR_QUEUE;
/**
* @var integer
*/
#[ORM\Column(name: 'max_queue_day', type: 'integer', nullable: false, options: ['default' => 2])]
protected $maxQueueDay = self::MAX_QUEUE_DAY;
/**
* @var integer
*/
#[ORM\Column(name: 'max_allow_queue_distance', type: 'integer', nullable: false, options: ['default' => 5])]
protected $maxAllowQueueDistance = self::MAX_ALLOWED_DISTANCE;
/**
* @var integer
*/
#[ORM\Column(name: 'buffer_time_after_queue', type: 'integer', nullable: false, options: ['default' => 240])]
protected $bufferTimeAfterQueue = self::BUFFER_TIME_AFTER_QUEUE;
/**
* @var string
*/
#[ORM\Column(name: 'queue_active', type: 'boolean', nullable: true, options: ['default' => 0])]
protected $queueActive = false;
/**
* @var string
*/
#[ORM\Column(name: 'queue_limits', type: 'string', length: 100, nullable: true)]
protected $queueLimits;
#[ORM\OneToMany(targetEntity: \DriverHistoryQueue::class, mappedBy: 'area')]
protected $driverHistoryQueues;
/**
* @var string
*
* @ORM\Column(name="pickup_details", type="text", nullable=true)
*/
protected $pickupDetails;
/**
* @var string
*
* @ORM\Column(name="dropoff_details", type="text", nullable=true)
*/
protected $dropoffDetails;
public function __construct()
{
$this->driverHistoryQueues = new ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getAreaCode()
{
return $this->areaCode;
}
/**
* @param string $areaCode
*/
public function setAreaCode($areaCode)
{
$this->areaCode = $areaCode;
}
/**
* @return string
*/
public function getAreaName()
{
return $this->areaName;
}
/**
* @param string $areaName
*/
public function setAreaName($areaName)
{
$this->areaName = $areaName;
}
/**
* @return string
*/
public function getAreaColor()
{
return $this->areaColor;
}
/**
* @param string $areaColor
*/
public function setAreaColor($areaColor)
{
$this->areaColor = $areaColor;
}
/**
* @return string
*/
public function getAreaCoords()
{
return $this->areaCoords;
}
/**
* @param string $areaCoords
*/
public function setAreaCoords($areaCoords)
{
$this->areaCoords = $areaCoords;
}
/**
* @return string
*/
public function getAreaType()
{
return $this->areaType;
}
/**
* @param string $areaType
*/
public function setAreaType($areaType)
{
$this->areaType = $areaType;
}
/**
* @return int
*/
public function getAreaStatus()
{
return $this->areaStatus;
}
/**
* @param int $areaStatus
*/
public function setAreaStatus($areaStatus)
{
$this->areaStatus = $areaStatus;
}
/**
* @return string
*/
public function getAreaPostCode()
{
return $this->areaPostCode;
}
/**
* @param string $areaPostCode
*/
public function setAreaPostCode($areaPostCode)
{
$this->areaPostCode = $areaPostCode;
}
/**
* @return int
*/
public function getAreaDropOffCharge()
{
return $this->areaDropOffCharge;
}
/**
* @param int $areaDropOffCharge
*/
public function setAreaDropOffCharge($areaDropOffCharge)
{
$this->areaDropOffCharge = $areaDropOffCharge;
}
/**
* @return int
*/
public function getAreaPickupCharge()
{
return $this->areaPickupCharge;
}
/**
* @param int $areaPickupCharge
*/
public function setAreaPickupCharge($areaPickupCharge)
{
$this->areaPickupCharge = $areaPickupCharge;
}
/**
* @return int
*/
public function getAreaPassOnCharge()
{
return $this->areaPassOnCharge;
}
/**
* @param int $areaPassOnCharge
*/
public function setAreaPassOnCharge($areaPassOnCharge)
{
$this->areaPassOnCharge = $areaPassOnCharge;
}
/**
* @return int
*/
public function getAreaPriority()
{
return $this->areaPriority;
}
/**
* @param int $areaPriority
*/
public function setAreaPriority($areaPriority)
{
$this->areaPriority = $areaPriority;
}
/**
* @return int
*/
public function getCategory()
{
return $this->category;
}
/**
* @param int $category
*/
public function setCategory($category)
{
$this->category = $category;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
public function __toString()
{
return $this->getAreaName() ? $this->getAreaName() : 'n\a';
}
/**
* @return float
*/
public function getPmgCost()
{
return $this->pmgCost;
}
/**
* @param float $pmg_cost
*
* @return Area
*/
public function setPmgCost(float $pmg_cost)
{
$this->pmgCost = $pmg_cost;
return $this;
}
/**
* @return int
*/
public function getBonusQueue()
{
return $this->bonusQueue;
}
/**
* @param int $bonusQueue
*
* @return Area
*/
public function setBonusQueue(int $bonusQueue)
{
$this->bonusQueue = $bonusQueue;
return $this;
}
/**
* @return int
*/
public function getTimeForQueue()
{
return $this->timeForQueue;
}
/**
* @param int $timeForQueue
*
* @return Area
*/
public function setTimeForQueue(int $timeForQueue)
{
$this->timeForQueue = $timeForQueue;
return $this;
}
/**
* @return int
*/
public function getMaxQueueDay()
{
return $this->maxQueueDay;
}
/**
* @param int $maxQueueDay
*
* @return Area
*/
public function setMaxQueueDay(int $maxQueueDay)
{
$this->maxQueueDay = $maxQueueDay;
return $this;
}
/**
* @return int
*/
public function getMaxAllowQueueDistance()
{
return $this->maxAllowQueueDistance;
}
/**
* @param int $maxAllowQueueDistance
*
* @return Area
*/
public function setMaxAllowQueueDistance(int $maxAllowQueueDistance)
{
$this->maxAllowQueueDistance = $maxAllowQueueDistance;
return $this;
}
/**
* @return int
*/
public function getBufferTimeAfterQueue()
{
return $this->bufferTimeAfterQueue;
}
/**
* @param int $bufferTimeAfterQueue
*
* @return Area
*/
public function setBufferTimeAfterQueue(int $bufferTimeAfterQueue)
{
$this->bufferTimeAfterQueue = $bufferTimeAfterQueue;
return $this;
}
/**
* @return string
*/
public function getQueueActive()
{
return $this->queueActive;
}
/**
* @param string $queueActive
*/
public function setQueueActive($queueActive)
{
$this->queueActive = $queueActive;
return $this;
}
/**
* @return string
*/
public function getQueueLimits()
{
return $this->queueLimits;
}
/**
* @param string $queueLimits
*/
public function setQueueLimits($queueLimits)
{
$this->queueLimits = $queueLimits;
return $this;
}
/**
* Get the value of driverHistoryQueues
*/
public function getDriverHistoryQueues()
{
return $this->driverHistoryQueues;
}
/**
* Set the value of driverHistoryQueues
*
* @return Area
*/
public function setDriverHistoryQueues(ArrayCollection $driverHistoryQueues)
{
$this->driverHistoryQueues = $driverHistoryQueues;
return $this;
}
/**
* @param DriverHistoryQueue $driverHistoryQueue
*
* @return Area
*/
public function addDriverHistoryQueue(DriverHistoryQueue $driverHistoryQueue)
{
$this->driverHistoryQueues[] = $driverHistoryQueue;
return $this;
}
/**
* @param DriverHistoryQueue $driverHistoryQueue
*
* @return Area
*/
public function removeDriverHistoryQueue(DriverHistoryQueue $driverHistoryQueue)
{
$this->driverHistoryQueues->removeElement($driverHistoryQueue);
return $this;
}
/**
* @return array
*/
public function getDriverHistoryActiveQueues()
{
$activeDriverQueue = [];
foreach ($this->getDriverHistoryQueues() as $driverHistoryQueue) {
if (!$driverHistoryQueue->getQueueTimeCompleted()
&& !$driverHistoryQueue->getBookingDispatched()
&& ($driverHistoryQueue->getCreatedAt() >= new DateTime('-1 hour') && $driverHistoryQueue->getCreatedAt() <= new DateTime())
&& !$driverHistoryQueue->getLeavedAt()
) {
$activeDriverQueue[] = $driverHistoryQueue;
}
}
return $activeDriverQueue;
}
/**
* @return int
*/
public function getActiveQueuesCount()
{
return count($this->getDriverHistoryActiveQueues());
}
/**
* Get the value of pickupDetails
*
* @return string
*/
public function getPickupDetails()
{
return $this->pickupDetails;
}
/**
* Set the value of pickupDetails
*
* @param string $pickupDetails
*
* @return self
*/
public function setPickupDetails($pickupDetails)
{
$this->pickupDetails = $pickupDetails;
return $this;
}
/**
* Get the value of dropoffDetails
*
* @return string
*/
public function getDropoffDetails()
{
return $this->dropoffDetails;
}
/**
* Set the value of dropoffDetails
*
* @param string $dropoffDetails
*
* @return self
*/
public function setDropoffDetails($dropoffDetails)
{
$this->dropoffDetails = $dropoffDetails;
return $this;
}
}