187 lines
3.5 KiB
PHP
187 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
/**
|
|
* Tallyday
|
|
*
|
|
* @ORM\Table(name="tallyday",indexes={@ORM\Index(name="search_idx", columns={"user_id", "dateof"})})
|
|
* @ORM\Entity(repositoryClass="App\Repository\TallydayRepository")
|
|
*/
|
|
class Tallyday
|
|
{
|
|
/**
|
|
* @var integer
|
|
*
|
|
* @ORM\Column(name="id", type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="date", nullable=false)
|
|
*/
|
|
private $dateof;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
private $datestart;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
private $dateend;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
private $validateuser;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
private $validatemaster;
|
|
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
private $isbreakday;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", nullable=true)
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="tallydays")
|
|
*/
|
|
private $user;
|
|
|
|
// Calculate
|
|
private $timeday;
|
|
public function getTimeday() {
|
|
$e = new \DateTime('00:00');
|
|
$f = clone $e;
|
|
|
|
if($this->datestart && $this->dateend)
|
|
$e->add(date_diff($this->datestart, $this->dateend));
|
|
|
|
return $f->diff($e);
|
|
|
|
}
|
|
public function getTimedayformatted() {
|
|
$interval=$this->getTimeday();
|
|
$timeday = sprintf("%02s",(($interval->days*24)) + $interval->h).":".sprintf("%02s",$interval->i);
|
|
return $timeday;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getDateof(): ?\DateTimeInterface
|
|
{
|
|
return $this->dateof;
|
|
}
|
|
|
|
public function setDateof(\DateTimeInterface $dateof): self
|
|
{
|
|
$this->dateof = $dateof;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDatestart(): ?\DateTimeInterface
|
|
{
|
|
return $this->datestart;
|
|
}
|
|
|
|
public function setDatestart(?\DateTimeInterface $datestart): self
|
|
{
|
|
$this->datestart = $datestart;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDateend(): ?\DateTimeInterface
|
|
{
|
|
return $this->dateend;
|
|
}
|
|
|
|
public function setDateend(?\DateTimeInterface $dateend): self
|
|
{
|
|
$this->dateend = $dateend;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getValidateuser(): ?bool
|
|
{
|
|
return $this->validateuser;
|
|
}
|
|
|
|
public function setValidateuser(bool $validateuser): self
|
|
{
|
|
$this->validateuser = $validateuser;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getValidatemaster(): ?bool
|
|
{
|
|
return $this->validatemaster;
|
|
}
|
|
|
|
public function setValidatemaster(bool $validatemaster): self
|
|
{
|
|
$this->validatemaster = $validatemaster;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUser(): ?User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function setUser(?User $user): self
|
|
{
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIsbreakday(): ?bool
|
|
{
|
|
return $this->isbreakday;
|
|
}
|
|
|
|
public function setIsbreakday(bool $isbreakday): self
|
|
{
|
|
$this->isbreakday = $isbreakday;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(?string $name): self
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
|
|
|
|
}
|