AbstractRepair.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <?php
  2. namespace AppBundle\Entity\Core;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Dunglas\ApiBundle\Annotation\Iri;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use AppBundle\Entity\Traits\TimestampableEntity;
  11. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  12. /**
  13. * Classe de base de @see PlaceRepair, RoomRepair, EquipmentRepair
  14. *
  15. * @author vincent
  16. *
  17. */
  18. #[ORM\Entity]
  19. #[ORM\Table(name: 'Repair')]
  20. #[ORM\InheritanceType('SINGLE_TABLE')]
  21. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  22. #[ORM\DiscriminatorMap(['place' => 'AppBundle\Entity\Place\PlaceRepair', 'room' => 'AppBundle\Entity\Place\RoomRepair', 'equipment' => 'AppBundle\Entity\Product\EquipmentRepair'])]
  23. abstract class AbstractRepair
  24. {
  25. use TimestampableEntity;
  26. use CreatorUpdaterEntity;
  27. use ActivityPeriodTrait;
  28. /**
  29. * @var int
  30. */
  31. #[ORM\Column(type: 'integer')]
  32. #[ORM\Id]
  33. #[ORM\GeneratedValue(strategy: 'AUTO')]
  34. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'equipment_details', 'repair_edit'])]
  35. private $id;
  36. /**
  37. * @var string
  38. */
  39. #[ORM\Column(type: 'string', nullable: true)]
  40. #[Assert\Type(type: 'string')]
  41. #[Assert\Choice(callback: ['AppBundle\Enum\Core\RepairTypeEnum', 'toArray'])]
  42. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'equipment_details_equipmentrepair', 'repair_edit'])]
  43. private $repairType;
  44. /**
  45. * @var string
  46. */
  47. #[ORM\Column(type: 'text', nullable: true)]
  48. #[Assert\Type(type: 'string')]
  49. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
  50. private $workToDo;
  51. /**
  52. * @var Access
  53. */
  54. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access')]
  55. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  56. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'equipment_details_equipmentrepair', 'repair_edit'])]
  57. private $provider;
  58. /**
  59. * @var string
  60. */
  61. #[ORM\Column(type: 'text', nullable: true)]
  62. #[Assert\Type(type: 'string')]
  63. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
  64. private $workDoing;
  65. /**
  66. * @var float
  67. */
  68. #[ORM\Column(type: 'float', nullable: true)]
  69. #[Assert\Type(type: 'float')]
  70. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
  71. private $cost;
  72. /**
  73. * @var float
  74. */
  75. #[ORM\Column(type: 'float', nullable: true)]
  76. #[Assert\Type(type: 'float')]
  77. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
  78. private $tva;
  79. /**
  80. * @var int
  81. */
  82. #[ORM\Column(type: 'string', nullable: true)]
  83. #[Assert\Type(type: 'string')]
  84. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
  85. private $invoiceNumber;
  86. /**
  87. * @var string
  88. */
  89. #[ORM\Column(type: 'string', nullable: true)]
  90. #[Assert\Type(type: 'string')]
  91. #[Assert\Choice(callback: ['AppBundle\Enum\Core\AppreciationEnum', 'toArray'])]
  92. #[Groups(['repair', 'equipmentrepair_list', 'placerepair_list', 'repair_edit'])]
  93. private $appreciation;
  94. /**
  95. * @var ArrayCollection<Tagg>
  96. */
  97. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'repairs')]
  98. #[Assert\Valid]
  99. #[ORM\JoinTable(name: 'tag_repair', joinColumns: [], inverseJoinColumns: [])]
  100. #[ORM\JoinColumn(name: 'repair_id', referencedColumnName: 'id')]
  101. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  102. #[Groups(['repair_tags', 'manage_tags', 'equipmentrepair_list', 'repair_edit'])]
  103. private $tags;
  104. public function __construct() {
  105. $this->tags = new ArrayCollection();
  106. }
  107. /**
  108. * Sets id.
  109. *
  110. * @param int $id
  111. *
  112. * @return $this
  113. */
  114. public function setId($id)
  115. {
  116. $this->id = $id;
  117. return $this;
  118. }
  119. /**
  120. * Gets id.
  121. *
  122. * @return int
  123. */
  124. public function getId()
  125. {
  126. return $this->id;
  127. }
  128. /**
  129. * Sets repairType.
  130. *
  131. * @param string $repairType
  132. *
  133. * @return $this
  134. */
  135. public function setRepairType($repairType)
  136. {
  137. $this->repairType = $repairType;
  138. return $this;
  139. }
  140. /**
  141. * Gets RepairType.
  142. *
  143. * @return string
  144. */
  145. public function getRepairType()
  146. {
  147. return $this->repairType;
  148. }
  149. /**
  150. * Sets workToDo.
  151. *
  152. * @param string $workToDo
  153. *
  154. * @return $this
  155. */
  156. public function setWorkToDo($workToDo)
  157. {
  158. $this->workToDo = $workToDo;
  159. return $this;
  160. }
  161. /**
  162. * Gets workToDo.
  163. *
  164. * @return string
  165. */
  166. public function getWorkToDo()
  167. {
  168. return $this->workToDo;
  169. }
  170. /**
  171. * Sets provider.
  172. *
  173. * @param Access $provider
  174. *
  175. * @return $this
  176. */
  177. public function setProvider(Access $provider = null)
  178. {
  179. $this->provider = $provider;
  180. return $this;
  181. }
  182. /**
  183. * Gets provider.
  184. *
  185. * @return Access
  186. */
  187. public function getProvider()
  188. {
  189. return $this->provider;
  190. }
  191. /**
  192. * Sets workDoing.
  193. *
  194. * @param string $workDoing
  195. *
  196. * @return $this
  197. */
  198. public function setWorkDoing($workDoing)
  199. {
  200. $this->workDoing = $workDoing;
  201. return $this;
  202. }
  203. /**
  204. * Gets workDoing.
  205. *
  206. * @return string
  207. */
  208. public function getWorkDoing()
  209. {
  210. return $this->workDoing;
  211. }
  212. /**
  213. * Sets cost.
  214. *
  215. * @param float $cost
  216. *
  217. * @return $this
  218. */
  219. public function setCost($cost)
  220. {
  221. $this->cost = floatval($cost);
  222. return $this;
  223. }
  224. /**
  225. * Gets cost.
  226. *
  227. * @return float
  228. */
  229. public function getCost()
  230. {
  231. return $this->cost;
  232. }
  233. /**
  234. * Sets tva.
  235. *
  236. * @param float $tva
  237. *
  238. * @return $this
  239. */
  240. public function setTva($tva)
  241. {
  242. $this->tva = floatval($tva);
  243. return $this;
  244. }
  245. /**
  246. * Gets tva.
  247. *
  248. * @return float
  249. */
  250. public function getTva()
  251. {
  252. return $this->tva;
  253. }
  254. /**
  255. * Sets invoiceNumber.
  256. *
  257. * @param string $invoiceNumber
  258. *
  259. * @return $this
  260. */
  261. public function setInvoiceNumber($invoiceNumber)
  262. {
  263. $this->invoiceNumber = $invoiceNumber;
  264. return $this;
  265. }
  266. /**
  267. * Gets invoiceNumber.
  268. *
  269. * @return string
  270. */
  271. public function getInvoiceNumber()
  272. {
  273. return $this->invoiceNumber;
  274. }
  275. /**
  276. * Sets appreciation.
  277. *
  278. * @param string $appreciation
  279. *
  280. * @return $this
  281. */
  282. public function setAppreciation($appreciation)
  283. {
  284. $this->appreciation = $appreciation;
  285. return $this;
  286. }
  287. /**
  288. * Gets appreciation.
  289. *
  290. * @return string
  291. */
  292. public function getAppreciation()
  293. {
  294. return $this->appreciation;
  295. }
  296. /**
  297. * Add tag
  298. *
  299. * @param \AppBundle\Entity\Core\Tagg $tag
  300. *
  301. * @return AbstractRepair
  302. */
  303. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  304. {
  305. $this->tags[] = $tag;
  306. return $this;
  307. }
  308. /**
  309. * Remove tag
  310. *
  311. * @param \AppBundle\Entity\Core\Tagg $tag
  312. */
  313. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  314. {
  315. $this->tags->removeElement($tag);
  316. }
  317. /**
  318. * Get tags
  319. *
  320. * @return \Doctrine\Common\Collections\Collection
  321. */
  322. public function getTags()
  323. {
  324. return $this->tags;
  325. }
  326. }