<?php
namespace MedBrief\MSR\Entity;
use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use MedBrief\MSR\Repository\MatterNoteRepository;
use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
/**
* MatterNote
*
* @ORM\Table(name="MatterNote")
*
* @ORM\Entity(repositoryClass=MatterNoteRepository::class)
*
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*
* @Audit\Auditable
*
* @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
*/
class MatterNote
{
use FilterableClassConstantsTrait;
public const TYPE_QUERY = 1;
public const TYPE_QUERY__LABEL = 'Query';
public const TYPE_PASSWORD = 2;
public const TYPE_PASSWORD__LABEL = 'Password';
public const TYPE_UPDATE = 3;
public const TYPE_UPDATE__LABEL = 'Update';
public const TYPE_GENERAL = 4;
public const TYPE_GENERAL__LABEL = 'General';
public const TYPE_INDEX_AMENDMENT = 5;
public const TYPE_INDEX_AMENDMENT__LABEL = 'Index Amendment';
public const TYPE_MEMO_AMENDMENT = 6;
public const TYPE_MEMO_AMENDMENT__LABEL = 'Memo Amendment';
public const TYPE_REDACTION = 7;
public const TYPE_REDACTION__LABEL = 'Redaction';
public const TYPE_FILES_RECEIVED = 8;
public const TYPE_FILES_RECEIVED__LABEL = 'File(s) Received ';
public const TYPE_ISSUE_ACTIVE = 9;
public const TYPE_ISSUE_ACTIVE__LABEL = 'Issue - Active';
public const TYPE_ISSUE_RESOLVED = 10;
public const TYPE_ISSUE_RESOLVED__LABEL = 'Issue - Resolved';
public const TYPE_INSTRUCTION_TO_DO = 11;
public const TYPE_INSTRUCTION_TO_DO__LABEL = 'Instruction - To Do';
public const TYPE_INSTRUCTION_COMPLETED = 12;
public const TYPE_INSTRUCTION_COMPLETED__LABEL = 'Instruction - Completed';
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var \DateTime|null
*
* @ORM\Column(name="displayDate", type="datetime", nullable=true)
*/
protected $displayDate;
/**
* @var int|null
*
* @ORM\Column(name="type", type="integer", nullable=true)
*/
protected $type;
/**
* @var string|null
*
* @ORM\Column(name="note", type="text", nullable=true)
*/
protected $note;
/**
* deletedAt
*
* @ORM\Column(name="creatorFullName", type="string", nullable=true)
*/
protected $creatorFullName;
/**
* @var \DateTime|null
*
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
protected $deletedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*
* @Gedmo\Timestampable(on="create")
*/
protected $created;
/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
*
* @Gedmo\Timestampable(on="update")
*/
protected $updated;
/**
* @var Project
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="matterNotes")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="project_id", referencedColumnName="id")
* })
*/
protected $project;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="matterNotes")
*
* @ORM\JoinColumns({
*
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=true)
* })
*/
protected $creator;
/**
* @ORM\Column(type="boolean", options={"default"=false})
*
* @var bool
*/
protected $isImportant = false;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set displayDate
*
* @param \DateTime $displayDate
*
* @return MatterNote
*/
public function setDisplayDate($displayDate)
{
$this->displayDate = $displayDate;
return $this;
}
/**
* Get displayDate
*
* @return \DateTime
*/
public function getDisplayDate()
{
return $this->displayDate ?: $this->created;
}
/**
* Set type
*
* @param int $type
*
* @return MatterNote
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param ?array $noteCounts - Used to append the count next to the note type in the label.
*
* @return array
*/
public static function getTypeOptions(?array $noteCounts = null): array
{
$noteTypes = array_flip(self::getConstantsWithLabelsAsChoices('TYPE'));
if ($noteCounts === null) {
return $noteTypes;
}
foreach ($noteTypes as $key => $noteType) {
$noteTypes[$key] = sprintf('%1$s (%2$s)', $noteType, $noteCounts[$key] ?? 0);
}
return $noteTypes;
}
/**
* Returns a human readable version of the types
*
* @return string
*/
public function getTypeName()
{
$options = self::getTypeOptions();
return
$options[$this->getType()] ?? $this->getType();
}
/**
* Set note
*
* @param string $note
*
* @return MatterNote
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* Get note
*
* @return string
*/
public function getNote()
{
return $this->note;
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return MatterNote
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set created
*
* @param \DateTime $created
*
* @return MatterNote
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* @param \DateTime $updated
*
* @return MatterNote
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set project
*
* @param Project $project
*
* @return MatterNote
*/
public function setProject(?Project $project = null)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* Set creator
*
* @param User $creator
*
* @return MatterNote
*/
public function setCreator(?User $creator = null)
{
$this->creator = $creator;
return $this;
}
/**
* Get creator
*
* @return User
*/
public function getCreator()
{
return $this->creator;
}
/**
* Set creatorFullName
*
* @param string $creatorFullName
*
* @return MatterNote
*/
public function setCreatorFullName($creatorFullName)
{
$this->creatorFullName = $creatorFullName;
return $this;
}
/**
* Get creatorFullName
*
* @return string
*/
public function getCreatorFullName()
{
return $this->creatorFullName;
}
/**
* @return bool
*/
public function getIsImportant(): bool
{
return $this->isImportant;
}
/**
* @param bool $isImportant
*
* @return self
*/
public function setIsImportant(bool $isImportant): self
{
$this->isImportant = $isImportant;
return $this;
}
/**
* Convenience method to determine if the type is set to password
*
* @return bool
*/
public function isPassword(): bool
{
return $this->getType() === self::TYPE_PASSWORD;
}
}