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. #[ORM\Column(name: 'pickup_details', type: 'text', nullable: true)]
  161. protected $pickupDetails;
  162. #[ORM\Column(name: 'dropoff_details', type: 'text', nullable: true)]
  163. protected $dropoffDetails;
  164. public function __construct()
  165. {
  166. $this->driverHistoryQueues = new ArrayCollection();
  167. }
  168. /**
  169. * @return int
  170. */
  171. public function getId()
  172. {
  173. return $this->id;
  174. }
  175. /**
  176. * @param int $id
  177. */
  178. public function setId($id)
  179. {
  180. $this->id = $id;
  181. }
  182. /**
  183. * @return string
  184. */
  185. public function getAreaCode()
  186. {
  187. return $this->areaCode;
  188. }
  189. /**
  190. * @param string $areaCode
  191. */
  192. public function setAreaCode($areaCode)
  193. {
  194. $this->areaCode = $areaCode;
  195. }
  196. /**
  197. * @return string
  198. */
  199. public function getAreaName()
  200. {
  201. return $this->areaName;
  202. }
  203. /**
  204. * @param string $areaName
  205. */
  206. public function setAreaName($areaName)
  207. {
  208. $this->areaName = $areaName;
  209. }
  210. /**
  211. * @return string
  212. */
  213. public function getAreaColor()
  214. {
  215. return $this->areaColor;
  216. }
  217. /**
  218. * @param string $areaColor
  219. */
  220. public function setAreaColor($areaColor)
  221. {
  222. $this->areaColor = $areaColor;
  223. }
  224. /**
  225. * @return string
  226. */
  227. public function getAreaCoords()
  228. {
  229. return $this->areaCoords;
  230. }
  231. /**
  232. * @param string $areaCoords
  233. */
  234. public function setAreaCoords($areaCoords)
  235. {
  236. $this->areaCoords = $areaCoords;
  237. }
  238. /**
  239. * @return string
  240. */
  241. public function getAreaType()
  242. {
  243. return $this->areaType;
  244. }
  245. /**
  246. * @param string $areaType
  247. */
  248. public function setAreaType($areaType)
  249. {
  250. $this->areaType = $areaType;
  251. }
  252. /**
  253. * @return int
  254. */
  255. public function getAreaStatus()
  256. {
  257. return $this->areaStatus;
  258. }
  259. /**
  260. * @param int $areaStatus
  261. */
  262. public function setAreaStatus($areaStatus)
  263. {
  264. $this->areaStatus = $areaStatus;
  265. }
  266. /**
  267. * @return string
  268. */
  269. public function getAreaPostCode()
  270. {
  271. return $this->areaPostCode;
  272. }
  273. /**
  274. * @param string $areaPostCode
  275. */
  276. public function setAreaPostCode($areaPostCode)
  277. {
  278. $this->areaPostCode = $areaPostCode;
  279. }
  280. /**
  281. * @return int
  282. */
  283. public function getAreaDropOffCharge()
  284. {
  285. return $this->areaDropOffCharge;
  286. }
  287. /**
  288. * @param int $areaDropOffCharge
  289. */
  290. public function setAreaDropOffCharge($areaDropOffCharge)
  291. {
  292. $this->areaDropOffCharge = $areaDropOffCharge;
  293. }
  294. /**
  295. * @return int
  296. */
  297. public function getAreaPickupCharge()
  298. {
  299. return $this->areaPickupCharge;
  300. }
  301. /**
  302. * @param int $areaPickupCharge
  303. */
  304. public function setAreaPickupCharge($areaPickupCharge)
  305. {
  306. $this->areaPickupCharge = $areaPickupCharge;
  307. }
  308. /**
  309. * @return int
  310. */
  311. public function getAreaPassOnCharge()
  312. {
  313. return $this->areaPassOnCharge;
  314. }
  315. /**
  316. * @param int $areaPassOnCharge
  317. */
  318. public function setAreaPassOnCharge($areaPassOnCharge)
  319. {
  320. $this->areaPassOnCharge = $areaPassOnCharge;
  321. }
  322. /**
  323. * @return int
  324. */
  325. public function getAreaPriority()
  326. {
  327. return $this->areaPriority;
  328. }
  329. /**
  330. * @param int $areaPriority
  331. */
  332. public function setAreaPriority($areaPriority)
  333. {
  334. $this->areaPriority = $areaPriority;
  335. }
  336. /**
  337. * @return int
  338. */
  339. public function getCategory()
  340. {
  341. return $this->category;
  342. }
  343. /**
  344. * @param int $category
  345. */
  346. public function setCategory($category)
  347. {
  348. $this->category = $category;
  349. }
  350. /**
  351. * @return string
  352. */
  353. public function getDescription()
  354. {
  355. return $this->description;
  356. }
  357. /**
  358. * @param string $description
  359. */
  360. public function setDescription($description)
  361. {
  362. $this->description = $description;
  363. }
  364. public function __toString()
  365. {
  366. return $this->getAreaName() ? $this->getAreaName() : 'n\a';
  367. }
  368. /**
  369. * @return float
  370. */
  371. public function getPmgCost()
  372. {
  373. return $this->pmgCost;
  374. }
  375. /**
  376. * @param float $pmg_cost
  377. *
  378. * @return Area
  379. */
  380. public function setPmgCost(float $pmg_cost)
  381. {
  382. $this->pmgCost = $pmg_cost;
  383. return $this;
  384. }
  385. /**
  386. * @return int
  387. */
  388. public function getBonusQueue()
  389. {
  390. return $this->bonusQueue;
  391. }
  392. /**
  393. * @param int $bonusQueue
  394. *
  395. * @return Area
  396. */
  397. public function setBonusQueue(int $bonusQueue)
  398. {
  399. $this->bonusQueue = $bonusQueue;
  400. return $this;
  401. }
  402. /**
  403. * @return int
  404. */
  405. public function getTimeForQueue()
  406. {
  407. return $this->timeForQueue;
  408. }
  409. /**
  410. * @param int $timeForQueue
  411. *
  412. * @return Area
  413. */
  414. public function setTimeForQueue(int $timeForQueue)
  415. {
  416. $this->timeForQueue = $timeForQueue;
  417. return $this;
  418. }
  419. /**
  420. * @return int
  421. */
  422. public function getMaxQueueDay()
  423. {
  424. return $this->maxQueueDay;
  425. }
  426. /**
  427. * @param int $maxQueueDay
  428. *
  429. * @return Area
  430. */
  431. public function setMaxQueueDay(int $maxQueueDay)
  432. {
  433. $this->maxQueueDay = $maxQueueDay;
  434. return $this;
  435. }
  436. /**
  437. * @return int
  438. */
  439. public function getMaxAllowQueueDistance()
  440. {
  441. return $this->maxAllowQueueDistance;
  442. }
  443. /**
  444. * @param int $maxAllowQueueDistance
  445. *
  446. * @return Area
  447. */
  448. public function setMaxAllowQueueDistance(int $maxAllowQueueDistance)
  449. {
  450. $this->maxAllowQueueDistance = $maxAllowQueueDistance;
  451. return $this;
  452. }
  453. /**
  454. * @return int
  455. */
  456. public function getBufferTimeAfterQueue()
  457. {
  458. return $this->bufferTimeAfterQueue;
  459. }
  460. /**
  461. * @param int $bufferTimeAfterQueue
  462. *
  463. * @return Area
  464. */
  465. public function setBufferTimeAfterQueue(int $bufferTimeAfterQueue)
  466. {
  467. $this->bufferTimeAfterQueue = $bufferTimeAfterQueue;
  468. return $this;
  469. }
  470. /**
  471. * @return string
  472. */
  473. public function getQueueActive()
  474. {
  475. return $this->queueActive;
  476. }
  477. /**
  478. * @param string $queueActive
  479. */
  480. public function setQueueActive($queueActive)
  481. {
  482. $this->queueActive = $queueActive;
  483. return $this;
  484. }
  485. /**
  486. * @return string
  487. */
  488. public function getQueueLimits()
  489. {
  490. return $this->queueLimits;
  491. }
  492. /**
  493. * @param string $queueLimits
  494. */
  495. public function setQueueLimits($queueLimits)
  496. {
  497. $this->queueLimits = $queueLimits;
  498. return $this;
  499. }
  500. /**
  501. * Get the value of driverHistoryQueues
  502. */
  503. public function getDriverHistoryQueues()
  504. {
  505. return $this->driverHistoryQueues;
  506. }
  507. /**
  508. * Set the value of driverHistoryQueues
  509. *
  510. * @return Area
  511. */
  512. public function setDriverHistoryQueues(ArrayCollection $driverHistoryQueues)
  513. {
  514. $this->driverHistoryQueues = $driverHistoryQueues;
  515. return $this;
  516. }
  517. /**
  518. * @param DriverHistoryQueue $driverHistoryQueue
  519. *
  520. * @return Area
  521. */
  522. public function addDriverHistoryQueue(DriverHistoryQueue $driverHistoryQueue)
  523. {
  524. $this->driverHistoryQueues[] = $driverHistoryQueue;
  525. return $this;
  526. }
  527. /**
  528. * @param DriverHistoryQueue $driverHistoryQueue
  529. *
  530. * @return Area
  531. */
  532. public function removeDriverHistoryQueue(DriverHistoryQueue $driverHistoryQueue)
  533. {
  534. $this->driverHistoryQueues->removeElement($driverHistoryQueue);
  535. return $this;
  536. }
  537. /**
  538. * @return array
  539. */
  540. public function getDriverHistoryActiveQueues()
  541. {
  542. $activeDriverQueue = [];
  543. foreach ($this->getDriverHistoryQueues() as $driverHistoryQueue) {
  544. if (!$driverHistoryQueue->getQueueTimeCompleted()
  545. && !$driverHistoryQueue->getBookingDispatched()
  546. && ($driverHistoryQueue->getCreatedAt() >= new DateTime('-1 hour') && $driverHistoryQueue->getCreatedAt() <= new DateTime())
  547. && !$driverHistoryQueue->getLeavedAt()
  548. ) {
  549. $activeDriverQueue[] = $driverHistoryQueue;
  550. }
  551. }
  552. return $activeDriverQueue;
  553. }
  554. /**
  555. * @return int
  556. */
  557. public function getActiveQueuesCount()
  558. {
  559. return count($this->getDriverHistoryActiveQueues());
  560. }
  561. /**
  562. * Get the value of pickupDetails
  563. *
  564. * @return string
  565. */
  566. public function getPickupDetails()
  567. {
  568. return $this->pickupDetails;
  569. }
  570. /**
  571. * Set the value of pickupDetails
  572. *
  573. * @param string $pickupDetails
  574. *
  575. * @return self
  576. */
  577. public function setPickupDetails($pickupDetails)
  578. {
  579. $this->pickupDetails = $pickupDetails;
  580. return $this;
  581. }
  582. /**
  583. * Get the value of dropoffDetails
  584. *
  585. * @return string
  586. */
  587. public function getDropoffDetails()
  588. {
  589. return $this->dropoffDetails;
  590. }
  591. /**
  592. * Set the value of dropoffDetails
  593. *
  594. * @param string $dropoffDetails
  595. *
  596. * @return self
  597. */
  598. public function setDropoffDetails($dropoffDetails)
  599. {
  600. $this->dropoffDetails = $dropoffDetails;
  601. return $this;
  602. }
  603. }