OrganizationFunction.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <?php
  2. namespace AppBundle\Entity\AccessAndFunction;
  3. use AppBundle\Annotation\DefaultField;
  4. use AppBundle\Annotation\ExportSplitFields;
  5. use AppBundle\Entity\Traits\ActivityPeriodTrait;
  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. use AppBundle\Entity\Organization\Activity;
  13. /**
  14. * Fonction d'un Access dans une Organization sur une période donnée
  15. *
  16. * @Iri("http://schema.org/OrganizationFunction")
  17. */
  18. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\AccessAndFunction\Repository\OrganizationFunctionRepository')]
  19. class OrganizationFunction
  20. {
  21. use TimestampableEntity;
  22. use CreatorUpdaterEntity;
  23. use ActivityPeriodTrait;
  24. /**
  25. * @var int
  26. */
  27. #[ORM\Column(type: 'integer')]
  28. #[ORM\Id]
  29. #[ORM\GeneratedValue(strategy: 'AUTO')]
  30. #[Groups(['organizationfunction', 'access_details', 'adherent_list', 'personnels_list', 'ca_list', 'accesses_list', 'othercontact_list', 'student_registration', 'student_registration_guardians', 'student_registration_accessfamily', 'board_list', 'licence_cmf', 'organization_function_edit', 'access_informations_edit', 'adherent_contact', 'cotisation_responsibles_accesses', 'view_from_manager_create', 'networkmanagers_list', 'online_registration_access_details', 'accesscmfnetwork'])]
  31. private $id;
  32. /**
  33. * @var Access
  34. */
  35. #[ORM\ManyToOne(targetEntity: 'Access', inversedBy: 'organizationFunction')]
  36. #[ORM\JoinColumn(nullable: false)]
  37. #[Assert\NotNull]
  38. #[Groups(['organizationfunction', 'organization_function_edit'])]
  39. private $access;
  40. /**
  41. * @var FunctionType
  42. */
  43. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\FunctionType')]
  44. #[ORM\JoinColumn(nullable: false)]
  45. #[Assert\NotNull]
  46. #[Groups(['organizationfunction', 'access_details_organizationfunction', 'adherent_list_organizationfunction', 'personnels_list_organizationfunction', 'othercontact_list_organizationfunction', 'ca_list_organizationfunction', 'accesses_list_organizationfunction', 'student_registration_organizationfunction', 'student_registration_guardians', 'student_registration_accessfamily', 'board_list_organizationfunction', 'licence_cmf_organizationfunction', 'access_informations_edit_organizationfunction', 'adherent_contact_organizationfunction', 'organization_function_edit', 'cotisation_responsibles_accesses_organizationfunction', 'view_from_manager_create_organizationfunction', 'networkmanagers_list_organizationfunction', 'online_registration_access_details_organizationfunction', 'accesscmfnetwork_organizationfunction'])]
  47. private $functionType;
  48. /**
  49. * @var string
  50. */
  51. #[ORM\Column(type: 'text', nullable: true)]
  52. #[Assert\Type(type: 'string')]
  53. #[Groups(['organizationfunction', 'access_details_organizationfunction', 'organization_function_edit', 'othercontact_list_organizationfunction', 'networkmanagers_list_organizationfunction', 'personnels_list_organizationfunction'])]
  54. private $functionComplement;
  55. /**
  56. * @var string
  57. */
  58. #[ORM\Column(type: 'string', nullable: true)]
  59. #[Assert\Type(type: 'string')]
  60. #[Assert\Choice(callback: ['\AppBundle\Enum\AccessAndFunction\DeparturesCauseEnum', 'toArray'])]
  61. #[Groups(['organizationfunction', 'accesses_list_organizationfunction', 'adherent_list_organizationfunction', 'personnels_list_organizationfunction', 'ca_list_organizationfunction', 'board_list_organizationfunction', 'access_details_organizationfunction', 'organization_function_edit', 'view_from_manager_create_organizationfunction'])]
  62. private $departureCause;
  63. /**
  64. * @var Activity
  65. */
  66. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Activity')]
  67. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  68. #[Groups(['organizationfunction', 'access_details_organizationfunction', 'organization_function_edit'])]
  69. private $activity;
  70. /**
  71. * @var bool
  72. */
  73. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  74. #[Assert\Type(type: 'boolean')]
  75. #[Assert\NotNull]
  76. #[Groups(['organizationfunction', 'organization_function_edit'])]
  77. private $isMemberSection = true;
  78. /**
  79. * @var string
  80. * @ExportSplitFields({"functionType.mission","startDate","endDate"})
  81. */
  82. #[Groups(['template'])]
  83. private $fullLabelTemplate;
  84. /**
  85. * Sets id.
  86. *
  87. * @param int $id
  88. *
  89. * @return $this
  90. */
  91. public function setId($id)
  92. {
  93. $this->id = $id;
  94. return $this;
  95. }
  96. /**
  97. * Gets id.
  98. *
  99. * @return int
  100. */
  101. public function getId()
  102. {
  103. return $this->id;
  104. }
  105. /**
  106. * Sets functionType.
  107. *
  108. * @param string $functionType
  109. *
  110. * @return $this
  111. */
  112. public function setFunctionType($functionType)
  113. {
  114. $this->functionType = $functionType;
  115. return $this;
  116. }
  117. /**
  118. * Get functionType
  119. *
  120. * @return \AppBundle\Entity\AccessAndFunction\FunctionType
  121. */
  122. public function getFunctionType()
  123. {
  124. return $this->functionType;
  125. }
  126. /**
  127. * Sets functionComplement.
  128. *
  129. * @param string $functionComplement
  130. *
  131. * @return $this
  132. */
  133. public function setFunctionComplement($functionComplement)
  134. {
  135. $this->functionComplement = $functionComplement;
  136. return $this;
  137. }
  138. /**
  139. * Gets functionComplement.
  140. *
  141. * @return string
  142. */
  143. public function getFunctionComplement()
  144. {
  145. return $this->functionComplement;
  146. }
  147. /**
  148. * Sets departureCause.
  149. *
  150. * @param string $departureCause
  151. *
  152. * @return $this
  153. */
  154. public function setDepartureCause($departureCause)
  155. {
  156. $this->departureCause = $departureCause;
  157. return $this;
  158. }
  159. /**
  160. * Gets departureCause.
  161. *
  162. * @return string
  163. */
  164. public function getDepartureCause()
  165. {
  166. return $this->departureCause;
  167. }
  168. /**
  169. * Sets activity.
  170. *
  171. * @param Activity $activity
  172. *
  173. * @return $this
  174. */
  175. public function setActivity(Activity $activity = null)
  176. {
  177. $this->activity = $activity;
  178. return $this;
  179. }
  180. /**
  181. * Gets activity.
  182. *
  183. * @return Activity
  184. */
  185. public function getActivity()
  186. {
  187. return $this->activity;
  188. }
  189. /**
  190. * Set access
  191. *
  192. * @param \AppBundle\Entity\AccessAndFunction\Access $access
  193. *
  194. * @return OrganizationFunction
  195. */
  196. public function setAccess(\AppBundle\Entity\AccessAndFunction\Access $access)
  197. {
  198. $this->access = $access;
  199. return $this;
  200. }
  201. /**
  202. * Get access
  203. *
  204. * @return \AppBundle\Entity\AccessAndFunction\Access
  205. */
  206. public function getAccess()
  207. {
  208. return $this->access;
  209. }
  210. /**
  211. * Sets isMemberSection.
  212. *
  213. * @param bool $isMemberSection
  214. *
  215. * @return $this
  216. */
  217. public function setIsPhysical($isMemberSection)
  218. {
  219. $this->isMemberSection = $isMemberSection;
  220. return $this;
  221. }
  222. /**
  223. * Gets isMemberSection.
  224. *
  225. * @return bool
  226. */
  227. public function getIsPhysical()
  228. {
  229. return $this->isMemberSection;
  230. }
  231. /**
  232. * Set isMemberSection
  233. *
  234. * @param boolean $isMemberSection
  235. *
  236. * @return OrganizationFunction
  237. */
  238. public function setIsMemberSection($isMemberSection)
  239. {
  240. $this->isMemberSection = $isMemberSection;
  241. return $this;
  242. }
  243. /**
  244. * Get isMemberSection
  245. *
  246. * @return boolean
  247. */
  248. public function getIsMemberSection()
  249. {
  250. return $this->isMemberSection;
  251. }
  252. /**
  253. * @return array
  254. * @throws \Exception
  255. */
  256. public function getFullLabelTemplate()
  257. {
  258. $startDate = new \DateTime($this->getStartDate());
  259. $fullLabelTemplate = [
  260. ['value' => $this->getFunctionType()->getMission(), 'translate' => true],
  261. $startDate->format('d-m-Y')
  262. ];
  263. if(!empty($this->getEndDate())){
  264. $endDate = new \DateTime($this->getEndDate());
  265. $fullLabelTemplate[] = $endDate->format('d-m-Y');
  266. }
  267. return $fullLabelTemplate;
  268. }
  269. }