Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

378 lines
8.6KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * @ORM\MappedSuperclass()
  6. */
  7. abstract class Address extends AbstractEntity
  8. {
  9. const TYPE_INDIVIDUAL = 'individual';
  10. const TYPE_LEGAL_PERSON = 'legal-person';
  11. /**
  12. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="addresses")
  13. * @ORM\JoinColumn(nullable=true)
  14. */
  15. protected $user;
  16. /**
  17. * @ORM\Column(type="string", length=255)
  18. */
  19. protected $title;
  20. /**
  21. * @ORM\Column(type="string", length=31)
  22. */
  23. protected $type;
  24. /**
  25. * @ORM\Column(type="boolean", nullable=true)
  26. */
  27. protected $civility;
  28. /**
  29. * @ORM\Column(type="string", length=127, nullable=true)
  30. */
  31. protected $lastname;
  32. /**
  33. * @ORM\Column(type="string", length=127, nullable=true)
  34. */
  35. protected $firstname;
  36. /**
  37. * @ORM\Column(type="text")
  38. */
  39. protected $address;
  40. /**
  41. * @ORM\Column(type="string", length=31)
  42. */
  43. protected $zip;
  44. /**
  45. * @ORM\Column(type="string", length=255)
  46. */
  47. protected $city;
  48. /**
  49. * @ORM\Column(type="string", length=255)
  50. */
  51. protected $country;
  52. /**
  53. * @ORM\Column(type="string", length=255, nullable=true)
  54. */
  55. protected $company;
  56. /**
  57. * @ORM\Column(type="string", length=127, nullable=true)
  58. */
  59. protected $siret;
  60. /**
  61. * @ORM\Column(type="string", length=127, nullable=true)
  62. */
  63. protected $tva;
  64. /**
  65. * @ORM\Column(type="array", nullable=true)
  66. */
  67. protected $phone;
  68. /**
  69. * @ORM\Column(type="text", nullable=true)
  70. */
  71. protected $comment;
  72. /**
  73. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", mappedBy="address", cascade={"persist", "remove"})
  74. */
  75. protected $pointSale;
  76. /**
  77. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", mappedBy="address", cascade={"persist", "remove"})
  78. */
  79. protected $merchant;
  80. /**
  81. * @ORM\Column(type="text", nullable=true)
  82. */
  83. protected $deliveryInfos;
  84. public function __construct()
  85. {
  86. $this->phone = [] ;
  87. }
  88. public function __toString()
  89. {
  90. return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity();
  91. }
  92. public function getSummaryShort()
  93. {
  94. return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity();
  95. }
  96. public function getSummary()
  97. {
  98. $html = '';
  99. if ($this->getTitle()) {
  100. $html .= $this->getTitle() . '<br />';
  101. }
  102. if ($this->getLastname() || $this->getFirstname()) {
  103. $html .= $this->getLastname() . ' ' . $this->getFirstname() . '<br />';
  104. }
  105. if ($this->getAddress()) {
  106. $html .= $this->getAddress() . '<br />';
  107. }
  108. if ($this->getZip() || $this->getCity()) {
  109. $html .= $this->getZip() . ' ' . $this->getCity() . '<br />';
  110. }
  111. if ($this->getPhone()) {
  112. foreach($this->getPhone() as $phone) {
  113. $html .= 'Tél. ' . $phone.'<br />';
  114. }
  115. }
  116. return $html;
  117. }
  118. public function getUser(): ?User
  119. {
  120. return $this->user;
  121. }
  122. public function setUser(?User $user): self
  123. {
  124. $this->user = $user;
  125. return $this;
  126. }
  127. public function getTitle(): ?string
  128. {
  129. return $this->title;
  130. }
  131. public function setTitle(string $title): self
  132. {
  133. $this->title = $title;
  134. return $this;
  135. }
  136. public function getType(): ?string
  137. {
  138. return $this->type;
  139. }
  140. public function setType(string $type): self
  141. {
  142. $this->type = $type;
  143. return $this;
  144. }
  145. public function getCivility(): ?bool
  146. {
  147. return $this->civility;
  148. }
  149. public function setCivility(?bool $civility): self
  150. {
  151. $this->civility = $civility;
  152. return $this;
  153. }
  154. public function getLastname(): ?string
  155. {
  156. return $this->lastname;
  157. }
  158. public function setLastname(?string $lastname): self
  159. {
  160. $this->lastname = $lastname;
  161. return $this;
  162. }
  163. public function getFirstname(): ?string
  164. {
  165. return $this->firstname;
  166. }
  167. public function setFirstname(?string $firstname): self
  168. {
  169. $this->firstname = $firstname;
  170. return $this;
  171. }
  172. public function getAddress(): ?string
  173. {
  174. return $this->address;
  175. }
  176. public function setAddress(string $address): self
  177. {
  178. $this->address = $address;
  179. return $this;
  180. }
  181. public function getZip(): ?string
  182. {
  183. return $this->zip;
  184. }
  185. public function setZip(string $zip): self
  186. {
  187. $this->zip = $zip;
  188. return $this;
  189. }
  190. public function getCity(): ?string
  191. {
  192. return $this->city;
  193. }
  194. public function setCity(string $city): self
  195. {
  196. $this->city = $city;
  197. return $this;
  198. }
  199. public function getCountry(): ?string
  200. {
  201. return $this->country;
  202. }
  203. public function setCountry(string $country): self
  204. {
  205. $this->country = $country;
  206. return $this;
  207. }
  208. public function getCompany(): ?string
  209. {
  210. return $this->company;
  211. }
  212. public function setCompany(?string $company): self
  213. {
  214. $this->company = $company;
  215. return $this;
  216. }
  217. public function getSiret(): ?string
  218. {
  219. return $this->siret;
  220. }
  221. public function setSiret(?string $siret): self
  222. {
  223. $this->siret = $siret;
  224. return $this;
  225. }
  226. public function getTva(): ?string
  227. {
  228. return $this->tva;
  229. }
  230. public function setTva(?string $tva): self
  231. {
  232. $this->tva = $tva;
  233. return $this;
  234. }
  235. public function getPhone(): ?array
  236. {
  237. return $this->phone;
  238. }
  239. public function setPhone(?array $phone): self
  240. {
  241. $this->phone = $phone;
  242. return $this;
  243. }
  244. public function getComment(): ?string
  245. {
  246. return $this->comment;
  247. }
  248. public function setComment(?string $comment): self
  249. {
  250. $this->comment = $comment;
  251. return $this;
  252. }
  253. public function getPointSale(): ?PointSale
  254. {
  255. return $this->pointSale;
  256. }
  257. public function setPointSale(PointSale $pointSale): self
  258. {
  259. $this->pointSale = $pointSale;
  260. // set the owning side of the relation if necessary
  261. if ($pointSale->getAddress() !== $this) {
  262. $pointSale->setAddress($this);
  263. }
  264. return $this;
  265. }
  266. public function getMerchant(): ?Merchant
  267. {
  268. return $this->merchant;
  269. }
  270. public function setMerchant(Merchant $merchant): self
  271. {
  272. $this->merchant = $merchant;
  273. // set the owning side of the relation if necessary
  274. if ($merchant->getAddress() !== $this) {
  275. $merchant->setAddress($this);
  276. }
  277. return $this;
  278. }
  279. public function getDeliveryInfos(): ?string
  280. {
  281. return $this->deliveryInfos;
  282. }
  283. public function setDeliveryInfos(?string $deliveryInfos): self
  284. {
  285. $this->deliveryInfos = $deliveryInfos;
  286. return $this;
  287. }
  288. }