<?php
namespace AdminBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* PeriodSettings
*/
#[ORM\Table(name: 'period_settings')]
#[ORM\Entity(repositoryClass: \AdminBundle\Repository\PeriodSettingsRepository::class)]
class PeriodSettings extends BaseEntity
{
const PERIOD_REPEATABLE_DAILY = 0;
const PERIOD_REPEATABLE_WEEKLY = 1;
const PERIOD_REPEATABLE_MONTHLY = 2;
const PERIOD_REPEATABLE_YEARLY = 3;
public static $periodRepeatableTypes = array(
self::PERIOD_REPEATABLE_DAILY => 'daily',
self::PERIOD_REPEATABLE_WEEKLY => 'weekly',
self::PERIOD_REPEATABLE_MONTHLY => 'monthly',
self::PERIOD_REPEATABLE_YEARLY => 'yearly'
);
const PERIOD_SPECIFIC_CHARGE_PERCENTAGE = 0;
const PERIOD_SPECIFIC_CHARGE_VALUE = 1;
public static $periodSpecificChargeTypes = array(
self::PERIOD_SPECIFIC_CHARGE_PERCENTAGE => '%',
self::PERIOD_SPECIFIC_CHARGE_VALUE => 'value'
);
const PERIOD_CHARGE_ADDED = 0;
const PERIOD_CHARGE_SUBSTRACTED = 1;
public static $periodChargeTypes = array(
self::PERIOD_CHARGE_ADDED => '+',
self::PERIOD_CHARGE_SUBSTRACTED => '-'
);
/**
* @var integer
*/
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
protected $id;
/**
* @var \String
*/
#[ORM\Column(name: 'period_name', type: 'string', length: 64)]
protected $periodName;
/**
* @var array
*/
#[ORM\Column(name: 'period_start', type: 'array')]
protected $periodStart;
/**
* @var array
*/
#[ORM\Column(name: 'period_end', type: 'array')]
protected $periodEnd;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'period_start_time', type: 'time')]
protected $periodStartTime;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'period_end_time', type: 'time')]
protected $periodEndTime;
/**
* @var \Integer
*/
#[ORM\Column(name: 'period_repeatable', type: 'integer')]
protected $periodRepeatable;
/**
* @var \Integer
*/
#[ORM\Column(name: 'period_specific_charge_type', type: 'integer')]
protected $periodSpecificChargeType;
/**
* @var \Integer
*/
#[ORM\Column(name: 'period_specific_charge_value', type: 'integer', nullable: true)]
protected $periodSpecificChargeValue;
/**
* @var \Integer
*/
#[ORM\Column(name: 'period_charge_type', type: 'integer')]
protected $periodChargeType;
/**
* @var integer
*/
#[ORM\Column(name: 'booking_disabled', type: 'boolean', nullable: true)]
protected $bookingDisabled = false;
/**
* @var \String
*/
#[ORM\Column(name: 'disabled_messages', type: 'string', nullable: true)]
protected $disabledMessages;
/**
* @var \String
*/
#[ORM\Column(name: 'operator_disabled_messages', type: 'string', nullable: true)]
protected $operatorDisabledMessage;
/**
* @var float
*/
#[ORM\Column(name: 'minimum_price_booking', type: 'decimal', precision: 7, scale: 2, nullable: true)]
protected $minimumPriceBooking = 0;
/**
* @var \Integer
*/
#[ORM\Column(name: 'period_priority', type: 'integer')]
protected $periodPriority;
#[ORM\JoinTable(name: 'periods_cartypes')]
#[ORM\JoinColumn(name: 'cartype_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'period_id', referencedColumnName: 'id')]
#[ORM\ManyToMany(targetEntity: \CarType::class)]
protected $carTypes;
static function convertToDateTime($dateString)
{
$dateArray = explode('/', $dateString);
return new \DateTime($dateArray[2]. '-' . $dateArray[0]. '-'. $dateArray[1]);
}
public function __construct()
{
$this->carTypes = new ArrayCollection();
$this->periodStartTime = new \DateTime();
$this->periodEndTime = new \DateTime();
}
/**
* @return mixed
*/
public function getCarTypes() {
return $this->carTypes;
}
/**
* @param mixed $var
*/
public function setCarTypes($var) {
$this->carTypes = $var;
}
/**
* @return array
*/
public function getCarTypeIds() {
$ids = [];
foreach ($this->getCarTypes() as $carType) {
$ids[] = $carType->getId();
}
return $ids;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return String
*/
public function getPeriodName()
{
return $this->periodName;
}
/**
* @param String $periodName
*/
public function setPeriodName($periodName)
{
$this->periodName = $periodName;
}
public function getPeriodStartTimeDateFormat()
{
$periodStartTime = new \DateTime();
$periodStartTime->setTime(
$this->periodStartTime->format('G'),
$this->periodStartTime->format('i'),
$this->periodStartTime->format('s')
);
return $periodStartTime;
}
public function getPeriodStartTime()
{
if (! $this->periodStartTime) {
return ;
}
return $this->periodStartTime->format('H:i');
}
public function setPeriodStartTime($periodStartTime)
{
if (is_string($periodStartTime)) {
$timeArray = explode(':', $periodStartTime);
$periodStartTime = new \DateTime();
$periodStartTime->setTime($timeArray[0], $timeArray[1]);
}
$date = clone $this->periodStartTime;
$date->setTime(
$periodStartTime->format('G'),
$periodStartTime->format('i'),
$periodStartTime->format('s')
);
$this->periodStartTime = $date;
}
/**
* @return array
*/
public function getPeriodStart()
{
return $this->periodStart;
}
/**
* @param array $periodStart
*/
public function setPeriodStart($periodStart)
{
$this->periodStart = $periodStart;
}
/**
* @return array
*/
public function getPeriodEnd()
{
return $this->periodEnd;
}
/**
* @param array $periodEnd
*/
public function setPeriodEnd($periodEnd)
{
$this->periodEnd = $periodEnd;
}
public function getPeriodEndTimeDateFormat()
{
$periodEndTime = new \DateTime();
$periodEndTime->setTime(
$this->periodEndTime->format('G'),
$this->periodEndTime->format('i'),
$this->periodEndTime->format('s')
);
return $periodEndTime;
}
public function getPeriodEndTime()
{
if (! $this->periodEndTime) {
return ;
}
return $this->periodEndTime->format('H:i');
}
public function setPeriodEndTime($periodEndTime)
{
if (is_string($periodEndTime)) {
$timeArray = explode(':', $periodEndTime);
$periodEndTime = new \DateTime();
$periodEndTime->setTime($timeArray[0], $timeArray[1]);
}
$date = clone $this->periodEndTime;
$date->setTime(
$periodEndTime->format('G'),
$periodEndTime->format('i'),
$periodEndTime->format('s')
);
$this->periodEndTime = $date;
}
/**
* @return int
*/
public function getPeriodRepeatable()
{
return $this->periodRepeatable;
}
/**
* @param int $periodRepeatable
*/
public function setPeriodRepeatable($periodRepeatable)
{
$this->periodRepeatable = $periodRepeatable;
}
/**
* @return int
*/
public function getPeriodSpecificChargeType()
{
return $this->periodSpecificChargeType;
}
/**
* @param int $periodSpecificChargeType
*/
public function setPeriodSpecificChargeType($periodSpecificChargeType)
{
$this->periodSpecificChargeType = $periodSpecificChargeType;
}
/**
* @return int
*/
public function getPeriodSpecificChargeValue()
{
return $this->periodSpecificChargeValue;
}
/**
* @param int $periodSpecificChargeValue
*/
public function setPeriodSpecificChargeValue($periodSpecificChargeValue)
{
$this->periodSpecificChargeValue = $periodSpecificChargeValue;
}
/**
* @return int
*/
public function getPeriodChargeType()
{
return $this->periodChargeType;
}
/**
* @param int $periodChargeType
*/
public function setPeriodChargeType($periodChargeType)
{
$this->periodChargeType = $periodChargeType;
}
/**
* @return int
*/
public function getPeriodPriority()
{
return $this->periodPriority;
}
/**
* @param int $periodPriority
*/
public function setPeriodPriority($periodPriority)
{
$this->periodPriority = $periodPriority;
}
/**
* @return boolean
*/
public function getBookingDisabled()
{
return $this->bookingDisabled;
}
/**
* @param boolean $bookingDisabled
*/
public function setBookingDisabled($bookingDisabled)
{
$this->bookingDisabled = $bookingDisabled;
}
/**
* @return String
*/
public function getDisabledMessages()
{
return $this->disabledMessages;
}
/**
* @param String $disabledMessages
*/
public function setDisabledMessages($disabledMessages)
{
$this->disabledMessages = $disabledMessages;
}
/**
* @return String
*/
public function getOperatorDisabledMessage()
{
return $this->operatorDisabledMessage;
}
/**
* @param String $operatorDisabledMessage
*/
public function setOperatorDisabledMessage($operatorDisabledMessage)
{
$this->operatorDisabledMessage = $operatorDisabledMessage;
}
/**
* @return float
*/
public function getMinimumPriceBooking()
{
return $this->minimumPriceBooking;
}
/**
* @param float $minimumPriceBooking
*/
public function setMinimumPriceBooking($minimumPriceBooking)
{
$this->minimumPriceBooking = $minimumPriceBooking;
}
public function __toString()
{
return $this->getId() ? $this->getId().'' : 'n\a';
}
}