src/Entity/User.php line 24
<?phpnamespace App\Entity;use App\Enum\Currency;use App\Enum\UnitType;use App\Enum\EmployeeStatus;use App\Enum\GroupName;use App\Enum\RegionEnum;use App\Repository\UserRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Gedmo\Timestampable\Traits\TimestampableEntity;#[ORM\Entity(repositoryClass: UserRepository::class)]#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]class User implements UserInterface, PasswordAuthenticatedUserInterface{use TimestampableEntity;public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';public const ROLE_ADMIN = 'ROLE_ADMIN';public const ROLE_USER = 'ROLE_USER';public const ROLE_INDIVIDUAL_PAYEE = 'ROLE_INDIVIDUAL_PAYEE';public const ROLE_MANAGER = 'ROLE_MANAGER';public const ROLE_EXECUTIVE = 'ROLE_EXECUTIVE';public const ROLE_DEFAULT = 'ROLE_USER';#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 320, unique: true)]private ?string $email = null;#[ORM\Column]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]private ?string $password = null;public $plainPassword;#[ORM\Column]private bool $incentAccess = true;#[ORM\Column(length: 255, nullable: true)]private ?GroupName $groupName = null;#[ORM\ManyToOne(targetEntity: self::class, fetch: "EAGER")]private ?self $manager = null;#[ORM\Column(nullable: true)]private ?bool $creditEligible = true;#[ORM\Column(nullable: true)]private ?bool $commissionEligible = true;#[ORM\Column(length: 255, nullable: true)]private ?string $employeeID = null;#[ORM\ManyToOne(fetch: "EAGER")]private ?Plan $plan = null;#[ORM\Column(length: 255, nullable: true)]private ?EmployeeStatus $employeeStatus = EmployeeStatus::ACTIVE;#[ORM\Column(nullable: true)]private ?int $guaranteePeriod = 0;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $guaranteeStartDate = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserPaymentPeriod::class, orphanRemoval: true)]private Collection $userPaymentPeriods;#[ORM\OneToMany(mappedBy: 'user', targetEntity: AggregatedTrueUp::class)]private Collection $aggregatedTrueUps;#[ORM\Column(length: 255, nullable: true)]private ?string $firstName = null;#[ORM\Column(length: 255, nullable: true)]private ?string $lastName = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Position::class, fetch: 'EAGER')]private Collection $positions;#[ORM\Column(length: 255, nullable: true)]private ?string $managerName = null;#[ORM\Column(length: 500, nullable: true)]private ?string $titleRole = null;#[ORM\Column(nullable: true)]private ?float $guaranteeAmount = null;#[ORM\Column(length: 255, nullable: true)]private ?UnitType $guaranteeAmountUnitType = null;#[ORM\Column(length: 255, nullable: true)]private ?UnitType $guaranteePeriodUnitType = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Commission::class)]private Collection $commissions;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Credit::class)]private Collection $credits;#[ORM\Column(length: 255, nullable: true)]private ?string $middleName = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $effectiveStartDate = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $description = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $hireDate = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $terminationDate = null;#[ORM\Column]private ?float $personalTarget = 0;#[ORM\Column]private ?float $proratedPersonalTarget = 0;#[ORM\Column(length: 255)]private ?Currency $personalCurrency = Currency::USD;#[ORM\Column]private ?float $proratedSalary = 0;#[ORM\Column(length: 255)]private ?Currency $paymentCurrency = Currency::USD;#[ORM\Column]private ?float $salary = 0;#[ORM\Column(length: 255)]private ?Currency $salaryCurrency = Currency::USD;#[ORM\OneToMany(mappedBy: 'user', targetEntity: ManualPayment::class)]private Collection $manualPayments;#[ORM\ManyToOne(inversedBy: 'users', fetch: 'EAGER')]private ?Title $title = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: OrderAssignment::class)]private Collection $orderAssignments;#[ORM\OneToMany(mappedBy: 'user', targetEntity: EmployeeRepCode::class)]private Collection $employeeRepCodes;#[ORM\OneToMany(mappedBy: 'fromUser', targetEntity: NamedRelationshipPosition::class)]private Collection $fromNamedRelationshipPositions;#[ORM\OneToMany(mappedBy: 'toUser', targetEntity: NamedRelationshipPosition::class)]private Collection $toNamedRelationshipPositions;#[ORM\OneToMany(mappedBy: 'assignedUser', targetEntity: LookUpTable::class)]private Collection $lookUpTables;#[ORM\OneToMany(mappedBy: 'user', targetEntity: RateTableAssignment::class)]private Collection $rateTableAssignments;#[ORM\OneToMany(mappedBy: 'User', targetEntity: RuleCondition::class)]private Collection $ruleConditions;#[ORM\OneToMany(mappedBy: 'user', targetEntity: Hierarchy::class, cascade: ['persist', 'remove'])]private Collection $hierarchies;#[ORM\OneToMany(mappedBy: 'parentUser', targetEntity: Hierarchy::class)]#[ORM\OrderBy(['effectiveStartDate' => 'ASC'])]private Collection $parentHierarchies;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $earningCommissionsStartDate = null;#[ORM\Column(nullable: true)]private ?int $earningCommissionsPeriod = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $guaranteeAlertSentAt = null;#[ORM\ManyToOne(inversedBy: 'users', fetch: 'EAGER')]private ?Region $region = null;#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserLogin::class)]private Collection $userLogins;#[ORM\OneToMany(mappedBy: 'user', targetEntity: AdMapping::class)]private Collection $adMappings;#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserRegion::class, cascade: ['persist', 'remove'])]private Collection $userRegions;#[ORM\OneToMany(mappedBy: 'toUser', targetEntity: CommissionShareRule::class)]private Collection $commissionShareRulesTo;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $leaveOfAbsenceStartDate = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $leaveOfAbsenceEndDate = null;public function __construct(){$this->userPaymentPeriods = new ArrayCollection();$this->aggregatedTrueUps = new ArrayCollection();$this->positions = new ArrayCollection();$this->commissions = new ArrayCollection();$this->credits = new ArrayCollection();$this->manualPayments = new ArrayCollection();$this->orderAssignments = new ArrayCollection();$this->employeeRepCodes = new ArrayCollection();$this->fromNamedRelationshipPositions = new ArrayCollection();$this->toNamedRelationshipPositions = new ArrayCollection();$this->lookUpTables = new ArrayCollection();$this->rateTableAssignments = new ArrayCollection();$this->ruleConditions = new ArrayCollection();$this->hierarchies = new ArrayCollection();$this->parentHierarchies = new ArrayCollection();$this->userLogins = new ArrayCollection();$this->adMappings = new ArrayCollection();$this->userRegions = new ArrayCollection();$this->hireDate = new \DateTime();$this->commissionShareRulesTo = new ArrayCollection();}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;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string) $this->email;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}public function addRole($role): self{$roles = $this->roles;$roles[] = $role;$this->setRoles(array_unique($roles));return $this;}public static function getRolesList($secure = false): array{$roles = [self::ROLE_USER => 'User',self::ROLE_SUPER_ADMIN => 'Super Admin',self::ROLE_ADMIN => 'Admin',self::ROLE_INDIVIDUAL_PAYEE => 'Individual Payee',self::ROLE_MANAGER => 'Manager',self::ROLE_EXECUTIVE => 'Executive',];return $roles;}public function getRolesLabels(): string{$rolesList = self::getRolesList();$roles = [];foreach ($this->getRoles() as $role) {$label = 'label-info';if ($role === self::ROLE_SUPER_ADMIN){$label = 'label-warning';}if ($role === self::ROLE_ADMIN){$label = 'label-primary';}if ($role !== self::ROLE_DEFAULT) {$roles[] = "<span class='label {$label}'>{$rolesList[$role]}</span> ";}}return implode(' ', $roles);}/*** {@inheritdoc}*/public function hasRole($role): bool{return in_array(strtoupper($role), $this->getRoles(), true);}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): ?string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function isIncentAccess(): ?bool{return $this->incentAccess;}public function setIncentAccess(bool $incentAccess): self{$this->incentAccess = $incentAccess;return $this;}public function getFullName(): ?string{$string = sprintf('%s %s', $this->firstName, $this->lastName);if($this->getEmployeeID()){$string = sprintf('%s (%s)', $string, $this->getEmployeeID());}return $string;}public function getGroupName(): ?GroupName{return $this->groupName;}public function setGroupName(?GroupName $groupName): self{$this->groupName = $groupName;return $this;}public function getManager(): ?self{return $this->manager;}public function setManager(?self $manager): self{$this->manager = $manager;return $this;}public function isCreditEligible(): ?bool{return $this->creditEligible;}public function setCreditEligible(?bool $creditEligible): self{$this->creditEligible = $creditEligible;return $this;}public function isCommissionEligible(): ?bool{return $this->commissionEligible;}public function setCommissionEligible(?bool $commissionEligible): self{$this->commissionEligible = $commissionEligible;return $this;}public function getEmployeeID(): ?string{return $this->employeeID;}public function setEmployeeID(?string $employeeID): self{$this->employeeID = $employeeID;return $this;}public function getPlan(): ?Plan{return $this->plan;}public function setPlan(?Plan $plan): self{$this->plan = $plan;return $this;}public function getEmployeeStatus(): ?EmployeeStatus{return $this->employeeStatus;}public function setEmployeeStatus(?EmployeeStatus $employeeStatus): self{$this->employeeStatus = $employeeStatus;return $this;}public function __toString(){return $this->getFullName() ?: $this->email;}public function getGuaranteePeriod(): ?int{return $this->guaranteePeriod;}public function setGuaranteePeriod(?int $guaranteePeriod): self{$this->guaranteePeriod = $guaranteePeriod;// reset alert sent at$this->guaranteeAlertSentAt = null;return $this;}public function getGuaranteeStartDate(): ?\DateTimeInterface{return $this->guaranteeStartDate;}public function setGuaranteeStartDate(?\DateTimeInterface $guaranteeStartDate): self{$this->guaranteeStartDate = $guaranteeStartDate;// reset alert sent at$this->guaranteeAlertSentAt = null;return $this;}public function getGuaranteeEndDate(): ?\DateTimeInterface{$startDate = clone $this->getGuaranteeStartDate();if($startDate){$startDate->modify("+{$this->getGuaranteePeriod()} months")->sub(new \DateInterval('P1D'));}return $startDate;}/*** @return Collection<int, UserPaymentPeriod>*/public function getFilteredUserPaymentPeriods(\DateTime $start, \DateTime $end): Collection{return $this->userPaymentPeriods;}/*** @return Collection<int, UserPaymentPeriod>*/public function getUserPaymentPeriods(): Collection{return $this->userPaymentPeriods;}public function addUserPaymentPeriod(UserPaymentPeriod $userPaymentPeriod): self{if (!$this->userPaymentPeriods->contains($userPaymentPeriod)) {$this->userPaymentPeriods->add($userPaymentPeriod);$userPaymentPeriod->setUser($this);}return $this;}public function removeUserPaymentPeriod(UserPaymentPeriod $userPaymentPeriod): self{if ($this->userPaymentPeriods->removeElement($userPaymentPeriod)) {// set the owning side to null (unless already changed)if ($userPaymentPeriod->getUser() === $this) {$userPaymentPeriod->setUser(null);}}return $this;}public function getUserPaymentPeriodsByDateRange(\DateTime $start, \DateTime $end){$upp = [];foreach($this->userPaymentPeriods as $cand) {if ($cand->getPaymentPeriod()->getStart() >= $start && $cand->getPaymentPeriod()->getEnd() <= $end) {$upp[] = $cand;}}return $upp;}/*** @return Collection<int, AggregatedTrueUp>*/public function getAggregatedTrueUps(): Collection{return $this->aggregatedTrueUps;}public function addAggregatedTrueUp(AggregatedTrueUp $aggregatedTrueUp): self{if (!$this->aggregatedTrueUps->contains($aggregatedTrueUp)) {$this->aggregatedTrueUps->add($aggregatedTrueUp);$aggregatedTrueUp->setUser($this);}return $this;}public function removeAggregatedTrueUp(AggregatedTrueUp $aggregatedTrueUp): self{if ($this->aggregatedTrueUps->removeElement($aggregatedTrueUp)) {// set the owning side to null (unless already changed)if ($aggregatedTrueUp->getUser() === $this) {$aggregatedTrueUp->setUser(null);}}return $this;}public static function getUserRoleChoices(){return [self::ROLE_USER => self::ROLE_USER,self::ROLE_ADMIN => self::ROLE_ADMIN];}public function getFirstName(): ?string{return $this->firstName;}public function setFirstName(?string $firstName): static{$this->firstName = $firstName;return $this;}public function getLastName(): ?string{return $this->lastName;}public function setLastName(?string $lastName): static{$this->lastName = $lastName;return $this;}/*** @return Collection<int, Position>*/public function getPositions(): Collection{return $this->positions;}public function addPosition(Position $position): static{if (!$this->positions->contains($position)) {$this->positions->add($position);$position->setUser($this);}return $this;}public function removePosition(Position $position): static{if ($this->positions->removeElement($position)) {// set the owning side to null (unless already changed)if ($position->getUser() === $this) {$position->setUser(null);}}return $this;}public function getManagerName(): ?string{return $this->managerName;}public function setManagerName(?string $managerName): static{$this->managerName = $managerName;return $this;}public function getTitleRole(): ?string{return $this->titleRole;}public function setTitleRole(?string $titleRole): self{$this->titleRole = $titleRole;return $this;}public function getGuaranteeAmount(): ?float{return $this->guaranteeAmount;}public function setGuaranteeAmount(?float $guaranteeAmount): self{$this->guaranteeAmount = $guaranteeAmount;return $this;}public function getGuaranteeAmountUnitType(): ?UnitType{return $this->guaranteeAmountUnitType;}public function setGuaranteeAmountUnitType(?UnitType $guaranteeAmountUnitType): self{$this->guaranteeAmountUnitType = $guaranteeAmountUnitType;return $this;}public function getGuaranteePeriodUnitType(): ?UnitType{return $this->guaranteePeriodUnitType;}public function setGuaranteePeriodUnitType(?UnitType $guaranteePeriodUnitType): self{$this->guaranteePeriodUnitType = $guaranteePeriodUnitType;return $this;}/*** @return Collection<int, Commission>*/public function getCommissions(): Collection{return $this->commissions;}public function addCommission(Commission $commission): static{if (!$this->commissions->contains($commission)) {$this->commissions->add($commission);$commission->setUser($this);}return $this;}public function removeCommission(Commission $commission): static{if ($this->commissions->removeElement($commission)) {// set the owning side to null (unless already changed)if ($commission->getUser() === $this) {$commission->setUser(null);}}return $this;}/*** @return Collection<int, Credit>*/public function getCredits(): Collection{return $this->credits;}public function addCredit(Credit $credit): static{if (!$this->credits->contains($credit)) {$this->credits->add($credit);$credit->setUser($this);}return $this;}public function removeCredit(Credit $credit): static{if ($this->credits->removeElement($credit)) {// set the owning side to null (unless already changed)if ($credit->getUser() === $this) {$credit->setUser(null);}}return $this;}public function getMiddleName(): ?string{return $this->middleName;}public function setMiddleName(?string $middleName): static{$this->middleName = $middleName;return $this;}public function getEffectiveStartDate(): ?\DateTimeInterface{return $this->effectiveStartDate;}public function setEffectiveStartDate(?\DateTimeInterface $effectiveStartDate): static{$this->effectiveStartDate = $effectiveStartDate;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): static{$this->description = $description;return $this;}public function getHireDate(): ?\DateTimeInterface{return $this->hireDate;}public function setHireDate(?\DateTimeInterface $hireDate): static{$this->hireDate = $hireDate;return $this;}public function getTerminationDate(): ?\DateTimeInterface{return $this->terminationDate;}public function setTerminationDate(?\DateTimeInterface $terminationDate): static{$this->terminationDate = $terminationDate;return $this;}public function getPersonalTarget(): ?float{return $this->personalTarget;}public function setPersonalTarget(float $personalTarget): static{$this->personalTarget = $personalTarget;return $this;}public function getProratedPersonalTarget(): ?float{return $this->proratedPersonalTarget;}public function setProratedPersonalTarget(float $proratedPersonalTarget): static{$this->proratedPersonalTarget = $proratedPersonalTarget;return $this;}public function getPersonalCurrency(): ?Currency{return $this->personalCurrency;}public function setPersonalCurrency(Currency $personalCurrency): static{$this->personalCurrency = $personalCurrency;return $this;}public function getProratedSalary(): ?float{return $this->proratedSalary;}public function setProratedSalary(float $proratedSalary): static{$this->proratedSalary = $proratedSalary;return $this;}public function getPaymentCurrency(): ?Currency{return $this->paymentCurrency;}public function setPaymentCurrency(Currency $paymentCurrency): static{$this->paymentCurrency = $paymentCurrency;return $this;}public function getSalary(): ?FLOAT{return $this->salary;}public function setSalary(float $salary): static{$this->salary = $salary;return $this;}public function getSalaryCurrency(): ?Currency{return $this->salaryCurrency;}public function setSalaryCurrency(Currency $salaryCurrency): static{$this->salaryCurrency = $salaryCurrency;return $this;}/*** @return Collection<int, ManualPayment>*/public function getManualPayments(): Collection{return $this->manualPayments;}public function addManualPayment(ManualPayment $manualPayment): static{if (!$this->manualPayments->contains($manualPayment)) {$this->manualPayments->add($manualPayment);$manualPayment->setUser($this);}return $this;}public function removeManualPayment(ManualPayment $manualPayment): static{if ($this->manualPayments->removeElement($manualPayment)) {// set the owning side to null (unless already changed)if ($manualPayment->getUser() === $this) {$manualPayment->setUser(null);}}return $this;}public function getTitle(): ?Title{return $this->title;}public function setTitle(?Title $title): static{$this->title = $title;return $this;}public function getPositionTitleByDate($date){if ($this->positions->isEmpty()) {return $this->getTitle();}$positions = $this->positions->toArray();usort($positions, function($a, $b) {return $b->getEffectiveStartDate() <=> $a->getEffectiveStartDate();});foreach ($positions as $position) {if ($position->getEffectiveStartDate() <= $date) {return $position->getTitle();}}return $this->getTitle();}/*** @return Collection<int, OrderAssignment>*/public function getOrderAssignments(): Collection{return $this->orderAssignments;}public function addOrderAssignment(OrderAssignment $orderAssignment): static{if (!$this->orderAssignments->contains($orderAssignment)) {$this->orderAssignments->add($orderAssignment);$orderAssignment->setUser($this);}return $this;}public function removeOrderAssignment(OrderAssignment $orderAssignment): static{if ($this->orderAssignments->removeElement($orderAssignment)) {// set the owning side to null (unless already changed)if ($orderAssignment->getUser() === $this) {$orderAssignment->setUser(null);}}return $this;}/*** @return Collection<int, EmployeeRepCode>*/public function getEmployeeRepCodes(): Collection{return $this->employeeRepCodes;}public function addEmployeeRepCode(EmployeeRepCode $employeeRepCode): static{if (!$this->employeeRepCodes->contains($employeeRepCode)) {$this->employeeRepCodes->add($employeeRepCode);$employeeRepCode->setUser($this);}return $this;}public function removeEmployeeRepCode(EmployeeRepCode $employeeRepCode): static{if ($this->employeeRepCodes->removeElement($employeeRepCode)) {// set the owning side to null (unless already changed)if ($employeeRepCode->getUser() === $this) {$employeeRepCode->setUser(null);}}return $this;}/*** @return Collection<int, NamedRelationshipPosition>*/public function getFromNamedRelationshipPositions(): Collection{return $this->fromNamedRelationshipPositions;}public function addFromNamedRelationshipPosition(NamedRelationshipPosition $fromNamedRelationshipPosition): static{if (!$this->fromNamedRelationshipPositions->contains($fromNamedRelationshipPosition)) {$this->fromNamedRelationshipPositions->add($fromNamedRelationshipPosition);$fromNamedRelationshipPosition->setFromUser($this);}return $this;}public function removeFromNamedRelationshipPosition(NamedRelationshipPosition $fromNamedRelationshipPosition): static{if ($this->fromNamedRelationshipPositions->removeElement($fromNamedRelationshipPosition)) {// set the owning side to null (unless already changed)if ($fromNamedRelationshipPosition->getFromUser() === $this) {$fromNamedRelationshipPosition->setFromUser(null);}}return $this;}/*** @return Collection<int, NamedRelationshipPosition>*/public function getToNamedRelationshipPositions(): Collection{return $this->toNamedRelationshipPositions;}public function addToNamedRelationshipPosition(NamedRelationshipPosition $toNamedRelationshipPosition): static{if (!$this->toNamedRelationshipPositions->contains($toNamedRelationshipPosition)) {$this->toNamedRelationshipPositions->add($toNamedRelationshipPosition);$toNamedRelationshipPosition->setToUser($this);}return $this;}public function removeToNamedRelationshipPosition(NamedRelationshipPosition $toNamedRelationshipPosition): static{if ($this->toNamedRelationshipPositions->removeElement($toNamedRelationshipPosition)) {// set the owning side to null (unless already changed)if ($toNamedRelationshipPosition->getToUser() === $this) {$toNamedRelationshipPosition->setToUser(null);}}return $this;}/*** @return Collection<int, LookUpTable>*/public function getLookUpTables(): Collection{return $this->lookUpTables;}public function addLookUpTable(LookUpTable $lookUpTable): static{if (!$this->lookUpTables->contains($lookUpTable)) {$this->lookUpTables->add($lookUpTable);$lookUpTable->setAssignedUser($this);}return $this;}public function removeLookUpTable(LookUpTable $lookUpTable): static{if ($this->lookUpTables->removeElement($lookUpTable)) {// set the owning side to null (unless already changed)if ($lookUpTable->getAssignedUser() === $this) {$lookUpTable->setAssignedUser(null);}}return $this;}/*** @return Collection<int, RateTableAssignment>*/public function getRateTableAssignments(): Collection{return $this->rateTableAssignments;}public function addRateTableAssignment(RateTableAssignment $rateTableAssignment): static{if (!$this->rateTableAssignments->contains($rateTableAssignment)) {$this->rateTableAssignments->add($rateTableAssignment);$rateTableAssignment->setUser($this);}return $this;}public function removeRateTableAssignment(RateTableAssignment $rateTableAssignment): static{if ($this->rateTableAssignments->removeElement($rateTableAssignment)) {// set the owning side to null (unless already changed)if ($rateTableAssignment->getUser() === $this) {$rateTableAssignment->setUser(null);}}return $this;}/*** @return Collection<int, RuleCondition>*/public function getRuleConditions(): Collection{return $this->ruleConditions;}public function addRuleCondition(RuleCondition $ruleCondition): static{if (!$this->ruleConditions->contains($ruleCondition)) {$this->ruleConditions->add($ruleCondition);$ruleCondition->setUser($this);}return $this;}public function removeRuleCondition(RuleCondition $ruleCondition): static{if ($this->ruleConditions->removeElement($ruleCondition)) {// set the owning side to null (unless already changed)if ($ruleCondition->getUser() === $this) {$ruleCondition->setUser(null);}}return $this;}/*** @return Collection<int, Hierarchy>*/public function getHierarchies(): Collection{return $this->hierarchies;}public function addHierarchy(Hierarchy $hierarchy): static{if (!$this->hierarchies->contains($hierarchy)) {$this->hierarchies->add($hierarchy);$hierarchy->setUser($this);}return $this;}public function removeHierarchy(Hierarchy $hierarchy): static{if ($this->hierarchies->removeElement($hierarchy)) {// set the owning side to null (unless already changed)if ($hierarchy->getUser() === $this) {$hierarchy->setUser(null);}}return $this;}/*** @return Collection<int, Hierarchy>*/public function getParentHierarchies(): Collection{return $this->parentHierarchies;}public function addParentHierarchy(Hierarchy $parentHierarchy): static{if (!$this->parentHierarchies->contains($parentHierarchy)) {$this->parentHierarchies->add($parentHierarchy);$parentHierarchy->setParentUser($this);}return $this;}public function removeParentHierarchy(Hierarchy $parentHierarchy): static{if ($this->parentHierarchies->removeElement($parentHierarchy)) {// set the owning side to null (unless already changed)if ($parentHierarchy->getParentUser() === $this) {$parentHierarchy->setParentUser(null);}}return $this;}public function getInitials(): string{$firstInitial = '';$lastInitial = '';if($this->getFirstName()) {$firstInitial = mb_substr($this->getFirstName(), 0, 1);}if($this->getLastName()) {$lastInitial = mb_substr($this->getLastName(), 0, 1);}return $firstInitial . $lastInitial;}public function isAdmin(): bool{return $this->hasRole(self::ROLE_SUPER_ADMIN) || $this->hasRole(self::ROLE_ADMIN);}public function getEarningCommissionsStartDate(): ?\DateTimeInterface{return $this->earningCommissionsStartDate;}public function setEarningCommissionsStartDate(?\DateTimeInterface $earningCommissionsStartDate): static{$this->earningCommissionsStartDate = $earningCommissionsStartDate;return $this;}public function getEarningCommissionsPeriod(): ?int{return $this->earningCommissionsPeriod;}public function setEarningCommissionsPeriod(?int $earningCommissionsPeriod): static{$this->earningCommissionsPeriod = $earningCommissionsPeriod;return $this;}public function getGuaranteeAlertSentAt(): ?\DateTimeInterface{return $this->guaranteeAlertSentAt;}public function setGuaranteeAlertSentAt(?\DateTimeInterface $guaranteeAlertSentAt): static{$this->guaranteeAlertSentAt = $guaranteeAlertSentAt;return $this;}public function getRegion(): ?Region{return $this->region;}public function setRegion(?Region $region): static{$this->region = $region;return $this;}/*** @return Collection<int, UserLogin>*/public function getUserLogins(): Collection{return $this->userLogins;}public function addUserLogin(UserLogin $userLogin): static{if (!$this->userLogins->contains($userLogin)) {$this->userLogins->add($userLogin);$userLogin->setUser($this);}return $this;}public function removeUserLogin(UserLogin $userLogin): static{if ($this->userLogins->removeElement($userLogin)) {// set the owning side to null (unless already changed)if ($userLogin->getUser() === $this) {$userLogin->setUser(null);}}return $this;}/*** @return Collection<int, AdMapping>*/public function getAdMappings(): Collection{return $this->adMappings;}public function addAdMapping(AdMapping $adMapping): static{if (!$this->adMappings->contains($adMapping)) {$this->adMappings->add($adMapping);$adMapping->setUser($this);}return $this;}public function removeAdMapping(AdMapping $adMapping): static{if ($this->adMappings->removeElement($adMapping)) {// set the owning side to null (unless already changed)if ($adMapping->getUser() === $this) {$adMapping->setUser(null);}}return $this;}/*** @return Collection<int, UserRegion>*/public function getUserRegions(): Collection{return $this->userRegions;}public function addUserRegion(UserRegion $userRegion): static{if (!$this->userRegions->contains($userRegion)) {$this->userRegions->add($userRegion);$userRegion->setUser($this);}return $this;}public function removeUserRegion(UserRegion $userRegion): static{if ($this->userRegions->removeElement($userRegion)) {// set the owning side to null (unless already changed)if ($userRegion->getUser() === $this) {$userRegion->setUser(null);}}return $this;}/*** @return Collection<int, CommissionShareRule>*/public function getCommissionShareRulesTo(): Collection{return $this->commissionShareRulesTo;}public function addCommissionShareRulesTo(CommissionShareRule $commissionShareRulesTo): static{if (!$this->commissionShareRulesTo->contains($commissionShareRulesTo)) {$this->commissionShareRulesTo->add($commissionShareRulesTo);$commissionShareRulesTo->setToUser($this);}return $this;}public function removeCommissionShareRulesTo(CommissionShareRule $commissionShareRulesTo): static{if ($this->commissionShareRulesTo->removeElement($commissionShareRulesTo)) {// set the owning side to null (unless already changed)if ($commissionShareRulesTo->getToUser() === $this) {$commissionShareRulesTo->setToUser(null);}}return $this;}public function getLeaveOfAbsenceStartDate(): ?\DateTimeInterface{return $this->leaveOfAbsenceStartDate;}public function setLeaveOfAbsenceStartDate(?\DateTimeInterface $leaveOfAbsenceStartDate): static{$this->leaveOfAbsenceStartDate = $leaveOfAbsenceStartDate;return $this;}public function getLeaveOfAbsenceEndDate(): ?\DateTimeInterface{return $this->leaveOfAbsenceEndDate;}public function setLeaveOfAbsenceEndDate(?\DateTimeInterface $leaveOfAbsenceEndDate): static{$this->leaveOfAbsenceEndDate = $leaveOfAbsenceEndDate;return $this;}public function isOnLeaveOfAbsence(?\DateTimeInterface $date = null): bool{if ($this->employeeStatus !== EmployeeStatus::LEAVE_OF_ABSENCE) {return false;}if ($this->leaveOfAbsenceStartDate === null || $this->leaveOfAbsenceEndDate === null) {return false;}$checkDate = $date ?? new \DateTime();return $checkDate >= $this->leaveOfAbsenceStartDate && $checkDate <= $this->leaveOfAbsenceEndDate;}}