src/Entity/MatterNote.php line 24

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use MedBrief\MSR\Repository\MatterNoteRepository;
  7. use MedBrief\MSR\Traits\FilterableClassConstantsTrait;
  8. /**
  9. * MatterNote
  10. *
  11. * @ORM\Table(name="MatterNote")
  12. *
  13. * @ORM\Entity(repositoryClass=MatterNoteRepository::class)
  14. *
  15. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  16. *
  17. * @Audit\Auditable
  18. *
  19. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  20. */
  21. class MatterNote
  22. {
  23. use FilterableClassConstantsTrait;
  24. public const TYPE_QUERY = 1;
  25. public const TYPE_QUERY__LABEL = 'Query';
  26. public const TYPE_PASSWORD = 2;
  27. public const TYPE_PASSWORD__LABEL = 'Password';
  28. public const TYPE_UPDATE = 3;
  29. public const TYPE_UPDATE__LABEL = 'Update';
  30. public const TYPE_GENERAL = 4;
  31. public const TYPE_GENERAL__LABEL = 'General';
  32. public const TYPE_INDEX_AMENDMENT = 5;
  33. public const TYPE_INDEX_AMENDMENT__LABEL = 'Index Amendment';
  34. public const TYPE_MEMO_AMENDMENT = 6;
  35. public const TYPE_MEMO_AMENDMENT__LABEL = 'Memo Amendment';
  36. public const TYPE_REDACTION = 7;
  37. public const TYPE_REDACTION__LABEL = 'Redaction';
  38. public const TYPE_FILES_RECEIVED = 8;
  39. public const TYPE_FILES_RECEIVED__LABEL = 'File(s) Received ';
  40. public const TYPE_ISSUE_ACTIVE = 9;
  41. public const TYPE_ISSUE_ACTIVE__LABEL = 'Issue - Active';
  42. public const TYPE_ISSUE_RESOLVED = 10;
  43. public const TYPE_ISSUE_RESOLVED__LABEL = 'Issue - Resolved';
  44. public const TYPE_INSTRUCTION_TO_DO = 11;
  45. public const TYPE_INSTRUCTION_TO_DO__LABEL = 'Instruction - To Do';
  46. public const TYPE_INSTRUCTION_COMPLETED = 12;
  47. public const TYPE_INSTRUCTION_COMPLETED__LABEL = 'Instruction - Completed';
  48. /**
  49. * @var int
  50. *
  51. * @ORM\Column(name="id", type="integer")
  52. *
  53. * @ORM\Id
  54. *
  55. * @ORM\GeneratedValue(strategy="IDENTITY")
  56. */
  57. protected $id;
  58. /**
  59. * @var \DateTime|null
  60. *
  61. * @ORM\Column(name="displayDate", type="datetime", nullable=true)
  62. */
  63. protected $displayDate;
  64. /**
  65. * @var int|null
  66. *
  67. * @ORM\Column(name="type", type="integer", nullable=true)
  68. */
  69. protected $type;
  70. /**
  71. * @var string|null
  72. *
  73. * @ORM\Column(name="note", type="text", nullable=true)
  74. */
  75. protected $note;
  76. /**
  77. * deletedAt
  78. *
  79. * @ORM\Column(name="creatorFullName", type="string", nullable=true)
  80. */
  81. protected $creatorFullName;
  82. /**
  83. * @var \DateTime|null
  84. *
  85. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  86. */
  87. protected $deletedAt;
  88. /**
  89. * @var \DateTime
  90. *
  91. * @ORM\Column(name="created", type="datetime")
  92. *
  93. * @Gedmo\Timestampable(on="create")
  94. */
  95. protected $created;
  96. /**
  97. * @var \DateTime
  98. *
  99. * @ORM\Column(name="updated", type="datetime")
  100. *
  101. * @Gedmo\Timestampable(on="update")
  102. */
  103. protected $updated;
  104. /**
  105. * @var Project
  106. *
  107. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="matterNotes")
  108. *
  109. * @ORM\JoinColumns({
  110. *
  111. * @ORM\JoinColumn(name="project_id", referencedColumnName="id")
  112. * })
  113. */
  114. protected $project;
  115. /**
  116. * @var User
  117. *
  118. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="matterNotes")
  119. *
  120. * @ORM\JoinColumns({
  121. *
  122. * @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=true)
  123. * })
  124. */
  125. protected $creator;
  126. /**
  127. * @ORM\Column(type="boolean", options={"default"=false})
  128. *
  129. * @var bool
  130. */
  131. protected $isImportant = false;
  132. /**
  133. * Get id
  134. *
  135. * @return int
  136. */
  137. public function getId()
  138. {
  139. return $this->id;
  140. }
  141. /**
  142. * Set displayDate
  143. *
  144. * @param \DateTime $displayDate
  145. *
  146. * @return MatterNote
  147. */
  148. public function setDisplayDate($displayDate)
  149. {
  150. $this->displayDate = $displayDate;
  151. return $this;
  152. }
  153. /**
  154. * Get displayDate
  155. *
  156. * @return \DateTime
  157. */
  158. public function getDisplayDate()
  159. {
  160. return $this->displayDate ?: $this->created;
  161. }
  162. /**
  163. * Set type
  164. *
  165. * @param int $type
  166. *
  167. * @return MatterNote
  168. */
  169. public function setType($type)
  170. {
  171. $this->type = $type;
  172. return $this;
  173. }
  174. /**
  175. * Get type
  176. *
  177. * @return int
  178. */
  179. public function getType()
  180. {
  181. return $this->type;
  182. }
  183. /**
  184. * @param ?array $noteCounts - Used to append the count next to the note type in the label.
  185. *
  186. * @return array
  187. */
  188. public static function getTypeOptions(?array $noteCounts = null): array
  189. {
  190. $noteTypes = array_flip(self::getConstantsWithLabelsAsChoices('TYPE'));
  191. if ($noteCounts === null) {
  192. return $noteTypes;
  193. }
  194. foreach ($noteTypes as $key => $noteType) {
  195. $noteTypes[$key] = sprintf('%1$s (%2$s)', $noteType, $noteCounts[$key] ?? 0);
  196. }
  197. return $noteTypes;
  198. }
  199. /**
  200. * Returns a human readable version of the types
  201. *
  202. * @return string
  203. */
  204. public function getTypeName()
  205. {
  206. $options = self::getTypeOptions();
  207. return
  208. $options[$this->getType()] ?? $this->getType();
  209. }
  210. /**
  211. * Set note
  212. *
  213. * @param string $note
  214. *
  215. * @return MatterNote
  216. */
  217. public function setNote($note)
  218. {
  219. $this->note = $note;
  220. return $this;
  221. }
  222. /**
  223. * Get note
  224. *
  225. * @return string
  226. */
  227. public function getNote()
  228. {
  229. return $this->note;
  230. }
  231. /**
  232. * Set deletedAt
  233. *
  234. * @param \DateTime $deletedAt
  235. *
  236. * @return MatterNote
  237. */
  238. public function setDeletedAt($deletedAt)
  239. {
  240. $this->deletedAt = $deletedAt;
  241. return $this;
  242. }
  243. /**
  244. * Get deletedAt
  245. *
  246. * @return \DateTime
  247. */
  248. public function getDeletedAt()
  249. {
  250. return $this->deletedAt;
  251. }
  252. /**
  253. * Set created
  254. *
  255. * @param \DateTime $created
  256. *
  257. * @return MatterNote
  258. */
  259. public function setCreated($created)
  260. {
  261. $this->created = $created;
  262. return $this;
  263. }
  264. /**
  265. * Get created
  266. *
  267. * @return \DateTime
  268. */
  269. public function getCreated()
  270. {
  271. return $this->created;
  272. }
  273. /**
  274. * Set updated
  275. *
  276. * @param \DateTime $updated
  277. *
  278. * @return MatterNote
  279. */
  280. public function setUpdated($updated)
  281. {
  282. $this->updated = $updated;
  283. return $this;
  284. }
  285. /**
  286. * Get updated
  287. *
  288. * @return \DateTime
  289. */
  290. public function getUpdated()
  291. {
  292. return $this->updated;
  293. }
  294. /**
  295. * Set project
  296. *
  297. * @param Project $project
  298. *
  299. * @return MatterNote
  300. */
  301. public function setProject(?Project $project = null)
  302. {
  303. $this->project = $project;
  304. return $this;
  305. }
  306. /**
  307. * Get project
  308. *
  309. * @return Project
  310. */
  311. public function getProject()
  312. {
  313. return $this->project;
  314. }
  315. /**
  316. * Set creator
  317. *
  318. * @param User $creator
  319. *
  320. * @return MatterNote
  321. */
  322. public function setCreator(?User $creator = null)
  323. {
  324. $this->creator = $creator;
  325. return $this;
  326. }
  327. /**
  328. * Get creator
  329. *
  330. * @return User
  331. */
  332. public function getCreator()
  333. {
  334. return $this->creator;
  335. }
  336. /**
  337. * Set creatorFullName
  338. *
  339. * @param string $creatorFullName
  340. *
  341. * @return MatterNote
  342. */
  343. public function setCreatorFullName($creatorFullName)
  344. {
  345. $this->creatorFullName = $creatorFullName;
  346. return $this;
  347. }
  348. /**
  349. * Get creatorFullName
  350. *
  351. * @return string
  352. */
  353. public function getCreatorFullName()
  354. {
  355. return $this->creatorFullName;
  356. }
  357. /**
  358. * @return bool
  359. */
  360. public function getIsImportant(): bool
  361. {
  362. return $this->isImportant;
  363. }
  364. /**
  365. * @param bool $isImportant
  366. *
  367. * @return self
  368. */
  369. public function setIsImportant(bool $isImportant): self
  370. {
  371. $this->isImportant = $isImportant;
  372. return $this;
  373. }
  374. /**
  375. * Convenience method to determine if the type is set to password
  376. *
  377. * @return bool
  378. */
  379. public function isPassword(): bool
  380. {
  381. return $this->getType() === self::TYPE_PASSWORD;
  382. }
  383. }