src/Entity/Office.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass'App\Repository\OfficeRepository')]
  9. class Office
  10. {
  11.     #[Groups(['LogService''APIJob''UserInfo''Recruitment'])]
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private $id;
  16.     #[Groups(['LogService''APIJob''UserInfo''Recruitment'])]
  17.     #[ORM\Column(type'string'length64nullabletrue)]
  18.     private $fullName;
  19.     #[Groups(['APIJob'])]
  20.     #[ORM\Column(type'string'length255nullabletrue)]
  21.     private $address;
  22.     #[Groups(['APIJob'])]
  23.     #[ORM\Column(type'string'length4nullabletrue)]
  24.     private $country;
  25.     #[ORM\Column(type'string'length128nullabletrue)]
  26.     private $contactPhone;
  27.     #[ORM\Column(type'string'length32nullabletrue)]
  28.     private $registrationNumber;
  29.     #[ORM\Column(type'string'length128nullabletrue)]
  30.     private $taxNumber;
  31.     #[ORM\OneToMany(targetEntity'App\Entity\User'mappedBy'office'fetch'LAZY')]
  32.     private $users;
  33.     #[ORM\OneToMany(targetEntity'App\Entity\Invitation'mappedBy'office'orphanRemovaltruefetch'LAZY')]
  34.     private $invitations;
  35.     #[ORM\ManyToOne(targetEntity'App\Entity\Company'inversedBy'offices')]
  36.     private $company;
  37.     #[ORM\OneToMany(targetEntity'App\Entity\Document'mappedBy'office')]
  38.     private $documents;
  39.     #[ORM\OneToMany(targetEntity'App\Entity\Bank'mappedBy'office')]
  40.     private $banks;
  41.     #[ORM\OneToMany(targetEntity'App\Entity\Organization'mappedBy'office'orphanRemovaltrue)]
  42.     private $organizations;
  43.     #[ORM\OneToMany(targetEntityAppraisalForm::class, mappedBy'office')]
  44.     private $appraisalForms;
  45.     #[ORM\Column(type'string'length255nullabletrue)]
  46.     private $workPermitType;
  47.     #[ORM\OneToOne(targetEntityWidget::class, inversedBy'office'cascade: ['persist''remove'])]
  48.     private $widget;
  49.     #[ORM\OneToMany(targetEntityQnA::class, mappedBy'office')]
  50.     private $QnAs;
  51.     #[ORM\OneToMany(targetEntityTraining::class, mappedBy'office')]
  52.     private $trainings;
  53.     #[ORM\OneToMany(targetEntityAnnouncement::class, mappedBy'office')]
  54.     private $announcements;
  55.     #[ORM\Column(type'text'nullabletrue)]
  56.     private $starterGuide;
  57.     #[ORM\OneToOne(targetEntityFlexiWorkArrangement::class, mappedBy'office'cascade: ['persist''remove'])]
  58.     private $flexiWorkArrangement;
  59.     #[ORM\OneToOne(targetEntityOfficeUserInfo::class, mappedBy'office'cascade: ['persist''remove'])]
  60.     private $officeUserInfo;
  61.     #[ORM\OneToOne(targetEntityOfficeLeave::class, mappedBy'office'cascade: ['persist''remove'])]
  62.     private $officeLeave;
  63.     #[ORM\OneToMany(targetEntityLeaveType::class, mappedBy'office')]
  64.     private $leaveTypes;
  65.     #[ORM\Column(type'string'length3nullabletrue)]
  66.     private $currency;
  67.     #[ORM\OneToMany(targetEntitySalary::class, mappedBy'office')]
  68.     #[ORM\OrderBy(['validAt' => 'DESC'])]
  69.     private $salaries;
  70.     #[Groups(['APIJob'])]
  71.     #[ORM\Column(type'integer'nullabletrue)]
  72.     private $customOrder;
  73.     #[Groups(['APIJob'])]
  74.     #[ORM\ManyToMany(targetEntityJob::class, mappedBy'office')]
  75.     private $jobs;
  76.     #[ORM\OneToMany(targetEntityAssetUsage::class, mappedBy'office')]
  77.     private $assetUsages;
  78.     #[ORM\ManyToMany(targetEntityCourse::class, mappedBy'offices')]
  79.     private $courses;
  80.     #[ORM\ManyToMany(targetEntityCourseAutoEnrollment::class, mappedBy'offices')]
  81.     private $courseAutoEnrollments;
  82.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  83.     private ?string $customPersonalInfo null;
  84.     #[ORM\OneToMany(mappedBy'office'targetEntityRecruitVacancyOffice::class, orphanRemovaltrue)]
  85.     private Collection $recruitVacancyOffices;
  86.     #[ORM\OneToMany(mappedBy'office'targetEntityRecruitQuestionOffice::class, orphanRemovaltrue)]
  87.     private Collection $recruitQuestionOffices;
  88.     public function __construct()
  89.     {
  90.         $this->users = new ArrayCollection();
  91.         $this->invitations = new ArrayCollection();
  92.         $this->documents = new ArrayCollection();
  93.         $this->banks = new ArrayCollection();
  94.         $this->organizations = new ArrayCollection();
  95.         $this->appraisalForms = new ArrayCollection();
  96.         $this->QnAs = new ArrayCollection();
  97.         $this->trainings = new ArrayCollection();
  98.         $this->announcements = new ArrayCollection();
  99.         $this->leaveBankHolidays = new ArrayCollection();
  100.         $this->leaveTypes = new ArrayCollection();
  101.         $this->salaries = new ArrayCollection();
  102.         $this->jobs = new ArrayCollection();
  103.         $this->assetUsages = new ArrayCollection();
  104.         $this->courses = new ArrayCollection();
  105.         $this->courseAutoEnrollments = new ArrayCollection();
  106.         $this->recruitVacancyOffices = new ArrayCollection();
  107.         $this->recruitQuestionOffices = new ArrayCollection();
  108.     }
  109.     public function getId(): ?int
  110.     {
  111.         return $this->id;
  112.     }
  113.     public function getFullName(): ?string
  114.     {
  115.         return $this->fullName;
  116.     }
  117.     public function setFullName(?string $fullName): self
  118.     {
  119.         $this->fullName $fullName;
  120.         return $this;
  121.     }
  122.     public function getAddress(): ?string
  123.     {
  124.         return $this->address;
  125.     }
  126.     public function setAddress(?string $address): self
  127.     {
  128.         $this->address $address;
  129.         return $this;
  130.     }
  131.     public function getCountry(): ?string
  132.     {
  133.         return $this->country;
  134.     }
  135.     public function setCountry(?string $country): self
  136.     {
  137.         $this->country $country;
  138.         return $this;
  139.     }
  140.     public function getContactPhone(): ?string
  141.     {
  142.         return $this->contactPhone;
  143.     }
  144.     public function setContactPhone(?string $contactPhone): self
  145.     {
  146.         $this->contactPhone $contactPhone;
  147.         return $this;
  148.     }
  149.     public function getRegistrationNumber(): ?string
  150.     {
  151.         return $this->registrationNumber;
  152.     }
  153.     public function setRegistrationNumber(?string $registrationNumber): self
  154.     {
  155.         $this->registrationNumber $registrationNumber;
  156.         return $this;
  157.     }
  158.     public function getTaxNumber(): ?string
  159.     {
  160.         return $this->taxNumber;
  161.     }
  162.     public function setTaxNumber(?string $taxNumber): self
  163.     {
  164.         $this->taxNumber $taxNumber;
  165.         return $this;
  166.     }
  167.     public function getCustomOrder(): ?int
  168.     {
  169.         $num $this->customOrder;
  170.         if (is_null($num)) {
  171.             $num 0;
  172.         }
  173.         return $num;
  174.     }
  175.     public function setCustomOrder(?int $order): self
  176.     {
  177.         $this->customOrder $order;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection|User[]
  182.      */
  183.     public function getUsers(): Collection
  184.     {
  185.         return $this->users;
  186.     }
  187.     /**
  188.      * Get the total number of active users.
  189.      *
  190.      * @return int
  191.      */
  192.     public function getTotalUsers(): int
  193.     {
  194.         $activeUsers $this->users->filter(function ($user) {
  195.             return $user->getIsActive() == true;
  196.         });
  197.         return $activeUsers->count();
  198.     }
  199.     public function addUser(User $user): self
  200.     {
  201.         if (!$this->users->contains($user)) {
  202.             $this->users[] = $user;
  203.             $user->setOffice($this);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeUser(User $user): self
  208.     {
  209.         if ($this->users->contains($user)) {
  210.             $this->users->removeElement($user);
  211.             // set the owning side to null (unless already changed)
  212.             if ($user->getOffice() === $this) {
  213.                 $user->setOffice(null);
  214.             }
  215.         }
  216.         return $this;
  217.     }
  218.     /**
  219.      * @return Collection|Invitation[]
  220.      */
  221.     public function getInvitations(): Collection
  222.     {
  223.         return $this->invitations;
  224.     }
  225.     public function addInvitation(Invitation $invitation): self
  226.     {
  227.         if (!$this->invitations->contains($invitation)) {
  228.             $this->invitations[] = $invitation;
  229.             $invitation->setOffice($this);
  230.         }
  231.         return $this;
  232.     }
  233.     public function removeInvitation(Invitation $invitation): self
  234.     {
  235.         if ($this->invitations->contains($invitation)) {
  236.             $this->invitations->removeElement($invitation);
  237.             // set the owning side to null (unless already changed)
  238.             if ($invitation->getOffice() === $this) {
  239.                 $invitation->setOffice(null);
  240.             }
  241.         }
  242.         return $this;
  243.     }
  244.     public function getCompany(): ?Company
  245.     {
  246.         return $this->company;
  247.     }
  248.     public function setCompany(?Company $company): self
  249.     {
  250.         $this->company $company;
  251.         return $this;
  252.     }
  253.     /**
  254.      * @return Collection|Document[]
  255.      */
  256.     public function getDocuments(): Collection
  257.     {
  258.         return $this->documents;
  259.     }
  260.     public function addDocument(Document $document): self
  261.     {
  262.         if (!$this->documents->contains($document)) {
  263.             $this->documents[] = $document;
  264.             $document->setOffice($this);
  265.         }
  266.         return $this;
  267.     }
  268.     public function removeDocument(Document $document): self
  269.     {
  270.         if ($this->documents->contains($document)) {
  271.             $this->documents->removeElement($document);
  272.             // set the owning side to null (unless already changed)
  273.             if ($document->getOffice() === $this) {
  274.                 $document->setOffice(null);
  275.             }
  276.         }
  277.         return $this;
  278.     }
  279.     /**
  280.      * @return Collection|Bank[]
  281.      */
  282.     public function getBanks(): Collection
  283.     {
  284.         return $this->banks;
  285.     }
  286.     public function addBank(Bank $bank): self
  287.     {
  288.         if (!$this->banks->contains($bank)) {
  289.             $this->banks[] = $bank;
  290.             $bank->setOffice($this);
  291.         }
  292.         return $this;
  293.     }
  294.     public function removeBank(Bank $bank): self
  295.     {
  296.         if ($this->banks->contains($bank)) {
  297.             $this->banks->removeElement($bank);
  298.             // set the owning side to null (unless already changed)
  299.             if ($bank->getOffice() === $this) {
  300.                 $bank->setOffice(null);
  301.             }
  302.         }
  303.         return $this;
  304.     }
  305.     /**
  306.      * @return Collection|Organization[]
  307.      */
  308.     public function getOrganizations(): Collection
  309.     {
  310.         return $this->organizations;
  311.     }
  312.     public function addOrganization(Organization $organization): self
  313.     {
  314.         if (!$this->organizations->contains($organization)) {
  315.             $this->organizations[] = $organization;
  316.             $organization->setOffice($this);
  317.         }
  318.         return $this;
  319.     }
  320.     public function removeOrganization(Organization $organization): self
  321.     {
  322.         if ($this->organizations->contains($organization)) {
  323.             $this->organizations->removeElement($organization);
  324.             // set the owning side to null (unless already changed)
  325.             if ($organization->getOffice() === $this) {
  326.                 $organization->setOffice(null);
  327.             }
  328.         }
  329.         return $this;
  330.     }
  331.     public function getActiveUsers()
  332.     {
  333.         $users = [];
  334.         foreach ($this->users as $user) {
  335.             if ($user->getIsActive() == true)
  336.                 array_push($users$user);
  337.         }
  338.         ;
  339.         return $users;
  340.     }
  341.     public function getUserByOffice($o_id)
  342.     {
  343.         $users = [];
  344.         foreach ($this->getOrganizations() as $user) {
  345.             if ($user->getDepartment()->getOffice() == $o_id)
  346.                 array_push($users$user);
  347.         }
  348.         ;
  349.         return $users;
  350.     }
  351.     public function getUserByDepartment($d_id)
  352.     {
  353.         $users = [];
  354.         $registered_users = [];
  355.         foreach ($this->getOrganizations() as $user) {
  356.             $uid $user->getUser() ? $user->getUser()->getId() : false;
  357.             if ($uid != null && $user->getDepartment() != null && $user->getDepartment()->getId() == $d_id && in_array($uid$registered_users) == false) {
  358.                 array_push($users$user);
  359.                 array_push($registered_users$uid);
  360.             }
  361.         }
  362.         ;
  363.         return $users;
  364.     }
  365.     public function getUserByOfficeDepartment($d_id)
  366.     {
  367.         $users = [];
  368.         $registered_users = [];
  369.         foreach ($this->getOrganizations() as $user) {
  370.             $uid $user->getUser() ? $user->getUser()->getId() : false;
  371.             if ($uid != null && $user->getUser()->getIsActive() == true && $user->getDepartment() != null && $user->getDepartment()->getId() == $d_id && $user->getUser()->getOffice()->getId() == $this->getId() && in_array($uid$registered_users) == false) {
  372.                 array_push($users$user);
  373.                 array_push($registered_users$uid);
  374.             }
  375.         }
  376.         ;
  377.         return $users;
  378.     }
  379.     public function getUserByAssignedDepartment($d_id)
  380.     {
  381.         $users = [];
  382.         $registered_users = [];
  383.         foreach ($this->getOrganizations() as $user) {
  384.             $uid $user->getUser() ? $user->getUser()->getId() : false;
  385.             if ($uid != null && $user->getDepartment() != null && $user->getDepartment()->getId() == $d_id) {
  386.                 array_push($users$user);
  387.                 array_push($registered_users$uid);
  388.             }
  389.         }
  390.         ;
  391.         return $users;
  392.     }
  393.     public function getOrganizationGroup()
  394.     {
  395.         $groups = [];
  396.         foreach ($this->getOrganizations() as $group) {
  397.             if ($group->getIsGroup())
  398.                 array_push($groups$group);
  399.         }
  400.         ;
  401.         return $groups;
  402.     }
  403.     public function getDepartments()
  404.     {
  405.         $departments = array();
  406.         foreach ($this->users as $user) {
  407.             if ($user->getIsActive() == true) {
  408.                 $d $user->getDepartment();
  409.                 if (!is_null($d)) {
  410.                     if (!isset($departments['d' $d->getId()])) {
  411.                         $dt = array();
  412.                         $dt['data'] = $d;
  413.                         $dt['total'] = 0;
  414.                         $departments['d' $d->getId()] = $dt;
  415.                     }
  416.                     $departments['d' $d->getId()]['total'] += 1;
  417.                 } else {
  418.                     if (!isset($departments['dother'])) {
  419.                         $dt = array();
  420.                         $dt['data'] = array();
  421.                         $dt['data']['id'] = 'other';
  422.                         $dt['data']['name'] = 'Others';
  423.                         $dt['total'] = 0;
  424.                         $departments['dother'] = $dt;
  425.                     }
  426.                     $departments['dother']['total'] += 1;
  427.                 }
  428.             }
  429.             ;
  430.         }
  431.         return $departments;
  432.     }
  433.     public function countStatus()
  434.     {
  435.         $status = [];
  436.         // need to register all status here
  437.         $status['status.new'] = 0;
  438.         $status['status.off'] = 0;
  439.         $status['status.working'] = 0;
  440.         $status['status.working_home'] = 0;
  441.         //$status['status.break'] = 0;
  442.         $status['status.sick'] = 0;
  443.         $status['status.leave'] = 0;
  444.         foreach ($this->users as $user) {
  445.             if ($user->getStatus() != null)
  446.                 $status[$user->getStatus()]++;
  447.         }
  448.         ;
  449.         return $status;
  450.     }
  451.     public function getAllUser()
  452.     {
  453.         $users = [];
  454.         foreach ($this->getUsers() as $user) {
  455.             if ($user->getIsActive() == true)
  456.                 array_push($users$user);
  457.         }
  458.         ;
  459.         return $users;
  460.     }
  461.     public function getAllUsers()
  462.     {
  463.         $users = [];
  464.         foreach ($this->getUsers() as $user) {
  465.             // if ($user->getIsActive() == true)
  466.                 array_push($users$user);
  467.         }
  468.         ;
  469.         return $users;
  470.     }
  471.     public function getAllManager($sort true$includeSub false)
  472.     {
  473.         $managers = [];
  474.         foreach ($this->getUsers() as $user) {
  475.             if ($user->getIsActive() == true && $user->getIsManager($includeSub))
  476.                 array_push($managers$user);
  477.         }
  478.         ;
  479.         if ($sort) {
  480.             usort($managers, function ($a$b) {
  481.                 return strcmp($a->getPersonalInfo()->getFirstName(), $b->getPersonalInfo()->getFirstName());
  482.             });
  483.         }
  484.         ;
  485.         return $managers;
  486.     }
  487.     public function getAllSubManager($sort true)
  488.     {
  489.         $managers = [];
  490.         foreach ($this->getUsers() as $user) {
  491.             if ($user->getIsActive() && $subManagers $user->getAllManager($user->getManager())) {
  492.                 $managers array_merge($managers$subManagers);
  493.             }
  494.         }
  495.         if ($sort) {
  496.             usort($managers, function ($a$b) {
  497.                 return strcmp($a->getPersonalInfo()->getFirstName(), $b->getPersonalInfo()->getFirstName());
  498.             });
  499.         }
  500.         return $managers;
  501.     }
  502.     /**
  503.      * @return Collection|AppraisalForm[]
  504.      */
  505.     public function getAppraisalForms(): Collection
  506.     {
  507.         return $this->appraisalForms;
  508.     }
  509.     public function addAppraisalForm(AppraisalForm $appraisalForm): self
  510.     {
  511.         if (!$this->appraisalForms->contains($appraisalForm)) {
  512.             $this->appraisalForms[] = $appraisalForm;
  513.             $appraisalForm->setOffice($this);
  514.         }
  515.         return $this;
  516.     }
  517.     public function removeAppraisalForm(AppraisalForm $appraisalForm): self
  518.     {
  519.         if ($this->appraisalForms->contains($appraisalForm)) {
  520.             $this->appraisalForms->removeElement($appraisalForm);
  521.             // set the owning side to null (unless already changed)
  522.             if ($appraisalForm->getOffice() === $this) {
  523.                 $appraisalForm->setOffice(null);
  524.             }
  525.         }
  526.         return $this;
  527.     }
  528.     public function getWorkPermitType(): ?string
  529.     {
  530.         return $this->workPermitType;
  531.     }
  532.     public function setWorkPermitType(?string $workPermitType): self
  533.     {
  534.         $this->workPermitType $workPermitType;
  535.         return $this;
  536.     }
  537.     public function getWidget(): ?Widget
  538.     {
  539.         return $this->widget;
  540.     }
  541.     public function setWidget(?Widget $widget): self
  542.     {
  543.         $this->widget $widget;
  544.         return $this;
  545.     }
  546.     /**
  547.      * @return Collection|QnA[]
  548.      */
  549.     public function getQnAs(): Collection
  550.     {
  551.         return $this->QnAs;
  552.     }
  553.     public function addQnA(QnA $qnA): self
  554.     {
  555.         if (!$this->QnAs->contains($qnA)) {
  556.             $this->QnAs[] = $qnA;
  557.             $qnA->setOffice($this);
  558.         }
  559.         return $this;
  560.     }
  561.     public function removeQnA(QnA $qnA): self
  562.     {
  563.         if ($this->QnAs->contains($qnA)) {
  564.             $this->QnAs->removeElement($qnA);
  565.             // set the owning side to null (unless already changed)
  566.             if ($qnA->getOffice() === $this) {
  567.                 $qnA->setOffice(null);
  568.             }
  569.         }
  570.         return $this;
  571.     }
  572.     /**
  573.      * @return Collection|Training[]
  574.      */
  575.     public function getTrainings(): Collection
  576.     {
  577.         return $this->trainings;
  578.     }
  579.     public function addTraining(Training $training): self
  580.     {
  581.         if (!$this->trainings->contains($training)) {
  582.             $this->trainings[] = $training;
  583.             $training->setOffice($this);
  584.         }
  585.         return $this;
  586.     }
  587.     public function removeTraining(Training $training): self
  588.     {
  589.         if ($this->trainings->contains($training)) {
  590.             $this->trainings->removeElement($training);
  591.             // set the owning side to null (unless already changed)
  592.             if ($training->getOffice() === $this) {
  593.                 $training->setOffice(null);
  594.             }
  595.         }
  596.         return $this;
  597.     }
  598.     /**
  599.      * @return Collection|Announcement[]
  600.      */
  601.     public function getAnnouncements(): Collection
  602.     {
  603.         return $this->announcements;
  604.     }
  605.     public function addAnnouncement(Announcement $announcement): self
  606.     {
  607.         if (!$this->announcements->contains($announcement)) {
  608.             $this->announcements[] = $announcement;
  609.             $announcement->setOffice($this);
  610.         }
  611.         return $this;
  612.     }
  613.     public function removeAnnouncement(Announcement $announcement): self
  614.     {
  615.         if ($this->announcements->contains($announcement)) {
  616.             $this->announcements->removeElement($announcement);
  617.             // set the owning side to null (unless already changed)
  618.             if ($announcement->getOffice() === $this) {
  619.                 $announcement->setOffice(null);
  620.             }
  621.         }
  622.         return $this;
  623.     }
  624.     public function getStarterGuide(): ?string
  625.     {
  626.         return $this->starterGuide;
  627.     }
  628.     public function setStarterGuide(?string $starterGuide): self
  629.     {
  630.         $this->starterGuide $starterGuide;
  631.         return $this;
  632.     }
  633.     public function getFlexiWorkArrangement(): ?FlexiWorkArrangement
  634.     {
  635.         return $this->flexiWorkArrangement;
  636.     }
  637.     public function setFlexiWorkArrangement(FlexiWorkArrangement $flexiWorkArrangement): self
  638.     {
  639.         $this->flexiWorkArrangement $flexiWorkArrangement;
  640.         // set the owning side of the relation if necessary
  641.         if ($flexiWorkArrangement->getOffice() !== $this) {
  642.             $flexiWorkArrangement->setOffice($this);
  643.         }
  644.         return $this;
  645.     }
  646.     public function getOfficeUserInfo(): ?OfficeUserInfo
  647.     {
  648.         return $this->officeUserInfo;
  649.     }
  650.     public function setOfficeUserInfo(OfficeUserInfo $officeUserInfo): self
  651.     {
  652.         // set the owning side of the relation if necessary
  653.         if ($officeUserInfo->getOffice() !== $this) {
  654.             $officeUserInfo->setOffice($this);
  655.         }
  656.         $this->officeUserInfo $officeUserInfo;
  657.         return $this;
  658.     }
  659.     public function fullyVaccinated()
  660.     {
  661.         $vaccinated = [];
  662.         foreach ($this->users as $user) {
  663.             if ($user->getPersonalInfo()->getVaccination() != null && $user->getPersonalInfo()->getVaccination()->getStatus() == 'form.vaccination.second')
  664.                 array_push($vaccinated$user);
  665.         }
  666.         ;
  667.         return $vaccinated;
  668.     }
  669.     public function getOfficeLeave(): ?OfficeLeave
  670.     {
  671.         return $this->officeLeave;
  672.     }
  673.     public function setOfficeLeave(OfficeLeave $officeLeave): self
  674.     {
  675.         // set the owning side of the relation if necessary
  676.         if ($officeLeave->getOffice() !== $this) {
  677.             $officeLeave->setOffice($this);
  678.         }
  679.         $this->officeLeave $officeLeave;
  680.         return $this;
  681.     }
  682.     /**
  683.      * @return Collection<int, LeaveType>
  684.      */
  685.     public function getLeaveTypes(): Collection
  686.     {
  687.         return $this->leaveTypes;
  688.     }
  689.     public function addLeaveType(LeaveType $leaveType): self
  690.     {
  691.         if (!$this->leaveTypes->contains($leaveType)) {
  692.             $this->leaveTypes[] = $leaveType;
  693.             $leaveType->setOffice($this);
  694.         }
  695.         return $this;
  696.     }
  697.     public function removeLeaveType(LeaveType $leaveType): self
  698.     {
  699.         if ($this->leaveTypes->removeElement($leaveType)) {
  700.             // set the owning side to null (unless already changed)
  701.             if ($leaveType->getOffice() === $this) {
  702.                 $leaveType->setOffice(null);
  703.             }
  704.         }
  705.         return $this;
  706.     }
  707.     public function getAllHourlyRates()
  708.     {
  709.         $hourlyRates = [];
  710.         foreach ($this->salaries as $salary) {
  711.             $hourlyRates[] = ['type' => 'office''date' => $salary->getValidAt()->format('Y-m-d'), 'rate' => $salary->getHourlyRate()];
  712.         }
  713.         return $hourlyRates;
  714.     }
  715.     public function getHourlyRate($date null)
  716.     {
  717.         $dateStr $date $date date('Y-m-d');
  718.         if (count($this->salaries) == 0)
  719.             return false;
  720.         foreach ($this->salaries as $salary) {
  721.             if ($dateStr >= $salary->getValidAt()->format('Y-m-d'))
  722.                 return $salary->getHourlyRate();
  723.         }
  724.         return 0;
  725.     }
  726.     public function getHourlyRateUsd($date null)
  727.     {
  728.         $dateStr $date $date date('Y-m-d');
  729.         if (count($this->salaries) == 0)
  730.             return false;
  731.         foreach ($this->salaries as $salary) {
  732.             if ($dateStr >= $salary->getValidAt()->format('Y-m-d'))
  733.                 return $salary->getHourlyRateUsd($dateStr);
  734.         }
  735.         return 0;
  736.     }
  737.     public function getCurrency(): ?string
  738.     {
  739.         return $this->currency ?? 'USD';
  740.     }
  741.     public function setCurrency(?string $currency): self
  742.     {
  743.         $this->currency $currency;
  744.         return $this;
  745.     }
  746.     /**
  747.      * @return Collection<int, Salary>
  748.      */
  749.     public function getSalaries(): Collection
  750.     {
  751.         return $this->salaries;
  752.     }
  753.     public function addSalary(Salary $salary): self
  754.     {
  755.         if (!$this->salaries->contains($salary)) {
  756.             $this->salaries[] = $salary;
  757.             $salary->setOffice($this);
  758.         }
  759.         return $this;
  760.     }
  761.     public function removeSalary(Salary $salary): self
  762.     {
  763.         if ($this->salaries->removeElement($salary)) {
  764.             // set the owning side to null (unless already changed)
  765.             if ($salary->getOffice() === $this) {
  766.                 $salary->setOffice(null);
  767.             }
  768.         }
  769.         return $this;
  770.     }
  771.     /**
  772.      * @return Collection|Job[]
  773.      */
  774.     public function getJobs(): Collection
  775.     {
  776.         return $this->jobs;
  777.     }
  778.     public function addJob(Job $job): self
  779.     {
  780.         if (!$this->jobs->contains($job)) {
  781.             $this->jobs[] = $job;
  782.             $job->addOffice($this);
  783.         }
  784.         return $this;
  785.     }
  786.     public function removeJob(Job $job): self
  787.     {
  788.         if ($this->jobs->removeElement($job)) {
  789.             $job->removeOffice($this);
  790.         }
  791.         return $this;
  792.     }
  793.     /**
  794.      * @return Collection|AssetUsage[]
  795.      */
  796.     public function getassetUsages(): Collection
  797.     {
  798.         return $this->assetUsages;
  799.     }
  800.     public function addassetUsages(AssetUsage $assetUsages): self
  801.     {
  802.         if (!$this->assetUsages->contains($assetUsages)) {
  803.             $this->assetUsages[] = $assetUsages;
  804.             $assetUsages->setOffice($this);
  805.         }
  806.         return $this;
  807.     }
  808.     public function removeassetUsages(AssetUsage $assetUsages): self
  809.     {
  810.         if ($this->assetUsages->removeElement($assetUsages)) {
  811.             // set the owning side to null (unless already changed)
  812.             if ($assetUsages->getOffice() === $this) {
  813.                 $assetUsages->setOffice(null);
  814.             }
  815.         }
  816.         return $this;
  817.     }
  818.     /**
  819.      * @return Collection|Course[]
  820.      */
  821.     public function getCourses(): Collection
  822.     {
  823.         return $this->courses;
  824.     }
  825.     public function addCourse(Course $course): self
  826.     {
  827.         if (!$this->courses->contains($course)) {
  828.             $this->courses[] = $course;
  829.             $course->addOffice($this);
  830.         }
  831.         return $this;
  832.     }
  833.     public function removeCourse(Course $course): self
  834.     {
  835.         if ($this->courses->removeElement($course)) {
  836.             $course->removeOffice($this);
  837.         }
  838.         return $this;
  839.     }
  840.     /**
  841.      * @return Collection|CourseAutoEnrollment[]
  842.      */
  843.     public function getCourseAutoEnrollments(): Collection
  844.     {
  845.         return $this->courseAutoEnrollments;
  846.     }
  847.     public function addCourseAutoEnrollment(CourseAutoEnrollment $CourseAutoEnrollment): self
  848.     {
  849.         if (!$this->courseAutoEnrollments->contains($CourseAutoEnrollment)) {
  850.             $this->courseAutoEnrollments[] = $CourseAutoEnrollment;
  851.             $CourseAutoEnrollment->addOffice($this);
  852.         }
  853.         return $this;
  854.     }
  855.     public function removeCourseAutoEnrollment(CourseAutoEnrollment $CourseAutoEnrollment): self
  856.     {
  857.         if ($this->courseAutoEnrollments->removeElement($CourseAutoEnrollment)) {
  858.             $CourseAutoEnrollment->removeOffice($this);
  859.         }
  860.         return $this;
  861.     }
  862.     public function getCustomPersonalInfo(): ?string
  863.     {
  864.         return $this->customPersonalInfo;
  865.     }
  866.     public function getCustomPersonalInfoData()
  867.     {
  868.         // return $this->customPersonalInfo;
  869.         $customData null;
  870.         if ($this->customPersonalInfo) {
  871.             $lines explode(PHP_EOL$this->customPersonalInfo);
  872.             $customData array_map(function ($item) {
  873.                 return trim($item" \t\n\r\0\x0B");
  874.             }, $lines);
  875.         }
  876.         return $customData;
  877.     }
  878.     public function getCustomPersonalInfoLabel()
  879.     {
  880.         // return $this->customPersonalInfo;
  881.         $customDataLabel null;
  882.         if ($this->customPersonalInfo) {
  883.             $lines explode(PHP_EOL$this->customPersonalInfo);
  884.             $customDataLabel array_map(function ($item) {
  885.                 $item str_replace(" """$item);
  886.                 $item str_replace("\r"""$item);
  887.                 return $item;
  888.             }, $lines);
  889.         }
  890.         return $customDataLabel;
  891.     }
  892.     public function getCustomPersonalInfoAssoc()
  893.     {
  894.         $result null;
  895.         if (!empty($this->getCustomPersonalInfoLabel()) && !empty($this->getCustomPersonalInfoData())) {
  896.             $result = [];
  897.             foreach ($this->getCustomPersonalInfoLabel() as $key => $label) {
  898.                 $result[$label] = $this->getCustomPersonalInfoData()[$key];
  899.             }
  900.             return $result;
  901.         }
  902.         return $result;
  903.     }
  904.     public function setCustomPersonalInfo(?string $customPersonalInfo): self
  905.     {
  906.         $this->customPersonalInfo $customPersonalInfo;
  907.         return $this;
  908.     }
  909.     /**
  910.      * @return Collection<int, RecruitVacancyOffice>
  911.      */
  912.     public function getRecruitVacancyOffices(): Collection
  913.     {
  914.         return $this->recruitVacancyOffices;
  915.     }
  916.     public function addRecruitVacancyOffice(RecruitVacancyOffice $recruitVacancyOffice): self
  917.     {
  918.         if (!$this->recruitVacancyOffices->contains($recruitVacancyOffice)) {
  919.             $this->recruitVacancyOffices->add($recruitVacancyOffice);
  920.             $recruitVacancyOffice->setOffice($this);
  921.         }
  922.         return $this;
  923.     }
  924.     public function removeRecruitVacancyOffice(RecruitVacancyOffice $recruitVacancyOffice): self
  925.     {
  926.         if ($this->recruitVacancyOffices->removeElement($recruitVacancyOffice)) {
  927.             // set the owning side to null (unless already changed)
  928.             if ($recruitVacancyOffice->getOffice() === $this) {
  929.                 $recruitVacancyOffice->setOffice(null);
  930.             }
  931.         }
  932.         return $this;
  933.     }
  934.     /**
  935.      * @return Collection<int, RecruitQuestionOffice>
  936.      */
  937.     public function getRecruitQuestionOffices(): Collection
  938.     {
  939.         return $this->recruitQuestionOffices;
  940.     }
  941.     public function addRecruitQuestionOffice(RecruitQuestionOffice $recruitQuestionOffice): self
  942.     {
  943.         if (!$this->recruitQuestionOffices->contains($recruitQuestionOffice)) {
  944.             $this->recruitQuestionOffices->add($recruitQuestionOffice);
  945.             $recruitQuestionOffice->setOffice($this);
  946.         }
  947.         return $this;
  948.     }
  949.     public function removeRecruitQuestionOffice(RecruitQuestionOffice $recruitQuestionOffice): self
  950.     {
  951.         if ($this->recruitQuestionOffices->removeElement($recruitQuestionOffice)) {
  952.             // set the owning side to null (unless already changed)
  953.             if ($recruitQuestionOffice->getOffice() === $this) {
  954.                 $recruitQuestionOffice->setOffice(null);
  955.             }
  956.         }
  957.         return $this;
  958.     }
  959. }