src/AdminBundle/Entity/PeriodSettings.php line 12

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * PeriodSettings
  7. */
  8. #[ORM\Table(name: 'period_settings')]
  9. #[ORM\Entity(repositoryClass: \AdminBundle\Repository\PeriodSettingsRepository::class)]
  10. class PeriodSettings extends BaseEntity
  11. {
  12. const PERIOD_REPEATABLE_DAILY = 0;
  13. const PERIOD_REPEATABLE_WEEKLY = 1;
  14. const PERIOD_REPEATABLE_MONTHLY = 2;
  15. const PERIOD_REPEATABLE_YEARLY = 3;
  16. public static $periodRepeatableTypes = array(
  17. self::PERIOD_REPEATABLE_DAILY => 'daily',
  18. self::PERIOD_REPEATABLE_WEEKLY => 'weekly',
  19. self::PERIOD_REPEATABLE_MONTHLY => 'monthly',
  20. self::PERIOD_REPEATABLE_YEARLY => 'yearly'
  21. );
  22. const PERIOD_SPECIFIC_CHARGE_PERCENTAGE = 0;
  23. const PERIOD_SPECIFIC_CHARGE_VALUE = 1;
  24. public static $periodSpecificChargeTypes = array(
  25. self::PERIOD_SPECIFIC_CHARGE_PERCENTAGE => '%',
  26. self::PERIOD_SPECIFIC_CHARGE_VALUE => 'value'
  27. );
  28. const PERIOD_CHARGE_ADDED = 0;
  29. const PERIOD_CHARGE_SUBSTRACTED = 1;
  30. public static $periodChargeTypes = array(
  31. self::PERIOD_CHARGE_ADDED => '+',
  32. self::PERIOD_CHARGE_SUBSTRACTED => '-'
  33. );
  34. /**
  35. * @var integer
  36. */
  37. #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
  38. #[ORM\Id]
  39. #[ORM\GeneratedValue(strategy: 'IDENTITY')]
  40. protected $id;
  41. /**
  42. * @var \String
  43. */
  44. #[ORM\Column(name: 'period_name', type: 'string', length: 64)]
  45. protected $periodName;
  46. /**
  47. * @var array
  48. */
  49. #[ORM\Column(name: 'period_start', type: 'array')]
  50. protected $periodStart;
  51. /**
  52. * @var array
  53. */
  54. #[ORM\Column(name: 'period_end', type: 'array')]
  55. protected $periodEnd;
  56. /**
  57. * @var \DateTime
  58. */
  59. #[ORM\Column(name: 'period_start_time', type: 'time')]
  60. protected $periodStartTime;
  61. /**
  62. * @var \DateTime
  63. */
  64. #[ORM\Column(name: 'period_end_time', type: 'time')]
  65. protected $periodEndTime;
  66. /**
  67. * @var \Integer
  68. */
  69. #[ORM\Column(name: 'period_repeatable', type: 'integer')]
  70. protected $periodRepeatable;
  71. /**
  72. * @var \Integer
  73. */
  74. #[ORM\Column(name: 'period_specific_charge_type', type: 'integer')]
  75. protected $periodSpecificChargeType;
  76. /**
  77. * @var \Integer
  78. */
  79. #[ORM\Column(name: 'period_specific_charge_value', type: 'integer', nullable: true)]
  80. protected $periodSpecificChargeValue;
  81. /**
  82. * @var \Integer
  83. */
  84. #[ORM\Column(name: 'period_charge_type', type: 'integer')]
  85. protected $periodChargeType;
  86. /**
  87. * @var integer
  88. */
  89. #[ORM\Column(name: 'booking_disabled', type: 'boolean', nullable: true)]
  90. protected $bookingDisabled = false;
  91. /**
  92. * @var \String
  93. */
  94. #[ORM\Column(name: 'disabled_messages', type: 'string', nullable: true)]
  95. protected $disabledMessages;
  96. /**
  97. * @var \String
  98. */
  99. #[ORM\Column(name: 'operator_disabled_messages', type: 'string', nullable: true)]
  100. protected $operatorDisabledMessage;
  101. /**
  102. * @var float
  103. */
  104. #[ORM\Column(name: 'minimum_price_booking', type: 'decimal', precision: 7, scale: 2, nullable: true)]
  105. protected $minimumPriceBooking = 0;
  106. /**
  107. * @var \Integer
  108. */
  109. #[ORM\Column(name: 'period_priority', type: 'integer')]
  110. protected $periodPriority;
  111. #[ORM\JoinTable(name: 'periods_cartypes')]
  112. #[ORM\JoinColumn(name: 'cartype_id', referencedColumnName: 'id')]
  113. #[ORM\InverseJoinColumn(name: 'period_id', referencedColumnName: 'id')]
  114. #[ORM\ManyToMany(targetEntity: \CarType::class)]
  115. protected $carTypes;
  116. static function convertToDateTime($dateString)
  117. {
  118. $dateArray = explode('/', $dateString);
  119. return new \DateTime($dateArray[2]. '-' . $dateArray[0]. '-'. $dateArray[1]);
  120. }
  121. public function __construct()
  122. {
  123. $this->carTypes = new ArrayCollection();
  124. $this->periodStartTime = new \DateTime();
  125. $this->periodEndTime = new \DateTime();
  126. }
  127. /**
  128. * @return mixed
  129. */
  130. public function getCarTypes() {
  131. return $this->carTypes;
  132. }
  133. /**
  134. * @param mixed $var
  135. */
  136. public function setCarTypes($var) {
  137. $this->carTypes = $var;
  138. }
  139. /**
  140. * @return array
  141. */
  142. public function getCarTypeIds() {
  143. $ids = [];
  144. foreach ($this->getCarTypes() as $carType) {
  145. $ids[] = $carType->getId();
  146. }
  147. return $ids;
  148. }
  149. /**
  150. * @return int
  151. */
  152. public function getId()
  153. {
  154. return $this->id;
  155. }
  156. /**
  157. * @param int $id
  158. */
  159. public function setId($id)
  160. {
  161. $this->id = $id;
  162. }
  163. /**
  164. * @return String
  165. */
  166. public function getPeriodName()
  167. {
  168. return $this->periodName;
  169. }
  170. /**
  171. * @param String $periodName
  172. */
  173. public function setPeriodName($periodName)
  174. {
  175. $this->periodName = $periodName;
  176. }
  177. public function getPeriodStartTimeDateFormat()
  178. {
  179. $periodStartTime = new \DateTime();
  180. $periodStartTime->setTime(
  181. $this->periodStartTime->format('G'),
  182. $this->periodStartTime->format('i'),
  183. $this->periodStartTime->format('s')
  184. );
  185. return $periodStartTime;
  186. }
  187. public function getPeriodStartTime()
  188. {
  189. if (! $this->periodStartTime) {
  190. return ;
  191. }
  192. return $this->periodStartTime->format('H:i');
  193. }
  194. public function setPeriodStartTime($periodStartTime)
  195. {
  196. if (is_string($periodStartTime)) {
  197. $timeArray = explode(':', $periodStartTime);
  198. $periodStartTime = new \DateTime();
  199. $periodStartTime->setTime($timeArray[0], $timeArray[1]);
  200. }
  201. $date = clone $this->periodStartTime;
  202. $date->setTime(
  203. $periodStartTime->format('G'),
  204. $periodStartTime->format('i'),
  205. $periodStartTime->format('s')
  206. );
  207. $this->periodStartTime = $date;
  208. }
  209. /**
  210. * @return array
  211. */
  212. public function getPeriodStart()
  213. {
  214. return $this->periodStart;
  215. }
  216. /**
  217. * @param array $periodStart
  218. */
  219. public function setPeriodStart($periodStart)
  220. {
  221. $this->periodStart = $periodStart;
  222. }
  223. /**
  224. * @return array
  225. */
  226. public function getPeriodEnd()
  227. {
  228. return $this->periodEnd;
  229. }
  230. /**
  231. * @param array $periodEnd
  232. */
  233. public function setPeriodEnd($periodEnd)
  234. {
  235. $this->periodEnd = $periodEnd;
  236. }
  237. public function getPeriodEndTimeDateFormat()
  238. {
  239. $periodEndTime = new \DateTime();
  240. $periodEndTime->setTime(
  241. $this->periodEndTime->format('G'),
  242. $this->periodEndTime->format('i'),
  243. $this->periodEndTime->format('s')
  244. );
  245. return $periodEndTime;
  246. }
  247. public function getPeriodEndTime()
  248. {
  249. if (! $this->periodEndTime) {
  250. return ;
  251. }
  252. return $this->periodEndTime->format('H:i');
  253. }
  254. public function setPeriodEndTime($periodEndTime)
  255. {
  256. if (is_string($periodEndTime)) {
  257. $timeArray = explode(':', $periodEndTime);
  258. $periodEndTime = new \DateTime();
  259. $periodEndTime->setTime($timeArray[0], $timeArray[1]);
  260. }
  261. $date = clone $this->periodEndTime;
  262. $date->setTime(
  263. $periodEndTime->format('G'),
  264. $periodEndTime->format('i'),
  265. $periodEndTime->format('s')
  266. );
  267. $this->periodEndTime = $date;
  268. }
  269. /**
  270. * @return int
  271. */
  272. public function getPeriodRepeatable()
  273. {
  274. return $this->periodRepeatable;
  275. }
  276. /**
  277. * @param int $periodRepeatable
  278. */
  279. public function setPeriodRepeatable($periodRepeatable)
  280. {
  281. $this->periodRepeatable = $periodRepeatable;
  282. }
  283. /**
  284. * @return int
  285. */
  286. public function getPeriodSpecificChargeType()
  287. {
  288. return $this->periodSpecificChargeType;
  289. }
  290. /**
  291. * @param int $periodSpecificChargeType
  292. */
  293. public function setPeriodSpecificChargeType($periodSpecificChargeType)
  294. {
  295. $this->periodSpecificChargeType = $periodSpecificChargeType;
  296. }
  297. /**
  298. * @return int
  299. */
  300. public function getPeriodSpecificChargeValue()
  301. {
  302. return $this->periodSpecificChargeValue;
  303. }
  304. /**
  305. * @param int $periodSpecificChargeValue
  306. */
  307. public function setPeriodSpecificChargeValue($periodSpecificChargeValue)
  308. {
  309. $this->periodSpecificChargeValue = $periodSpecificChargeValue;
  310. }
  311. /**
  312. * @return int
  313. */
  314. public function getPeriodChargeType()
  315. {
  316. return $this->periodChargeType;
  317. }
  318. /**
  319. * @param int $periodChargeType
  320. */
  321. public function setPeriodChargeType($periodChargeType)
  322. {
  323. $this->periodChargeType = $periodChargeType;
  324. }
  325. /**
  326. * @return int
  327. */
  328. public function getPeriodPriority()
  329. {
  330. return $this->periodPriority;
  331. }
  332. /**
  333. * @param int $periodPriority
  334. */
  335. public function setPeriodPriority($periodPriority)
  336. {
  337. $this->periodPriority = $periodPriority;
  338. }
  339. /**
  340. * @return boolean
  341. */
  342. public function getBookingDisabled()
  343. {
  344. return $this->bookingDisabled;
  345. }
  346. /**
  347. * @param boolean $bookingDisabled
  348. */
  349. public function setBookingDisabled($bookingDisabled)
  350. {
  351. $this->bookingDisabled = $bookingDisabled;
  352. }
  353. /**
  354. * @return String
  355. */
  356. public function getDisabledMessages()
  357. {
  358. return $this->disabledMessages;
  359. }
  360. /**
  361. * @param String $disabledMessages
  362. */
  363. public function setDisabledMessages($disabledMessages)
  364. {
  365. $this->disabledMessages = $disabledMessages;
  366. }
  367. /**
  368. * @return String
  369. */
  370. public function getOperatorDisabledMessage()
  371. {
  372. return $this->operatorDisabledMessage;
  373. }
  374. /**
  375. * @param String $operatorDisabledMessage
  376. */
  377. public function setOperatorDisabledMessage($operatorDisabledMessage)
  378. {
  379. $this->operatorDisabledMessage = $operatorDisabledMessage;
  380. }
  381. /**
  382. * @return float
  383. */
  384. public function getMinimumPriceBooking()
  385. {
  386. return $this->minimumPriceBooking;
  387. }
  388. /**
  389. * @param float $minimumPriceBooking
  390. */
  391. public function setMinimumPriceBooking($minimumPriceBooking)
  392. {
  393. $this->minimumPriceBooking = $minimumPriceBooking;
  394. }
  395. public function __toString()
  396. {
  397. return $this->getId() ? $this->getId().'' : 'n\a';
  398. }
  399. }