112 lines
2.4 KiB
PHP
112 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Model;
|
|
|
|
use App\Entity\Destination;
|
|
use App\Entity\JobProfile;
|
|
|
|
class AssignmentFilterDto
|
|
{
|
|
public const DURATION_WEEKEND = 1;
|
|
public const DURATION_MID_WEEK = 2;
|
|
public const DURATION_FULL_WEEK = 3;
|
|
public const DURATION_MORE = 4;
|
|
|
|
private ?\DateTimeImmutable $dateFrom = null;
|
|
private ?\DateTimeImmutable $dateTo = null;
|
|
private ?JobProfile $jobProfile = null;
|
|
private ?Destination $destination = null;
|
|
private ?int $duration = null;
|
|
private bool $reset;
|
|
|
|
public function __construct(bool $reset = false)
|
|
{
|
|
$this->reset = $reset;
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return $this->getActiveFiltersCount() > 0;
|
|
}
|
|
|
|
public function getActiveFiltersCount(): int
|
|
{
|
|
$freshInstance = new static();
|
|
$filterCount = 0;
|
|
$reflection = new \ReflectionClass(static::class);
|
|
|
|
foreach ($reflection->getProperties() as $property) {
|
|
$name = $property->getName();
|
|
if ($this->$name !== $freshInstance->$name) {
|
|
++$filterCount;
|
|
}
|
|
}
|
|
|
|
return $filterCount;
|
|
}
|
|
|
|
public function getDateFrom(): ?\DateTimeImmutable
|
|
{
|
|
return $this->dateFrom;
|
|
}
|
|
|
|
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
|
|
{
|
|
$this->dateFrom = $dateFrom;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDateTo(): ?\DateTimeImmutable
|
|
{
|
|
return $this->dateTo;
|
|
}
|
|
|
|
public function setDateTo(?\DateTimeImmutable $dateTo): static
|
|
{
|
|
$this->dateTo = $dateTo;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getJobProfile(): ?JobProfile
|
|
{
|
|
return $this->jobProfile;
|
|
}
|
|
|
|
public function setJobProfile(?JobProfile $jobProfile): static
|
|
{
|
|
$this->jobProfile = $jobProfile;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDestination(): ?Destination
|
|
{
|
|
return $this->destination;
|
|
}
|
|
|
|
public function setDestination(?Destination $destination): static
|
|
{
|
|
$this->destination = $destination;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDuration(): ?int
|
|
{
|
|
return $this->duration;
|
|
}
|
|
|
|
public function setDuration(?int $duration): static
|
|
{
|
|
$this->duration = $duration;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isReset(): bool
|
|
{
|
|
return $this->reset;
|
|
}
|
|
} |