src/Entity/CRM/WorkTimeHistory.php line 11

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Repository\WorkTimeHistoryRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassWorkTimeHistoryRepository::class)]
  7. #[ORM\HasLifecycleCallbacks]
  8. class WorkTimeHistory
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(typeTypes::INTEGER)]
  15.     private ?int $workTimeId null;
  16.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  17.     private ?\DateTimeInterface $startTime null;
  18.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  19.     private ?\DateTimeInterface $endTime null;
  20.     #[ORM\Column(typeTypes::INTEGER,nullabletrue)]
  21.     private ?int $consultantId null;
  22.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  23.     private ?int $absenceReasonId null;
  24.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  25.     private ?int $hourStartChangeReasonId null;
  26.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  27.     private ?\DateTimeInterface $workDate null;
  28.     #[ORM\Column]
  29.     private ?bool $accepted null;
  30.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  31.     private ?int $hourEndChangeReasonId null;
  32.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  33.     private ?string $hourStartChangeReasonConsultantNote null;
  34.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  35.     private ?string $hourEndChangeReasonConsultantNote null;
  36.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  37.     private ?\DateTimeInterface $createdAt null;
  38.     #[ORM\Column(length255)]
  39.     private ?string $action null// CREATE, UPDATE, DELETE
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $changedBy null;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?int $adminId null;
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getWorkTimeId(): ?int
  49.     {
  50.         return $this->workTimeId;
  51.     }
  52.     public function setWorkTimeId(int $workTimeId): self
  53.     {
  54.         $this->workTimeId $workTimeId;
  55.         return $this;
  56.     }
  57.     public function getStartTime(): ?\DateTimeInterface
  58.     {
  59.         return $this->startTime;
  60.     }
  61.     public function setStartTime(?\DateTimeInterface $startTime): self
  62.     {
  63.         $this->startTime $startTime;
  64.         return $this;
  65.     }
  66.     public function getEndTime(): ?\DateTimeInterface
  67.     {
  68.         return $this->endTime;
  69.     }
  70.     public function setEndTime(?\DateTimeInterface $endTime): self
  71.     {
  72.         $this->endTime $endTime;
  73.         return $this;
  74.     }
  75.     public function getConsultantId(): ?int
  76.     {
  77.         return $this->consultantId;
  78.     }
  79.     public function setConsultantId(int $consultantId): self
  80.     {
  81.         $this->consultantId $consultantId;
  82.         return $this;
  83.     }
  84.     public function getAbsenceReasonId(): ?int
  85.     {
  86.         return $this->absenceReasonId;
  87.     }
  88.     public function setAbsenceReasonId(?int $absenceReasonId): self
  89.     {
  90.         $this->absenceReasonId $absenceReasonId;
  91.         return $this;
  92.     }
  93.     public function getHourStartChangeReasonId(): ?int
  94.     {
  95.         return $this->hourStartChangeReasonId;
  96.     }
  97.     public function setHourStartChangeReasonId(?int $hourStartChangeReasonId): self
  98.     {
  99.         $this->hourStartChangeReasonId $hourStartChangeReasonId;
  100.         return $this;
  101.     }
  102.     public function getWorkDate(): ?\DateTimeInterface
  103.     {
  104.         return $this->workDate;
  105.     }
  106.     public function setWorkDate(\DateTimeInterface $workDate): self
  107.     {
  108.         $this->workDate $workDate;
  109.         return $this;
  110.     }
  111.     public function isAccepted(): ?bool
  112.     {
  113.         return $this->accepted;
  114.     }
  115.     public function setAccepted(bool $accepted): self
  116.     {
  117.         $this->accepted $accepted;
  118.         return $this;
  119.     }
  120.     public function getHourEndChangeReasonId(): ?int
  121.     {
  122.         return $this->hourEndChangeReasonId;
  123.     }
  124.     public function setHourEndChangeReasonId(?int $hourEndChangeReasonId): self
  125.     {
  126.         $this->hourEndChangeReasonId $hourEndChangeReasonId;
  127.         return $this;
  128.     }
  129.     public function getHourStartChangeReasonConsultantNote(): ?string
  130.     {
  131.         return $this->hourStartChangeReasonConsultantNote;
  132.     }
  133.     public function setHourStartChangeReasonConsultantNote(?string $hourStartChangeReasonConsultantNote): self
  134.     {
  135.         $this->hourStartChangeReasonConsultantNote $hourStartChangeReasonConsultantNote;
  136.         return $this;
  137.     }
  138.     public function getHourEndChangeReasonConsultantNote(): ?string
  139.     {
  140.         return $this->hourEndChangeReasonConsultantNote;
  141.     }
  142.     public function setHourEndChangeReasonConsultantNote(?string $hourEndChangeReasonConsultantNote): self
  143.     {
  144.         $this->hourEndChangeReasonConsultantNote $hourEndChangeReasonConsultantNote;
  145.         return $this;
  146.     }
  147.     public function getCreatedAt(): ?\DateTimeInterface
  148.     {
  149.         return $this->createdAt;
  150.     }
  151.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  152.     {
  153.         $this->createdAt $createdAt;
  154.         return $this;
  155.     }
  156.     public function getAction(): ?string
  157.     {
  158.         return $this->action;
  159.     }
  160.     public function setAction(string $action): self
  161.     {
  162.         $this->action $action;
  163.         return $this;
  164.     }
  165.     public function getChangedBy(): ?string
  166.     {
  167.         return $this->changedBy;
  168.     }
  169.     public function setChangedBy(?string $changedBy): self
  170.     {
  171.         $this->changedBy $changedBy;
  172.         return $this;
  173.     }
  174.     #[ORM\PrePersist]
  175.     public function setCreatedAtValue(): void
  176.     {
  177.         $this->createdAt = new \DateTime();
  178.     }
  179.     /**
  180.      * Create a history record from a WorkTime entity
  181.      */
  182.     public static function createFromWorkTime(WorkTime $workTimestring $action, ?string $changedBy null): self
  183.     {
  184.         $history = new self();
  185.         $history->setWorkTimeId($workTime->getId());
  186.         $history->setStartTime($workTime->getStartTime());
  187.         $history->setEndTime($workTime->getEndTime());
  188.         if( $workTime->getConsultant()){
  189.             $history->setConsultantId($workTime->getConsultant()->getId());
  190.         }
  191.         if($workTime->getAdmin()){
  192.             $history->setAdminId($workTime->getAdmin()->getId());
  193.         }
  194.         $history->setWorkDate($workTime->getWorkDate());
  195.         $history->setAccepted($workTime->isAccepted());
  196.         $history->setHourStartChangeReasonConsultantNote($workTime->getHourStartChangeReasonConsultantNote());
  197.         $history->setHourEndChangeReasonConsultantNote($workTime->getHourEndChangeReasonConsultantNote());
  198.         if ($workTime->getAbsenceReason()) {
  199.             $history->setAbsenceReasonId($workTime->getAbsenceReason()->getId());
  200.         }
  201.         if ($workTime->getHourStartChangeReason()) {
  202.             $history->setHourStartChangeReasonId($workTime->getHourStartChangeReason()->getId());
  203.         }
  204.         if ($workTime->getHourEndChangeReason()) {
  205.             $history->setHourEndChangeReasonId($workTime->getHourEndChangeReason()->getId());
  206.         }
  207.         $history->setAction($action);
  208.         $history->setChangedBy($changedBy);
  209.         $history->setCreatedAt(new \DateTime());
  210.         return $history;
  211.     }
  212.     public function getAdminId(): ?int
  213.     {
  214.         return $this->adminId;
  215.     }
  216.     public function setAdminId(?int $adminId): static
  217.     {
  218.         $this->adminId $adminId;
  219.         return $this;
  220.     }
  221. }