<?php
namespace App\Entity;
use App\Entity\Traits\DefaultTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\String\ByteString;
/**
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User
{
use DefaultTrait;
public const GENDER_NONE = 0;
public const GENDER_BINARY = 1;
public const GENDER_MALE = 2;
public const GENDER_FEMALE = 3;
public const GENDER = [
'NONE' => self::GENDER_NONE,
'BINARY' => self::GENDER_BINARY,
'MALE' => self::GENDER_MALE,
'FEMALE' => self::GENDER_FEMALE
];
public const STATUS_UNPUBLISHED = 0;
public const STATUS_PUBLISHED = 1;
public const STATUS_PENDING = 2;
public const STATUS = [
'UNPUBLISHED' => self::STATUS_UNPUBLISHED,
'PUBLISHED' => self::STATUS_PUBLISHED,
'PENDING' => self::STATUS_PENDING
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Headquarter", inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private Headquarter $headquarter;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
* @ORM\JoinColumn(nullable=false)
*/
private Language $preferred_language;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Role", inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private Role $role;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private Category $category;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $type = null;
/**
* @ORM\Column(type="string", length=255)
*/
private string $email;
/**
* @ORM\Column(type="string", length=255)
*/
private string $password;
/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
/**
* @ORM\Column(type="string", length=255)
*/
private string $surname;
/**
* @ORM\Column(type="integer")
*/
private int $gender = self::GENDER_NONE;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $entity = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $avatar = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $cover = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $code_alpha = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $document_type = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $document_number = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $address = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $city = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $postal = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $region = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $country = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $phone = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $current_position = null;
/**
* @ORM\Column(type="date", nullable=true)
*/
private ?\DateTime $birthdate = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $about_me = null;
/**
* @ORM\Column(type="integer")
*/
private int $num_total_holidays = 0;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $tos_accepted = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $is_enabled_newsletter = true;
/**
* @ORM\Column(type="boolean")
*/
private bool $is_enabled_push = true;
/**
* @ORM\Column(type="boolean")
*/
private bool $is_enabled_email = true;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $last_visit_date = null;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_monday = 0;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_tuesday = 0;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_wednesday = 0;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_thursday = 0;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_friday = 0;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_saturday = 0;
/**
* @ORM\Column(type="float", scale="2")
*/
private float $daily_hours_sunday = 0;
/**
* @var ArrayCollection|UserDevice[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserDevice", mappedBy="user", cascade={"persist", "remove"})
*/
private $devices;
/**
* @var ArrayCollection|UserHoliday[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserHoliday", mappedBy="user", cascade={"persist", "remove"})
*/
private $holidays;
/**
* @var ArrayCollection|UserRecovery[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserRecovery", mappedBy="user", cascade={"persist", "remove"})
*/
private $recoveries;
/**
* @var ArrayCollection|UserTimesheet[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserTimesheet", mappedBy="user", cascade={"persist", "remove"})
*/
private $timesheets;
/**
* @var ArrayCollection|UserSchedule[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserSchedule", mappedBy="user", cascade={"persist", "remove"})
*/
private $schedules;
/**
* @var ArrayCollection|SurveyUserAnswer[]
*
* @ORM\OneToMany(targetEntity="App\Entity\SurveyUserAnswer", mappedBy="user", cascade={"persist", "remove"})
* @ORM\OrderBy({"cdate" = "DESC"})
*/
private $surveys;
/**
* @var ArrayCollection|QuizzUserAnswer[]
*
* @ORM\OneToMany(targetEntity="App\Entity\QuizzUserAnswer", mappedBy="user", cascade={"persist", "remove"})
* @ORM\OrderBy({"cdate" = "DESC"})
*/
private $quizzes;
/**
* @var ArrayCollection|Tag[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Tag", inversedBy="users")
* @ORM\JoinTable(name="user_tag")
*/
private $tags;
/**
* @var ArrayCollection|Audience[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Audience", mappedBy="users")
*/
private $audiences;
/**
* @var ArrayCollection|Audience[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Audience", mappedBy="filter_users")
*/
private $filter_audiences;
/**
* @var ArrayCollection|Article[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Article", mappedBy="users_assigned")
*/
private $articles_assigned;
/**
* @var ArrayCollection|Email[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Email", mappedBy="users_assigned")
*/
private $emails_assigned;
/**
* @var ArrayCollection|Notification[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Notification", mappedBy="users_assigned")
*/
private $notifications_assigned;
/**
* @var ArrayCollection|Reservation[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Reservation", mappedBy="users_assigned")
*/
private $reservations_assigned;
/**
* @var ArrayCollection|UserNotification[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserNotification", mappedBy="user", cascade={"persist", "remove"})
*/
private $notifications;
/**
* @var ArrayCollection|Survey[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Survey", mappedBy="users_assigned")
*/
private $surveys_assigned;
/**
* @var ArrayCollection|WorkgroupUserSubscribed[]
*
* @ORM\OneToMany(targetEntity="App\Entity\WorkgroupUserSubscribed", mappedBy="user", cascade={"persist", "remove"})
*/
private $workgroups_subscribed;
/**
* @var ArrayCollection|WorkgroupComment[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\WorkgroupComment", mappedBy="likes")
*/
private $workgroup_comment_likes;
/**
* @var ArrayCollection|Article[]
*
* @ORM\ManyToMany(targetEntity="App\Entity\Article", mappedBy="users_subscribed")
*/
private $articles_subscribed;
/**
* @var ArrayCollection|UserReservation[]
*
* @ORM\OneToMany(targetEntity="App\Entity\UserReservation", mappedBy="user", cascade={"persist", "remove"})
*/
private $reservations;
/**
* @var ArrayCollection|Category[]
*
* @ORM\OneToMany(targetEntity="App\Entity\Category", mappedBy="head_holidays")
*/
private $categories_head_holidays;
/**
* @var ArrayCollection|Category[]
*
* @ORM\OneToMany(targetEntity="App\Entity\Category", mappedBy="head_timesheets")
*/
private $categories_head_timesheets;
/**
* @var User
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="users_head_holidays")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $head_holidays;
/**
* @var ArrayCollection|User[]
* @ORM\OneToMany(targetEntity=User::class, mappedBy="head_holidays")
*/
private $users_head_holidays;
/**
* @var User
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="users_head_timesheets")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $head_timesheets;
/**
* @var ArrayCollection|User[]
* @ORM\OneToMany(targetEntity=User::class, mappedBy="head_timesheets")
*/
private $users_head_timesheets;
/**
* @var Workplace
* @ORM\ManyToOne(targetEntity=Workplace::class, inversedBy="users")
*/
private $workplace;
/**
* @var float
* @ORM\Column(type="float", nullable=true)
*/
private $daily_hours;
/**
* @var ArrayCollection|ArticleUserView[]
*
* @ORM\OneToMany(targetEntity=ArticleUserView::class, mappedBy="user")
*/
private $articleUserViews;
/**
* @var ArrayCollection|WorkgroupUserView[]
*
* @ORM\OneToMany(targetEntity=WorkgroupUserView::class, mappedBy="user")
*/
private $workgroupUserViews;
/**
* @var ArrayCollection|DocumentFileView[]
*
* @ORM\OneToMany(targetEntity=DocumentFileView::class, mappedBy="user")
*/
private $documentFileViews;
/**
* @ORM\OneToMany(targetEntity=Fingerprint::class, mappedBy="user", orphanRemoval=true)
*/
private $fingerprints;
public function __construct(Headquarter $headquarter)
{
$this->headquarter = $headquarter;
$this->preferred_language = $headquarter->getPreferredLanguage();
$this->setPassword(ByteString::fromRandom(4)->upper());
$this->status = self::STATUS_PUBLISHED;
$this->devices = new ArrayCollection();
$this->recoveries = new ArrayCollection();
$this->timesheets = new ArrayCollection();
$this->surveys = new ArrayCollection();
$this->tags = new ArrayCollection();
$this->audiences = new ArrayCollection();
$this->filter_audiences = new ArrayCollection();
$this->articles_assigned = new ArrayCollection();
$this->emails_assigned = new ArrayCollection();
$this->notifications_assigned = new ArrayCollection();
$this->reservations_assigned = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->surveys_assigned = new ArrayCollection();
$this->workgroups_subscribed = new ArrayCollection();
$this->workgroup_comment_likes = new ArrayCollection();
$this->articles_subscribed = new ArrayCollection();
$this->reservations = new ArrayCollection();
$this->holidays = new ArrayCollection();
$this->categories_head_holidays = new ArrayCollection();
$this->categories_head_timesheets = new ArrayCollection();
$this->users_head_holidays = new ArrayCollection();
$this->users_head_timesheets = new ArrayCollection();
$this->articleUserViews = new ArrayCollection();
$this->workgroupUserViews = new ArrayCollection();
$this->quizzes = new ArrayCollection();
$this->documentFileViews = new ArrayCollection();
$this->schedules = new ArrayCollection();
$this->fingerprints = new ArrayCollection();
}
/**
* @internal Added function
*/
public function getFullname(): ?string
{
return sprintf('%s %s', $this->name, $this->surname);
}
/**
* @return false|string
* @internal Added function
*
*/
public function getGenderToString()
{
return array_search($this->gender, self::GENDER);
}
/**
* @internal Added function
*/
public function setGenderFromString(string $gender): self
{
$this->gender = self::GENDER[$gender];
return $this;
}
/**
* @internal Added function
*/
public function getIsTosAccepted(): bool
{
return $this->tos_accepted !== null;
}
/*
* @internal Added function
*
public function setPasswordBcrypt(string $bcrypt): self
{
$this->password = $bcrypt;
return $this;
}
*/
/**
* @internal Updated function
*/
public function setPassword(string $password): self
{
$this->password = (string)password_hash($password, PASSWORD_BCRYPT);
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(?int $type): self
{
$this->type = $type;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSurname(): ?string
{
return $this->surname;
}
public function setSurname(string $surname): self
{
$this->surname = $surname;
return $this;
}
public function getGender(): ?int
{
return $this->gender;
}
public function setGender(int $gender): self
{
$this->gender = $gender;
return $this;
}
public function getAvatar(): ?string
{
return $this->avatar;
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getCover(): ?string
{
return $this->cover;
}
public function setCover(?string $cover): self
{
$this->cover = $cover;
return $this;
}
public function getCodeAlpha(): ?string
{
return $this->code_alpha;
}
public function setCodeAlpha(?string $code_alpha): self
{
$this->code_alpha = $code_alpha;
return $this;
}
public function getDocumentType(): ?string
{
return $this->document_type;
}
public function setDocumentType(?string $document_type): self
{
$this->document_type = $document_type;
return $this;
}
public function getDocumentNumber(): ?string
{
return $this->document_number;
}
public function setDocumentNumber(?string $document_number): self
{
$this->document_number = $document_number;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getPostal(): ?string
{
return $this->postal;
}
public function setPostal(?string $postal): self
{
$this->postal = $postal;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(?string $region): self
{
$this->region = $region;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getCurrentPosition(): ?string
{
return $this->current_position;
}
public function setCurrentPosition(?string $current_position): self
{
$this->current_position = $current_position;
return $this;
}
public function getBirthdate(): ?\DateTime
{
return $this->birthdate;
}
public function setBirthdate(?\DateTime $birthdate): self
{
$this->birthdate = $birthdate;
return $this;
}
public function getAboutMe(): ?string
{
return $this->about_me;
}
public function setAboutMe(?string $about_me): self
{
$this->about_me = $about_me;
return $this;
}
public function getTosAccepted(): ?\DateTime
{
return $this->tos_accepted;
}
public function setTosAccepted(?\DateTime $tos_accepted): self
{
$this->tos_accepted = $tos_accepted;
return $this;
}
public function getIsEnabledNewsletter(): ?bool
{
return $this->is_enabled_newsletter;
}
public function setIsEnabledNewsletter(bool $is_enabled_newsletter): self
{
$this->is_enabled_newsletter = $is_enabled_newsletter;
return $this;
}
public function getIsEnabledPush(): ?bool
{
return $this->is_enabled_push;
}
public function setIsEnabledPush(bool $is_enabled_push): self
{
$this->is_enabled_push = $is_enabled_push;
return $this;
}
public function getIsEnabledEmail(): ?bool
{
return $this->is_enabled_email;
}
public function setIsEnabledEmail(bool $is_enabled_email): self
{
$this->is_enabled_email = $is_enabled_email;
return $this;
}
public function getLastVisitDate(): ?\DateTime
{
return $this->last_visit_date;
}
public function setLastVisitDate(?\DateTime $last_visit_date): self
{
$this->last_visit_date = $last_visit_date;
return $this;
}
public function getEntity(): ?string
{
return $this->entity;
}
public function setEntity(?string $entity): self
{
$this->entity = $entity;
return $this;
}
public function getHeadquarter(): ?Headquarter
{
return $this->headquarter;
}
public function setHeadquarter(?Headquarter $headquarter): self
{
$this->headquarter = $headquarter;
return $this;
}
public function getPreferredLanguage(): ?Language
{
return $this->preferred_language;
}
public function setPreferredLanguage(?Language $preferred_language): self
{
$this->preferred_language = $preferred_language;
return $this;
}
public function getRole(): ?Role
{
return $this->role;
}
public function setRole(?Role $role): self
{
$this->role = $role;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Collection|UserDevice[]
*/
public function getDevices(): Collection
{
return $this->devices;
}
public function addDevice(UserDevice $device): self
{
if (!$this->devices->contains($device)) {
$this->devices[] = $device;
$device->setUser($this);
}
return $this;
}
public function removeDevice(UserDevice $device): self
{
if ($this->devices->removeElement($device)) {
// set the owning side to null (unless already changed)
if ($device->getUser() === $this) {
$device->setUser(null);
}
}
return $this;
}
/**
* @return Collection|UserRecovery[]
*/
public function getRecoveries(): Collection
{
return $this->recoveries;
}
public function addRecovery(UserRecovery $recovery): self
{
if (!$this->recoveries->contains($recovery)) {
$this->recoveries[] = $recovery;
$recovery->setUser($this);
}
return $this;
}
public function removeRecovery(UserRecovery $recovery): self
{
if ($this->recoveries->removeElement($recovery)) {
// set the owning side to null (unless already changed)
if ($recovery->getUser() === $this) {
$recovery->setUser(null);
}
}
return $this;
}
/**
* @return Collection|UserTimesheet[]
*/
public function getTimesheets(): Collection
{
return $this->timesheets;
}
public function addTimesheet(UserTimesheet $timesheet): self
{
if (!$this->timesheets->contains($timesheet)) {
$this->timesheets[] = $timesheet;
$timesheet->setUser($this);
}
return $this;
}
public function removeTimesheet(UserTimesheet $timesheet): self
{
if ($this->timesheets->removeElement($timesheet)) {
// set the owning side to null (unless already changed)
if ($timesheet->getUser() === $this) {
$timesheet->setUser(null);
}
}
return $this;
}
/**
* @return Collection|SurveyUserAnswer[]
*/
public function getSurveys(): Collection
{
return $this->surveys;
}
public function addSurvey(SurveyUserAnswer $survey): self
{
if (!$this->surveys->contains($survey)) {
$this->surveys[] = $survey;
$survey->setUser($this);
}
return $this;
}
public function removeSurvey(SurveyUserAnswer $survey): self
{
if ($this->surveys->removeElement($survey)) {
// set the owning side to null (unless already changed)
if ($survey->getUser() === $this) {
$survey->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Tag[]
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): self
{
if (!$this->tags->contains($tag)) {
$this->tags[] = $tag;
}
return $this;
}
public function removeTag(Tag $tag): self
{
$this->tags->removeElement($tag);
return $this;
}
/**
* @return Collection|Audience[]
*/
public function getAudiences(): Collection
{
return $this->audiences;
}
public function addAudience(Audience $audience): self
{
if (!$this->audiences->contains($audience)) {
$this->audiences[] = $audience;
$audience->addUser($this);
}
return $this;
}
public function removeAudience(Audience $audience): self
{
if ($this->audiences->removeElement($audience)) {
$audience->removeUser($this);
}
return $this;
}
/**
* @return Collection|Audience[]
*/
public function getFilterAudiences(): Collection
{
return $this->filter_audiences;
}
public function addFilterAudience(Audience $filterAudience): self
{
if (!$this->filter_audiences->contains($filterAudience)) {
$this->filter_audiences[] = $filterAudience;
$filterAudience->addFilterUser($this);
}
return $this;
}
public function removeFilterAudience(Audience $filterAudience): self
{
if ($this->filter_audiences->removeElement($filterAudience)) {
$filterAudience->removeFilterUser($this);
}
return $this;
}
/**
* @return Collection|Article[]
*/
public function getArticlesAssigned(): Collection
{
return $this->articles_assigned;
}
public function addArticlesAssigned(Article $articlesAssigned): self
{
if (!$this->articles_assigned->contains($articlesAssigned)) {
$this->articles_assigned[] = $articlesAssigned;
$articlesAssigned->addUsersAssigned($this);
}
return $this;
}
public function removeArticlesAssigned(Article $articlesAssigned): self
{
if ($this->articles_assigned->removeElement($articlesAssigned)) {
$articlesAssigned->removeUsersAssigned($this);
}
return $this;
}
/**
* @return Collection|Email[]
*/
public function getEmailsAssigned(): Collection
{
return $this->emails_assigned;
}
public function addEmailsAssigned(Email $emailsAssigned): self
{
if (!$this->emails_assigned->contains($emailsAssigned)) {
$this->emails_assigned[] = $emailsAssigned;
$emailsAssigned->addUsersAssigned($this);
}
return $this;
}
public function removeEmailsAssigned(Email $emailsAssigned): self
{
if ($this->emails_assigned->removeElement($emailsAssigned)) {
$emailsAssigned->removeUsersAssigned($this);
}
return $this;
}
/**
* @return Collection|Notification[]
*/
public function getNotificationsAssigned(): Collection
{
return $this->notifications_assigned;
}
public function addNotificationsAssigned(Notification $notificationsAssigned): self
{
if (!$this->notifications_assigned->contains($notificationsAssigned)) {
$this->notifications_assigned[] = $notificationsAssigned;
$notificationsAssigned->addUsersAssigned($this);
}
return $this;
}
public function removeNotificationsAssigned(Notification $notificationsAssigned): self
{
if ($this->notifications_assigned->removeElement($notificationsAssigned)) {
$notificationsAssigned->removeUsersAssigned($this);
}
return $this;
}
/**
* @return Collection|Reservation[]
*/
public function getReservationsAssigned(): Collection
{
return $this->reservations_assigned;
}
public function addReservationsAssigned(Reservation $reservationsAssigned): self
{
if (!$this->reservations_assigned->contains($reservationsAssigned)) {
$this->reservations_assigned[] = $reservationsAssigned;
$reservationsAssigned->addUsersAssigned($this);
}
return $this;
}
public function removeReservationsAssigned(Reservation $reservationsAssigned): self
{
if ($this->reservations_assigned->removeElement($reservationsAssigned)) {
$reservationsAssigned->removeUsersAssigned($this);
}
return $this;
}
/**
* @return Collection|UserNotification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(UserNotification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUser($this);
}
return $this;
}
public function removeNotification(UserNotification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Survey[]
*/
public function getSurveysAssigned(): Collection
{
return $this->surveys_assigned;
}
public function addSurveysAssigned(Survey $surveysAssigned): self
{
if (!$this->surveys_assigned->contains($surveysAssigned)) {
$this->surveys_assigned[] = $surveysAssigned;
$surveysAssigned->addUsersAssigned($this);
}
return $this;
}
public function removeSurveysAssigned(Survey $surveysAssigned): self
{
if ($this->surveys_assigned->removeElement($surveysAssigned)) {
$surveysAssigned->removeUsersAssigned($this);
}
return $this;
}
/**
* @return Collection|WorkgroupUserSubscribed[]
*/
public function getWorkgroupsSubscribed(): Collection
{
return $this->workgroups_subscribed;
}
public function addWorkgroupsSubscribed(WorkgroupUserSubscribed $workgroupsSubscribed): self
{
if (!$this->workgroups_subscribed->contains($workgroupsSubscribed)) {
$this->workgroups_subscribed[] = $workgroupsSubscribed;
$workgroupsSubscribed->setUser($this);
}
return $this;
}
public function removeWorkgroupsSubscribed(WorkgroupUserSubscribed $workgroupsSubscribed): self
{
if ($this->workgroups_subscribed->removeElement($workgroupsSubscribed)) {
// set the owning side to null (unless already changed)
if ($workgroupsSubscribed->getUser() === $this) {
$workgroupsSubscribed->setUser(null);
}
}
return $this;
}
/**
* @return Collection|WorkgroupComment[]
*/
public function getWorkgroupCommentLikes(): Collection
{
return $this->workgroup_comment_likes;
}
public function addWorkgroupCommentLike(WorkgroupComment $workgroupCommentLike): self
{
if (!$this->workgroup_comment_likes->contains($workgroupCommentLike)) {
$this->workgroup_comment_likes[] = $workgroupCommentLike;
$workgroupCommentLike->addLike($this);
}
return $this;
}
public function removeWorkgroupCommentLike(WorkgroupComment $workgroupCommentLike): self
{
if ($this->workgroup_comment_likes->removeElement($workgroupCommentLike)) {
$workgroupCommentLike->removeLike($this);
}
return $this;
}
/**
* @return Collection|Article[]
*/
public function getArticlesSubscribed(): Collection
{
return $this->articles_subscribed;
}
public function addArticleSubscribed(Article $articleSubscribed): self
{
if (!$this->articles_subscribed->contains($articleSubscribed)) {
$this->articles_subscribed[] = $articleSubscribed;
$articleSubscribed->addUsersSubscribed($this);
}
return $this;
}
public function removeArticleSubscribed(Article $articleSubscribed): self
{
if ($this->articles_subscribed->removeElement($articleSubscribed)) {
$articleSubscribed->removeUsersSubscribed($this);
}
return $this;
}
/**
* @return Collection|UserReservation[]
*/
public function getReservations(): Collection
{
return $this->reservations;
}
public function addReservation(UserReservation $reservation): self
{
if (!$this->reservations->contains($reservation)) {
$this->reservations[] = $reservation;
$reservation->setUser($this);
}
return $this;
}
public function removeReservation(UserReservation $reservation): self
{
if ($this->reservations->removeElement($reservation)) {
// set the owning side to null (unless already changed)
if ($reservation->getUser() === $this) {
$reservation->setUser(null);
}
}
return $this;
}
public function getNumTotalHolidays(): ?int
{
return $this->num_total_holidays;
}
public function setNumTotalHolidays(int $num_total_holidays): self
{
$this->num_total_holidays = $num_total_holidays;
return $this;
}
/**
* @return Collection|UserHoliday[]
*/
public function getHolidays(): Collection
{
return $this->holidays;
}
public function addHoliday(UserHoliday $holiday): self
{
if (!$this->holidays->contains($holiday)) {
$this->holidays[] = $holiday;
$holiday->setUser($this);
}
return $this;
}
public function removeHoliday(UserHoliday $holiday): self
{
if ($this->holidays->removeElement($holiday)) {
// set the owning side to null (unless already changed)
if ($holiday->getUser() === $this) {
$holiday->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategoriesHeadHolidays(): Collection
{
return $this->categories_head_holidays;
}
public function addCategoriesHeadHoliday(Category $categoriesHeadHoliday): self
{
if (!$this->categories_head_holidays->contains($categoriesHeadHoliday)) {
$this->categories_head_holidays[] = $categoriesHeadHoliday;
$categoriesHeadHoliday->setHeadHolidays($this);
}
return $this;
}
public function removeCategoriesHeadHoliday(Category $categoriesHeadHoliday): self
{
if ($this->categories_head_holidays->removeElement($categoriesHeadHoliday)) {
// set the owning side to null (unless already changed)
if ($categoriesHeadHoliday->getHeadHolidays() === $this) {
$categoriesHeadHoliday->setHeadHolidays(null);
}
}
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategoriesHeadTimesheets(): Collection
{
return $this->categories_head_timesheets;
}
public function addCategoriesHeadTimesheet(Category $categoriesHeadTimesheet): self
{
if (!$this->categories_head_timesheets->contains($categoriesHeadTimesheet)) {
$this->categories_head_timesheets[] = $categoriesHeadTimesheet;
$categoriesHeadTimesheet->setHeadTimesheets($this);
}
return $this;
}
public function removeCategoriesHeadTimesheet(Category $categoriesHeadTimesheet): self
{
if ($this->categories_head_timesheets->removeElement($categoriesHeadTimesheet)) {
// set the owning side to null (unless already changed)
if ($categoriesHeadTimesheet->getHeadTimesheets() === $this) {
$categoriesHeadTimesheet->setHeadTimesheets(null);
}
}
return $this;
}
public function getHeadHolidays(): ?self
{
return $this->head_holidays;
}
public function setHeadHolidays(?self $head_holidays): self
{
$this->head_holidays = $head_holidays;
return $this;
}
/**
* @return Collection|self[]
*/
public function getUsersHeadHolidays(): Collection
{
return $this->users_head_holidays;
}
public function addUsersHeadHoliday(self $usersHeadHoliday): self
{
if (!$this->users_head_holidays->contains($usersHeadHoliday)) {
$this->users_head_holidays[] = $usersHeadHoliday;
$usersHeadHoliday->setHeadHolidays($this);
}
return $this;
}
public function removeUsersHeadHoliday(self $usersHeadHoliday): self
{
if ($this->users_head_holidays->removeElement($usersHeadHoliday)) {
// set the owning side to null (unless already changed)
if ($usersHeadHoliday->getHeadHolidays() === $this) {
$usersHeadHoliday->setHeadHolidays(null);
}
}
return $this;
}
public function getHeadTimesheets(): ?self
{
return $this->head_timesheets;
}
public function setHeadTimesheets(?self $head_timesheets): self
{
$this->head_timesheets = $head_timesheets;
return $this;
}
/**
* @return Collection|self[]
*/
public function getUsersHeadTimesheets(): Collection
{
return $this->users_head_timesheets;
}
public function addUsersHeadTimesheet(self $usersHeadTimesheet): self
{
if (!$this->users_head_timesheets->contains($usersHeadTimesheet)) {
$this->users_head_timesheets[] = $usersHeadTimesheet;
$usersHeadTimesheet->setHeadTimesheets($this);
}
return $this;
}
public function removeUsersHeadTimesheet(self $usersHeadTimesheet): self
{
if ($this->users_head_timesheets->removeElement($usersHeadTimesheet)) {
// set the owning side to null (unless already changed)
if ($usersHeadTimesheet->getHeadTimesheets() === $this) {
$usersHeadTimesheet->setHeadTimesheets(null);
}
}
return $this;
}
public function getWorkplace(): ?Workplace
{
return $this->workplace;
}
public function setWorkplace(?Workplace $workplace): self
{
$this->workplace = $workplace;
return $this;
}
public function getDailyHours(): ?float
{
return $this->daily_hours;
}
public function setDailyHours(?float $daily_hours): self
{
$this->daily_hours = $daily_hours;
return $this;
}
/**
* @return Collection|ArticleUserView[]
*/
public function getArticleUserViews(): Collection
{
return $this->articleUserViews;
}
public function addArticleUserView(ArticleUserView $articleUserView): self
{
if (!$this->articleUserViews->contains($articleUserView)) {
$this->articleUserViews[] = $articleUserView;
$articleUserView->setUser($this);
}
return $this;
}
public function removeArticleUserView(ArticleUserView $articleUserView): self
{
if ($this->articleUserViews->removeElement($articleUserView)) {
// set the owning side to null (unless already changed)
if ($articleUserView->getUser() === $this) {
$articleUserView->setUser(null);
}
}
return $this;
}
/**
* @return Collection|WorkgroupUserView[]
*/
public function getWorkgroupUserViews(): Collection
{
return $this->workgroupUserViews;
}
public function addWorkgroupUserView(WorkgroupUserView $workgroupUserView): self
{
if (!$this->workgroupUserViews->contains($workgroupUserView)) {
$this->workgroupUserViews[] = $workgroupUserView;
$workgroupUserView->setUser($this);
}
return $this;
}
public function removeWorkgroupUserView(WorkgroupUserView $workgroupUserView): self
{
if ($this->workgroupUserViews->removeElement($workgroupUserView)) {
// set the owning side to null (unless already changed)
if ($workgroupUserView->getUser() === $this) {
$workgroupUserView->setUser(null);
}
}
return $this;
}
/**
* @return Collection|QuizzUserAnswer[]
*/
public function getQuizzes(): Collection
{
return $this->quizzes;
}
public function addQuiz(QuizzUserAnswer $quiz): self
{
if (!$this->quizzes->contains($quiz)) {
$this->quizzes[] = $quiz;
$quiz->setUser($this);
}
return $this;
}
public function removeQuiz(QuizzUserAnswer $quiz): self
{
if ($this->quizzes->removeElement($quiz)) {
// set the owning side to null (unless already changed)
if ($quiz->getUser() === $this) {
$quiz->setUser(null);
}
}
return $this;
}
/**
* @return Collection|DocumentFileView[]
*/
public function getDocumentFileViews(): Collection
{
return $this->documentFileViews;
}
public function addDocumentFileView(DocumentFileView $documentFileView): self
{
if (!$this->documentFileViews->contains($documentFileView)) {
$this->documentFileViews[] = $documentFileView;
$documentFileView->setUser($this);
}
return $this;
}
public function removeDocumentFileView(DocumentFileView $documentFileView): self
{
if ($this->documentFileViews->removeElement($documentFileView)) {
// set the owning side to null (unless already changed)
if ($documentFileView->getUser() === $this) {
$documentFileView->setUser(null);
}
}
return $this;
}
/**
* @return Collection|UserSchedule[]
*/
public function getSchedules(): Collection
{
return $this->schedules;
}
public function addSchedule(UserSchedule $schedule): self
{
if (!$this->schedules->contains($schedule)) {
$this->schedules[] = $schedule;
$schedule->setUser($this);
}
return $this;
}
public function removeSchedule(UserSchedule $schedule): self
{
if ($this->schedules->removeElement($schedule)) {
// set the owning side to null (unless already changed)
if ($schedule->getUser() === $this) {
$schedule->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Fingerprint>
*/
public function getFingerprints(): Collection
{
return $this->fingerprints;
}
public function addFingerprint(Fingerprint $fingerprint): self
{
if (!$this->fingerprints->contains($fingerprint)) {
$this->fingerprints[] = $fingerprint;
$fingerprint->setUser($this);
}
return $this;
}
public function removeFingerprint(Fingerprint $fingerprint): self
{
if ($this->fingerprints->removeElement($fingerprint)) {
// set the owning side to null (unless already changed)
if ($fingerprint->getUser() === $this) {
$fingerprint->setUser(null);
}
}
return $this;
}
public function getDailyHoursMonday(): ?float
{
return $this->daily_hours_monday;
}
public function setDailyHoursMonday(float $daily_hours_monday): self
{
$this->daily_hours_monday = $daily_hours_monday;
return $this;
}
public function getDailyHoursTuesday(): ?float
{
return $this->daily_hours_tuesday;
}
public function setDailyHoursTuesday(float $daily_hours_tuesday): self
{
$this->daily_hours_tuesday = $daily_hours_tuesday;
return $this;
}
public function getDailyHoursWednesday(): ?float
{
return $this->daily_hours_wednesday;
}
public function setDailyHoursWednesday(float $daily_hours_wednesday): self
{
$this->daily_hours_wednesday = $daily_hours_wednesday;
return $this;
}
public function getDailyHoursThursday(): ?float
{
return $this->daily_hours_thursday;
}
public function setDailyHoursThursday(float $daily_hours_thursday): self
{
$this->daily_hours_thursday = $daily_hours_thursday;
return $this;
}
public function getDailyHoursFriday(): ?float
{
return $this->daily_hours_friday;
}
public function setDailyHoursFriday(float $daily_hours_friday): self
{
$this->daily_hours_friday = $daily_hours_friday;
return $this;
}
public function getDailyHoursSaturday(): ?float
{
return $this->daily_hours_saturday;
}
public function setDailyHoursSaturday(float $daily_hours_saturday): self
{
$this->daily_hours_saturday = $daily_hours_saturday;
return $this;
}
public function getDailyHoursSunday(): ?float
{
return $this->daily_hours_sunday;
}
public function setDailyHoursSunday(float $daily_hours_sunday): self
{
$this->daily_hours_sunday = $daily_hours_sunday;
return $this;
}
public function getDailyHoursByDate(\DateTimeInterface $date): ?float
{
return match ($date->format('l')) {
'Monday' => $this->daily_hours_monday,
'Tuesday' => $this->daily_hours_tuesday,
'Wednesday' => $this->daily_hours_wednesday,
'Thursday' => $this->daily_hours_thursday,
'Friday' => $this->daily_hours_friday,
'Saturday' => $this->daily_hours_saturday,
'Sunday' => $this->daily_hours_sunday,
default => $this->daily_hours,
};
}
public function getStatusLabel(): string
{
return match ($this->getStatus()) {
self::STATUS['PENDING'] => 'Pendiente',
self::STATUS['PUBLISHED'] => 'Habilitado',
self::STATUS_UNPUBLISHED => 'Deshabilitado',
default => '',
};
}
}