src/Entity/CRM/WorkTimeHistory.php line 11
<?phpnamespace App\Entity\CRM;use App\Repository\WorkTimeHistoryRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: WorkTimeHistoryRepository::class)]#[ORM\HasLifecycleCallbacks]class WorkTimeHistory{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(type: Types::INTEGER)]private ?int $workTimeId = null;#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $startTime = null;#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $endTime = null;#[ORM\Column(type: Types::INTEGER,nullable: true)]private ?int $consultantId = null;#[ORM\Column(type: Types::INTEGER, nullable: true)]private ?int $absenceReasonId = null;#[ORM\Column(type: Types::INTEGER, nullable: true)]private ?int $hourStartChangeReasonId = null;#[ORM\Column(type: Types::DATE_MUTABLE)]private ?\DateTimeInterface $workDate = null;#[ORM\Column]private ?bool $accepted = null;#[ORM\Column(type: Types::INTEGER, nullable: true)]private ?int $hourEndChangeReasonId = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $hourStartChangeReasonConsultantNote = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $hourEndChangeReasonConsultantNote = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $createdAt = null;#[ORM\Column(length: 255)]private ?string $action = null; // CREATE, UPDATE, DELETE#[ORM\Column(length: 255, nullable: true)]private ?string $changedBy = null;#[ORM\Column(nullable: true)]private ?int $adminId = null;public function getId(): ?int{return $this->id;}public function getWorkTimeId(): ?int{return $this->workTimeId;}public function setWorkTimeId(int $workTimeId): self{$this->workTimeId = $workTimeId;return $this;}public function getStartTime(): ?\DateTimeInterface{return $this->startTime;}public function setStartTime(?\DateTimeInterface $startTime): self{$this->startTime = $startTime;return $this;}public function getEndTime(): ?\DateTimeInterface{return $this->endTime;}public function setEndTime(?\DateTimeInterface $endTime): self{$this->endTime = $endTime;return $this;}public function getConsultantId(): ?int{return $this->consultantId;}public function setConsultantId(int $consultantId): self{$this->consultantId = $consultantId;return $this;}public function getAbsenceReasonId(): ?int{return $this->absenceReasonId;}public function setAbsenceReasonId(?int $absenceReasonId): self{$this->absenceReasonId = $absenceReasonId;return $this;}public function getHourStartChangeReasonId(): ?int{return $this->hourStartChangeReasonId;}public function setHourStartChangeReasonId(?int $hourStartChangeReasonId): self{$this->hourStartChangeReasonId = $hourStartChangeReasonId;return $this;}public function getWorkDate(): ?\DateTimeInterface{return $this->workDate;}public function setWorkDate(\DateTimeInterface $workDate): self{$this->workDate = $workDate;return $this;}public function isAccepted(): ?bool{return $this->accepted;}public function setAccepted(bool $accepted): self{$this->accepted = $accepted;return $this;}public function getHourEndChangeReasonId(): ?int{return $this->hourEndChangeReasonId;}public function setHourEndChangeReasonId(?int $hourEndChangeReasonId): self{$this->hourEndChangeReasonId = $hourEndChangeReasonId;return $this;}public function getHourStartChangeReasonConsultantNote(): ?string{return $this->hourStartChangeReasonConsultantNote;}public function setHourStartChangeReasonConsultantNote(?string $hourStartChangeReasonConsultantNote): self{$this->hourStartChangeReasonConsultantNote = $hourStartChangeReasonConsultantNote;return $this;}public function getHourEndChangeReasonConsultantNote(): ?string{return $this->hourEndChangeReasonConsultantNote;}public function setHourEndChangeReasonConsultantNote(?string $hourEndChangeReasonConsultantNote): self{$this->hourEndChangeReasonConsultantNote = $hourEndChangeReasonConsultantNote;return $this;}public function getCreatedAt(): ?\DateTimeInterface{return $this->createdAt;}public function setCreatedAt(\DateTimeInterface $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getAction(): ?string{return $this->action;}public function setAction(string $action): self{$this->action = $action;return $this;}public function getChangedBy(): ?string{return $this->changedBy;}public function setChangedBy(?string $changedBy): self{$this->changedBy = $changedBy;return $this;}#[ORM\PrePersist]public function setCreatedAtValue(): void{$this->createdAt = new \DateTime();}/*** Create a history record from a WorkTime entity*/public static function createFromWorkTime(WorkTime $workTime, string $action, ?string $changedBy = null): self{$history = new self();$history->setWorkTimeId($workTime->getId());$history->setStartTime($workTime->getStartTime());$history->setEndTime($workTime->getEndTime());if( $workTime->getConsultant()){$history->setConsultantId($workTime->getConsultant()->getId());}if($workTime->getAdmin()){$history->setAdminId($workTime->getAdmin()->getId());}$history->setWorkDate($workTime->getWorkDate());$history->setAccepted($workTime->isAccepted());$history->setHourStartChangeReasonConsultantNote($workTime->getHourStartChangeReasonConsultantNote());$history->setHourEndChangeReasonConsultantNote($workTime->getHourEndChangeReasonConsultantNote());if ($workTime->getAbsenceReason()) {$history->setAbsenceReasonId($workTime->getAbsenceReason()->getId());}if ($workTime->getHourStartChangeReason()) {$history->setHourStartChangeReasonId($workTime->getHourStartChangeReason()->getId());}if ($workTime->getHourEndChangeReason()) {$history->setHourEndChangeReasonId($workTime->getHourEndChangeReason()->getId());}$history->setAction($action);$history->setChangedBy($changedBy);$history->setCreatedAt(new \DateTime());return $history;}public function getAdminId(): ?int{return $this->adminId;}public function setAdminId(?int $adminId): static{$this->adminId = $adminId;return $this;}}