src/Entity/Appraisal.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass'App\Repository\AppraisalRepository')]
  8. class Appraisal
  9. {
  10.     #[Groups(['LogService''EmailSchedule'])]
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[Groups(['LogService''EmailSchedule'])]
  16.     #[ORM\Column(type'string'length255nullabletrue)]
  17.     private $title;
  18.     #[Groups(['LogService'])]
  19.     #[ORM\Column(type'datetime')]
  20.     private $createdAt;
  21.     #[Groups(['LogService''EmailSchedule'])]
  22.     #[ORM\Column(type'datetime'nullabletrue)]
  23.     private $reviewedAt;
  24.     #[Groups(['LogService''EmailSchedule'])]
  25.     #[ORM\ManyToOne(targetEntity'App\Entity\User')]
  26.     private $reviewedBy;
  27.     #[Groups(['LogService'])]
  28.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'appraisals')]
  29.     #[ORM\JoinColumn(nullabletrue)]
  30.     private $user;
  31.     #[Groups(['LogService'])]
  32.     #[ORM\OneToMany(targetEntity'App\Entity\AppraisalComment'mappedBy'appraisal'orphanRemovaltrue)]
  33.     private $appraisalComments;
  34.     #[Groups(['LogService'])]
  35.     #[ORM\ManyToOne(targetEntityUser::class)]
  36.     #[ORM\JoinColumn(nullabletrue)]
  37.     private $createdBy;
  38.     #[Groups(['LogService''EmailSchedule'])]
  39.     #[ORM\Column(type'datetime'nullabletrue)]
  40.     private $submitAt null;
  41.     #[Groups(['LogService''EmailSchedule'])]
  42.     #[ORM\Column(type'datetime'nullabletrue)]
  43.     private $reviewAt null;
  44.     #[Groups(['LogService''EmailSchedule'])]
  45.     #[ORM\Column(type'datetime'nullabletrue)]
  46.     private $submittedAt;
  47.     #[ORM\Column(type'string'length32nullabletrue)]
  48.     private $icsToken;
  49.     #[ORM\OneToMany(targetEntityAppraisalNote::class, mappedBy'appraisal'cascade: ['persist''remove'])]
  50.     private $appraisalNotes;
  51.     #[Groups(['LogService'])]
  52.     #[ORM\Column(type'smallint')]
  53.     private $reschedule 0;
  54.     #[ORM\ManyToMany(targetEntityUser::class)]
  55.     private $reviewers;
  56.     #[ORM\OneToMany(targetEntityAppraisalForm::class, mappedBy'appraisal'cascade: ['persist''remove'])]
  57.     private $appraisalForms;
  58.     #[ORM\Column(type'datetime'nullabletrue)]
  59.     private $lastReminder;
  60.     #[ORM\Column(type'datetime'nullabletrue)]
  61.     private $concludedAt;
  62.     #[ORM\Column(type'boolean')]
  63.     private $adHoc false;
  64.     #[ORM\Column(type'boolean')]
  65.     private $probation false;
  66.     public function __construct()
  67.     {
  68.         $this->appraisalComments = new ArrayCollection();
  69.         $this->appraisalNotes = new ArrayCollection();
  70.         $this->reviewers = new ArrayCollection();
  71.         $this->appraisalForms = new ArrayCollection();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getTitle(): ?string
  78.     {
  79.         return $this->title;
  80.     }
  81.     public function setTitle(?string $title): self
  82.     {
  83.         $this->title $title;
  84.         return $this;
  85.     }
  86.     public function getCreatedAt(): ?\DateTimeInterface
  87.     {
  88.         return $this->createdAt;
  89.     }
  90.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  91.     {
  92.         $this->createdAt $createdAt;
  93.         return $this;
  94.     }
  95.     public function getReviewedAt(): ?\DateTimeInterface
  96.     {
  97.         return $this->reviewedAt;
  98.     }
  99.     public function setReviewedAt(\DateTimeInterface $reviewedAt): self
  100.     {
  101.         $this->reviewedAt $reviewedAt;
  102.         return $this;
  103.     }
  104.     public function getReviewedBy(): ?User
  105.     {
  106.         return $this->reviewedBy;
  107.     }
  108.     public function setReviewedBy(?User $reviewedBy): self
  109.     {
  110.         $this->reviewedBy $reviewedBy;
  111.         return $this;
  112.     }
  113.     public function getUser(): ?User
  114.     {
  115.         return $this->user;
  116.     }
  117.     public function setUser(?User $user): self
  118.     {
  119.         $this->user $user;
  120.         return $this;
  121.     }
  122.     /**
  123.      * @return Collection|AppraisalComment[]
  124.      */
  125.     public function getAppraisalComments(): Collection
  126.     {
  127.         return $this->appraisalComments;
  128.     }
  129.     public function addAppraisalComment(AppraisalComment $appraisalComment): self
  130.     {
  131.         if (!$this->appraisalComments->contains($appraisalComment)) {
  132.             $this->appraisalComments[] = $appraisalComment;
  133.             $appraisalComment->setAppraisal($this);
  134.         }
  135.         return $this;
  136.     }
  137.     public function removeAppraisalComment(AppraisalComment $appraisalComment): self
  138.     {
  139.         if ($this->appraisalComments->contains($appraisalComment)) {
  140.             $this->appraisalComments->removeElement($appraisalComment);
  141.             // set the owning side to null (unless already changed)
  142.             if ($appraisalComment->getAppraisal() === $this) {
  143.                 $appraisalComment->setAppraisal(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148.     public function hasComment($user)
  149.     {
  150.         foreach ($this->appraisalComments as $comment) {
  151.             if ($comment->getUser() == $user) {
  152.                 return true;
  153.             }
  154.         };
  155.         return false;
  156.     }
  157.     public function hasDraftComment($user)
  158.     {
  159.         foreach ($this->appraisalComments as $comment) {
  160.             if ($comment->getUser() == $user && $comment->getDraft() == true) {
  161.                 return true;
  162.             }
  163.         };
  164.         return false;
  165.     }
  166.     public function getCreatedBy(): ?User
  167.     {
  168.         return $this->createdBy;
  169.     }
  170.     public function setCreatedBy(?User $createdBy): self
  171.     {
  172.         $this->createdBy $createdBy;
  173.         return $this;
  174.     }
  175.     public function getSubmitAt(): ?\DateTimeInterface
  176.     {
  177.         return $this->submitAt;
  178.     }
  179.     public function setSubmitAt(\DateTimeInterface $submitAt): self
  180.     {
  181.         $this->submitAt $submitAt;
  182.         return $this;
  183.     }
  184.     public function getReviewAt(): ?\DateTimeInterface
  185.     {
  186.         return $this->reviewAt;
  187.     }
  188.     public function setReviewAt(\DateTimeInterface $reviewAt): self
  189.     {
  190.         $this->reviewAt $reviewAt;
  191.         return $this;
  192.     }
  193.     public function getSubmittedAt(): ?\DateTimeInterface
  194.     {
  195.         return $this->submittedAt;
  196.     }
  197.     public function setSubmittedAt(?\DateTimeInterface $submittedAt): self
  198.     {
  199.         $this->submittedAt $submittedAt;
  200.         return $this;
  201.     }
  202.     public function appraisalCommentsByUser($uid)
  203.     {
  204.         $comments = [];
  205.         foreach ($this->appraisalComments as $comment) {
  206.             if ($comment->getUser()->getId() == $uid) {
  207.                 array_push($comments$comment);
  208.             }
  209.         };
  210.         return $comments;
  211.     }
  212.     public function totalAppraisalForm(){ // used for counting form if form deleted
  213.         $total 0;
  214.         if($this->appraisalForms->toArray()){
  215.             $total count($this->appraisalForms);
  216.         } else {
  217.             foreach($this->appraisalComments as $commentForm){
  218.                 if($commentForm->getUser() == $this->user){
  219.                     $total++;
  220.                 }
  221.             }
  222.     
  223.         }
  224.        
  225.         return $total;
  226.     }
  227.     public function appraisalCommentsByForm($form$index null)
  228.     {
  229.         $comments = [];
  230.         if(is_int($form) || $form->getForm()){
  231.             $fid is_int($form) ? $form $form->getForm()->getId();
  232.             foreach ($this->appraisalComments as $comment) {
  233.                 if ($comment->getForm()->getId() == $fid) {
  234.                     array_push($comments$comment);
  235.                 }
  236.             };
  237.         } else { // if form deleted, this will be used
  238.             $totalForm $this->totalAppraisalForm();
  239.             $form json_decode($form->getFormContent());
  240.             $formIndex 1;
  241.             foreach ($this->appraisalComments as $comment) {
  242.                 // $formContent = json_decode($comment->getFormContent());
  243.                 if ($formIndex == $index){
  244.                     array_push($comments$comment);
  245.                 }
  246.                 $formIndex $formIndex == $totalForm $formIndex 1;
  247.             };
  248.         }
  249.         return $comments;
  250.     }
  251.     public function appraisalScore(){
  252.         $totalForm $this->totalAppraisalForm();
  253.         $formIndex 1;
  254.         $score 0;
  255.         $totalValidScore 0;
  256.         foreach($this->appraisalComments as $commentForm){
  257.             if($commentForm->getUser() != $this->user || $commentForm->getDraft() == true) continue;
  258.             $questionScore $this->appraisalQuestionScore($commentForm$formIndex);
  259.             if($questionScore 0){
  260.                 $score += $questionScore;
  261.                 $totalValidScore++;
  262.             }
  263.             $formIndex $formIndex == $totalForm $formIndex 1;
  264.          
  265.         };
  266.         if($totalValidScore 0){
  267.             return number_format($score $totalValidScore1'.''');
  268.         } else {
  269.             return null;
  270.         }
  271.     }
  272.     
  273.     public function appraisalQuestionScore($form$index null){
  274.         $score 0;
  275.         // $totalValidScore = 0;
  276.         $baseScore 0;
  277.         $reviewerScore 0;
  278.         $managerScore 0;
  279.         $otherScore 0;
  280.         $totalOtherScore 0;
  281.         
  282.         if(is_int($form) || $form->getForm()){
  283.             $fid is_int($form) ? $form $form->getForm()->getId();
  284.             foreach ($this->appraisalComments as $comment) {
  285.                 if ($comment->getForm() && $comment->getForm()->getId() == $fid && $comment->getDraft() == false) {
  286.                     if($comment->getUser() == $this->user){
  287.                         $baseScore $comment->getScore();
  288.                     } else if($comment->getUser() == $this->user->getManager() || $comment->getUser() == $this->reviewedBy){
  289.                         $managerScore $comment->getScore();
  290.                     } else {
  291.                         $otherScore += $comment->getScore();
  292.                         $totalOtherScore++;
  293.                     }
  294.                 }
  295.             };
  296.         } else { // if form deleted, this will be used
  297.             $formIndex 1;
  298.             $totalForm $this->totalAppraisalForm();
  299.             // $form = json_decode($form->getFormContent());
  300.             foreach ($this->appraisalComments as $comment) {
  301.                 // $formContent = json_decode($comment->getFormContent());
  302.                 if ($formIndex == $index){
  303.                     if($comment->getUser() == $this->user){
  304.                         $baseScore $comment->getScore();
  305.                     } else if($comment->getUser() == $this->user->getManager() || $comment->getUser() == $this->reviewedBy){
  306.                         $managerScore $comment->getScore();
  307.                     } else { 
  308.                         $otherScore += $comment->getScore();
  309.                         $totalOtherScore++;
  310.                     } 
  311.                 }
  312.                 $formIndex $formIndex == $totalForm $formIndex 1;
  313.             };
  314.         }
  315.         
  316.         if($totalOtherScore 0){ // avarage other reviewer score
  317.             $otherScore $otherScore $totalOtherScore;
  318.         }
  319.      
  320.         if($otherScore != && $managerScore != 0){ // if manager already review and other reviewer already review too
  321.             $reviewerScore $otherScore $managerScore $managerScore : ($managerScore $otherScore) / 2// if other score lower than manager score, use manager score
  322.         } else if($managerScore == 0){ // if manager not yet review, use other score
  323.             $reviewerScore $otherScore;
  324.         } else { // if other reviewer not review, use manager score
  325.             $reviewerScore $managerScore;
  326.         }
  327.         $score $baseScore $reviewerScore $reviewerScore : ($baseScore $reviewerScore) / 2// if base score higher than reviewer score, use reviewer score
  328.         return number_format($score1'.'''); // final score
  329.         // return  number_format($score / $totalValidScore, 1, '.', '');
  330.     }
  331.     public function getIcsToken(): ?string
  332.     {
  333.         return $this->icsToken;
  334.     }
  335.     public function setIcsToken(?string $icsToken): self
  336.     {
  337.         $this->icsToken $icsToken;
  338.         return $this;
  339.     }
  340.     /**
  341.      * @return Collection|AppraisalNote[]
  342.      */
  343.     public function getAppraisalNotes(): Collection
  344.     {
  345.         return $this->appraisalNotes;
  346.     }
  347.     public function addAppraisalNote(AppraisalNote $appraisalNote): self
  348.     {
  349.         if (!$this->appraisalNotes->contains($appraisalNote)) {
  350.             $this->appraisalNotes[] = $appraisalNote;
  351.             $appraisalNote->setAppraisal($this);
  352.         }
  353.         return $this;
  354.     }
  355.     public function removeAppraisalNote(AppraisalNote $appraisalNote): self
  356.     {
  357.         if ($this->appraisalNotes->removeElement($appraisalNote)) {
  358.             // set the owning side to null (unless already changed)
  359.             if ($appraisalNote->getAppraisal() === $this) {
  360.                 $appraisalNote->setAppraisal(null);
  361.             }
  362.         }
  363.         return $this;
  364.     }
  365.     public function hasEmptyNote()
  366.     {
  367.         $totalEmptyNote 0;
  368.         foreach ($this->appraisalNotes as $note) {
  369.             if ($note->getNote() == null && $note->getDraft() == false){
  370.                 $totalEmptyNote++;
  371.             }
  372.         }
  373.         if($totalEmptyNote == 0){
  374.             return false;
  375.         } else {
  376.             return $totalEmptyNote count($this->appraisalNotes) ? false true;
  377.         }
  378.     }
  379.     public function getReschedule(): ?int
  380.     {
  381.         return $this->reschedule;
  382.     }
  383.     public function setReschedule(?int $reschedule): self
  384.     {
  385.         $this->reschedule $reschedule;
  386.         return $this;
  387.     }
  388.     /**
  389.      * @return Collection|User[]
  390.      */
  391.     public function getReviewers(): Collection
  392.     {
  393.         return $this->reviewers;
  394.     }
  395.     public function addReviewer(User $reviewer): self
  396.     {
  397.         if (!$this->reviewers->contains($reviewer)) {
  398.             $this->reviewers[] = $reviewer;
  399.         }
  400.         return $this;
  401.     }
  402.     public function removeReviewer(User $reviewer): self
  403.     {
  404.         $this->reviewers->removeElement($reviewer);
  405.         return $this;
  406.     }
  407.     public function hasReviewed($user null)
  408.     {
  409.         if ($this->reviewers != null && count($this->reviewers) > 0) {
  410.             if($user == null){
  411.                 return true;
  412.             } else {
  413.                 foreach ($this->reviewers as $reviewer) {
  414.                     if ($user == $reviewer) {
  415.                         return true;
  416.                     }
  417.                 }
  418.             }
  419.            
  420.         // } elseif ($user != null && $this->reviewedBy == $user) {
  421.         //     return true;
  422.         }
  423.         return false;
  424.     }
  425.     public function reviewedByManager(){
  426.         $managers $this->user->getAllManager();
  427.         foreach ($managers as $manager) {
  428.             if($this->hasReviewed($manager)){
  429.                 return true;
  430.             }
  431.         }
  432.         return false;
  433.     }
  434.     /**
  435.      * @return Collection|AppraisalForm[]
  436.      */
  437.     public function getAppraisalForms(): Collection
  438.     {
  439.         return $this->appraisalForms;
  440.     }
  441.     public function addAppraisalForm(AppraisalForm $appraisalForm): self
  442.     {
  443.         if (!$this->appraisalForms->contains($appraisalForm)) {
  444.             $this->appraisalForms[] = $appraisalForm;
  445.             $appraisalForm->setAppraisal($this);
  446.         }
  447.         return $this;
  448.     }
  449.     public function removeAppraisalForm(AppraisalForm $appraisalForm): self
  450.     {
  451.         if ($this->appraisalForms->removeElement($appraisalForm)) {
  452.             // set the owning side to null (unless already changed)
  453.             if ($appraisalForm->getAppraisal() === $this) {
  454.                 $appraisalForm->setAppraisal(null);
  455.             }
  456.         }
  457.         return $this;
  458.     }
  459.     public function getLastReminder(): ?\DateTimeInterface
  460.     {
  461.         return $this->lastReminder;
  462.     }
  463.     public function setLastReminder(?\DateTimeInterface $lastReminder): self
  464.     {
  465.         $this->lastReminder $lastReminder;
  466.         return $this;
  467.     }
  468.     public function getConcludedAt(): ?\DateTimeInterface
  469.     {
  470.         return $this->concludedAt;
  471.     }
  472.     public function setconcludedAt(?\DateTimeInterface $concludedAt): self
  473.     {
  474.         $this->concludedAt $concludedAt;
  475.         return $this;
  476.     }
  477.     public function currentStep($reviewer null)
  478.     {
  479.         /*
  480.         -1 = legacy
  481.         0 = disabled
  482.         1 = waiting user to fill
  483.         2 = waiting manager to fill
  484.         3 = waiting review time
  485.         4 = review time
  486.         5 = review done but still need main manager conclusion
  487.         6 = review done
  488.         7 = past review/summary/adhoc
  489.         */
  490.         if($this->user == null) return false;
  491.         $lastRevamp '20220328'// the date is from when the last appraisal revamp done
  492.         $lastRevamp2 '20220920'// the date is from when the last appraisal revamp done 2
  493.         if ($this->getAdHoc()) {
  494.             if ($this->getReviewAt()->format('Ymd') > date('Ymd') && ($this->hasReviewed($reviewer) == true || $this->getReviewedBy() != null)) {
  495.                 return 3;
  496.             } else if ($this->getReviewAt()->format('Ymd') == date('Ymd')) {
  497.                 return 4;
  498.             } else {
  499.                 return 7;
  500.             }
  501.         } else if ($this->getCreatedAt() !== null && $this->getCreatedAt()->format('Ymd') >= $lastRevamp2) { // new appraisal system 2022-09-20;
  502.             if($this->getConcludedAt() == null){
  503.                 if ($this->getSubmitAt() != null && $this->getSubmittedAt() == null && $this->getReviewAt() == null) {
  504.                     return 1;
  505.                 //} else if ($this->getSubmittedAt() != null && $this->getReviewedAt() == null && $this->getSubmitAt()->format('Ymd') > $lastRevamp2 && $this->hasReviewed() == false && $this->getReviewedBy() == null) {
  506.                 } else if ($this->getSubmittedAt() != null && $this->getReviewedAt() == null && $this->getSubmitAt()->format('Ymd') > $lastRevamp2 && $this->reviewedByManager() == false) {
  507.                     return 2;
  508.                 } else if ($this->getSubmittedAt() != null && ($this->getReviewAt() == null || ($this->getReviewAt()->format('Ymd') > date('Ymd') && $this->reviewedByManager() == true))) {
  509.                     return 3;
  510.                 } else if ($this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') == date('Ymd') && $this->getSubmittedAt() != null && $this->getReviewedAt() != null && $this->getConcludedAt() == null) {
  511.                     return 4;
  512.                 } else if ($this->getSubmitAt() != null  && $this->getReviewAt() != null  && $this->getSubmittedAt() != null && $this->getReviewedAt() != null && $this->getConcludedAt() == null) {
  513.                     return 5;
  514.                 } else if ($this->getSubmitAt() == null && $this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') < date('Ymd') && $this->getSubmittedAt() == null) {
  515.                     return 7;
  516.                 } else {
  517.                     return 0;
  518.                 };
  519.             // } else if ($this->getSubmitAt() != null && $this->getSubmittedAt() != null &&$this->getReviewAt() == null) {
  520.             //     return 8;
  521.             // } else if ($this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') < date('Ymd') && $this->getSubmittedAt() != null && $this->getReviewedAt() != null) {
  522.             } else {
  523.                 return 6;
  524.            
  525.             }
  526.            
  527.         } else if ($this->probation) { //old rule for probation (previously for all)
  528.             if($this->getConcludedAt() == null){
  529.                 if ($this->getSubmitAt() != null && $this->getSubmittedAt() == null && $this->getReviewAt() == null) {
  530.                     return 1;
  531.                 } else if ($this->getSubmittedAt() != null && $this->getReviewedAt() == null && $this->getSubmitAt()->format('Ymd') > $lastRevamp && $this->reviewedByManager() == false) {
  532.                     return 2;
  533.                 } else if ($this->getSubmittedAt() != null && ($this->getReviewAt() == null || $this->getReviewAt()->format('Ymd') > date('Ymd')) && ($this->reviewedByManager() == true)) {
  534.                 //} else if ($this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') > date('Ymd') && $this->getSubmittedAt() != null && ($this->hasReviewed($reviewer) == true || $this->getReviewedBy() != null)) {
  535.                     return 3;
  536.                 } else if ($this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') == date('Ymd') && $this->getSubmittedAt() != null && $this->getReviewedAt() != null && $this->getConcludedAt() == null) {
  537.                     return 4;
  538.                 } else if ($this->getSubmitAt() != null  && $this->getReviewAt() != null  && $this->getSubmittedAt() != null && $this->getReviewedAt() != null && $this->getConcludedAt() == null) {
  539.                     if ($this->getCreatedAt()->format('Ymd') < $lastRevamp && $this->getSubmitAt()->format('Ymd') < $lastRevamp) {
  540.                         return 6;
  541.                     } else {
  542.                         return 5;
  543.                     }
  544.                 } else if ($this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') < date('Ymd') && $this->getSubmittedAt() != null && $this->getReviewedAt() != null) {
  545.                     return 6;
  546.                 } else if ($this->getSubmitAt() == null && $this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') < date('Ymd') && $this->getSubmittedAt() == null) {
  547.                     return 7;
  548.                 } else if ($this->getSubmittedAt() != null && $this->getReviewedBy() != null) {
  549.                     return -1;
  550.                 } else {
  551.                     return 0;
  552.                 };
  553.             } else {
  554.                 return 6;
  555.             };
  556.         } else { // old rule for the rest
  557.             if ($this->getSubmitAt() == null && $this->getReviewAt() != null && $this->getReviewAt()->format('Ymd') < date('Ymd') && $this->getSubmittedAt() == null) {
  558.                 return 7;
  559.             } else {
  560.                 return -1;
  561.             };
  562.         };
  563.     }
  564.     public function getAdHoc(): ?bool
  565.     {
  566.         return $this->adHoc;
  567.     }
  568.     public function setAdHoc(bool $adHoc): self
  569.     {
  570.         $this->adHoc $adHoc;
  571.         return $this;
  572.     }
  573.     public function getProbation(): ?bool
  574.     {
  575.         return $this->probation;
  576.     }
  577.     public function setProbation(bool $probation): self
  578.     {
  579.         $this->probation $probation;
  580.         return $this;
  581.     }
  582.     public function getInUserDraft()
  583.     {
  584.         if($this->appraisalComments == null || count($this->appraisalComments) == 0){
  585.             return false;
  586.         }
  587.         foreach ($this->appraisalComments as $comment) {
  588.             if ($comment->getUser() == $this->user && $comment->getDraft() == true) {
  589.                 return true;
  590.             }
  591.         };
  592.         return false;
  593.     }
  594.     public function getInManagerDraft()
  595.     {
  596.         if($this->appraisalComments == null || count($this->appraisalComments) == 0){
  597.             return false;
  598.         }
  599.         foreach ($this->appraisalComments as $comment) {
  600.             if ($comment->getUser() == $this->user->getManager() && $comment->getDraft() == true) {
  601.                 return true;
  602.             }
  603.         };
  604.         return false;
  605.     }
  606. }