AbstractControl.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <?php
  2. namespace AppBundle\Entity\Core;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use AppBundle\Entity\Person\Person;
  5. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Dunglas\ApiBundle\Annotation\Iri;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use AppBundle\Entity\Traits\TimestampableEntity;
  12. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  13. /**
  14. * Contrôle du bon état des Place, Room et Equipment, effectué ou planifié
  15. * Classe de base de @see PlaceControl, RoomControl, EquipmentControl
  16. *
  17. * @author vincent
  18. *
  19. */
  20. #[ORM\Entity]
  21. #[ORM\Table(name: 'Control')]
  22. #[ORM\InheritanceType('SINGLE_TABLE')]
  23. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  24. #[ORM\DiscriminatorMap(['place' => 'AppBundle\Entity\Place\PlaceControl', 'room' => 'AppBundle\Entity\Place\RoomControl', 'equipment' => 'AppBundle\Entity\Product\EquipmentControl'])]
  25. abstract class AbstractControl
  26. {
  27. use TimestampableEntity;
  28. use CreatorUpdaterEntity;
  29. use ActivityPeriodTrait;
  30. /**
  31. * @var int
  32. */
  33. #[ORM\Column(type: 'integer')]
  34. #[ORM\Id]
  35. #[ORM\GeneratedValue(strategy: 'AUTO')]
  36. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'equipment_details', 'control_edit'])]
  37. private $id;
  38. /**
  39. * @var string
  40. */
  41. #[ORM\Column(type: 'string', nullable: true)]
  42. #[Assert\Type(type: 'string')]
  43. #[Assert\Choice(callback: ['\AppBundle\Enum\Product\ControlTypeEnum', 'toArray'])]
  44. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'equipment_details_equipmentcontrol', 'control_edit'])]
  45. private $controlType;
  46. /**
  47. * @var bool
  48. */
  49. #[ORM\Column(type: 'boolean', nullable: true)]
  50. #[Assert\Type(type: 'boolean')]
  51. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'control_edit'])]
  52. private $report;
  53. /**
  54. * @var string
  55. */
  56. #[ORM\Column(type: 'string', nullable: true)]
  57. #[Assert\Type(type: 'string')]
  58. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'equipment_details_equipmentcontrol', 'control_edit'])]
  59. private $operator;
  60. /**
  61. * @var string
  62. */
  63. #[ORM\Column(type: 'text', nullable: true)]
  64. #[Assert\Type(type: 'string')]
  65. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'control_edit'])]
  66. private $finding;
  67. /**
  68. * @var string
  69. */
  70. #[ORM\Column(type: 'text', nullable: true)]
  71. #[Assert\Type(type: 'string')]
  72. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'control_edit'])]
  73. private $workDoing;
  74. /**
  75. * @var int
  76. */
  77. #[ORM\Column(type: 'integer', nullable: true)]
  78. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  79. #[Groups(['control', 'equipmentcontrol_list', 'equipment_details_equipmentcontrol', 'control_edit'])]
  80. private $lifeBalance;
  81. /**
  82. * @var int
  83. */
  84. #[ORM\Column(type: 'integer', nullable: true)]
  85. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  86. #[Groups(['control', 'equipmentcontrol_list', 'control_edit'])]
  87. private $usedDuration;
  88. /**
  89. * @var Access
  90. */
  91. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'accompanistControl')]
  92. #[ORM\JoinColumn(nullable: true)]
  93. #[Groups(['control', 'equipmentcontrol_list', 'control_edit'])]
  94. private $accompanist;
  95. /**
  96. * @var int
  97. */
  98. #[ORM\Column(type: 'integer', nullable: true)]
  99. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  100. #[Groups(['control', 'equipmentcontrol_list', 'equipment_details_equipmentcontrol', 'control_edit'])]
  101. private $balanceUsefulLife;
  102. /**
  103. * @var \DateTime
  104. */
  105. #[ORM\Column(type: 'date', nullable: true)]
  106. #[Assert\Date]
  107. #[Groups(['control', 'equipmentcontrol_list', 'placecontrol_list', 'equipment_details_equipmentcontrol', 'control_edit'])]
  108. private $nextControl;
  109. /**
  110. * @var ArrayCollection<Tagg>
  111. */
  112. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'controls')]
  113. #[Assert\Valid]
  114. #[ORM\JoinTable(name: 'tag_control', joinColumns: [], inverseJoinColumns: [])]
  115. #[ORM\JoinColumn(name: 'control_id', referencedColumnName: 'id')]
  116. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  117. #[Groups(['control_tags', 'manage_tags', 'equipmentcontrol_list'])]
  118. private $tags;
  119. public function __construct() {
  120. $this->tags = new ArrayCollection();
  121. }
  122. /**
  123. * Sets id.
  124. *
  125. * @param int $id
  126. *
  127. * @return $this
  128. */
  129. public function setId($id)
  130. {
  131. $this->id = $id;
  132. return $this;
  133. }
  134. /**
  135. * Gets id.
  136. *
  137. * @return int
  138. */
  139. public function getId()
  140. {
  141. return $this->id;
  142. }
  143. /**
  144. * Sets controlType.
  145. *
  146. * @param string $controlType
  147. *
  148. * @return $this
  149. */
  150. public function setControlType($controlType)
  151. {
  152. $this->controlType = $controlType;
  153. return $this;
  154. }
  155. /**
  156. * Gets controlType.
  157. *
  158. * @return string
  159. */
  160. public function getControlType()
  161. {
  162. return $this->controlType;
  163. }
  164. /**
  165. * Sets report.
  166. *
  167. * @param bool $report
  168. *
  169. * @return $this
  170. */
  171. public function setReport($report)
  172. {
  173. $this->report = $report;
  174. return $this;
  175. }
  176. /**
  177. * Gets report.
  178. *
  179. * @return bool
  180. */
  181. public function getReport()
  182. {
  183. return $this->report;
  184. }
  185. /**
  186. * Sets operator.
  187. *
  188. * @param string $operator
  189. *
  190. * @return $this
  191. */
  192. public function setOperator($operator)
  193. {
  194. $this->operator = $operator;
  195. return $this;
  196. }
  197. /**
  198. * Gets operator.
  199. *
  200. * @return string
  201. */
  202. public function getOperator()
  203. {
  204. return $this->operator;
  205. }
  206. /**
  207. * Sets finding.
  208. *
  209. * @param string $finding
  210. *
  211. * @return $this
  212. */
  213. public function setFinding($finding)
  214. {
  215. $this->finding = $finding;
  216. return $this;
  217. }
  218. /**
  219. * Gets finding.
  220. *
  221. * @return string
  222. */
  223. public function getFinding()
  224. {
  225. return $this->finding;
  226. }
  227. /**
  228. * Sets workDoing.
  229. *
  230. * @param string $workDoing
  231. *
  232. * @return $this
  233. */
  234. public function setWorkDoing($workDoing)
  235. {
  236. $this->workDoing = $workDoing;
  237. return $this;
  238. }
  239. /**
  240. * Gets workDoing.
  241. *
  242. * @return string
  243. */
  244. public function getWorkDoing()
  245. {
  246. return $this->workDoing;
  247. }
  248. /**
  249. * Sets lifeBalance.
  250. *
  251. * @param int $lifeBalance
  252. *
  253. * @return $this
  254. */
  255. public function setLifeBalance($lifeBalance)
  256. {
  257. $this->lifeBalance = $lifeBalance;
  258. return $this;
  259. }
  260. /**
  261. * Gets lifeBalance.
  262. *
  263. * @return int
  264. */
  265. public function getLifeBalance()
  266. {
  267. return $this->lifeBalance;
  268. }
  269. /**
  270. * Sets usedDuration.
  271. *
  272. * @param int $usedDuration
  273. *
  274. * @return $this
  275. */
  276. public function setUsedDuration($usedDuration)
  277. {
  278. $this->usedDuration = $usedDuration;
  279. return $this;
  280. }
  281. /**
  282. * Gets usedDuration.
  283. *
  284. * @return int
  285. */
  286. public function getUsedDuration()
  287. {
  288. return $this->usedDuration;
  289. }
  290. /**
  291. * @param Access|null $accompanist
  292. * @return $this
  293. */
  294. public function setAccompanist(Access $accompanist = null)
  295. {
  296. $this->accompanist = $accompanist;
  297. return $this;
  298. }
  299. /**
  300. * Gets accompanist.
  301. *
  302. * @return Access
  303. */
  304. public function getAccompanist()
  305. {
  306. return $this->accompanist;
  307. }
  308. /**
  309. * Sets balanceUsefulLife.
  310. *
  311. * @param int $balanceUsefulLife
  312. *
  313. * @return $this
  314. */
  315. public function setBalanceUsefulLife($balanceUsefulLife)
  316. {
  317. $this->balanceUsefulLife = $balanceUsefulLife;
  318. return $this;
  319. }
  320. /**
  321. * Gets balanceUsefulLife.
  322. *
  323. * @return int
  324. */
  325. public function getBalanceUsefulLife()
  326. {
  327. return $this->balanceUsefulLife;
  328. }
  329. /**
  330. * Sets nextControl.
  331. *
  332. * @param \DateTime $nextControl
  333. *
  334. * @return $this
  335. */
  336. public function setNextControl(\DateTime $nextControl = null)
  337. {
  338. $this->nextControl = $nextControl;
  339. return $this;
  340. }
  341. /**
  342. * Gets nextControl.
  343. *
  344. * @return \DateTime
  345. */
  346. public function getNextControl()
  347. {
  348. return $this->nextControl ? $this->nextControl->format('Y-m-d') : $this->nextControl;
  349. }
  350. /**
  351. * Add tag
  352. *
  353. * @param \AppBundle\Entity\Core\Tagg $tag
  354. *
  355. * @return AbstractControl
  356. */
  357. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  358. {
  359. $this->tags[] = $tag;
  360. return $this;
  361. }
  362. /**
  363. * Remove tag
  364. *
  365. * @param \AppBundle\Entity\Core\Tagg $tag
  366. */
  367. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  368. {
  369. $this->tags->removeElement($tag);
  370. }
  371. /**
  372. * Get tags
  373. *
  374. * @return \Doctrine\Common\Collections\Collection
  375. */
  376. public function getTags()
  377. {
  378. return $this->tags;
  379. }
  380. }