<?php
namespace App\Entity;
use App\Service\RecruitmentStatus;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Symfony\Component\Validator\Constraints as Assert;
use Exception;
#[ORM\Entity(repositoryClass: 'App\Repository\UserRepository')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[Groups(['LogService', 'EmailSchedule', 'UserInfo', 'Basic', 'Recruitment'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Groups(['LogService', 'EmailSchedule', 'UserInfo', 'Basic', 'Recruitment'])]
#[ORM\Column(type: 'string', length: 128, unique: true)]
private $email;
#[ORM\Column(type: 'string', length: 128, unique: true)]
private $canonicalEmail;
#[ORM\Column(type: 'boolean', nullable: true)]
private $emailValidated;
#[ORM\Column(type: 'string', length: 255, unique: true, nullable: true)]
private $password;
#[Assert\Length(max: 4096)]
private $plainPassword;
#[Groups(['UserInfo'])]
#[ORM\Column(type: 'boolean')]
private $isActive;
#[Groups(['UserInfo'])]
#[ORM\Column(type: 'array', nullable: true)]
private $roles = [];
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $confirmationToken;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $forgetToken;
#[ORM\Column(type: 'datetime', nullable: true)]
private $createdAt;
#[ORM\Column(type: 'datetime', nullable: true)]
private $lastActivityAt;
#[MaxDepth(1)]
#[Groups(['EmailSchedule', 'UserInfo', 'Recruitment'])]
#[ORM\OneToOne(targetEntity: 'App\Entity\PersonalInfo', mappedBy: 'user', fetch: 'EXTRA_LAZY', cascade: ['persist', 'remove'])]
private $personalInfo;
#[MaxDepth(1)]
#[Groups(['UserInfo'])]
#[ORM\ManyToOne(targetEntity: 'App\Entity\Office', inversedBy: 'users', fetch: 'EXTRA_LAZY')]
private $office;
#[ORM\OneToMany(targetEntity: 'App\Entity\Company', mappedBy: 'user', orphanRemoval: true)]
private $company;
#[ORM\Column(type: 'datetime', nullable: true)]
private $lastLoginAt;
#[ORM\OneToMany(targetEntity: 'App\Entity\Invitation', mappedBy: 'inviter')]
private $invitations;
#[ORM\OneToMany(targetEntity: 'App\Entity\Document', mappedBy: 'user')]
private $documents;
#[ORM\OneToMany(targetEntity: 'App\Entity\Organization', mappedBy: 'user', orphanRemoval: true)]
private $organizations;
#[ORM\OneToMany(targetEntity: 'App\Entity\Objective', mappedBy: 'user', orphanRemoval: true)]
private $objectives;
#[ORM\OneToMany(targetEntity: 'App\Entity\Appraisal', mappedBy: 'user', orphanRemoval: true)]
#[ORM\OrderBy(['createdAt' => 'DESC'])]
private $appraisals;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $googleId;
#[ORM\Column(type: 'text', nullable: true)]
private $temporaryPicture;
#[ORM\Column(type: 'string', length: 32, nullable: true)]
private $status;
#[ORM\OneToMany(targetEntity: Log::class, mappedBy: 'owner', cascade: ['persist', 'remove'])]
private $logs;
#[MaxDepth(1)]
#[Groups(['UserInfo'])]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'subordinate')]
private $manager;
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'manager')]
private $subordinate;
#[ORM\OneToMany(targetEntity: Notification::class, mappedBy: 'user')]
private $notifications;
#[ORM\OneToMany(targetEntity: Certification::class, mappedBy: 'user', orphanRemoval: true)]
private $certifications;
#[ORM\OneToMany(targetEntity: FlexiWorkArrangementRequest::class, mappedBy: 'user')]
private $flexiWorkArrangementRequest;
#[ORM\ManyToMany(targetEntity: 'User')]
#[ORM\JoinColumn(name: 'sub_manager_id', referencedColumnName: 'id', nullable: true)]
private $subManager;
#[ORM\OneToMany(targetEntity: Job::class, mappedBy: 'createdBy')]
private $jobs;
#[ORM\OneToOne(targetEntity: FlexiWorkArrangementOption::class, mappedBy: 'user', cascade: ['persist', 'remove'])]
private $flexiWorkArrangementOption;
#[Groups(['UserInfo'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $fwaStatus;
#[ORM\Column(type: 'array', nullable: true)]
private $reminder = [];
#[ORM\Column(type: 'boolean')]
private $featureDocumentManagement = false;
#[ORM\OneToMany(targetEntity: LeaveEntitlement::class, mappedBy: 'user', orphanRemoval: true)]
private $leaveEntitlements;
#[ORM\OneToMany(targetEntity: LeaveRequest::class, mappedBy: 'user')]
private $leaveRequests;
#[ORM\OneToMany(targetEntity: LeaveMCRecord::class, mappedBy: 'user', orphanRemoval: true)]
private $leaveMCRecords;
#[ORM\ManyToOne(targetEntity: Department::class, inversedBy: 'users')]
private $department;
#[ORM\OneToMany(targetEntity: AppraisalQuestionnaire::class, mappedBy: 'user')]
private $appraisalQuestionnaires;
#[ORM\OneToMany(targetEntity: TimeSpent::class, mappedBy: 'user')]
private $timeSpents;
#[ORM\OneToMany(targetEntity: Task::class, mappedBy: 'user')]
private $tasks;
#[ORM\OneToMany(targetEntity: Project::class, mappedBy: 'createdBy')]
private $projects;
#[ORM\OneToMany(targetEntity: PurchaseOrder::class, mappedBy: 'createdBy')]
private $purchaseOrders;
#[ORM\OneToMany(targetEntity: Project::class, mappedBy: 'personInCharge')]
private $projectsUserIsPIC;
#[ORM\OneToMany(targetEntity: VendorQuotation::class, mappedBy: 'createdBy')]
private $vendorQuotations;
#[ORM\OneToOne(targetEntity: JobInfo::class, mappedBy: 'user', cascade: ['persist', 'remove'])]
private $jobInfo;
#[ORM\Column(type: 'array', nullable: true)]
private $permission = [];
#[ORM\OneToMany(targetEntity: Salary::class, mappedBy: 'user')]
private $salaries;
#[ORM\OneToMany(targetEntity: ProjectMember::class, mappedBy: 'user')]
private $projectMembers;
#[ORM\Column(type: 'json', nullable: true)]
private $appraisalStatus = [];
#[ORM\Column(type: 'json', nullable: true)]
private $objectiveStatus = [];
#[ORM\OneToMany(targetEntity: UserTitle::class, mappedBy: 'user', orphanRemoval: true)]
private $userTitles;
#[ORM\OneToMany(targetEntity: AssetUsage::class, mappedBy: 'user')]
private $assetUsages;
#[ORM\OneToMany(targetEntity: CourseUserEnrollment::class, mappedBy: 'user')]
private $courseUserEnrollments;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isManager;
#[ORM\OneToMany(mappedBy: 'Requester', targetEntity: ExpenseRequest::class)]
private Collection $expenseRequests;
#[ORM\OneToMany(mappedBy: 'commentRejectedBy', targetEntity: RecruitApplication::class)]
private Collection $recruitApplicationComments;
#[ORM\OneToMany(mappedBy: 'commentsWithdrawnBy', targetEntity: RecruitApplication::class)]
private Collection $recruitApplicationWithdrawComments;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: RecruitVacancyHiringmanager::class, orphanRemoval: true)]
private Collection $recruitVacancyHiringmanagers;
#[ORM\OneToMany(mappedBy: 'approver', targetEntity: RecruitVacancyApprover::class, orphanRemoval: true)]
private Collection $recruitVacancyApprovers;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: RecruitVacancy::class)]
private Collection $recruitVacancies;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: RecruitApplicationActivity::class)]
private Collection $recruitApplicationActivities;
#[ORM\OneToMany(mappedBy: 'commentBy', targetEntity: RecruitApplicationComment::class, orphanRemoval: true)]
private Collection $recruitApplicationCommentsMultiple;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: RecruitQuestion::class)]
private Collection $recruitQuestions;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: RecruitEvaluationScore::class, orphanRemoval: true)]
private Collection $recruitEvaluationScores;
#[ORM\OneToMany(mappedBy: 'reportingTo', targetEntity: RecruitApplication::class)]
private Collection $recruitApplications;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: RecruitDefaultApprover::class, orphanRemoval: true)]
private Collection $defaultApprovers;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: RecruitVacancyHistory::class, orphanRemoval: true)]
private Collection $recruitVacancyHistories;
#[ORM\OneToMany(mappedBy: 'User', targetEntity: RecruitSettingActivity::class)]
private Collection $recruitSettingActivities;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: RecruitTalentSearchSession::class, orphanRemoval: true)]
private Collection $recruitTalentSearchSessions;
#[ORM\OneToMany(mappedBy: 'interviewer', targetEntity: RecruitApplication::class)]
private Collection $applicationsAsInterviewer;
#[ORM\OneToMany(mappedBy: 'hrInterviewer', targetEntity: RecruitApplication::class)]
private Collection $hrInterviewer;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: WorkingFromAbroad::class)]
private Collection $workingFromAbroads;
#[ORM\OneToMany(mappedBy: 'defaultAssignee', targetEntity: ChecklistTask::class)]
private Collection $checklistTasksAsAssignee;
#[ORM\OneToMany(mappedBy: 'verifier', targetEntity: ChecklistTask::class)]
private Collection $checklistTaskAsVerifier;
#[ORM\OneToMany(mappedBy: 'defaultAssignee', targetEntity: Checklist::class)]
private Collection $checklistsAsAssignee;
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Checklist::class)]
private Collection $checklistsAsOwner;
#[ORM\OneToMany(mappedBy: 'onboardUser', targetEntity: Checklist::class)]
private Collection $onboardedChecklists;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: ChecklistActivity::class)]
private Collection $checklistActivities;
#[ORM\OneToMany(mappedBy: 'userId', targetEntity: ChatbotThreads::class, orphanRemoval: true)]
private Collection $chatbotThreads;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: ChatbotSection::class, orphanRemoval: true)]
private Collection $chatbotSections;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: ChatbotPrompt::class)]
private Collection $chatbotPrompts;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: ChatbotCompanyPrompt::class, orphanRemoval: true)]
private Collection $chatbotCompanyPrompts;
#[ORM\OneToMany(mappedBy: 'updatedBy', targetEntity: ChatbotFaq::class)]
private Collection $chatbotFaqs;
#[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: ProjectDynamicField::class, orphanRemoval: true)]
private Collection $projectDynamicFields;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: XeroUser::class)]
private Collection $xeroUsers;
public function __construct()
{
// $this->offices = new ArrayCollection();
$this->company = new ArrayCollection();
$this->invitations = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->organizations = new ArrayCollection();
$this->objectives = new ArrayCollection();
$this->appraisals = new ArrayCollection();
$this->logs = new ArrayCollection();
$this->subordinate = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->certifications = new ArrayCollection();
$this->flexiWorkArrangementRequest = new ArrayCollection();
$this->subManager = new ArrayCollection();
$this->jobs = new ArrayCollection();
$this->appraisalQuestionnaires = new ArrayCollection();
$this->leaveEntitlements = new ArrayCollection();
$this->leaveRequests = new ArrayCollection();
$this->leaveMCRecords = new ArrayCollection();
$this->timeSpents = new ArrayCollection();
$this->tasks = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->purchaseOrders = new ArrayCollection();
$this->projectsUserIsPIC = new ArrayCollection();
$this->vendorQuotations = new ArrayCollection();
$this->salaries = new ArrayCollection();
$this->projectMembers = new ArrayCollection();
$this->userTitles = new ArrayCollection();
$this->assetUsages = new ArrayCollection();
$this->courseUserEnrollments = new ArrayCollection();
$this->expenseRequests = new ArrayCollection();
$this->recruitApplicationComments = new ArrayCollection();
$this->recruitApplicationWithdrawComments = new ArrayCollection();
$this->recruitVacancies = new ArrayCollection();
$this->recruitVacancyHiringmanagers = new ArrayCollection();
$this->recruitVacancyApprovers = new ArrayCollection();
$this->recruitApplicationActivities = new ArrayCollection();
$this->recruitApplicationCommentsMultiple = new ArrayCollection();
$this->recruitQuestions = new ArrayCollection();
$this->recruitEvaluationScores = new ArrayCollection();
$this->recruitApplications = new ArrayCollection();
$this->defaultApprovers = new ArrayCollection();
$this->recruitVacancyHistories = new ArrayCollection();
$this->recruitSettingActivities = new ArrayCollection();
$this->recruitTalentSearchSessions = new ArrayCollection();
$this->applicationsAsInterviewer = new ArrayCollection();
$this->hrInterviewer = new ArrayCollection();
$this->workingFromAbroads = new ArrayCollection();
$this->checklistTasksAsAssignee = new ArrayCollection();
$this->checklistTaskAsVerifier = new ArrayCollection();
$this->checklistsAsAssignee = new ArrayCollection();
$this->checklistsAsOwner = new ArrayCollection();
$this->onboardedChecklists = new ArrayCollection();
$this->checklistActivities = new ArrayCollection();
$this->chatbotThreads = new ArrayCollection();
$this->chatbotSections = new ArrayCollection();
$this->chatbotPrompts = new ArrayCollection();
$this->chatbotCompanyPrompts = new ArrayCollection();
$this->chatbotFaqs = new ArrayCollection();
$this->projectDynamicFields = new ArrayCollection();
$this->xeroUsers = new ArrayCollection();
}
public function getSalt(): ?string
{
return null;
}
public function eraseCredentials(): void {}
public function getUserIdentifier(): string
{
return $this->email;
}
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;
}
/**
* @return mixed
*/
public function getCanonicalEmail()
{
return $this->canonicalEmail;
}
/**
* @param mixed $canonicalEmail
*/
public function setCanonicalEmail($canonicalEmail): void
{
$this->canonicalEmail = $canonicalEmail;
}
public function getEmailValidated(): ?bool
{
return $this->emailValidated;
}
public function setEmailValidated(?bool $emailValidated): self
{
$this->emailValidated = $emailValidated;
return $this;
}
public function getUsername(): string
{
return $this->email;
}
public function getNameAndSurname()
{
return $this->personalInfo->getFirstName() . ' ' . $this->personalInfo->getLastName();
}
public function getNickname()
{
$email = $this->getCanonicalEmail();
$parts = explode('@', $email);
$namePart = $parts[0];
$nameParts = explode('.', $namePart);
$result = ucfirst($nameParts[0]);
return $result;
// $capitalizedParts = array_map('ucfirst', $nameParts);
// $result = implode(' ', $capitalizedParts);
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @return mixed
*/
public function getPlainPassword()
{
return $this->plainPassword;
}
/**
* @param mixed $plainPassword
*/
public function setPlainPassword($plainPassword): void
{
$this->plainPassword = $plainPassword;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getRoles(): array
{
$roles = $this->roles;
$roles[] = 'ROLE_STAFF';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function addRole($role): self
{
$roles = $this->roles;
array_push($roles, $role);
$this->roles = array_unique($roles);
return $this;
}
public function hasRole($role): bool
{
return in_array($role, $this->roles);
}
public function removeRole($role): self
{
$roles = $this->roles;
if (($key = array_search($role, $roles)) !== false) {
unset($roles[$key]);
}
$this->roles = array_unique($roles);
return $this;
}
public function getPublicRoles(): ?string
{
if (in_array('ROLE_OWNER', $this->roles)) {
return 'roles.owner';
} elseif (in_array('ROLE_MANAGEMENT', $this->roles)) {
return 'roles.management';
} elseif (in_array('ROLE_HR', $this->roles)) {
return 'roles.hr';
} elseif (in_array('ROLE_TEAM_LEADER', $this->roles)) {
return 'roles.leader';
} elseif (in_array('ROLE_FINANCE', $this->roles)) {
return 'roles.finance';
} elseif (in_array('ROLE_MARCOM', $this->roles)) {
return 'roles.marcom';
} else {
return 'roles.user';
}
}
public function setPublicRoles($publicRole, $allOffice = false): ?self
{
/*
# Main Roles
ROLE_STAFF
ROLE_ACCOUNT
ROLE_FINANCE
ROLE_MARCOM
ROLE_HR
ROLE_MANAGEMENT
# Sub Roles
ROLE_ACCESS_ALL_OFFICE
*/
$roles = [];
switch ($publicRole) {
case 'roles.owner':
array_push($roles, 'ROLE_OWNER');
break;
case 'roles.management':
array_push($roles, 'ROLE_MANAGEMENT');
break;
case 'roles.hr':
array_push($roles, 'ROLE_HR');
break;
case 'roles.leader':
array_push($roles, 'ROLE_TEAM_LEADER');
break;
case 'roles.finance':
array_push($roles, 'ROLE_FINANCE');
break;
case 'roles.marcom':
array_push($roles, 'ROLE_MARCOM');
break;
default:
array_push($roles, 'ROLE_STAFF');
break;
}
if (!in_array('ROLE_MANAGEMENT', $roles) && $allOffice == true || in_array('ROLE_ACCESS_ALL_OFFICE', $roles)) {
array_push($roles, 'ROLE_ACCESS_ALL_OFFICE');
};
$this->roles = $roles;
return $this;
}
public function getAllOfficeAccess()
{
$rolesToCheck = ['ROLE_ACCESS_ALL_OFFICE', 'ROLE_MANAGEMENT', 'ROLE_OWNER'];
foreach ($rolesToCheck as $role) {
if (in_array($role, $this->roles)) {
return true;
}
}
return false;
}
public function getConfirmationToken(): ?string
{
return $this->confirmationToken;
}
public function setConfirmationToken(?string $confirmationToken): self
{
$this->confirmationToken = $confirmationToken;
return $this;
}
/**
* @return mixed
*/
public function getForgetToken()
{
return $this->forgetToken;
}
/**
* @param mixed $forgetToken
*/
public function setForgetToken($forgetToken): void
{
$this->forgetToken = $forgetToken;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getLastActivityAt(): ?\DateTimeInterface
{
return $this->lastActivityAt;
}
public function setLastActivityAt(?\DateTimeInterface $lastActivityAt): self
{
$this->lastActivityAt = $lastActivityAt;
return $this;
}
public function getPersonalInfo(): ?PersonalInfo
{
return $this->personalInfo;
}
public function setPersonalInfo(PersonalInfo $personalInfo): self
{
$this->personalInfo = $personalInfo;
// set the owning side of the relation if necessary
if ($personalInfo->getUser() !== $this) {
$personalInfo->setUser($this);
}
return $this;
}
public function getOffice(): ?Office
{
return $this->office;
}
public function setOffice(?Office $office): self
{
$this->office = $office;
return $this;
}
/**
* @return Collection|Company[]
*/
public function getCompany(): Collection
{
return $this->company;
}
public function addCompany(Company $company): self
{
if (!$this->company->contains($company)) {
$this->company[] = $company;
$company->setUser($this);
}
return $this;
}
public function removeCompany(Company $company): self
{
if ($this->company->contains($company)) {
$this->company->removeElement($company);
// set the owning side to null (unless already changed)
if ($company->getUser() === $this) {
$company->setUser(null);
}
}
return $this;
}
public function getLastLoginAt(): ?\DateTimeInterface
{
return $this->lastLoginAt;
}
public function setLastLoginAt(?\DateTimeInterface $lastLoginAt): self
{
$this->lastLoginAt = $lastLoginAt;
return $this;
}
public function companyOwner($companyNumber = 0)
{
if ($this->company[$companyNumber] != null && $this->company[$companyNumber]->getUser() == $this) {
return true;
} else {
return false;
}
}
public function assignedOffices($companyNumber = 0, $forceAccessAll = false)
{
if ($this->companyOwner()) {
return $this->company[$companyNumber]->getOffices();
} else if (in_array('ROLE_ACCESS_ALL_OFFICE', $this->roles) || $forceAccessAll) {
return $this->assignedCompany($companyNumber)->getOffices();
} else {
return [$this->office];
}
}
public function assignedCompany($companyNumber = 0)
{
if ($this->companyOwner()) {
return $this->company[$companyNumber];
} else {
return $this->office->getCompany();
}
}
/**
* @return Collection|Invitation[]
*/
public function getInvitations(): Collection
{
return $this->invitations;
}
public function addInvitation(Invitation $invitation): self
{
if (!$this->invitations->contains($invitation)) {
$this->invitations[] = $invitation;
$invitation->setInviter($this);
}
return $this;
}
public function removeInvitation(Invitation $invitation): self
{
if ($this->invitations->contains($invitation)) {
$this->invitations->removeElement($invitation);
// set the owning side to null (unless already changed)
if ($invitation->getInviter() === $this) {
$invitation->setInviter(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setUser($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
// set the owning side to null (unless already changed)
if ($document->getUser() === $this) {
$document->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Organization[]
*/
public function getOrganizations(): Collection
{
return $this->organizations;
}
public function addOrganization(Organization $organization): self
{
if (!$this->organizations->contains($organization)) {
$this->organizations[] = $organization;
$organization->setUser($this);
}
return $this;
}
public function removeOrganization(Organization $organization): self
{
if ($this->organizations->contains($organization)) {
$this->organizations->removeElement($organization);
// set the owning side to null (unless already changed)
if ($organization->getUser() === $this) {
$organization->setUser(null);
}
}
return $this;
}
function organizationTitles()
{
if ($this->personalInfo->getJobTitle()) {
return $this->personalInfo->getJobTitle();
} else { // For transitioning
$titles = [];
foreach ($this->getOrganizations() as $organization) {
if (!in_array($organization->getTitle(), $titles))
array_push($titles, $organization->getTitle());
}
return implode(', ', $titles);
};
}
function organizationDepartments()
{
if ($this->department) {
return $this->department;
} else { // For transitioning
$departments = [];
foreach ($this->getOrganizations() as $organization) {
if (in_array($organization->getDepartment(), $departments) == false)
array_push($departments, $organization->getDepartment());
}
return $departments;
}
}
function organizationDepartmentNames()
{
if ($this->department) {
return $this->department->getName();
} else { // For transitioning
$departments = [];
foreach ($this->getOrganizations() as $organization) {
if (in_array($organization->getDepartment()->getName(), $departments) == false)
array_push($departments, $organization->getDepartment()->getName());
}
return implode(', ', $departments);
};
}
function organizationDepartmentIds()
{
$departments = [];
foreach ($this->getOrganizations() as $organization) {
if (in_array($organization->getDepartment()->getId(), $departments) == false)
array_push($departments, $organization->getDepartment()->getId());
}
return $departments;
}
function organizationSupervisor()
{
$superior = [];
$registered_superior = [];
foreach ($this->getOrganizations() as $organization) {
if (method_exists($organization->getSupervisor(), 'getIsGroup') && $organization->getSupervisor()->getIsGroup()) {
foreach ($organization->getSupervisor()->getGroupUsers() as $gu) {
if (in_array($gu->getUser()->getId(), $registered_superior) == false) {
array_push($superior, $gu->getUser());
array_push($registered_superior, $gu->getUser()->getId());
}
}
} else {
if (method_exists($organization->getSupervisor(), 'getUser') && in_array($organization->getSupervisor()->getUser()->getId(), $registered_superior) == false) {
array_push($superior, $organization->getSupervisor()->getUser());
array_push($registered_superior, $organization->getSupervisor()->getUser()->getId());
}
};
};
return $superior;
}
function isSubordinate($uid)
{
// this code is ugly, need to refactor
foreach ($this->getOrganizations() as $organization) {
foreach ($organization->getSupervisorChilds() as $child) {
if ($child->getUser() != null && $child->getUser()->getId() == $uid) return true;
if ($child->getSupervisorChilds()) {
foreach ($child->getSupervisorChilds() as $child2) {
if ($child2->getUser()->getId() == $uid)
return true;
if ($child2->getSupervisorChilds()) {
foreach ($child2->getSupervisorChilds() as $child3) {
if ($child3->getUser()->getId() == $uid)
return true;
if ($child3->getSupervisorChilds()) {
foreach ($child3->getSupervisorChilds() as $child4) {
if ($child4->getUser()->getId() == $uid)
return true;
if ($child4->getSupervisorChilds()) {
foreach ($child4->getSupervisorChilds() as $child5) {
if ($child5->getUser()->getId() == $uid)
return true;
}
}
}
}
}
}
}
}
}
};
return false;
}
/**
* @return Collection|Objective[]
*/
public function getObjectives(): Collection
{
return $this->objectives;
}
public function addObjective(Objective $objective): self
{
if (!$this->objectives->contains($objective)) {
$this->objectives[] = $objective;
$objective->setUser($this);
}
return $this;
}
public function removeObjective(Objective $objective): self
{
if ($this->objectives->contains($objective)) {
$this->objectives->removeElement($objective);
// set the owning side to null (unless already changed)
if ($objective->getUser() === $this) {
$objective->setUser(null);
}
}
return $this;
}
public function totalObjective()
{
return count($this->objectives);
}
public function totalActiveObjective()
{
// $total = 0;
// foreach ($this->objectives as $objective) {
// if ($objective->getDeadlineAt()->format('Ymd') >= date('Ymd')) {
// $total++;
// };
// };
// return $total;
// if($this->personalInfo->getJobExpiryDate() != null && $this->personalInfo->getJobExpiryDate()->format('Ymd') >= date('Ymd')){
// return count($this->objectives);
// } else {
// return 0;
// }
$total = 0;
foreach ($this->objectives as $objective) {
if ($objective->getAppraisalYear() == null) {
$total++;
};
};
return $total;
}
public function totalDueObjective()
{
$total = 0;
foreach ($this->objectives as $objective) {
if ($objective->getAppraisalYear() == date('Y')) {
$total++;
};
};
return $total;
// if($this->personalInfo->getJobExpiryDate() != null && $this->personalInfo->getJobExpiryDate()->format('Ymd') < date('Ymd')){
// return count($this->objectives);
// } else {
// return 0;
// }
}
public function allObjectiveExpired()
{
if ($this->totalObjective() == $this->totalDueObjective()) {
return true;
} else {
return false;
}
}
/**
* @return Collection|Appraisal[]
*/
public function getAppraisals(): Collection
{
return $this->appraisals;
}
public function addAppraisal(Appraisal $appraisal): self
{
if (!$this->appraisals->contains($appraisal)) {
$this->appraisals[] = $appraisal;
$appraisal->setUser($this);
}
return $this;
}
public function removeAppraisal(Appraisal $appraisal): self
{
if ($this->appraisals->contains($appraisal)) {
$this->appraisals->removeElement($appraisal);
// set the owning side to null (unless already changed)
if ($appraisal->getUser() === $this) {
$appraisal->setUser(null);
}
}
return $this;
}
public function activeAppraisals()
{
$activeAppraisals = [];
foreach ($this->appraisals as $appraisal) {
// Old rule
// if ($appraisal->currentStep() > 0 && $appraisal->currentStep() <= 5 && !$appraisal->getAdHoc()) {
// array_push($activeAppraisals, $appraisal);
// };
if ($appraisal->getCreatedAt()->format('Ymd') >= '20220920' && $appraisal->currentStep() > 0 && $appraisal->currentStep() <= 5 && !$appraisal->getAdHoc()) {
array_push($activeAppraisals, $appraisal);
}
};
return $activeAppraisals;
}
public function submittedAppraisals()
{
$submittedAppraisals = [];
foreach ($this->appraisals as $appraisal) {
if ($appraisal->getSubmittedAt() != null) {
array_push($submittedAppraisals, $appraisal);
};
};
return $submittedAppraisals;
}
public function reviewedAppraisals()
{
$reviewedAppraisals = [];
foreach ($this->appraisals as $appraisal) {
//if ($appraisal->getReviewedAt() != null) {
if (date('Ymd') <= $appraisal->getSubmitAt()->format('Ymd')) {
array_push($reviewedAppraisals, $appraisal);
};
};
return $reviewedAppraisals;
}
public function pendingAppraisals()
{
$pendingAppraisals = [];
foreach ($this->appraisals as $appraisal) {
if ($appraisal->getSubmittedAt() != null) {
array_push($pendingAppraisals, $appraisal);
} else if (date('Ymd') > $appraisal->getSubmitAt()->format('Ymd') && $appraisal->getSubmittedAt() == null) {
array_push($pendingAppraisals, $appraisal);
};
};
return $pendingAppraisals;
}
public function latestAppraisal($compareObject = null)
{
$latestDate = null;
$latestAppraisal = null;
if (count($this->appraisals) > 0) {
foreach ($this->appraisals as $appraisal) {
if ($appraisal->getCreatedAt()->format('Ymd') > $latestDate) {
$latestDate = $appraisal->getCreatedAt()->format('Ymd');
$latestAppraisal = $appraisal;
};
};
};
if ($compareObject) {
return $compareObject == $latestAppraisal;
} else {
return $latestAppraisal;
};
}
public function probationAppraisal()
{
foreach ($this->appraisals as $appraisal) {
if ($appraisal->getCreatedAt()->format('Ymd') >= '20220920' && $appraisal->getProbation()) {
return $appraisal;
}
};
}
public function appraisalDetail($step = null)
{
$activeAppraisals = $this->activeAppraisals();
if ($activeAppraisals) {
switch ($step) {
case '1':
if ($activeAppraisals[0]->getSubmitAt()->format('Ymd') < date('Ymd')) {
return ['step' => '1', 'missed' => true, 'text' => 'form.appraisal.missed.title'];
} else {
return ['step' => '1', 'missed' => false, 'text' => 'form.appraisal.pending.user_default'];
}
break;
case '2':
return ['step' => '2', 'missed' => false, 'text' => 'form.appraisal.pending.manager'];
break;
case '3':
return ['step' => '3', 'missed' => false, 'text' => 'form.appraisal.pending.review'];
break;
case '4':
return ['step' => '4', 'missed' => false, 'text' => 'form.appraisal.ready'];
break;
case '5':
return ['step' => '5', 'missed' => false, 'text' => 'form.appraisal.pending.conclusion.manager'];
break;
default:
return ['step' => '6', 'missed' => false, 'text' => 'form.appraisal.done'];
break;
}
} else {
$jobExpiryDate = $this->personalInfo->getJobExpiryDate();
if ($jobExpiryDate) {
return ['step' => '0', 'missed' => false, 'text' => $jobExpiryDate->format('Ymd') < date('Ymd') ? 'overdue/invalid' : 'scheduled'];
} else {
return ['step' => '0', 'missed' => false, 'text' => 'job expiry date not set'];
}
}
}
public function appraisalType($appraisal = null)
{
if ($this->hasRole('ROLE_OWNER')) return null;
if ($this->inProbation() || ($appraisal != null && $this->probationAppraisal() == $appraisal)) {
if ($this->getIsManager()) {
return 'form.appraisal.type.new_manager';
} else {
return 'form.appraisal.type.new_non_manager';
}
} else {
if ($this->hasRole('ROLE_TEAM_LEADER') || $this->hasRole('ROLE_MANAGEMENT')) {
return 'form.appraisal.type.team_leader';
} elseif ($this->getIsManager()) {
return 'form.appraisal.type.manager';
} else {
return 'form.appraisal.type.non_manager';
}
}
}
public function elligibleForAppraisal()
{
if (in_array($this->personalInfo->getJobStatus(), ['form.job_status.permanent', 'form.job_status.probation'])) {
return true;
} else {
return false;
}
}
public function getGoogleId(): ?string
{
return $this->googleId;
}
public function setGoogleId(?string $googleId): self
{
$this->googleId = $googleId;
return $this;
}
public function getTemporaryPicture(): ?string
{
return $this->temporaryPicture;
}
public function setTemporaryPicture(?string $temporaryPicture): self
{
$this->temporaryPicture = $temporaryPicture;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function statusLabel()
{
return $this->status ? $this->status . '.label' : false;
}
public function statusColor()
{
return $this->status ? $this->status . '.color' : false;
}
/**
* @return Collection|Log[]
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setOwner($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->contains($log)) {
$this->logs->removeElement($log);
// set the owning side to null (unless already changed)
if ($log->getOwner() === $this) {
$log->setOwner(null);
}
}
return $this;
}
public function getManager(): ?self
{
return $this->manager;
}
public function setManager(?self $manager): self
{
$this->manager = $manager;
return $this;
}
/**
* @return Collection|self[]
*/
public function getSubordinate(): Collection
{
return $this->subordinate;
}
public function addSubordinate(self $subordinate): self
{
if (!$this->subordinate->contains($subordinate)) {
$this->subordinate[] = $subordinate;
$subordinate->setManager($this);
}
return $this;
}
public function removeSubordinate(self $subordinate): self
{
if ($this->subordinate->contains($subordinate)) {
$this->subordinate->removeElement($subordinate);
// set the owning side to null (unless already changed)
if ($subordinate->getManager() === $this) {
$subordinate->setManager(null);
}
}
return $this;
}
public function getSubordinates()
{
$subordinates = [];
foreach ($this->assignedCompany()->getAllUser() as $user) {
/*if ($user->getManager() != null && $user->getManager()->getId() == $this->id) {
$subordinates[] = $user;
}*/
foreach ($user->getAllManager() as $manager) {
if ($manager->getId() == $this->id) {
$subordinates[] = $user;
}
}
}
return $subordinates;
}
/**
* @return Collection|Notification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUser($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->contains($notification)) {
$this->notifications->removeElement($notification);
// set the owning side to null (unless already changed)
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
return $this;
}
public function unreadNotifications()
{
$data = [];
foreach ($this->notifications as $notification) {
if ($notification->getReadAt() == null)
array_push($data, $notification);
}
return $data;
}
/**
* @return Collection|Certification[]
*/
public function getCertifications(): Collection
{
return $this->certifications;
}
public function addCertification(Certification $certification): self
{
if (!$this->certifications->contains($certification)) {
$this->certifications[] = $certification;
$certification->setUser($this);
}
return $this;
}
public function removeCertification(Certification $certification): self
{
if ($this->certifications->contains($certification)) {
$this->certifications->removeElement($certification);
// set the owning side to null (unless already changed)
if ($certification->getUser() === $this) {
$certification->setUser(null);
}
}
return $this;
}
public function activeCertifications()
{
$activeCertifications = [];
foreach ($this->certifications as $certification) {
if ($certification->getFilename() != '') {
array_push($activeCertifications, $certification);
};
};
return $activeCertifications;
}
/**
* @return Collection|FlexiWorkArrangementRequest[]
*/
public function getFlexiWorkArrangementRequest(): Collection
{
return $this->flexiWorkArrangementRequest;
}
public function addFlexiWorkArrangementRequest(FlexiWorkArrangementRequest $flexiWorkArrangementRequest): self
{
if (!$this->flexiWorkArrangementRequest->contains($flexiWorkArrangementRequest)) {
$this->flexiWorkArrangementRequest[] = $flexiWorkArrangementRequest;
$flexiWorkArrangementRequest->setUser($this);
}
return $this;
}
public function removeFlexiWorkArrangementRequest(FlexiWorkArrangementRequest $flexiWorkArrangementRequest): self
{
if ($this->flexiWorkArrangementRequest->contains($flexiWorkArrangementRequest)) {
$this->flexiWorkArrangementRequest->removeElement($flexiWorkArrangementRequest);
// set the owning side to null (unless already changed)
if ($flexiWorkArrangementRequest->getUser() === $this) {
$flexiWorkArrangementRequest->setUser(null);
}
}
return $this;
}
public function requestedFWAProgram()
{
foreach ($this->flexiWorkArrangementRequest as $FWA) {
//if($FWA->getApprovedAt() == null){
return $FWA->getTitle();
//}
}
return null;
}
public function activeFWAProgram()
{
foreach ($this->flexiWorkArrangementRequest as $FWA) {
if ($FWA->getApprovedAt() != null) {
return $FWA->getTitle();
}
}
return null;
}
public function pendingFlexiWorkArrangementRequest()
{
$FWAS = [];
foreach ($this->flexiWorkArrangementRequest as $FWA) {
if ($FWA->getApprovedAt() == null) {
array_push($FWAS, $FWA);
}
}
return $FWAS;
}
/**
* @return Collection|self[]
*/
public function getSubManager(): Collection
{
return $this->subManager;
}
public function addSubManager(self $subManager): self
{
if (!$this->subManager->contains($subManager)) {
$this->subManager[] = $subManager;
}
return $this;
}
public function removeSubManager(self $subManager): self
{
$this->subManager->removeElement($subManager);
return $this;
}
public function getSubManagerId()
{
$subManager = [];
foreach ($this->subManager as $sm) {
$subManager[$sm->getId()] = $sm->getId();
}
return $subManager;
}
public function isIncludedSubManager($user)
{
foreach ($this->subManager as $sm) {
if ($sm == $user && $this->getManager() != $user) return true;
}
return false;
}
public function getAllManager($userException = null)
{
$allManager = [];
if ($this->manager != $userException && $this->manager->getIsActive()) $allManager[$this->manager->getId()] = $this->manager;
foreach ($this->subManager as $sm) {
if ($sm != $userException && $sm->getIsActive()) {
$allManager[$sm->getId()] = $sm;
};
}
return $allManager;
}
public function getIsIncludedManager($user)
{
$allManager = $this->getAllManager();
foreach ($allManager as $manager) {
if ($manager == $user) {
return true;
};
}
return false;
}
/**
* @return Collection|Job[]
*/
public function getJobs(): Collection
{
return $this->jobs;
}
public function addJob(Job $job): self
{
if (!$this->jobs->contains($job)) {
$this->jobs[] = $job;
$job->setCreatedBy($this);
}
return $this;
}
public function removeJob(Job $job): self
{
if ($this->jobs->removeElement($job)) {
// set the owning side to null (unless already changed)
if ($job->getCreatedBy() === $this) {
$job->setCreatedBy(null);
}
}
return $this;
}
public function getFlexiWorkArrangementOption(): ?FlexiWorkArrangementOption
{
return $this->flexiWorkArrangementOption;
}
public function setFlexiWorkArrangementOption(?FlexiWorkArrangementOption $flexiWorkArrangementOption): self
{
// unset the owning side of the relation if necessary
if ($flexiWorkArrangementOption === null && $this->flexiWorkArrangementOption !== null) {
$this->flexiWorkArrangementOption->setUser(null);
}
// set the owning side of the relation if necessary
if ($flexiWorkArrangementOption !== null && $flexiWorkArrangementOption->getUser() !== $this) {
$flexiWorkArrangementOption->setUser($this);
}
$this->flexiWorkArrangementOption = $flexiWorkArrangementOption;
return $this;
}
public function getFlexiWorkArrangementOptionList()
{
$list = [];
if (isset($this->flexiWorkArrangementOption)) {
if ($this->flexiWorkArrangementOption->getFWH()) {
$list[] = 'page.user.profile.fwa.option.fwh_abbrv';
/*$list[]['full'] = 'page.user.profile.fwa.option.fwh';
$list[]['abbrv'] = 'page.user.profile.fwa.option.fwh_abbrv';*/
};
if ($this->flexiWorkArrangementOption->getFP()) {
$list[] = 'page.user.profile.fwa.option.fp_abbrv';
/*$list[]['full'] = 'page.user.profile.fwa.option.fp';
$list[]['abbrv'] = 'page.user.profile.fwa.option.fp_abbrv';*/
};
if ($this->flexiWorkArrangementOption->getPT()) {
$list[] = 'page.user.profile.fwa.option.pt_abbrv';
/*$list[]['full'] = 'page.user.profile.fwa.option.pt';
$list[]['abbrv'] = 'page.user.profile.fwa.option.pt_abbrv';*/
};
};
return $list;
}
public function getFwaStatus(): ?string
{
return $this->fwaStatus;
}
public function setFwaStatus(?string $fwaStatus): self
{
$this->fwaStatus = $fwaStatus;
return $this;
}
public function getReminder(): ?array
{
return $this->reminder;
}
public function setReminder(?array $reminder): self
{
$this->reminder = $reminder;
return $this;
}
public function getFeatureDocumentManagement(): ?bool
{
return $this->featureDocumentManagement;
}
public function setFeatureDocumentManagement(bool $featureDocumentManagement): self
{
$this->featureDocumentManagement = $featureDocumentManagement;
return $this;
}
public function inProbation()
{
return $this->personalInfo->getJobStatus() == 'form.job_status.probation' ? true : false;
}
public function inExtendedProbation()
{
if ($this->inProbation()) {
try {
$join = $this->personalInfo->getJobJoinDate();
$end = $this->personalInfo->getJobExpiryDate();
if ($end) {
$interval = $join->diff($end);
return $interval->format("%m") >= 3 && $interval->format("%d") >= 14 ? true : false;
} else {
return false;
}
} catch (Exception $e) {
return false;
}
} else {
return false;
}
}
/**
* @return Collection<int, LeaveEntitlement>
*/
public function getLeaveEntitlements(): Collection
{
return $this->leaveEntitlements;
}
public function addLeaveEntitlement(LeaveEntitlement $leaveEntitlement): self
{
if (!$this->leaveEntitlements->contains($leaveEntitlement)) {
$this->leaveEntitlements[] = $leaveEntitlement;
$leaveEntitlement->setUser($this);
}
return $this;
}
public function removeLeaveEntitlement(LeaveEntitlement $leaveEntitlement): self
{
if ($this->leaveEntitlements->removeElement($leaveEntitlement)) {
// set the owning side to null (unless already changed)
if ($leaveEntitlement->getUser() === $this) {
$leaveEntitlement->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, LeaveRequest>
*/
public function getLeaveRequests(): Collection
{
return $this->leaveRequests;
}
public function addLeaveRequest(LeaveRequest $leaveRequest): self
{
if (!$this->leaveRequests->contains($leaveRequest)) {
$this->leaveRequests[] = $leaveRequest;
$leaveRequest->setUser($this);
}
return $this;
}
public function removeLeaveRequest(LeaveRequest $leaveRequest): self
{
if ($this->leaveRequests->removeElement($leaveRequest)) {
// set the owning side to null (unless already changed)
if ($leaveRequest->getUser() === $this) {
$leaveRequest->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, LeaveMCRecord>
*/
public function getLeaveMCRecords(): Collection
{
return $this->leaveMCRecords;
}
public function addLeaveMCRecord(LeaveMCRecord $leaveMCRecord): self
{
if (!$this->leaveMCRecords->contains($leaveMCRecord)) {
$this->leaveMCRecords[] = $leaveMCRecord;
$leaveMCRecord->setUser($this);
}
return $this;
}
public function removeLeaveMCRecord(LeaveMCRecord $leaveMCRecord): self
{
if ($this->leaveMCRecords->removeElement($leaveMCRecord)) {
// set the owning side to null (unless already changed)
if ($leaveMCRecord->getUser() === $this) {
$leaveMCRecord->setUser(null);
}
}
return $this;
}
public function getDepartment(): ?Department
{
return $this->department;
}
public function setDepartment(?Department $department): self
{
$this->department = $department;
return $this;
}
/**
* @return Collection<int, TimeSpent>
*/
public function getTimeSpents(): Collection
{
return $this->timeSpents;
}
public function getTotalTimeSpents($start, $end)
{
$totalHours = 0;
if ($start && $end) {
foreach ($this->timeSpents as $timespent) {
$timeSpentDate = $timespent->getDate()->format('Y-m-d');
if ($timeSpentDate >= $start && $timeSpentDate <= $end) {
$totalHours += $timespent->getHours();
}
}
}
return $totalHours;
}
public function addTimeSpent(TimeSpent $timeSpent): self
{
if (!$this->timeSpents->contains($timeSpent)) {
$this->timeSpents[] = $timeSpent;
$timeSpent->setUser($this);
}
return $this;
}
public function removeTimeSpent(TimeSpent $timeSpent): self
{
if ($this->timeSpents->removeElement($timeSpent)) {
// set the owning side to null (unless already changed)
if ($timeSpent->getUser() === $this) {
$timeSpent->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Task>
*/
public function getTasks(): Collection
{
return $this->tasks;
}
public function addTask(Task $task): self
{
if (!$this->tasks->contains($task)) {
$this->tasks[] = $task;
$task->setUser($this);
}
return $this;
}
public function removeTask(Task $task): self
{
if ($this->tasks->removeElement($task)) {
// set the owning side to null (unless already changed)
if ($task->getUser() === $this) {
$task->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Project>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Project $project): self
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
$project->setCreatedBy($this);
}
return $this;
}
public function removeProject(Project $project): self
{
if ($this->projects->removeElement($project)) {
// set the owning side to null (unless already changed)
if ($project->getCreatedBy() === $this) {
$project->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, PurchaseOrder>
*/
public function getPurchaseOrders(): Collection
{
return $this->purchaseOrders;
}
public function addPurchaseOrder(PurchaseOrder $purchaseOrder): self
{
if (!$this->purchaseOrders->contains($purchaseOrder)) {
$this->purchaseOrders[] = $purchaseOrder;
$purchaseOrder->setCreatedBy($this);
}
return $this;
}
public function removePurchaseOrder(PurchaseOrder $purchaseOrder): self
{
if ($this->purchaseOrders->removeElement($purchaseOrder)) {
// set the owning side to null (unless already changed)
if ($purchaseOrder->getCreatedBy() === $this) {
$purchaseOrder->setCreatedBy(null);
}
}
return $this;
}
public function getJustifiedMCRecords()
{
$data = [];
foreach ($this->leaveRequests as $leaveRequest) {
if ($leaveRequest->getLeaveType()->getAttributes()['label'] == 'Sick') {
if ($leaveRequest->getIsApproved()) {
array_push($data, $leaveRequest);
}
}
}
return $data;
}
public function getAllMCRecords()
{
$data = [];
foreach ($this->leaveRequests as $leaveRequest) {
if ($leaveRequest->getLeaveType()->getAttributes()['label'] == 'Sick') {
if ($leaveRequest->getIsApproved() == true || is_null($leaveRequest->getIsApproved()) == true) {
array_push($data, $leaveRequest);
}
}
}
return $data;
}
public function getAllLeaveRequests()
{
$data = [];
foreach ($this->leaveRequests as $leaveRequest) {
if ($leaveRequest->getLeaveType()->getAttributes()['label'] == 'Annual') {
if ($leaveRequest->getIsApproved() == true || is_null($leaveRequest->getIsApproved()) == true) {
array_push($data, $leaveRequest);
}
}
}
return $data;
}
public function getAllOtherRequests()
{
$data = [];
foreach ($this->leaveRequests as $leaveRequest) {
if ($leaveRequest->getLeaveType()->getAttributes()['label'] != 'Sick' && $leaveRequest->getLeaveType()->getAttributes()['label'] != 'Annual') {
if ($leaveRequest->getIsApproved() == true || is_null($leaveRequest->getIsApproved()) == true) {
array_push($data, $leaveRequest);
}
}
}
return $data;
}
public function getApprovedLeaveRequests()
{
$data = [];
foreach ($this->leaveRequests as $leaveRequest) {
if ($leaveRequest->getLeaveType()->getAttributes()['label'] == 'Annual') {
if ($leaveRequest->getIsApproved()) {
array_push($data, $leaveRequest);
}
}
}
return $data;
}
/**
* @return Collection<int, Project>
*/
public function getProjectsUserIsPIC(): Collection
{
return $this->projectsUserIsPIC;
}
public function addProjectsUserIsPIC(Project $projectsUserIsPIC): self
{
if (!$this->projectsUserIsPIC->contains($projectsUserIsPIC)) {
$this->projectsUserIsPIC[] = $projectsUserIsPIC;
$projectsUserIsPIC->setPersonInCharge($this);
}
return $this;
}
public function removeProjectsUserIsPIC(Project $projectsUserIsPIC): self
{
if ($this->projectsUserIsPIC->removeElement($projectsUserIsPIC)) {
// set the owning side to null (unless already changed)
if ($projectsUserIsPIC->getPersonInCharge() === $this) {
$projectsUserIsPIC->setPersonInCharge(null);
}
}
return $this;
}
/**
* @return Collection<int, VendorQuotation>
*/
public function getVendorQuotations(): Collection
{
return $this->vendorQuotations;
}
public function addVendorQuotation(VendorQuotation $vendorQuotation): self
{
if (!$this->vendorQuotations->contains($vendorQuotation)) {
$this->vendorQuotations[] = $vendorQuotation;
$vendorQuotation->setCreatedBy($this);
}
return $this;
}
public function removeVendorQuotation(VendorQuotation $vendorQuotation): self
{
if ($this->vendorQuotations->removeElement($vendorQuotation)) {
// set the owning side to null (unless already changed)
if ($vendorQuotation->getCreatedBy() === $this) {
$vendorQuotation->setCreatedBy(null);
}
}
return $this;
}
public function getJobInfo(): ?JobInfo
{
return $this->jobInfo;
}
public function setJobInfo(?JobInfo $jobInfo): self
{
// unset the owning side of the relation if necessary
if ($jobInfo === null && $this->jobInfo !== null) {
$this->jobInfo->setUser(null);
}
// set the owning side of the relation if necessary
if ($jobInfo !== null && $jobInfo->getUser() !== $this) {
$jobInfo->setUser($this);
}
$this->jobInfo = $jobInfo;
return $this;
}
public function getPermission(): ?array
{
return $this->permission;
}
public function setPermission(?array $permission): self
{
$this->permission = $permission;
return $this;
}
/**
* @return Collection<int, Salary>
*/
public function getSalaries(): Collection
{
return $this->salaries;
}
public function addSalary(Salary $salary): self
{
if (!$this->salaries->contains($salary)) {
$this->salaries[] = $salary;
$salary->setUser($this);
}
return $this;
}
public function removeSalary(Salary $salary): self
{
if ($this->salaries->removeElement($salary)) {
// set the owning side to null (unless already changed)
if ($salary->getUser() === $this) {
$salary->setUser(null);
}
}
return $this;
}
public function getAllHourlyRates($all = false)
{
$hourlyRates = [];
if ($all) {
$officeHourlyRates = $this->getOffice()->getAllHourlyRates();
if (count($officeHourlyRates) > 0) {
$hourlyRates = array_merge($hourlyRates, $officeHourlyRates);
}
if ($this->personalInfo->getUserRole()) {
if (count($this->personalInfo->getUserRole()->getDepartmentCosts()) > 0) {
foreach ($this->personalInfo->getUserRole()->getDepartmentCosts() as $deptCost) {
$hourlyRates[] = ['type' => 'role', 'date' => $deptCost->getValidAt()->format('Y-m-d'), 'rate' => $deptCost->getRate()];
}
}
}
if (count($this->salaries) > 0) {
foreach ($this->salaries as $salary) {
if ($salary->isAuthentic() == true) continue;
$hourlyRates[] = ['type' => 'salary', 'date' => $salary->getValidAt()->format('Y-m-d'), 'rate' => $salary->getHourlyRate()];
}
}
usort($hourlyRates, function ($a, $b) {
return $a['date'] <=> $b['date'];
});
} else {
if (count($this->salaries) > 0) {
foreach ($this->salaries as $salary) {
if ($salary->isAuthentic() == true) continue;
$hourlyRates[] = ['type' => 'salary', 'date' => $salary->getValidAt()->format('Y-m-d'), 'rate' => $salary->getHourlyRate()];
}
}
usort($hourlyRates, function ($a, $b) {
return $a['date'] <=> $b['date'];
});
if ($this->personalInfo->getUserRole()) {
if (count($this->personalInfo->getUserRole()->getDepartmentCosts()) > 0) {
foreach ($this->personalInfo->getUserRole()->getDepartmentCosts() as $deptCost) {
$hourlyRates[] = ['type' => 'role', 'date' => $deptCost->getValidAt()->format('Y-m-d'), 'rate' => $deptCost->getRate()];
}
}
}
usort($hourlyRates, function ($a, $b) {
return $a['date'] <=> $b['date'];
});
$hasSalary = false;
foreach ($hourlyRates as $key => $hourlyRate) {
if ($hasSalary && $hourlyRate['type'] == 'role') {
unset($hourlyRates[$key]);
}
if (!$hasSalary) $hasSalary = $hourlyRate['type'] == 'salary';
}
if ($this->getOffice() == null) return $hourlyRates;
$officeHourlyRates = $this->getOffice()->getAllHourlyRates();
if (count($officeHourlyRates) > 0) {
foreach ($officeHourlyRates as $officeHourlyRate) {
$hourlyRates[] = $officeHourlyRate;
}
}
usort($hourlyRates, function ($a, $b) {
return $a['date'] <=> $b['date'];
});
$hasOther = false;
foreach ($hourlyRates as $key => $hourlyRate) {
if ($hasOther && $hourlyRate['type'] == 'office') {
unset($hourlyRates[$key]);
}
if (!$hasOther) $hasOther = ($hourlyRate['type'] == 'role' || $hourlyRate['type']) == 'salary';
}
}
foreach ($hourlyRates as $key => $hourlyRate) {
$hourlyRates[$key]['date'] = new \DateTime($hourlyRate['date']);
}
return $hourlyRates;
}
public function getHourlyRate($date = null)
{
$dateStr = $date ? $date : date('Y-m-d');
if (count($this->salaries) > 0) {
$latestSalary = [];
foreach ($this->salaries as $salary) {
if ($salary->isAuthentic() == true) continue;
if ($dateStr >= $salary->getValidAt()->format('Y-m-d')) array_push($latestSalary, $salary);
}
usort($latestSalary, function ($a, $b) {
return $b->getValidAt() <=> $a->getValidAt();
});
if (isset($latestSalary[0])) {
return $latestSalary[0]->getHourlyRate();
}
}
// if($this->personalInfo->getUserRole()){
// if(count($this->personalInfo->getUserRole()->getDepartmentCosts()) > 0){
// $latestRates = [];
// foreach($this->personalInfo->getUserRole()->getDepartmentCosts() as $deptCost){
// if($dateStr >= $deptCost->getValidAt()->format('Y-m-d')) array_push($latestRates, $deptCost);
// }
// usort($latestRates, function ($a, $b) {
// return $b->getValidAt() <=> $a->getValidAt();
// });
// if (isset($latestSalary[0])) {
// return $latestSalary[0]->getRate();
// }
// }
// }
$officeHourlyRate = $this->getOffice()->getHourlyRate($dateStr) ?? 0;
return $officeHourlyRate == null ? 0 : $officeHourlyRate;
}
public function getHourlyRateUsd($date = null, $onlySalary = false)
{
// $dateStr = $date ? $date : date('Y-m-d');
// if ($this->personalInfo->getUserRole()) {
// if (count($this->personalInfo->getUserRole()->getDepartmentCosts()) > 0) {
// $latestRates = [];
// foreach ($this->personalInfo->getUserRole()->getDepartmentCosts() as $deptCost) {
// if ($dateStr >= $deptCost->getValidAt()->format('Y-m-d')) array_push($latestRates, $deptCost);
// }
// usort($latestRates, function ($a, $b) {
// return $b->getValidAt() <=> $a->getValidAt();
// });
// return isset($latestRates[0]) ? $latestRates[0]->getRate() : 0;
// }
// }
// if(count($this->salaries) > 0) {
// foreach($this->salaries as $salary){
// if($salary->isAuthentic() == true) continue;
// if($dateStr >= $salary->getValidAt()->format('Y-m-d')) return $salary->getHourlyRateUsd($dateStr);
// }
// return $salary->getHourlyRateUsd($dateStr);
// };
// $officeHourlyRate = $this->getOffice()->getHourlyRateUsd($dateStr);
// return $officeHourlyRate == null ? 0 : $officeHourlyRate;
return $this->getHourlyRate($date, $onlySalary);
}
public function getCostRateUsd($date = null)
{
$dateStr = $date ? $date : date('Y-m-d');
if (count($this->salaries) > 0) {
foreach ($this->salaries as $salary) {
if ($salary->isAuthentic() == true) continue;
if ($dateStr >= $salary->getValidAt()->format('Y-m-d')) return $salary->getHourlyRateUsd($dateStr);
}
return $salary->getHourlyRateUsd($dateStr);
};
return 0;
}
public function getRateCardUsd($date = null)
{
$dateStr = $date ? $date : date('Y-m-d');
if ($this->personalInfo->getUserRole()) {
if (count($this->personalInfo->getUserRole()->getDepartmentCosts()) > 0) {
$latestRates = [];
foreach ($this->personalInfo->getUserRole()->getDepartmentCosts() as $deptCost) {
if ($dateStr >= $deptCost->getValidAt()->format('Y-m-d')) array_push($latestRates, $deptCost);
}
usort($latestRates, function ($a, $b) {
return $b->getValidAt() <=> $a->getValidAt();
});
return isset($latestRates[0]) ? $latestRates[0]->getRate() : 0;
}
}
return 0;
}
public function getSalary(): ?Salary
{
$latestSalary = null;
$sortedSalaries = [];
foreach ($this->salaries as $salary) {
if ($salary->isAuthentic() == false) continue;
array_push($sortedSalaries, $salary);
}
// $sortedSalaries = $this->getSalaries()->toArray();
usort($sortedSalaries, function (Salary $a, Salary $b) {
return $b->getValidAt() <=> $a->getValidAt();
});
if (!empty($sortedSalaries)) {
$latestSalary = reset($sortedSalaries);
}
return $latestSalary;
}
/**
* @return Collection<int, ProjectMember>
*/
public function getProjectMembers(): Collection
{
return $this->projectMembers;
}
public function addProjectMember(ProjectMember $projectMember): self
{
if (!$this->projectMembers->contains($projectMember)) {
$this->projectMembers[] = $projectMember;
$projectMember->setUser($this);
}
return $this;
}
public function removeProjectMember(ProjectMember $projectMember): self
{
if ($this->projectMembers->removeElement($projectMember)) {
// set the owning side to null (unless already changed)
if ($projectMember->getUser() === $this) {
$projectMember->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, AppraisalQuestionnaire>
*/
public function getAppraisalQuestionnaires(): Collection
{
return $this->appraisalQuestionnaires;
}
public function addAppraisalQuestionnaire(AppraisalQuestionnaire $appraisalQuestionnaire): self
{
if (!$this->appraisalQuestionnaires->contains($appraisalQuestionnaire)) {
$this->appraisalQuestionnaires[] = $appraisalQuestionnaire;
$appraisalQuestionnaire->setUser($this);
}
return $this;
}
public function removeAppraisalQuestionnaire(AppraisalQuestionnaire $appraisalQuestionnaire): self
{
if ($this->appraisalQuestionnaires->removeElement($appraisalQuestionnaire)) {
// set the owning side to null (unless already changed)
if ($appraisalQuestionnaire->getUser() === $this) {
$appraisalQuestionnaire->setUser(null);
}
}
return $this;
}
public function getAppraisalStatus(): ?array
{
return $this->appraisalStatus;
}
public function setAppraisalStatus(?array $appraisalStatus): self
{
$this->appraisalStatus = $appraisalStatus;
return $this;
}
public function getObjectiveStatus(): ?array
{
return $this->objectiveStatus;
}
public function setObjectiveStatus(?array $objectiveStatus): self
{
$this->objectiveStatus = $objectiveStatus;
return $this;
}
public function getTotalHoursByProject($project)
{
$totalHours = 0;
foreach ($this->tasks as $task) {
if ($task->getProject()->getName() == $project) {
$totalHours += $task->getWeeklyTotalHours();
}
}
return $totalHours;
}
/**
* @return Collection|UserTitle[]
*/
public function getUserTitles(): Collection
{
return $this->userTitles;
}
public function addUserTitle(UserTitle $userTitle): self
{
if (!$this->userTitles->contains($userTitle)) {
$this->userTitles[] = $userTitle;
$userTitle->setUser($this);
}
return $this;
}
public function removeUserTitle(UserTitle $userTitle): self
{
if ($this->userTitles->removeElement($userTitle)) {
// set the owning side to null (unless already changed)
if ($userTitle->getUser() === $this) {
$userTitle->setUser(null);
}
}
return $this;
}
public function getUserTitle($asArray = false)
{
$latestTitle = null;
if (count($this->userTitles) == 0) return null;
foreach ($this->userTitles as $userTitle) {
if ($latestTitle == null) $latestTitle = $userTitle;
if ($latestTitle->getValidAt() < $userTitle->getValidAt() && $userTitle->getValidAt() <= new \DateTimeImmutable()) $latestTitle = $userTitle;
}
return $asArray ? $latestTitle : ($latestTitle->getTitle() ?? null);
}
/**
* @return Collection|AssetUsage[]
*/
public function getAssetUsages(): Collection
{
return $this->assetUsages;
}
public function addAssetUsage(AssetUsage $assetUsage): self
{
if (!$this->assetUsages->contains($assetUsage)) {
$this->assetUsages[] = $assetUsage;
$assetUsage->setUser($this);
}
return $this;
}
public function removeAssetUsage(AssetUsage $assetUsage): self
{
if ($this->assetUsages->removeElement($assetUsage)) {
// set the owning side to null (unless already changed)
if ($assetUsage->getUser() === $this) {
$assetUsage->setUser(null);
}
}
return $this;
}
/**
* @return Collection|CourseUserEnrollment[]
*/
public function getCourseUserEnrollments(): Collection
{
// return $this->courseUserEnrollments;
return $this->courseUserEnrollments->filter(function (CourseUserEnrollment $enrollment) {
return !$enrollment->isDeleted();
});
}
public function addCourseUserEnrollment(CourseUserEnrollment $courseUserEnrollment): self
{
if (!$this->courseUserEnrollments->contains($courseUserEnrollment)) {
$this->courseUserEnrollments[] = $courseUserEnrollment;
$courseUserEnrollment->setUser($this);
}
return $this;
}
public function removeCourseUserEnrollment(CourseUserEnrollment $courseUserEnrollment): self
{
if ($this->courseUserEnrollments->removeElement($courseUserEnrollment)) {
// set the owning side to null (unless already changed)
if ($courseUserEnrollment->getUser() === $this) {
$courseUserEnrollment->setUser(null);
}
}
return $this;
}
public function checkIsManager($includeSub = true)
{
$offices = $this->assignedCompany()->getOffices();
foreach ($offices as $office) {
foreach ($office->getAllUser() as $user) {
if ($user->getManager() != null && $user->getManager()->getId() == $this->id || ($includeSub ? $user->isIncludedSubManager($this) : '')) {
return true;
}
}
};
return false;
}
public function getIsManager(): ?bool
{
return $this->isManager;
}
public function setIsManager(?bool $isManager): self
{
$this->isManager = $isManager;
return $this;
}
/**
* @return Collection<int, ExpenseRequest>
*/
public function getExpenseRequests(): Collection
{
return $this->expenseRequests;
}
public function addExpenseRequest(ExpenseRequest $expenseRequest): self
{
if (!$this->expenseRequests->contains($expenseRequest)) {
$this->expenseRequests->add($expenseRequest);
$expenseRequest->setRequester($this);
}
return $this;
}
/*
* @return Collection<int, RecruitApplication>
*/
public function getRecruitApplicationComments(): Collection
{
return $this->recruitApplicationComments;
}
public function addRecruitApplicationComment(RecruitApplication $recruitApplicationComment): self
{
if (!$this->recruitApplicationComments->contains($recruitApplicationComment)) {
$this->recruitApplicationComments->add($recruitApplicationComment);
$recruitApplicationComment->setCommentRejectedBy($this);
}
return $this;
}
public function removeExpenseRequest(ExpenseRequest $expenseRequest): self
{
if ($this->expenseRequests->removeElement($expenseRequest)) {
// set the owning side to null (unless already changed)
if ($expenseRequest->getRequester() === $this) {
$expenseRequest->setRequester(null);
}
}
return $this;
}
public function removeRecruitApplicationComment(RecruitApplication $recruitApplicationComment): self
{
if ($this->recruitApplicationComments->removeElement($recruitApplicationComment)) {
// set the owning side to null (unless already changed)
if ($recruitApplicationComment->getCommentRejectedBy() === $this) {
$recruitApplicationComment->setCommentRejectedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitApplication>
*/
public function getRecruitApplicationWithdrawComments(): Collection
{
return $this->recruitApplicationWithdrawComments;
}
public function addRecruitApplicationWithdrawComment(RecruitApplication $recruitApplicationWithdrawComment): self
{
if (!$this->recruitApplicationWithdrawComments->contains($recruitApplicationWithdrawComment)) {
$this->recruitApplicationWithdrawComments->add($recruitApplicationWithdrawComment);
$recruitApplicationWithdrawComment->setCommentsWithdrawnBy($this);
}
return $this;
}
public function removeRecruitApplicationWithdrawComment(RecruitApplication $recruitApplicationWithdrawComment): self
{
if ($this->recruitApplicationWithdrawComments->removeElement($recruitApplicationWithdrawComment)) {
// set the owning side to null (unless already changed)
if ($recruitApplicationWithdrawComment->getCommentsWithdrawnBy() === $this) {
$recruitApplicationWithdrawComment->setCommentsWithdrawnBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitVacancyHiringmanager>
*/
public function getRecruitVacancyHiringmanagers(): Collection
{
return $this->recruitVacancyHiringmanagers;
}
public function addRecruitVacancyHiringmanager(RecruitVacancyHiringmanager $recruitVacancyHiringmanager): self
{
if (!$this->recruitVacancyHiringmanagers->contains($recruitVacancyHiringmanager)) {
$this->recruitVacancyHiringmanagers->add($recruitVacancyHiringmanager);
$recruitVacancyHiringmanager->setUser($this);
}
return $this;
}
public function removeRecruitVacancyHiringmanager(RecruitVacancyHiringmanager $recruitVacancyHiringmanager): self
{
if ($this->recruitVacancyHiringmanagers->removeElement($recruitVacancyHiringmanager)) {
// set the owning side to null (unless already changed)
if ($recruitVacancyHiringmanager->getUser() === $this) {
$recruitVacancyHiringmanager->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitVacancyApprover>
*/
public function getRecruitVacancyApprovers(): Collection
{
return $this->recruitVacancyApprovers;
}
public function addRecruitVacancyApprover(RecruitVacancyApprover $recruitVacancyApprover): self
{
if (!$this->recruitVacancyApprovers->contains($recruitVacancyApprover)) {
$this->recruitVacancyApprovers->add($recruitVacancyApprover);
$recruitVacancyApprover->setApprover($this);
}
return $this;
}
public function removeRecruitVacancyApprover(RecruitVacancyApprover $recruitVacancyApprover): self
{
if ($this->recruitVacancyApprovers->removeElement($recruitVacancyApprover)) {
// set the owning side to null (unless already changed)
if ($recruitVacancyApprover->getApprover() === $this) {
$recruitVacancyApprover->setApprover(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitVacancy>
*/
public function getRecruitVacancies(): Collection
{
return $this->recruitVacancies;
}
public function addRecruitVacancy(RecruitVacancy $recruitVacancy): self
{
if (!$this->recruitVacancies->contains($recruitVacancy)) {
$this->recruitVacancies->add($recruitVacancy);
$recruitVacancy->setCreatedBy($this);
}
return $this;
}
public function removeRecruitVacancy(RecruitVacancy $recruitVacancy): self
{
if ($this->recruitVacancies->removeElement($recruitVacancy)) {
// set the owning side to null (unless already changed)
if ($recruitVacancy->getCreatedBy() === $this) {
$recruitVacancy->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitApplicationActivity>
*/
public function getRecruitApplicationActivities(): Collection
{
return $this->recruitApplicationActivities;
}
public function addRecruitApplicationActivity(RecruitApplicationActivity $recruitApplicationActivity): self
{
if (!$this->recruitApplicationActivities->contains($recruitApplicationActivity)) {
$this->recruitApplicationActivities->add($recruitApplicationActivity);
$recruitApplicationActivity->setCreatedBy($this);
}
return $this;
}
public function removeRecruitApplicationActivity(RecruitApplicationActivity $recruitApplicationActivity): self
{
if ($this->recruitApplicationActivities->removeElement($recruitApplicationActivity)) {
// set the owning side to null (unless already changed)
if ($recruitApplicationActivity->getCreatedBy() === $this) {
$recruitApplicationActivity->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitApplicationComment>
*/
public function getRecruitApplicationCommentsMultiple(): Collection
{
return $this->recruitApplicationCommentsMultiple;
}
public function addRecruitApplicationCommentsMultiple(RecruitApplicationComment $recruitApplicationCommentsMultiple): self
{
if (!$this->recruitApplicationCommentsMultiple->contains($recruitApplicationCommentsMultiple)) {
$this->recruitApplicationCommentsMultiple->add($recruitApplicationCommentsMultiple);
$recruitApplicationCommentsMultiple->setCommentBy($this);
}
return $this;
}
public function removeRecruitApplicationCommentsMultiple(RecruitApplicationComment $recruitApplicationCommentsMultiple): self
{
if ($this->recruitApplicationCommentsMultiple->removeElement($recruitApplicationCommentsMultiple)) {
// set the owning side to null (unless already changed)
if ($recruitApplicationCommentsMultiple->getCommentBy() === $this) {
$recruitApplicationCommentsMultiple->setCommentBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitQuestion>
*/
public function getRecruitQuestions(): Collection
{
return $this->recruitQuestions;
}
public function addRecruitQuestion(RecruitQuestion $recruitQuestion): self
{
if (!$this->recruitQuestions->contains($recruitQuestion)) {
$this->recruitQuestions->add($recruitQuestion);
$recruitQuestion->setCreatedBy($this);
}
return $this;
}
public function removeRecruitQuestion(RecruitQuestion $recruitQuestion): self
{
if ($this->recruitQuestions->removeElement($recruitQuestion)) {
// set the owning side to null (unless already changed)
if ($recruitQuestion->getCreatedBy() === $this) {
$recruitQuestion->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitEvaluationScore>
*/
public function getRecruitEvaluationScores(): Collection
{
return $this->recruitEvaluationScores;
}
public function addRecruitEvaluationScore(RecruitEvaluationScore $recruitEvaluationScore): self
{
if (!$this->recruitEvaluationScores->contains($recruitEvaluationScore)) {
$this->recruitEvaluationScores->add($recruitEvaluationScore);
$recruitEvaluationScore->setUser($this);
}
return $this;
}
public function removeRecruitEvaluationScore(RecruitEvaluationScore $recruitEvaluationScore): self
{
if ($this->recruitEvaluationScores->removeElement($recruitEvaluationScore)) {
// set the owning side to null (unless already changed)
if ($recruitEvaluationScore->getUser() === $this) {
$recruitEvaluationScore->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitApplication>
*/
public function getRecruitApplications(): Collection
{
return $this->recruitApplications;
}
public function addRecruitApplication(RecruitApplication $recruitApplication): self
{
if (!$this->recruitApplications->contains($recruitApplication)) {
$this->recruitApplications->add($recruitApplication);
$recruitApplication->setReportingTo($this);
}
return $this;
}
public function removeRecruitApplication(RecruitApplication $recruitApplication): self
{
if ($this->recruitApplications->removeElement($recruitApplication)) {
// set the owning side to null (unless already changed)
if ($recruitApplication->getReportingTo() === $this) {
$recruitApplication->setReportingTo(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitDefaultApprover>
*/
public function getDefaultApprovers(): Collection
{
return $this->defaultApprovers;
}
public function addDefaultApprover(RecruitDefaultApprover $defaultApprover): self
{
if (!$this->defaultApprovers->contains($defaultApprover)) {
$this->defaultApprovers->add($defaultApprover);
$defaultApprover->setUser($this);
}
return $this;
}
public function removeDefaultApprover(RecruitDefaultApprover $defaultApprover): self
{
if ($this->defaultApprovers->removeElement($defaultApprover)) {
// set the owning side to null (unless already changed)
if ($defaultApprover->getUser() === $this) {
$defaultApprover->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitVacancyHistory>
*/
public function getRecruitVacancyHistories(): Collection
{
return $this->recruitVacancyHistories;
}
public function addRecruitVacancyHistory(RecruitVacancyHistory $recruitVacancyHistory): self
{
if (!$this->recruitVacancyHistories->contains($recruitVacancyHistory)) {
$this->recruitVacancyHistories->add($recruitVacancyHistory);
$recruitVacancyHistory->setCreatedBy($this);
}
return $this;
}
public function removeRecruitVacancyHistory(RecruitVacancyHistory $recruitVacancyHistory): self
{
if ($this->recruitVacancyHistories->removeElement($recruitVacancyHistory)) {
// set the owning side to null (unless already changed)
if ($recruitVacancyHistory->getCreatedBy() === $this) {
$recruitVacancyHistory->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitSettingActivity>
*/
public function getRecruitSettingActivities(): Collection
{
return $this->recruitSettingActivities;
}
public function addRecruitSettingActivity(RecruitSettingActivity $recruitSettingActivity): self
{
if (!$this->recruitSettingActivities->contains($recruitSettingActivity)) {
$this->recruitSettingActivities->add($recruitSettingActivity);
$recruitSettingActivity->setUser($this);
}
return $this;
}
public function removeRecruitSettingActivity(RecruitSettingActivity $recruitSettingActivity): self
{
if ($this->recruitSettingActivities->removeElement($recruitSettingActivity)) {
// set the owning side to null (unless already changed)
if ($recruitSettingActivity->getUser() === $this) {
$recruitSettingActivity->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitTalentSearchSession>
*/
public function getRecruitTalentSearchSessions(): Collection
{
return $this->recruitTalentSearchSessions;
}
public function addRecruitTalentSearchSession(RecruitTalentSearchSession $recruitTalentSearchSession): self
{
if (!$this->recruitTalentSearchSessions->contains($recruitTalentSearchSession)) {
$this->recruitTalentSearchSessions->add($recruitTalentSearchSession);
$recruitTalentSearchSession->setUser($this);
}
return $this;
}
public function removeRecruitTalentSearchSession(RecruitTalentSearchSession $recruitTalentSearchSession): self
{
if ($this->recruitTalentSearchSessions->removeElement($recruitTalentSearchSession)) {
// set the owning side to null (unless already changed)
if ($recruitTalentSearchSession->getUser() === $this) {
$recruitTalentSearchSession->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitApplication>
*/
public function getApplicationsAsInterviewer(): Collection
{
return $this->applicationsAsInterviewer;
}
public function addApplicationsAsInterviewer(RecruitApplication $applicationsAsInterviewer): self
{
if (!$this->applicationsAsInterviewer->contains($applicationsAsInterviewer)) {
$this->applicationsAsInterviewer->add($applicationsAsInterviewer);
$applicationsAsInterviewer->setInterviewer($this);
}
return $this;
}
public function removeApplicationsAsInterviewer(RecruitApplication $applicationsAsInterviewer): self
{
if ($this->applicationsAsInterviewer->removeElement($applicationsAsInterviewer)) {
// set the owning side to null (unless already changed)
if ($applicationsAsInterviewer->getInterviewer() === $this) {
$applicationsAsInterviewer->setInterviewer(null);
}
}
return $this;
}
/**
* @return Collection<int, RecruitApplication>
*/
public function getHrInterviewer(): Collection
{
return $this->hrInterviewer;
}
public function addHrInterviewer(RecruitApplication $hrInterviewer): self
{
if (!$this->hrInterviewer->contains($hrInterviewer)) {
$this->hrInterviewer->add($hrInterviewer);
$hrInterviewer->setHrInterviewer($this);
}
return $this;
}
public function removeHrInterviewer(RecruitApplication $hrInterviewer): self
{
if ($this->hrInterviewer->removeElement($hrInterviewer)) {
// set the owning side to null (unless already changed)
if ($hrInterviewer->getHrInterviewer() === $this) {
$hrInterviewer->setHrInterviewer(null);
}
}
return $this;
}
/**
* @return Collection<int, WorkingFromAbroad>
*/
public function getWorkingFromAbroads(): Collection
{
return $this->workingFromAbroads;
}
public function getTotalWfaDays()
{
$total = 0;
if ($this->workingFromAbroads) {
foreach ($this->workingFromAbroads as $wfa) {
if ($wfa->getStatus() >= 3 && $wfa->isIsApproved() == true) {
$total += $wfa->getWfaDays();
}
}
}
return $total;
}
public function getTotalWfaDaysLeft()
{
$left = 40;
if ($this->getTotalWfaDays()) {
$left = 40 - $this->getTotalWfaDays();
}
return $left;
}
public function addWorkingFromAbroad(WorkingFromAbroad $workingFromAbroad): self
{
if (!$this->workingFromAbroads->contains($workingFromAbroad)) {
$this->workingFromAbroads->add($workingFromAbroad);
$workingFromAbroad->setUser($this);
}
return $this;
}
public function removeWorkingFromAbroad(WorkingFromAbroad $workingFromAbroad): self
{
if ($this->workingFromAbroads->removeElement($workingFromAbroad)) {
// set the owning side to null (unless already changed)
if ($workingFromAbroad->getUser() === $this) {
$workingFromAbroad->setUser(null);
}
}
return $this;
}
/*
* @return Collection<int, ChecklistTask>
*/
public function getChecklistTasksAsAssignee(): Collection
{
return $this->checklistTasksAsAssignee;
}
public function addChecklistTasksAsAssignee(ChecklistTask $checklistTasksAsAssignee): self
{
if (!$this->checklistTasksAsAssignee->contains($checklistTasksAsAssignee)) {
$this->checklistTasksAsAssignee->add($checklistTasksAsAssignee);
$checklistTasksAsAssignee->setDefaultAssignee($this);
}
return $this;
}
public function removeChecklistTasksAsAssignee(ChecklistTask $checklistTasksAsAssignee): self
{
if ($this->checklistTasksAsAssignee->removeElement($checklistTasksAsAssignee)) {
// set the owning side to null (unless already changed)
if ($checklistTasksAsAssignee->getDefaultAssignee() === $this) {
$checklistTasksAsAssignee->setDefaultAssignee(null);
}
}
return $this;
}
/**
* @return Collection<int, ChecklistTask>
*/
public function getChecklistTaskAsVerifier(): Collection
{
return $this->checklistTaskAsVerifier;
}
public function addChecklistTaskAsVerifier(ChecklistTask $checklistTaskAsVerifier): self
{
if (!$this->checklistTaskAsVerifier->contains($checklistTaskAsVerifier)) {
$this->checklistTaskAsVerifier->add($checklistTaskAsVerifier);
$checklistTaskAsVerifier->setVerifier($this);
}
return $this;
}
public function removeChecklistTaskAsVerifier(ChecklistTask $checklistTaskAsVerifier): self
{
if ($this->checklistTaskAsVerifier->removeElement($checklistTaskAsVerifier)) {
// set the owning side to null (unless already changed)
if ($checklistTaskAsVerifier->getVerifier() === $this) {
$checklistTaskAsVerifier->setVerifier(null);
}
}
return $this;
}
/**
* @return Collection<int, Checklist>
*/
public function getChecklistsAsAssignee(): Collection
{
return $this->checklistsAsAssignee;
}
public function addChecklistsAsAssignee(Checklist $checklistsAsAssignee): self
{
if (!$this->checklistsAsAssignee->contains($checklistsAsAssignee)) {
$this->checklistsAsAssignee->add($checklistsAsAssignee);
$checklistsAsAssignee->setDefaultAssignee($this);
}
return $this;
}
public function removeChecklistsAsAssignee(Checklist $checklistsAsAssignee): self
{
if ($this->checklistsAsAssignee->removeElement($checklistsAsAssignee)) {
// set the owning side to null (unless already changed)
if ($checklistsAsAssignee->getDefaultAssignee() === $this) {
$checklistsAsAssignee->setDefaultAssignee(null);
}
}
return $this;
}
/**
* @return Collection<int, Checklist>
*/
public function getChecklistsAsOwner(): Collection
{
return $this->checklistsAsOwner;
}
public function addChecklistsAsOwner(Checklist $checklistsAsOwner): self
{
if (!$this->checklistsAsOwner->contains($checklistsAsOwner)) {
$this->checklistsAsOwner->add($checklistsAsOwner);
$checklistsAsOwner->setOwner($this);
}
return $this;
}
public function removeChecklistsAsOwner(Checklist $checklistsAsOwner): self
{
if ($this->checklistsAsOwner->removeElement($checklistsAsOwner)) {
// set the owning side to null (unless already changed)
if ($checklistsAsOwner->getOwner() === $this) {
$checklistsAsOwner->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, Checklist>
*/
public function getOnboardedChecklists(): Collection
{
return $this->onboardedChecklists;
}
public function addOnboardedChecklist(Checklist $onboardedChecklist): self
{
if (!$this->onboardedChecklists->contains($onboardedChecklist)) {
$this->onboardedChecklists->add($onboardedChecklist);
$onboardedChecklist->setOnboardUser($this);
}
return $this;
}
public function removeOnboardedChecklist(Checklist $onboardedChecklist): self
{
if ($this->onboardedChecklists->removeElement($onboardedChecklist)) {
// set the owning side to null (unless already changed)
if ($onboardedChecklist->getOnboardUser() === $this) {
$onboardedChecklist->setOnboardUser(null);
}
}
return $this;
}
public function getOnboardedChecklistsByType($type)
{
$onboardedChecklists = [];
foreach ($this->onboardedChecklists as $onboardedChecklist) {
if ($onboardedChecklist->getStatus() != 'ACTIVE') continue;
if ($onboardedChecklist->getType() == $type) array_push($onboardedChecklists, $onboardedChecklist);
}
return $onboardedChecklists;
}
/**
* @return Collection<int, ChecklistActivity>
*/
public function getChecklistActivities(): Collection
{
return $this->checklistActivities;
}
public function addChecklistActivity(ChecklistActivity $checklistActivity): self
{
if (!$this->checklistActivities->contains($checklistActivity)) {
$this->checklistActivities->add($checklistActivity);
$checklistActivity->setUser($this);
}
return $this;
}
public function removeChecklistActivity(ChecklistActivity $checklistActivity): self
{
if ($this->checklistActivities->removeElement($checklistActivity)) {
// set the owning side to null (unless already changed)
if ($checklistActivity->getUser() === $this) {
$checklistActivity->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, ChatbotThreads>
*/
public function getChatbotThreads(): Collection
{
return $this->chatbotThreads;
}
public function addChatbotThread(ChatbotThreads $chatbotThread): self
{
if (!$this->chatbotThreads->contains($chatbotThread)) {
$this->chatbotThreads->add($chatbotThread);
$chatbotThread->setUserId($this);
}
return $this;
}
public function removeChatbotThread(ChatbotThreads $chatbotThread): self
{
if ($this->chatbotThreads->removeElement($chatbotThread)) {
// set the owning side to null (unless already changed)
if ($chatbotThread->getUserId() === $this) {
$chatbotThread->setUserId(null);
}
}
return $this;
}
/**
* @return Collection<int, ChatbotSection>
*/
public function getChatbotSections(): Collection
{
return $this->chatbotSections;
}
public function addChatbotSection(ChatbotSection $chatbotSection): self
{
if (!$this->chatbotSections->contains($chatbotSection)) {
$this->chatbotSections->add($chatbotSection);
$chatbotSection->setCreatedBy($this);
}
return $this;
}
public function removeChatbotSection(ChatbotSection $chatbotSection): self
{
if ($this->chatbotSections->removeElement($chatbotSection)) {
// set the owning side to null (unless already changed)
if ($chatbotSection->getCreatedBy() === $this) {
$chatbotSection->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, ChatbotPrompt>
*/
public function getChatbotPrompts(): Collection
{
return $this->chatbotPrompts;
}
public function addChatbotPrompt(ChatbotPrompt $chatbotPrompt): self
{
if (!$this->chatbotPrompts->contains($chatbotPrompt)) {
$this->chatbotPrompts->add($chatbotPrompt);
$chatbotPrompt->setCreatedBy($this);
}
return $this;
}
public function removeChatbotPrompt(ChatbotPrompt $chatbotPrompt): self
{
if ($this->chatbotPrompts->removeElement($chatbotPrompt)) {
// set the owning side to null (unless already changed)
if ($chatbotPrompt->getCreatedBy() === $this) {
$chatbotPrompt->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, ChatbotCompanyPrompt>
*/
public function getChatbotCompanyPrompts(): Collection
{
return $this->chatbotCompanyPrompts;
}
public function addChatbotCompanyPrompt(ChatbotCompanyPrompt $chatbotCompanyPrompt): self
{
if (!$this->chatbotCompanyPrompts->contains($chatbotCompanyPrompt)) {
$this->chatbotCompanyPrompts->add($chatbotCompanyPrompt);
$chatbotCompanyPrompt->setCreatedBy($this);
}
return $this;
}
public function removeChatbotCompanyPrompt(ChatbotCompanyPrompt $chatbotCompanyPrompt): self
{
if ($this->chatbotCompanyPrompts->removeElement($chatbotCompanyPrompt)) {
// set the owning side to null (unless already changed)
if ($chatbotCompanyPrompt->getCreatedBy() === $this) {
$chatbotCompanyPrompt->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, ChatbotFaq>
*/
public function getChatbotFaqs(): Collection
{
return $this->chatbotFaqs;
}
public function addChatbotFaq(ChatbotFaq $chatbotFaq): self
{
if (!$this->chatbotFaqs->contains($chatbotFaq)) {
$this->chatbotFaqs->add($chatbotFaq);
$chatbotFaq->setUpdatedBy($this);
}
return $this;
}
public function removeChatbotFaq(ChatbotFaq $chatbotFaq): self
{
if ($this->chatbotFaqs->removeElement($chatbotFaq)) {
// set the owning side to null (unless already changed)
if ($chatbotFaq->getUpdatedBy() === $this) {
$chatbotFaq->setUpdatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectDynamicField>
*/
public function getProjectDynamicFields(): Collection
{
return $this->projectDynamicFields;
}
public function addProjectDynamicField(ProjectDynamicField $projectDynamicField): self
{
if (!$this->projectDynamicFields->contains($projectDynamicField)) {
$this->projectDynamicFields->add($projectDynamicField);
$projectDynamicField->setCreatedBy($this);
}
return $this;
}
public function removeProjectDynamicField(ProjectDynamicField $projectDynamicField): self
{
if ($this->projectDynamicFields->removeElement($projectDynamicField)) {
// set the owning side to null (unless already changed)
if ($projectDynamicField->getCreatedBy() === $this) {
$projectDynamicField->setCreatedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, XeroUser>
*/
public function getXeroUsers(): Collection
{
return $this->xeroUsers;
}
public function addXeroUser(XeroUser $xeroUser): self
{
if (!$this->xeroUsers->contains($xeroUser)) {
$this->xeroUsers->add($xeroUser);
$xeroUser->setUser($this);
}
return $this;
}
public function removeXeroUser(XeroUser $xeroUser): self
{
if ($this->xeroUsers->removeElement($xeroUser)) {
// set the owning side to null (unless already changed)
if ($xeroUser->getUser() === $this) {
$xeroUser->setUser(null);
}
}
return $this;
}
}