AddressPostal.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <?php
  2. namespace AppBundle\Entity\Core;
  3. use AppBundle\Annotation\ExportSplitFields;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use AppBundle\Entity\Person\Person;
  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\Annotation\Confidentiality;
  13. use AppBundle\Validator\Constraints as OpentalentAssert;
  14. /**
  15. * Subclass of: ContactPoint Source: GoodRelationsProperties.
  16. * Coordonnées postales des Person, des Organization et des Places
  17. *
  18. * @Iri("http://schema.org/AddressPostal")
  19. */
  20. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Core\Repository\AddressPostalRepository')]
  21. #[ORM\Table(name: 'AddressPostal')]
  22. #[ORM\Index(name: 'viewIndex', columns: ['streetAddress', 'streetAddressSecond', 'streetAddressThird'])]
  23. class AddressPostal
  24. {
  25. use TimestampableEntity;
  26. use CreatorUpdaterEntity;
  27. /**
  28. * @var int
  29. */
  30. #[ORM\Column(type: 'integer')]
  31. #[ORM\Id]
  32. #[ORM\GeneratedValue(strategy: 'AUTO')]
  33. #[Groups(['addresspostal', 'organizationaddresspostal_reference', 'place_list', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'planning_list_addresspostal', 'board_list_person', 'place_reference', 'planning_list', 'placesystem_reference', 'organization_cotisation_steps_organizationaddresspostal'])]
  34. private $id;
  35. /**
  36. * @var Country
  37. */
  38. #[ORM\ManyToOne(targetEntity: 'Country')]
  39. #[Groups(['addresspostal', 'access_details_person', 'place_list_addresspostal', 'report_card_person', 'report_card_guardians', 'student_registration_person', 'student_registration_guardians', 'networkmanagers_list_person', 'access_duplicate_control_list_person', 'sepa_debit_mandate_person', 'student_list_guardians', 'organization_cotisation_steps_organizationaddresspostal', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'online_registration_access_details_person', 'build_bills_access', 'organization_params_list_organizationaddresspostal'])]
  40. private $addressCountry;
  41. /**
  42. * @var string
  43. *
  44. * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_PUBLIC)
  45. */
  46. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  47. #[Assert\Type(type: 'string')]
  48. #[Assert\Length(max: 100, maxMessage: 'invalid-max-length')]
  49. #[Groups(['addresspostal', 'access_details_person', 'morals_list_person', 'place_list_addresspostal', 'report_card_person', 'report_card_guardians', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'networkmanagers_list_person', 'place_reference_addresspostal', 'placesystem_reference_addresspostal', 'organization_details_organizationaddresspostal', 'all_accesses_list_person', 'payer_list_person', 'planning_detail_place', 'template', 'sepa_debit_mandate_person', 'student_list_guardians', 'organization_cotisation_steps_organizationaddresspostal', 'equipment_availability_form_borrower', 'activity_report', 'view_from_manager_create_person', 'planning_list', 'online_registration_access_details_person', 'cmf_network_organizations_organizationaddresspostalprincipal', 'build_bills_access', 'organization_params_list_organizationaddresspostal'])]
  50. private $addressCity;
  51. /**
  52. * @var string
  53. */
  54. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  55. #[Assert\Type(type: 'string')]
  56. #[Assert\Length(max: 100, maxMessage: 'invalid-max-length')]
  57. #[Groups(['addresspostal', 'organization_cotisation_steps_organizationaddresspostal'])]
  58. private $addressOwner;
  59. /**
  60. * @var string
  61. *
  62. * @OpentalentAssert\PostalCode
  63. * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_PUBLIC)
  64. */
  65. #[ORM\Column(type: 'string', length: 20, nullable: true)]
  66. #[Assert\Type(type: 'string')]
  67. #[Groups(['addresspostal', 'access_details_person', 'place_list_addresspostal', 'report_card_person', 'report_card_guardians', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'networkmanagers_list_person', 'place_reference_addresspostal', 'placesystem_reference_addresspostal', 'all_accesses_list_person', 'organization_details_organizationaddresspostal', 'payer_list_person', 'planning_detail_place', 'template', 'sepa_debit_mandate_person', 'student_list_guardians', 'organization_cotisation_steps_organizationaddresspostal', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'planning_list', 'online_registration_access_details_person', 'cmf_network_organizations_organizationaddresspostalprincipal', 'build_bills_access', 'organization_params_list_organizationaddresspostal'])]
  68. private $postalCode;
  69. /**
  70. * @var string
  71. *
  72. * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_PUBLIC)
  73. */
  74. #[ORM\Column(type: 'string', nullable: true)]
  75. #[Assert\Type(type: 'string')]
  76. #[Groups(['addresspostal', 'access_details_person', 'organizationaddresspostal_reference_addresspostal', 'place_list_addresspostal', 'report_card_person', 'report_card_guardians', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'networkmanagers_list_person', 'organization_details_organizationaddresspostal', 'all_accesses_list_person', 'payer_list_person', 'planning_detail_place', 'template', 'sepa_debit_mandate_person', 'student_list_guardians', 'organization_cotisation_steps_organizationaddresspostal', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'planning_list', 'online_registration_access_details_person', 'cmf_network_organizations_organizationaddresspostalprincipal', 'build_bills_access', 'organization_params_list_organizationaddresspostal'])]
  77. private $streetAddress;
  78. /**
  79. * @var string
  80. *
  81. * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_PUBLIC)
  82. */
  83. #[ORM\Column(type: 'string', nullable: true)]
  84. #[Assert\Type(type: 'string')]
  85. #[Groups(['addresspostal', 'access_details_person', 'organizationaddresspostal_reference_addresspostal', 'place_list_addresspostal', 'report_card_person', 'report_card_guardians', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'all_accesses_list_person', 'networkmanagers_list_person', 'organization_details_organizationaddresspostal', 'payer_list_person', 'planning_detail_place', 'template', 'sepa_debit_mandate_person', 'student_list_guardians', 'organization_cotisation_steps_organizationaddresspostal', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'planning_list', 'online_registration_access_details_person', 'cmf_network_organizations_organizationaddresspostalprincipal', 'build_bills_access', 'organization_params_list_organizationaddresspostal'])]
  86. private $streetAddressSecond;
  87. /**
  88. * @var string
  89. *
  90. * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_PUBLIC)
  91. */
  92. #[ORM\Column(type: 'string', nullable: true)]
  93. #[Assert\Type(type: 'string')]
  94. #[Groups(['addresspostal', 'access_details_person', 'organizationaddresspostal_reference_addresspostal', 'place_list_addresspostal', 'report_card_person', 'report_card_guardians', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'network_list_organizationaddresspostal', 'federations_list_organizationaddresspostal', 'networkmanagers_list_organization', 'network_artist_school_list_organizationaddresspostal', 'networkmanagers_list_person', 'organization_details_organizationaddresspostal', 'payer_list_person', 'all_accesses_list_person', 'planning_detail_place', 'template', 'sepa_debit_mandate_person', 'student_list_guardians', 'organization_cotisation_steps_organizationaddresspostal', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'planning_list', 'online_registration_access_details_person', 'cmf_network_organizations_organizationaddresspostalprincipal', 'build_bills_access', 'organization_params_list_organizationaddresspostal'])]
  95. private $streetAddressThird;
  96. /**
  97. * @var float
  98. */
  99. #[ORM\Column(type: 'float', nullable: true)]
  100. #[Assert\Type(type: 'float')]
  101. #[Groups(['addresspostal', 'organization_cotisation_steps_organizationaddresspostal'])]
  102. private $latitude;
  103. /**
  104. * @var float
  105. */
  106. #[ORM\Column(type: 'float', nullable: true)]
  107. #[Assert\Type(type: 'float')]
  108. #[Groups(['addresspostal', 'organization_cotisation_steps_organizationaddresspostal'])]
  109. private $longitude;
  110. /**
  111. * @var ArrayCollection<Place>
  112. */
  113. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Place\Place', mappedBy: 'addressPostal')]
  114. #[Groups(['addresspostal_place'])]
  115. private $places;
  116. /**
  117. * @var ArrayCollection<Place>
  118. */
  119. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Person\PersonAddressPostal', mappedBy: 'addressPostal')]
  120. private $personAddressPostal;
  121. /**
  122. * @var string
  123. * @ExportSplitFields({"streetAddress","streetAddressSecond","streetAddressThird","postalCode","addressCity"})
  124. */
  125. #[Groups(['template'])]
  126. private $fullLabelTemplate;
  127. /**
  128. * @var string
  129. */
  130. #[Groups(['template', 'addresspostal'])]
  131. private $addressPostalFormat;
  132. /**
  133. * Constructor
  134. */
  135. public function __construct()
  136. {
  137. $this->places = new ArrayCollection();
  138. $this->personAddressPostal = new ArrayCollection();
  139. }
  140. /**
  141. * Sets id.
  142. *
  143. * @param int $id
  144. *
  145. * @return $this
  146. */
  147. public function setId($id)
  148. {
  149. $this->id = $id;
  150. return $this;
  151. }
  152. /**
  153. * Gets id.
  154. *
  155. * @return int
  156. */
  157. public function getId()
  158. {
  159. return $this->id;
  160. }
  161. /**
  162. * Sets addressCountry.
  163. *
  164. * @param Country $addressCountry
  165. *
  166. * @return $this
  167. */
  168. public function setAddressCountry(Country $addressCountry = null)
  169. {
  170. $this->addressCountry = $addressCountry;
  171. return $this;
  172. }
  173. /**
  174. * Gets addressCountry.
  175. *
  176. * @return Country
  177. */
  178. public function getAddressCountry()
  179. {
  180. return $this->addressCountry;
  181. }
  182. /**
  183. * Sets addressCity.
  184. *
  185. * @param string $addressCity
  186. *
  187. * @return $this
  188. */
  189. public function setAddressCity($addressCity)
  190. {
  191. $this->addressCity = $addressCity;
  192. return $this;
  193. }
  194. /**
  195. * Gets addressCity.
  196. *
  197. * @return string
  198. */
  199. public function getAddressCity()
  200. {
  201. return $this->addressCity;
  202. }
  203. /**
  204. * Sets postalCode.
  205. *
  206. * @param string $postalCode
  207. *
  208. * @return $this
  209. */
  210. public function setPostalCode($postalCode)
  211. {
  212. $this->postalCode = $postalCode;
  213. return $this;
  214. }
  215. /**
  216. * Gets postalCode.
  217. *
  218. * @return string
  219. */
  220. public function getPostalCode()
  221. {
  222. return $this->postalCode;
  223. }
  224. /**
  225. * Sets streetAddress.
  226. *
  227. * @param string $streetAddress
  228. *
  229. * @return $this
  230. */
  231. public function setStreetAddress($streetAddress)
  232. {
  233. $this->streetAddress = $streetAddress;
  234. return $this;
  235. }
  236. /**
  237. * Gets streetAddress.
  238. *
  239. * @return string
  240. */
  241. public function getStreetAddress()
  242. {
  243. return $this->streetAddress;
  244. }
  245. /**
  246. * Sets streetAddressSecond.
  247. *
  248. * @param string $streetAddressSecond
  249. *
  250. * @return $this
  251. */
  252. public function setStreetAddressSecond($streetAddressSecond)
  253. {
  254. $this->streetAddressSecond = $streetAddressSecond;
  255. return $this;
  256. }
  257. /**
  258. * Gets streetAddressSecond.
  259. *
  260. * @return string
  261. */
  262. public function getStreetAddressSecond()
  263. {
  264. return $this->streetAddressSecond;
  265. }
  266. /**
  267. * Sets streetAddressThird.
  268. *
  269. * @param string $streetAddressThird
  270. *
  271. * @return $this
  272. */
  273. public function setStreetAddressThird($streetAddressThird)
  274. {
  275. $this->streetAddressThird = $streetAddressThird;
  276. return $this;
  277. }
  278. /**
  279. * Gets streetAddressThird.
  280. *
  281. * @return string
  282. */
  283. public function getStreetAddressThird()
  284. {
  285. return $this->streetAddressThird;
  286. }
  287. /**
  288. * Sets latitude.
  289. *
  290. * @param float $latitude
  291. *
  292. * @return $this
  293. */
  294. public function setLatitude($latitude)
  295. {
  296. $this->latitude = floatval($latitude);
  297. return $this;
  298. }
  299. /**
  300. * Gets latitude.
  301. *
  302. * @return float
  303. */
  304. public function getLatitude()
  305. {
  306. return $this->latitude;
  307. }
  308. /**
  309. * Sets longitude.
  310. *
  311. * @param float $longitude
  312. *
  313. * @return $this
  314. */
  315. public function setLongitude($longitude)
  316. {
  317. $this->longitude = floatval($longitude);
  318. return $this;
  319. }
  320. /**
  321. * Gets longitude.
  322. *
  323. * @return float
  324. */
  325. public function getLongitude()
  326. {
  327. return $this->longitude;
  328. }
  329. public function getLocation() {
  330. if (null === $this->getLatitude() || null === $this->getLongitude()) {
  331. return null;
  332. }
  333. return $this->getLatitude().','.$this->getLongitude();
  334. }
  335. /**
  336. * @return string
  337. */
  338. public function getAddressOwner()
  339. {
  340. return $this->addressOwner;
  341. }
  342. /**
  343. * @param string $addressOwner
  344. */
  345. public function setAddressOwner($addressOwner)
  346. {
  347. $this->addressOwner = $addressOwner;
  348. }
  349. /**
  350. * Add place
  351. *
  352. * @param \AppBundle\Entity\Place\Place $place
  353. *
  354. * @return AddressPostal
  355. */
  356. public function addPlace(\AppBundle\Entity\Place\Place $place)
  357. {
  358. $this->places[] = $place;
  359. return $this;
  360. }
  361. /**
  362. * Remove place
  363. *
  364. * @param \AppBundle\Entity\Place\Place $place
  365. */
  366. public function removePlace(\AppBundle\Entity\Place\Place $place)
  367. {
  368. $this->places->removeElement($place);
  369. }
  370. /**
  371. * Get places
  372. *
  373. * @return \Doctrine\Common\Collections\Collection
  374. */
  375. public function getPlaces()
  376. {
  377. return $this->places;
  378. }
  379. /**
  380. * Get person address postal
  381. *
  382. * @return \Doctrine\Common\Collections\Collection
  383. */
  384. public function getPersonAddressPostal()
  385. {
  386. return $this->personAddressPostal;
  387. }
  388. /**
  389. * Gets full label.
  390. *
  391. * @return string
  392. */
  393. public function getFullLabelTemplate()
  394. {
  395. $fullAddressArray = [];
  396. if(!empty($this->getStreetAddress()))
  397. $fullAddressArray[] = $this->getStreetAddress();
  398. if(!empty($this->getStreetAddressSecond()))
  399. $fullAddressArray[] = $this->getStreetAddressSecond();
  400. if(!empty($this->getStreetAddressThird()))
  401. $fullAddressArray[] = $this->getStreetAddressThird();
  402. if(!empty($this->getPostalCode()))
  403. $fullAddressArray[] = $this->getPostalCode();
  404. if(!empty($this->getAddressCity()))
  405. $fullAddressArray[] = $this->getAddressCity();
  406. return implode(" ", $fullAddressArray);
  407. }
  408. /**
  409. * Gets full label.
  410. *
  411. * @return string
  412. */
  413. public function getAddressPostalFormat()
  414. {
  415. $fullAddressArray = [];
  416. if(!empty($this->getStreetAddress()))
  417. $fullAddressArray[] = $this->getStreetAddress();
  418. if(!empty($this->getStreetAddressSecond()))
  419. $fullAddressArray[] = $this->getStreetAddressSecond();
  420. if(!empty($this->getStreetAddressThird()))
  421. $fullAddressArray[] = $this->getStreetAddressThird();
  422. $cityAndPostCodeArray = [];
  423. if(!empty($this->getPostalCode()))
  424. $cityAndPostCodeArray[] = $this->getPostalCode();
  425. if(!empty($this->getAddressCity()))
  426. $cityAndPostCodeArray[] = $this->getAddressCity();
  427. $fullAddressArray[] = implode(" ", $cityAndPostCodeArray);
  428. return implode("<br />", $fullAddressArray);
  429. }
  430. /**
  431. * Add personAddressPostal
  432. *
  433. * @param \AppBundle\Entity\Person\PersonAddressPostal $personAddressPostal
  434. *
  435. * @return AddressPostal
  436. */
  437. public function addPersonAddressPostal(\AppBundle\Entity\Person\PersonAddressPostal $personAddressPostal)
  438. {
  439. $this->personAddressPostal[] = $personAddressPostal;
  440. return $this;
  441. }
  442. /**
  443. * Remove personAddressPostal
  444. *
  445. * @param \AppBundle\Entity\Person\PersonAddressPostal $personAddressPostal
  446. */
  447. public function removePersonAddressPostal(\AppBundle\Entity\Person\PersonAddressPostal $personAddressPostal)
  448. {
  449. $this->personAddressPostal->removeElement($personAddressPostal);
  450. }
  451. }