src/Entity/System/Address.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\System\AddressRepository")
  6.  *
  7.  * @ORM\Table(name="ps_address")
  8.  */
  9. class Address
  10. {
  11.     public const TYPE_INDIVIDUAL 1;
  12.     public const TYPE_SELF_EMPLOYED 2;
  13.     public const TYPE_COMPANY 3;
  14.     public const CUSTOMER_TYPE_IDS_INDEXED_BY_TYPE_VALUES = [
  15.         'INDIVIDUAL' => self::TYPE_INDIVIDUAL,
  16.         'SELF_EMPLOYED' => self::TYPE_SELF_EMPLOYED,
  17.         'COMPANY' => self::TYPE_COMPANY,
  18.     ];
  19.     /**
  20.      * @var int
  21.      *
  22.      * @ORM\Id
  23.      *
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      *
  26.      * @ORM\Column(type="integer", name="id_address")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @var Country
  31.      *
  32.      * @ORM\ManyToOne(targetEntity="App\Entity\System\Country", inversedBy="addresses")
  33.      *
  34.      * @ORM\JoinColumn(referencedColumnName="id_country", name="id_country")
  35.      */
  36.     private $country;
  37.     /**
  38.      * @var State|null
  39.      *
  40.      * @ORM\ManyToOne(targetEntity="App\Entity\System\State")
  41.      *
  42.      * @ORM\JoinColumn(referencedColumnName="id_state", name="id_state", nullable=true)
  43.      */
  44.     private $state;
  45.     /**
  46.      * @var string|null
  47.      *
  48.      * @ORM\Column(type="string", length=50, name="state_name", nullable=true)
  49.      */
  50.     private $stateName;
  51.     /**
  52.      * @var int|null
  53.      *
  54.      * @ORM\Column(type="integer", name="id_manufacturer", length=10, options={"default" : 0})
  55.      */
  56.     private $manufacturer;
  57.     /**
  58.      * @var string|null
  59.      *
  60.      * @ORM\Column(type="string", length=32, nullable=true)
  61.      */
  62.     private $alias;
  63.     /**
  64.      * @var string|null
  65.      *
  66.      * @ORM\Column(type="string", length=64, nullable=true)
  67.      */
  68.     private $company;
  69.     /**
  70.      * @var string|null
  71.      *
  72.      * @ORM\Column(type="string", length=32, nullable=true)
  73.      */
  74.     private $name;
  75.     /**
  76.      * @var string
  77.      *
  78.      * @ORM\Column(type="string", length=128)
  79.      */
  80.     private $email;
  81.     /**
  82.      * @var string|null
  83.      *
  84.      * @ORM\Column(type="string", length=32, nullable=true)
  85.      */
  86.     private $surnames;
  87.     /**
  88.      * @var string
  89.      *
  90.      * @ORM\Column(type="string", length=128)
  91.      */
  92.     private $address1;
  93.     /**
  94.      * @var string|null
  95.      *
  96.      * @ORM\Column(type="string", length=128, nullable=true)
  97.      */
  98.     private $address2;
  99.     /**
  100.      * @var string|null
  101.      *
  102.      * @ORM\Column(type="string", length=12, nullable=true)
  103.      */
  104.     private $postcode;
  105.     /**
  106.      * @var string
  107.      *
  108.      * @ORM\Column(type="string", length=64)
  109.      */
  110.     private $city;
  111.     /**
  112.      * @var string|null
  113.      *
  114.      * @ORM\Column(type="text", nullable=true)
  115.      */
  116.     private $other;
  117.     /**
  118.      * @var string|null
  119.      *
  120.      * @ORM\Column(type="string", length=32, nullable=true)
  121.      */
  122.     private $phone;
  123.     /**
  124.      * @var string|null
  125.      *
  126.      * @ORM\Column(type="string", length=32, nullable=true)
  127.      */
  128.     private $phoneMobile;
  129.     /**
  130.      * @var string|null
  131.      *
  132.      * @ORM\Column(type="string", length=32, nullable=true)
  133.      */
  134.     private $vatNumber;
  135.     /**
  136.      * @var \DateTime
  137.      *
  138.      * @ORM\Column(type="datetime")
  139.      */
  140.     private $dateAdd;
  141.     /**
  142.      * @var \DateTime
  143.      *
  144.      * @ORM\Column(type="datetime")
  145.      */
  146.     private $dateUpd;
  147.     /**
  148.      * @var bool
  149.      *
  150.      * @ORM\Column(type="boolean", options={"default" : 1})
  151.      */
  152.     private $active;
  153.     /**
  154.      * @var bool
  155.      *
  156.      * @ORM\Column(type="boolean", options={"default" : 0})
  157.      */
  158.     private $invoiceAddress;
  159.     /**
  160.      * @var bool
  161.      *
  162.      * @ORM\Column(type="boolean", options={"default" : 0})
  163.      */
  164.     private $defaultInvoiceAddress;
  165.     /**
  166.      * @var bool
  167.      *
  168.      * @ORM\Column(type="boolean", options={"default" : 0})
  169.      */
  170.     private $defaultShippingAddress;
  171.     /**
  172.      * @ORM\Column(type="boolean", nullable=true, options={"default" : 0})
  173.      */
  174.     private bool $vise;
  175.     /**
  176.      * @var bool|null
  177.      *
  178.      * @ORM\Column(type="boolean", length=4, nullable=true, options={"default" : 0})
  179.      */
  180.     private $re;
  181.     /**
  182.      * @var string|null
  183.      *
  184.      * @ORM\Column(type="string", length=3, nullable=true)
  185.      */
  186.     private $isoCode;
  187.     /**
  188.      * @var string|null
  189.      *
  190.      * @ORM\Column(type="string", length=128, nullable=true)
  191.      */
  192.     private $comercialName;
  193.     /**
  194.      * @var int|null
  195.      *
  196.      * @ORM\Column(type="integer",length=1, nullable=true, options={"default" : 1}))
  197.      */
  198.     private $typeCustomer;
  199.     /**
  200.      * @var string|null
  201.      *
  202.      * @ORM\Column(type="string", length=50, nullable=true, options={"default" : "1"})
  203.      */
  204.     private $contactName;
  205.     /**
  206.      * @var string|null
  207.      *
  208.      * @ORM\Column(type="string", length=50, nullable=true, options={"default" : "1"})
  209.      */
  210.     private $url;
  211.     /**
  212.      * @var int
  213.      *
  214.      * @ORM\Column(type="integer", length=10, options={"default" : 0})
  215.      */
  216.     private $phonePrefix;
  217.     /**
  218.      * @var int
  219.      *
  220.      * @ORM\Column(type="integer", length=10, options={"default" : 0})
  221.      */
  222.     private $phoneMobilePrefix;
  223.     /**
  224.      * @var int|null
  225.      *
  226.      * @ORM\Column(type="integer", length=4, nullable=true)
  227.      */
  228.     private $favorite;
  229.     /**
  230.      * @var string|null
  231.      *
  232.      * @ORM\Column(type="string", length=64, nullable=true)
  233.      */
  234.     private $companyName;
  235.     /**
  236.      * @var string|null
  237.      *
  238.      * @ORM\Column(type="string", length=3, nullable=true)
  239.      */
  240.     private $isoVatNumber;
  241.     /**
  242.      * @var Customer
  243.      *
  244.      * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer", inversedBy="addresses")
  245.      *
  246.      * @ORM\JoinColumn(name="id_customer", referencedColumnName="id_customer")
  247.      */
  248.     private $customer;
  249.     /**
  250.      * @ORM\Column(type="boolean", nullable=true, options={"default" : 0})
  251.      */
  252.     private bool $companyVerified false;
  253.     public function __construct()
  254.     {
  255.         $this->dateUpd = new \DateTime();
  256.         $this->active true;
  257.         $this->invoiceAddress true;
  258.         $this->defaultInvoiceAddress false;
  259.         $this->defaultShippingAddress false;
  260.         $this->vise false;
  261.         $this->re false;
  262.         $this->typeCustomer true;
  263.         $this->contactName '1';
  264.         $this->phonePrefix 0;
  265.         $this->phoneMobilePrefix 0;
  266.         $this->favorite 0;
  267.         $this->manufacturer 0;
  268.     }
  269.     public static function createEmptyInvoiceAddress(string $customerEmail, \DateTime $dateTime, ?State $state): Address
  270.     {
  271.         $address = new self();
  272.         $address->email $customerEmail;
  273.         $address->address1 '';
  274.         $address->city '';
  275.         $address->dateAdd $dateTime;
  276.         $address->state $state;
  277.         $address->defaultInvoiceAddress true;
  278.         $address->invoiceAddress true;
  279.         return $address;
  280.     }
  281.     /**
  282.      * @return int
  283.      */
  284.     public function getId(): int
  285.     {
  286.         return $this->id;
  287.     }
  288.     /**
  289.      * @param int $id
  290.      *
  291.      * @return Address
  292.      */
  293.     public function setId(int $id): Address
  294.     {
  295.         $this->id $id;
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Country
  300.      */
  301.     public function getCountry(): Country
  302.     {
  303.         return $this->country;
  304.     }
  305.     /**
  306.      * @param Country $country
  307.      *
  308.      * @return Address
  309.      */
  310.     public function setCountry(Country $country): Address
  311.     {
  312.         $this->country $country;
  313.         return $this;
  314.     }
  315.     /**
  316.      * @return State|null
  317.      */
  318.     public function getState(): ?State
  319.     {
  320.         if ($this->state && $this->state->getId() === 0) {
  321.             return null;
  322.         }
  323.         return $this->state;
  324.     }
  325.     /**
  326.      * @param State|null $state
  327.      *
  328.      * @return Address
  329.      */
  330.     public function setState(?State $state): Address
  331.     {
  332.         $this->state $state;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return string|null
  337.      */
  338.     public function getStateName(): ?string
  339.     {
  340.         return $this->stateName;
  341.     }
  342.     /**
  343.      * @param string|null $stateName
  344.      *
  345.      * @return Address
  346.      */
  347.     public function setStateName(?string $stateName): Address
  348.     {
  349.         $this->stateName $stateName;
  350.         return $this;
  351.     }
  352.     /**
  353.      * @return string|null
  354.      */
  355.     public function getAlias(): ?string
  356.     {
  357.         return $this->alias;
  358.     }
  359.     /**
  360.      * @param string|null $alias
  361.      *
  362.      * @return Address
  363.      */
  364.     public function setAlias(?string $alias): Address
  365.     {
  366.         $this->alias $alias;
  367.         return $this;
  368.     }
  369.     /**
  370.      * @return string|null
  371.      */
  372.     public function getCompany(): ?string
  373.     {
  374.         return $this->company;
  375.     }
  376.     /**
  377.      * @param string|null $company
  378.      *
  379.      * @return Address
  380.      */
  381.     public function setCompany(?string $company): Address
  382.     {
  383.         $this->company $company;
  384.         return $this;
  385.     }
  386.     /**
  387.      * @return string|null
  388.      */
  389.     public function getName(): ?string
  390.     {
  391.         return $this->name;
  392.     }
  393.     /**
  394.      * @param string|null $name
  395.      *
  396.      * @return Address
  397.      */
  398.     public function setName(?string $name): Address
  399.     {
  400.         $this->name $name;
  401.         return $this;
  402.     }
  403.     /**
  404.      * @return string
  405.      */
  406.     public function getEmail(): string
  407.     {
  408.         return $this->email;
  409.     }
  410.     /**
  411.      * @param string $email
  412.      *
  413.      * @return Address
  414.      */
  415.     public function setEmail(string $email): Address
  416.     {
  417.         $this->email $email;
  418.         return $this;
  419.     }
  420.     /**
  421.      * @return string|null
  422.      */
  423.     public function getSurnames(): ?string
  424.     {
  425.         return $this->surnames;
  426.     }
  427.     /**
  428.      * @param string|null $surnames
  429.      *
  430.      * @return Address
  431.      */
  432.     public function setSurnames(?string $surnames): Address
  433.     {
  434.         $this->surnames $surnames;
  435.         return $this;
  436.     }
  437.     /**
  438.      * @return string
  439.      */
  440.     public function getAddress1(): string
  441.     {
  442.         return $this->address1;
  443.     }
  444.     /**
  445.      * @param string $address1
  446.      *
  447.      * @return Address
  448.      */
  449.     public function setAddress1(string $address1): Address
  450.     {
  451.         $this->address1 $address1;
  452.         return $this;
  453.     }
  454.     /**
  455.      * @return string|null
  456.      */
  457.     public function getAddress2(): ?string
  458.     {
  459.         return $this->address2;
  460.     }
  461.     /**
  462.      * @param string|null $address2
  463.      *
  464.      * @return Address
  465.      */
  466.     public function setAddress2(?string $address2): Address
  467.     {
  468.         $this->address2 $address2;
  469.         return $this;
  470.     }
  471.     /**
  472.      * @return string|null
  473.      */
  474.     public function getPostcode(): ?string
  475.     {
  476.         return $this->postcode;
  477.     }
  478.     /**
  479.      * @param string|null $postcode
  480.      *
  481.      * @return Address
  482.      */
  483.     public function setPostcode(?string $postcode): Address
  484.     {
  485.         $this->postcode $postcode;
  486.         return $this;
  487.     }
  488.     /**
  489.      * @return string
  490.      */
  491.     public function getCity(): string
  492.     {
  493.         return $this->city;
  494.     }
  495.     /**
  496.      * @param string $city
  497.      *
  498.      * @return Address
  499.      */
  500.     public function setCity(string $city): Address
  501.     {
  502.         $this->city $city;
  503.         return $this;
  504.     }
  505.     /**
  506.      * @return string|null
  507.      */
  508.     public function getOther(): ?string
  509.     {
  510.         return $this->other;
  511.     }
  512.     /**
  513.      * @param string|null $other
  514.      *
  515.      * @return Address
  516.      */
  517.     public function setOther(?string $other): Address
  518.     {
  519.         $this->other $other;
  520.         return $this;
  521.     }
  522.     /**
  523.      * @return string|null
  524.      */
  525.     public function getPhone(): ?string
  526.     {
  527.         return $this->phone;
  528.     }
  529.     /**
  530.      * @param string|null $phone
  531.      *
  532.      * @return Address
  533.      */
  534.     public function setPhone(?string $phone): Address
  535.     {
  536.         $this->phone $phone;
  537.         return $this;
  538.     }
  539.     /**
  540.      * @return string|null
  541.      */
  542.     public function getPhoneMobile(): ?string
  543.     {
  544.         return $this->phoneMobile;
  545.     }
  546.     /**
  547.      * @param string|null $phoneMobile
  548.      *
  549.      * @return Address
  550.      */
  551.     public function setPhoneMobile(?string $phoneMobile): Address
  552.     {
  553.         $this->phoneMobile $phoneMobile;
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return string|null
  558.      */
  559.     public function getVatNumber(): ?string
  560.     {
  561.         return $this->vatNumber;
  562.     }
  563.     /**
  564.      * @param string|null $vatNumber
  565.      *
  566.      * @return Address
  567.      */
  568.     public function setVatNumber(?string $vatNumber): Address
  569.     {
  570.         $this->vatNumber preg_replace('/[^A-Za-z0-9]/i'''$vatNumber);
  571.         return $this;
  572.     }
  573.     /**
  574.      * @return \DateTime
  575.      */
  576.     public function getDateAdd(): \DateTime
  577.     {
  578.         return $this->dateAdd;
  579.     }
  580.     /**
  581.      * @param \DateTime $dateAdd
  582.      *
  583.      * @return Address
  584.      */
  585.     public function setDateAdd(\DateTime $dateAdd): Address
  586.     {
  587.         $this->dateAdd $dateAdd;
  588.         return $this;
  589.     }
  590.     /**
  591.      * @return \DateTime
  592.      */
  593.     public function getDateUpd(): \DateTime
  594.     {
  595.         return $this->dateUpd;
  596.     }
  597.     /**
  598.      * @param \DateTime $dateUpd
  599.      *
  600.      * @return Address
  601.      */
  602.     public function setDateUpd(\DateTime $dateUpd): Address
  603.     {
  604.         $this->dateUpd $dateUpd;
  605.         return $this;
  606.     }
  607.     /**
  608.      * @return bool
  609.      */
  610.     public function isActive(): bool
  611.     {
  612.         return $this->active;
  613.     }
  614.     /**
  615.      * @param bool $active
  616.      *
  617.      * @return Address
  618.      */
  619.     public function setActive(bool $active): Address
  620.     {
  621.         $this->active $active;
  622.         return $this;
  623.     }
  624.     /**
  625.      * @return bool
  626.      */
  627.     public function isInvoiceAddress(): bool
  628.     {
  629.         return $this->invoiceAddress;
  630.     }
  631.     /**
  632.      * @param bool $invoiceAddress
  633.      *
  634.      * @return Address
  635.      */
  636.     public function setInvoiceAddress(bool $invoiceAddress): Address
  637.     {
  638.         $this->invoiceAddress $invoiceAddress;
  639.         return $this;
  640.     }
  641.     /**
  642.      * @return bool
  643.      */
  644.     public function isDefaultInvoiceAddress(): bool
  645.     {
  646.         return $this->defaultInvoiceAddress;
  647.     }
  648.     /**
  649.      * @param bool $defaultInvoiceAddress
  650.      *
  651.      * @return Address
  652.      */
  653.     public function setDefaultInvoiceAddress(bool $defaultInvoiceAddress): Address
  654.     {
  655.         $this->defaultInvoiceAddress $defaultInvoiceAddress;
  656.         return $this;
  657.     }
  658.     /**
  659.      * @return bool
  660.      */
  661.     public function isDefaultShippingAddress(): bool
  662.     {
  663.         return $this->defaultShippingAddress;
  664.     }
  665.     /**
  666.      * @param bool $defaultShippingAddress
  667.      *
  668.      * @return Address
  669.      */
  670.     public function setDefaultShippingAddress(bool $defaultShippingAddress): Address
  671.     {
  672.         $this->defaultShippingAddress $defaultShippingAddress;
  673.         return $this;
  674.     }
  675.     /**
  676.      * @return bool|null
  677.      */
  678.     public function getVise(): ?bool
  679.     {
  680.         return $this->vise;
  681.     }
  682.     /**
  683.      * @param bool|null $vise
  684.      *
  685.      * @return Address
  686.      */
  687.     public function setVise(?bool $vise): Address
  688.     {
  689.         $this->vise $vise;
  690.         return $this;
  691.     }
  692.     public function getRe(): ?bool
  693.     {
  694.         return $this->re;
  695.     }
  696.     public function setRe(?bool $re): Address
  697.     {
  698.         $this->re $re;
  699.         return $this;
  700.     }
  701.     /**
  702.      * @return string|null
  703.      */
  704.     public function getIsoCode(): ?string
  705.     {
  706.         return $this->isoCode;
  707.     }
  708.     /**
  709.      * @param string|null $isoCode
  710.      *
  711.      * @return Address
  712.      */
  713.     public function setIsoCode(?string $isoCode): Address
  714.     {
  715.         $this->isoCode $isoCode;
  716.         return $this;
  717.     }
  718.     /**
  719.      * @return string|null
  720.      */
  721.     public function getComercialName(): ?string
  722.     {
  723.         return $this->comercialName;
  724.     }
  725.     /**
  726.      * @param string|null $comercialName
  727.      *
  728.      * @return Address
  729.      */
  730.     public function setComercialName(?string $comercialName): Address
  731.     {
  732.         $this->comercialName $comercialName;
  733.         return $this;
  734.     }
  735.     /**
  736.      * @return int|null
  737.      */
  738.     public function getTypeCustomer(): ?int
  739.     {
  740.         return $this->typeCustomer;
  741.     }
  742.     /**
  743.      * @param int $typeCustomer
  744.      *
  745.      * @return Address
  746.      */
  747.     public function setTypeCustomer(int $typeCustomer): Address
  748.     {
  749.         $this->typeCustomer $typeCustomer;
  750.         return $this;
  751.     }
  752.     /**
  753.      * @return string|null
  754.      */
  755.     public function getContactName(): ?string
  756.     {
  757.         return $this->contactName;
  758.     }
  759.     /**
  760.      * @param string|null $contactName
  761.      *
  762.      * @return Address
  763.      */
  764.     public function setContactName(?string $contactName): Address
  765.     {
  766.         $this->contactName $contactName;
  767.         return $this;
  768.     }
  769.     /**
  770.      * @return string|null
  771.      */
  772.     public function getUrl(): ?string
  773.     {
  774.         return $this->url;
  775.     }
  776.     /**
  777.      * @param string|null $url
  778.      *
  779.      * @return Address
  780.      */
  781.     public function setUrl(?string $url): Address
  782.     {
  783.         $this->url $url;
  784.         return $this;
  785.     }
  786.     /**
  787.      * @return int
  788.      */
  789.     public function getPhonePrefix(): int
  790.     {
  791.         return $this->phonePrefix;
  792.     }
  793.     /**
  794.      * @param int $phonePrefix
  795.      *
  796.      * @return Address
  797.      */
  798.     public function setPhonePrefix(int $phonePrefix): Address
  799.     {
  800.         $this->phonePrefix $phonePrefix;
  801.         return $this;
  802.     }
  803.     /**
  804.      * @return int
  805.      */
  806.     public function getPhoneMobilePrefix(): int
  807.     {
  808.         return $this->phoneMobilePrefix;
  809.     }
  810.     /**
  811.      * @param int $phoneMobilePrefix
  812.      *
  813.      * @return Address
  814.      */
  815.     public function setPhoneMobilePrefix(int $phoneMobilePrefix): Address
  816.     {
  817.         $this->phoneMobilePrefix $phoneMobilePrefix;
  818.         return $this;
  819.     }
  820.     /**
  821.      * @return int|null
  822.      */
  823.     public function getFavorite(): ?int
  824.     {
  825.         return $this->favorite;
  826.     }
  827.     /**
  828.      * @param int|null $favorite
  829.      *
  830.      * @return Address
  831.      */
  832.     public function setFavorite(?int $favorite): Address
  833.     {
  834.         $this->favorite $favorite;
  835.         return $this;
  836.     }
  837.     /**
  838.      * @return string|null
  839.      */
  840.     public function getCompanyName(): ?string
  841.     {
  842.         return $this->companyName;
  843.     }
  844.     /**
  845.      * @param string|null $companyName
  846.      *
  847.      * @return Address
  848.      */
  849.     public function setCompanyName(?string $companyName): Address
  850.     {
  851.         $this->companyName $companyName;
  852.         return $this;
  853.     }
  854.     public function getCustomer(): ?Customer
  855.     {
  856.         return $this->customer;
  857.     }
  858.     public function setCustomer(?Customer $customer): self
  859.     {
  860.         $this->customer $customer;
  861.         return $this;
  862.     }
  863.     /**
  864.      * @return int|null
  865.      */
  866.     public function getManufacturer(): ?int
  867.     {
  868.         return $this->manufacturer;
  869.     }
  870.     /**
  871.      * @param int|null $manufacturer
  872.      *
  873.      * @return Address
  874.      */
  875.     public function setManufacturer(?int $manufacturer): self
  876.     {
  877.         $this->manufacturer $manufacturer;
  878.         return $this;
  879.     }
  880.     /**
  881.      * @return string|null
  882.      */
  883.     public function getIsoVatNumber(): ?string
  884.     {
  885.         return $this->isoVatNumber;
  886.     }
  887.     /**
  888.      * @param string|null $isoVatNumber
  889.      *
  890.      * @return Address
  891.      */
  892.     public function setIsoVatNumber(?string $isoVatNumber): self
  893.     {
  894.         $this->isoVatNumber $isoVatNumber;
  895.         return $this;
  896.     }
  897.     public function isCompanyVerified(): bool
  898.     {
  899.         return $this->companyVerified;
  900.     }
  901.     public function setCompanyVerified(bool $companyVerified): Address
  902.     {
  903.         $this->companyVerified $companyVerified;
  904.         return $this;
  905.     }
  906.     public function getFullName(): ?string
  907.     {
  908.         return $this->name.' '.$this->surnames;
  909.     }
  910. }