<?php
namespace App\Entity\Pro;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OpeningHour
*
* @ORM\Table(name="tam_opening_hours")
* @ORM\Entity(repositoryClass="App\Repository\Pro\OpeningHourRepository")
*/
class OpeningHour
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \Pro
*
* @ORM\ManyToOne(targetEntity="\App\Entity\Pro\Pro", inversedBy="openingHours")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="pro", referencedColumnName="id", onDelete="CASCADE", nullable=false)
* })
*/
private $pro;
/**
* @var integer
*
* @ORM\Column(name="day", type="integer", options={"default": 0})
*/
private $day;
/**
* @var \Time
*
* @ORM\Column(name="hour_start", type="time", nullable=true)
*/
private $hourStart;
/**
* @var \Time
*
* @ORM\Column(name="hour_end", type="time", nullable=true)
*/
private $hourEnd;
/**
* @var \Time
*
* @ORM\Column(name="hour_start2", type="time", nullable=true)
*/
private $hourStart2;
/**
* @var \Time
*
* @ORM\Column(name="hour_end2", type="time", nullable=true)
*/
private $hourEnd2;
/**
* @var boolean
*
* @ORM\Column(name="all_day_service", type="boolean", options={"default": FALSE})
*/
private $allDayService;
/**
* @var boolean
*
* @ORM\Column(name="closed", type="boolean", options={"default": FALSE})
*/
private $closed;
public function __construct($_id = null)
{
if($_id)
$this->id = $_id;
$this->allDayService = false;
$this->closed = false;
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set pro
*
* @param \App\Entity\Pro\Pro $pro
*
* @return OpeningHour
*/
public function setPro(\App\Entity\Pro\Pro $pro)
{
$this->pro = $pro;
return $this;
}
/**
* Get pro
*
* @return \App\Entity\Pro\Pro
*/
public function getPro()
{
return $this->pro;
}
/**
* Set day
*
* @param integer $day
*
* @return OpeningHour
*/
public function setDay($day)
{
$this->day = $day;
return $this;
}
/**
* Get day
*
* @return integer
*/
public function getDay()
{
return $this->day;
}
/**
* Set hourStart
*
* @param \Time $hourStart
*
* @return OpeningHour
*/
public function setHourStart($hourStart)
{
$this->hourStart = $hourStart;
return $this;
}
/**
* Get hourStart
*
* @return \Time
*/
public function getHourStart()
{
return $this->hourStart;
}
/**
* Set hourEnd
*
* @param \Time $hourEnd
*
* @return OpeningHour
*/
public function setHourEnd($hourEnd)
{
$this->hourEnd = $hourEnd;
return $this;
}
/**
* Get hourEnd
*
* @return \Time
*/
public function getHourEnd()
{
return $this->hourEnd;
}
/**
* Set hourStart2
*
* @param \Time $hourStart2
*
* @return OpeningHour
*/
public function setHourStart2($hourStart2)
{
$this->hourStart2 = $hourStart2;
return $this;
}
/**
* Get hourStart2
*
* @return \Time
*/
public function getHourStart2()
{
return $this->hourStart2;
}
/**
* Set hourEnd2
*
* @param \Time $hourEnd2
*
* @return OpeningHour
*/
public function setHourEnd2($hourEnd2)
{
$this->hourEnd2 = $hourEnd2;
return $this;
}
/**
* Get hourEnd2
*
* @return \Time
*/
public function getHourEnd2()
{
return $this->hourEnd2;
}
/**
* Set allDayService
*
* @param boolean $allDayService
*
* @return OpeningHour
*/
public function setAllDayService($allDayService)
{
$this->allDayService = $allDayService;
return $this;
}
/**
* Get allDayService
*
* @return boolean
*/
public function getAllDayService()
{
return $this->allDayService;
}
/**
* Set closed
*
* @param boolean $closed
*
* @return OpeningHour
*/
public function setClosed($closed)
{
$this->closed = $closed;
return $this;
}
/**
* Get closed
*
* @return boolean
*/
public function getClosed()
{
return $this->closed;
}
/***********************
* OTHER FUNCTION
***********************/
public function updateFromJson($jsonObject){
$this->day = $jsonObject->day;
if(isset($jsonObject->hourStart) && $jsonObject->hourStart != "NULL"){
$this->setHourStart(\DateTime::createFromFormat("H:i", gmdate("H:i", $jsonObject->hourStart)));
}else{
$this->setHourStart(null);
}
if(isset($jsonObject->hourEnd) && $jsonObject->hourEnd != "NULL"){
$this->setHourEnd(\DateTime::createFromFormat("H:i", gmdate("H:i", $jsonObject->hourEnd)));
}else{
$this->setHourEnd(null);
}
if(isset($jsonObject->hourStart2) && $jsonObject->hourStart2 != "NULL"){
$this->setHourStart2(\DateTime::createFromFormat("H:i", gmdate("H:i", $jsonObject->hourStart2)));
}else{
$this->setHourStart2(null);
}
if(isset($jsonObject->hourEnd2) && $jsonObject->hourEnd2 != "NULL"){
$this->setHourEnd2(\DateTime::createFromFormat("H:i", gmdate("H:i", $jsonObject->hourEnd2)));
}else{
$this->setHourEnd2(null);
}
$this->setClosed($jsonObject->closed);
}
public function getArrayForJson(){
$array = array();
$array['id'] = $this->getId();
$array['day'] = $this->getDay();
if($this->getHourStart())
$array['hourStart'] = $this->getHourStart()->format("H") * 3600 + $this->getHourStart()->format("i") * 60;
else
$array['hourStart'] = null;
if($this->getHourEnd())
$array['hourEnd'] = $this->getHourEnd()->format("H") * 3600 + $this->getHourEnd()->format("i") * 60;
else
$array['hourEnd'] = null;
if($this->getHourStart2())
$array['hourStart2'] = $this->getHourStart2()->format("H") * 3600 + $this->getHourStart2()->format("i") * 60;
else
$array['hourStart2'] = null;
if($this->getHourEnd2())
$array['hourEnd2'] = $this->getHourEnd2()->format("H") * 3600 + $this->getHourEnd2()->format("i") * 60;
else
$array['hourEnd2'] = null;
$array['closed'] = $this->getClosed();
return $array;
}
}