You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 satır
7.6KB

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