src/AdminBundle/Entity/Area.php line 14

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * Area
  8. */
  9. #[ORM\Table(name: 'ctlf_area')]
  10. #[ORM\Entity(repositoryClass: \AdminBundle\Repository\AreaRepository::class)]
  11. class Area extends BaseEntity
  12. {
  13. const AREA_TYPE_POLYLINE = 'polyline';
  14. const AREA_TYPE_POLYGON = 'polygon';
  15. const AREA_TYPE_RECTANGLE = 'rectangle';
  16. const AREA_TYPE_CIRCLE = 'circle';
  17. const AREA_TYPE_MARKER = 'marker';
  18. const AREA_TYPE_POSTCODE = 'postcode';
  19. const CATEGORY_AIRPORT = 1;
  20. const CATEGORY_PORT = 2;
  21. const CATEGORY_TRAIN = 3;
  22. const QUEUE_STATUS_JOINED = 1;
  23. const QUEUE_STATUS_FULL = 2;
  24. const QUEUE_STATUS_AVAILABLE = 3;
  25. public static $categories = [
  26. self::CATEGORY_AIRPORT => 'Airport',
  27. self::CATEGORY_PORT => 'Port',
  28. self::CATEGORY_TRAIN => 'Train',
  29. ];
  30. public static $googleMapsCategories = [
  31. self::CATEGORY_AIRPORT => 'airport',
  32. self::CATEGORY_PORT => 'port',
  33. self::CATEGORY_TRAIN => 'train_station',
  34. ];
  35. public static $queueStatuses = [
  36. self::QUEUE_STATUS_JOINED => 'Joined',
  37. self::QUEUE_STATUS_FULL => 'Full',
  38. self::QUEUE_STATUS_AVAILABLE => 'Available',
  39. ];
  40. const BONUS_QUEUE = 10;
  41. const TIME_FOR_QUEUE = 60;
  42. const MAX_QUEUE_DAY = 2;
  43. const MAX_ALLOWED_DISTANCE = 5;
  44. const BUFFER_TIME_AFTER_QUEUE = 240;
  45. /**
  46. * @var integer
  47. */
  48. #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
  49. #[ORM\Id]
  50. #[ORM\GeneratedValue(strategy: 'IDENTITY')]
  51. protected $id;
  52. /**
  53. * @var string
  54. */
  55. #[ORM\Column(name: 'area_code', type: 'string', length: 64)]
  56. protected $areaCode;
  57. /**
  58. * @var string
  59. */
  60. #[ORM\Column(name: 'area_name', type: 'string', length: 64)]
  61. protected $areaName;
  62. /**
  63. * @var string
  64. */
  65. #[ORM\Column(name: 'area_post_code', type: 'string', length: 64)]
  66. protected $areaPostCode;
  67. /**
  68. * @var string
  69. */
  70. #[ORM\Column(name: 'area_color', type: 'string', length: 64)]
  71. protected $areaColor;
  72. /**
  73. * @var string
  74. */
  75. #[ORM\Column(name: 'area_coords', type: 'text')]
  76. protected $areaCoords;
  77. /**
  78. * @var string
  79. */
  80. #[ORM\Column(name: 'area_type', type: 'string', length: 32)]
  81. protected $areaType;
  82. /**
  83. * @var integer
  84. */
  85. #[ORM\Column(name: 'area_status', type: 'integer', nullable: true)]
  86. protected $areaStatus;
  87. /**
  88. * @var integer
  89. */
  90. #[ORM\Column(name: 'area_drop_off_charge', type: 'integer', nullable: true)]
  91. protected $areaDropOffCharge;
  92. /**
  93. * @var integer
  94. */
  95. #[ORM\Column(name: 'area_pickup_charge', type: 'integer', nullable: true)]
  96. protected $areaPickupCharge;
  97. /**
  98. * @var integer
  99. */
  100. #[ORM\Column(name: 'area_pass_on_charge', type: 'integer', nullable: true)]
  101. protected $areaPassOnCharge;
  102. /**
  103. * @var integer
  104. */
  105. #[ORM\GeneratedValue(strategy: 'AUTO')]
  106. #[ORM\Column(name: 'area_priority', type: 'integer', nullable: true)]
  107. protected $areaPriority;
  108. /**
  109. * @var integer
  110. */
  111. #[ORM\Column(name: 'category', type: 'integer', nullable: true)]
  112. protected $category;
  113. /**
  114. * @var string
  115. */
  116. #[ORM\Column(name: 'description', type: 'text', nullable: true)]
  117. protected $description;
  118. /**
  119. * @var float
  120. */
  121. #[ORM\Column(name: 'pmg_cost', type: 'float', scale: 2, nullable: true)]
  122. protected $pmgCost;
  123. /**
  124. * @var integer
  125. */
  126. #[ORM\Column(name: 'bonus_queue', type: 'integer', nullable: false, options: ['default' => 10])]
  127. protected $bonusQueue = self::BONUS_QUEUE;
  128. /**
  129. * @var integer
  130. */
  131. #[ORM\Column(name: 'time_for_queue', type: 'integer', nullable: false, options: ['default' => 60])]
  132. protected $timeForQueue = self::TIME_FOR_QUEUE;
  133. /**
  134. * @var integer
  135. */
  136. #[ORM\Column(name: 'max_queue_day', type: 'integer', nullable: false, options: ['default' => 2])]
  137. protected $maxQueueDay = self::MAX_QUEUE_DAY;
  138. /**
  139. * @var integer
  140. */
  141. #[ORM\Column(name: 'max_allow_queue_distance', type: 'integer', nullable: false, options: ['default' => 5])]
  142. protected $maxAllowQueueDistance = self::MAX_ALLOWED_DISTANCE;
  143. /**
  144. * @var integer
  145. */
  146. #[ORM\Column(name: 'buffer_time_after_queue', type: 'integer', nullable: false, options: ['default' => 240])]
  147. protected $bufferTimeAfterQueue = self::BUFFER_TIME_AFTER_QUEUE;
  148. /**
  149. * @var string
  150. */
  151. #[ORM\Column(name: 'queue_active', type: 'boolean', nullable: true, options: ['default' => 0])]
  152. protected $queueActive = false;
  153. /**
  154. * @var string
  155. */
  156. #[ORM\Column(name: 'queue_limits', type: 'string', length: 100, nullable: true)]
  157. protected $queueLimits;
  158. #[ORM\OneToMany(targetEntity: \DriverHistoryQueue::class, mappedBy: 'area')]
  159. protected $driverHistoryQueues;
  160. /**
  161. * @var string
  162. *
  163. * @ORM\Column(name="pickup_details", type="text", nullable=true)
  164. */
  165. protected $pickupDetails;
  166. /**
  167. * @var string
  168. *
  169. * @ORM\Column(name="dropoff_details", type="text", nullable=true)
  170. */
  171. protected $dropoffDetails;
  172. public function __construct()
  173. {
  174. $this->driverHistoryQueues = new ArrayCollection();
  175. }
  176. /**
  177. * @return int
  178. */
  179. public function getId()
  180. {
  181. return $this->id;
  182. }
  183. /**
  184. * @param int $id
  185. */
  186. public function setId($id)
  187. {
  188. $this->id = $id;
  189. }
  190. /**
  191. * @return string
  192. */
  193. public function getAreaCode()
  194. {
  195. return $this->areaCode;
  196. }
  197. /**
  198. * @param string $areaCode
  199. */
  200. public function setAreaCode($areaCode)
  201. {
  202. $this->areaCode = $areaCode;
  203. }
  204. /**
  205. * @return string
  206. */
  207. public function getAreaName()
  208. {
  209. return $this->areaName;
  210. }
  211. /**
  212. * @param string $areaName
  213. */
  214. public function setAreaName($areaName)
  215. {
  216. $this->areaName = $areaName;
  217. }
  218. /**
  219. * @return string
  220. */
  221. public function getAreaColor()
  222. {
  223. return $this->areaColor;
  224. }
  225. /**
  226. * @param string $areaColor
  227. */
  228. public function setAreaColor($areaColor)
  229. {
  230. $this->areaColor = $areaColor;
  231. }
  232. /**
  233. * @return string
  234. */
  235. public function getAreaCoords()
  236. {
  237. return $this->areaCoords;
  238. }
  239. /**
  240. * @param string $areaCoords
  241. */
  242. public function setAreaCoords($areaCoords)
  243. {
  244. $this->areaCoords = $areaCoords;
  245. }
  246. /**
  247. * @return string
  248. */
  249. public function getAreaType()
  250. {
  251. return $this->areaType;
  252. }
  253. /**
  254. * @param string $areaType
  255. */
  256. public function setAreaType($areaType)
  257. {
  258. $this->areaType = $areaType;
  259. }
  260. /**
  261. * @return int
  262. */
  263. public function getAreaStatus()
  264. {
  265. return $this->areaStatus;
  266. }
  267. /**
  268. * @param int $areaStatus
  269. */
  270. public function setAreaStatus($areaStatus)
  271. {
  272. $this->areaStatus = $areaStatus;
  273. }
  274. /**
  275. * @return string
  276. */
  277. public function getAreaPostCode()
  278. {
  279. return $this->areaPostCode;
  280. }
  281. /**
  282. * @param string $areaPostCode
  283. */
  284. public function setAreaPostCode($areaPostCode)
  285. {
  286. $this->areaPostCode = $areaPostCode;
  287. }
  288. /**
  289. * @return int
  290. */
  291. public function getAreaDropOffCharge()
  292. {
  293. return $this->areaDropOffCharge;
  294. }
  295. /**
  296. * @param int $areaDropOffCharge
  297. */
  298. public function setAreaDropOffCharge($areaDropOffCharge)
  299. {
  300. $this->areaDropOffCharge = $areaDropOffCharge;
  301. }
  302. /**
  303. * @return int
  304. */
  305. public function getAreaPickupCharge()
  306. {
  307. return $this->areaPickupCharge;
  308. }
  309. /**
  310. * @param int $areaPickupCharge
  311. */
  312. public function setAreaPickupCharge($areaPickupCharge)
  313. {
  314. $this->areaPickupCharge = $areaPickupCharge;
  315. }
  316. /**
  317. * @return int
  318. */
  319. public function getAreaPassOnCharge()
  320. {
  321. return $this->areaPassOnCharge;
  322. }
  323. /**
  324. * @param int $areaPassOnCharge
  325. */
  326. public function setAreaPassOnCharge($areaPassOnCharge)
  327. {
  328. $this->areaPassOnCharge = $areaPassOnCharge;
  329. }
  330. /**
  331. * @return int
  332. */
  333. public function getAreaPriority()
  334. {
  335. return $this->areaPriority;
  336. }
  337. /**
  338. * @param int $areaPriority
  339. */
  340. public function setAreaPriority($areaPriority)
  341. {
  342. $this->areaPriority = $areaPriority;
  343. }
  344. /**
  345. * @return int
  346. */
  347. public function getCategory()
  348. {
  349. return $this->category;
  350. }
  351. /**
  352. * @param int $category
  353. */
  354. public function setCategory($category)
  355. {
  356. $this->category = $category;
  357. }
  358. /**
  359. * @return string
  360. */
  361. public function getDescription()
  362. {
  363. return $this->description;
  364. }
  365. /**
  366. * @param string $description
  367. */
  368. public function setDescription($description)
  369. {
  370. $this->description = $description;
  371. }
  372. public function __toString()
  373. {
  374. return $this->getAreaName() ? $this->getAreaName() : 'n\a';
  375. }
  376. /**
  377. * @return float
  378. */
  379. public function getPmgCost()
  380. {
  381. return $this->pmgCost;
  382. }
  383. /**
  384. * @param float $pmg_cost
  385. *
  386. * @return Area
  387. */
  388. public function setPmgCost(float $pmg_cost)
  389. {
  390. $this->pmgCost = $pmg_cost;
  391. return $this;
  392. }
  393. /**
  394. * @return int
  395. */
  396. public function getBonusQueue()
  397. {
  398. return $this->bonusQueue;
  399. }
  400. /**
  401. * @param int $bonusQueue
  402. *
  403. * @return Area
  404. */
  405. public function setBonusQueue(int $bonusQueue)
  406. {
  407. $this->bonusQueue = $bonusQueue;
  408. return $this;
  409. }
  410. /**
  411. * @return int
  412. */
  413. public function getTimeForQueue()
  414. {
  415. return $this->timeForQueue;
  416. }
  417. /**
  418. * @param int $timeForQueue
  419. *
  420. * @return Area
  421. */
  422. public function setTimeForQueue(int $timeForQueue)
  423. {
  424. $this->timeForQueue = $timeForQueue;
  425. return $this;
  426. }
  427. /**
  428. * @return int
  429. */
  430. public function getMaxQueueDay()
  431. {
  432. return $this->maxQueueDay;
  433. }
  434. /**
  435. * @param int $maxQueueDay
  436. *
  437. * @return Area
  438. */
  439. public function setMaxQueueDay(int $maxQueueDay)
  440. {
  441. $this->maxQueueDay = $maxQueueDay;
  442. return $this;
  443. }
  444. /**
  445. * @return int
  446. */
  447. public function getMaxAllowQueueDistance()
  448. {
  449. return $this->maxAllowQueueDistance;
  450. }
  451. /**
  452. * @param int $maxAllowQueueDistance
  453. *
  454. * @return Area
  455. */
  456. public function setMaxAllowQueueDistance(int $maxAllowQueueDistance)
  457. {
  458. $this->maxAllowQueueDistance = $maxAllowQueueDistance;
  459. return $this;
  460. }
  461. /**
  462. * @return int
  463. */
  464. public function getBufferTimeAfterQueue()
  465. {
  466. return $this->bufferTimeAfterQueue;
  467. }
  468. /**
  469. * @param int $bufferTimeAfterQueue
  470. *
  471. * @return Area
  472. */
  473. public function setBufferTimeAfterQueue(int $bufferTimeAfterQueue)
  474. {
  475. $this->bufferTimeAfterQueue = $bufferTimeAfterQueue;
  476. return $this;
  477. }
  478. /**
  479. * @return string
  480. */
  481. public function getQueueActive()
  482. {
  483. return $this->queueActive;
  484. }
  485. /**
  486. * @param string $queueActive
  487. */
  488. public function setQueueActive($queueActive)
  489. {
  490. $this->queueActive = $queueActive;
  491. return $this;
  492. }
  493. /**
  494. * @return string
  495. */
  496. public function getQueueLimits()
  497. {
  498. return $this->queueLimits;
  499. }
  500. /**
  501. * @param string $queueLimits
  502. */
  503. public function setQueueLimits($queueLimits)
  504. {
  505. $this->queueLimits = $queueLimits;
  506. return $this;
  507. }
  508. /**
  509. * Get the value of driverHistoryQueues
  510. */
  511. public function getDriverHistoryQueues()
  512. {
  513. return $this->driverHistoryQueues;
  514. }
  515. /**
  516. * Set the value of driverHistoryQueues
  517. *
  518. * @return Area
  519. */
  520. public function setDriverHistoryQueues(ArrayCollection $driverHistoryQueues)
  521. {
  522. $this->driverHistoryQueues = $driverHistoryQueues;
  523. return $this;
  524. }
  525. /**
  526. * @param DriverHistoryQueue $driverHistoryQueue
  527. *
  528. * @return Area
  529. */
  530. public function addDriverHistoryQueue(DriverHistoryQueue $driverHistoryQueue)
  531. {
  532. $this->driverHistoryQueues[] = $driverHistoryQueue;
  533. return $this;
  534. }
  535. /**
  536. * @param DriverHistoryQueue $driverHistoryQueue
  537. *
  538. * @return Area
  539. */
  540. public function removeDriverHistoryQueue(DriverHistoryQueue $driverHistoryQueue)
  541. {
  542. $this->driverHistoryQueues->removeElement($driverHistoryQueue);
  543. return $this;
  544. }
  545. /**
  546. * @return array
  547. */
  548. public function getDriverHistoryActiveQueues()
  549. {
  550. $activeDriverQueue = [];
  551. foreach ($this->getDriverHistoryQueues() as $driverHistoryQueue) {
  552. if (!$driverHistoryQueue->getQueueTimeCompleted()
  553. && !$driverHistoryQueue->getBookingDispatched()
  554. && ($driverHistoryQueue->getCreatedAt() >= new DateTime('-1 hour') && $driverHistoryQueue->getCreatedAt() <= new DateTime())
  555. && !$driverHistoryQueue->getLeavedAt()
  556. ) {
  557. $activeDriverQueue[] = $driverHistoryQueue;
  558. }
  559. }
  560. return $activeDriverQueue;
  561. }
  562. /**
  563. * @return int
  564. */
  565. public function getActiveQueuesCount()
  566. {
  567. return count($this->getDriverHistoryActiveQueues());
  568. }
  569. /**
  570. * Get the value of pickupDetails
  571. *
  572. * @return string
  573. */
  574. public function getPickupDetails()
  575. {
  576. return $this->pickupDetails;
  577. }
  578. /**
  579. * Set the value of pickupDetails
  580. *
  581. * @param string $pickupDetails
  582. *
  583. * @return self
  584. */
  585. public function setPickupDetails($pickupDetails)
  586. {
  587. $this->pickupDetails = $pickupDetails;
  588. return $this;
  589. }
  590. /**
  591. * Get the value of dropoffDetails
  592. *
  593. * @return string
  594. */
  595. public function getDropoffDetails()
  596. {
  597. return $this->dropoffDetails;
  598. }
  599. /**
  600. * Set the value of dropoffDetails
  601. *
  602. * @param string $dropoffDetails
  603. *
  604. * @return self
  605. */
  606. public function setDropoffDetails($dropoffDetails)
  607. {
  608. $this->dropoffDetails = $dropoffDetails;
  609. return $this;
  610. }
  611. }