src/Entity/Address.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use AppBundle\Entity\Article;
  10. use FOS\UserBundle\Model\User as BaseUser;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * @ORM\Entity
  15.  * @ORM\Table(name="user_address")
  16.  * @ORM\HasLifecycleCallbacks
  17.  */
  18. class Address implements BlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  19.     use BlameableTrait;
  20.     use TimestampableTrait;
  21.     
  22.     use SoftDeletableTrait;
  23.     
  24. //powiązane z kontem użytkownika
  25.     const ADDRESS_TYPE_DELIVERY 'delivery';
  26.     const ADDRESS_TYPE_INVOICE 'invoice';
  27.     //powiązane już z konkretnym adresem z zamówienia
  28.     const ADDRESS_TYPE_ORDER 'delivery_order';
  29.     const ADDRESS_TYPE_ORDER_INVOICE 'invoice_order';
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\Column(type="integer")
  33.      * @ORM\GeneratedValue(strategy="AUTO")
  34.      */
  35.     protected $id;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="address")
  38.      */
  39.     private $user;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="App\Entity\Order", inversedBy="address")
  42.      */
  43.     private $order;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity="App\Entity\RoJudet")
  46.      */
  47.     private $roJudet;
  48.     /**
  49.      * @var string
  50.      *
  51.      * @ORM\Column(name="street", type="string", length=255, nullable=true)
  52.      * @Assert\NotBlank(message = "Wpisz nazwę ulicy")
  53.      */
  54.     protected $street;
  55.     /**
  56.      * @var string
  57.      *
  58.      * @ORM\Column(name="firstname", type="string", length=255, nullable=true)
  59.      */
  60.     private $firstname;
  61.     /**
  62.      * @var string
  63.      *
  64.      * @ORM\Column(name="surname", type="string", length=255, nullable=true)
  65.      */
  66.     private $surname;
  67.     /**
  68.      * @var string
  69.      *
  70.      * @ORM\Column(name="street_housenum", type="string", length=255, nullable=true)
  71.      */
  72.     protected $streetHousenum;
  73.     /**
  74.      * @var string
  75.      *
  76.      * @ORM\Column(name="street_flatnum", type="string", length=255, nullable=true)
  77.      */
  78.     protected $streetFlatnum;
  79.     /**
  80.      * @var string
  81.      *
  82.      * @ORM\Column(name="citycode", type="string", length=255, nullable=true)
  83.      */
  84.     protected $citycode;
  85.     /**
  86.      * @var string
  87.      *
  88.      * @ORM\Column(name="city", type="string", length=255, nullable=true)
  89.      * @Assert\NotBlank(message = "Wpisz nazwę miejscowości")
  90.      */
  91.     protected $city;
  92.     /**
  93.      * @var string
  94.      *
  95.      * @ORM\Column(name="mail", type="string", length=255, nullable=true)
  96.      */
  97.     protected $mail;
  98.     /**
  99.      * @var string
  100.      *
  101.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  102.      */
  103.     protected $email;
  104.     /**
  105.      * @var string
  106.      *
  107.      * @ORM\Column(name="telephone", type="string", length=255, nullable=true)
  108.      */
  109.     private $telephone;
  110.     /**
  111.      * @ORM\ManyToOne(targetEntity="App\Entity\Country")
  112.      * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
  113.      */
  114.     protected $country;
  115.     /**
  116.      * Domyślny
  117.      * @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true, options={"default"=0})
  118.      */
  119.     protected $isDefault;
  120.     /**
  121.      * @var string
  122.      *
  123.      * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
  124.      */
  125.     private $companyName;
  126.     /**
  127.      * @var string
  128.      *
  129.      * @ORM\Column(name="vat_id", type="string", length=255, nullable=true)
  130.      */
  131.     private $vatId;
  132.     /**
  133.      * @var string
  134.      *
  135.      * @ORM\Column(name="regon", type="string", length=255, nullable=true)
  136.      */
  137.     private $regon;
  138.     /**
  139.      * @var string
  140.      *
  141.      * @ORM\Column(name="bank_account", type="string", length=255, nullable=true)
  142.      */
  143.     private $bankAccount;
  144.     /**
  145.      * @var string
  146.      *
  147.      * @ORM\Column(name="iban", type="string", length=255, nullable=true)
  148.      */
  149.     private $iban;
  150.     /**
  151.      * @var string
  152.      *
  153.      * @ORM\Column(name="address_type", type="string", length=255, nullable=true)
  154.      */
  155.     private $addressType;
  156.     public function getCustomerId() {
  157.         if ($this->getVatId()) {
  158.             return $this->getVatId();
  159.         }
  160.         return 'brak';
  161.     }
  162.     public function jpkAddress() {
  163.         $beginning '';
  164.         $address $beginning.''.$this->street ' ' $this->streetHousenum '<br/>'.
  165.             ( $this->streetFlatnum '/' $this->streetFlatnum '' )
  166.             . ' ' $this->citycode ' ' $this->city
  167.         ;
  168.         return $address;
  169.     }
  170.     public function getCustomerName() {
  171.         if ($this->getCompanyName()) {
  172.             return $this->getCompanyName();
  173.         }
  174.         return $this->getFirstname().' '.$this->getSurname();
  175.     }
  176.     public function __construct()
  177.     {
  178.         $this->addressType self::ADDRESS_TYPE_DELIVERY;
  179.     }
  180.     public function __toString()
  181.     {
  182.         $adres $this->firstname.' '.$this->surname.'<br/>'.$this->street ' ' $this->streetHousenum '<br/>'.
  183.             ( $this->streetFlatnum '/' $this->streetFlatnum '' )
  184.             . '' $this->citycode ' ' $this->city;
  185.         if ($this->getRoJudet()) {
  186.             $adres .= '<br/>Județ: '.$this->getRoJudet()->getName();
  187.         }
  188.         return $adres;
  189.     }
  190.     public function getInvoiceAddress($locale 'pl') {
  191.         if ($this->companyName) {
  192.             $beginning $this->companyName;
  193.         } else {
  194.             $beginning $this->firstname.' '.$this->surname;
  195.         }
  196.         $address $beginning.'<br/>'.$this->street ' ' $this->streetHousenum '<br/>'.
  197.             ( $this->streetFlatnum '/' $this->streetFlatnum '' )
  198.             . '' $this->citycode ' ' $this->city
  199.         ;
  200.         if ($this->getRoJudet()) {
  201.             $address .= '<br/>Județ: '.$this->getRoJudet()->getName();
  202.         }
  203.         if ($locale == 'pl') {
  204.             if ($this->vatId) {
  205.                 $address .= '<br/>NIP: '.$this->vatId;
  206.             }
  207.         } elseif ($locale == 'ro') {
  208.             if ($this->vatId) {
  209.                 $address .= '<br/>CIF: '.$this->vatId;
  210.             }
  211.             if ($this->regon) {
  212.                 $address .= '<br/>Nr.ord.Reg.Com: '.$this->regon;
  213.             }
  214.             if ($this->bankAccount) {
  215.                 $address .= '<br/>Bancă: '.$this->bankAccount;
  216.             }
  217.             if ($this->iban) {
  218.                 $address .= '<br/>Cont IBAN: '.$this->iban;
  219.             }
  220.         } elseif ($locale == 'cz') {
  221.             if ($this->vatId) {
  222.                 $address .= '<br/>DIČ: '.$this->vatId;
  223.             }
  224.             if ($this->regon) {
  225.                 $address .= '<br/>IČO: '.$this->regon;
  226.             }
  227.         }
  228.         return $address;
  229.     }
  230.     /**
  231.      * Set street
  232.      *
  233.      * @param string $street
  234.      *
  235.      * @return Address
  236.      */
  237.     public function setStreet($street)
  238.     {
  239.         $this->street $street;
  240.         return $this;
  241.     }
  242.     /**
  243.      * Get street
  244.      *
  245.      * @return string
  246.      */
  247.     public function getStreet()
  248.     {
  249.         return $this->street;
  250.     }
  251.     /**
  252.      * Set citycode
  253.      *
  254.      * @param string $citycode
  255.      *
  256.      * @return Address
  257.      */
  258.     public function setCitycode($citycode)
  259.     {
  260.         $this->citycode $citycode;
  261.         return $this;
  262.     }
  263.     /**
  264.      * Get citycode
  265.      *
  266.      * @return string
  267.      */
  268.     public function getCitycode()
  269.     {
  270.         return $this->citycode;
  271.     }
  272.     /**
  273.      * Set city
  274.      *
  275.      * @param string $city
  276.      *
  277.      * @return Address
  278.      */
  279.     public function setCity($city)
  280.     {
  281.         $this->city $city;
  282.         return $this;
  283.     }
  284.     /**
  285.      * Get city
  286.      *
  287.      * @return string
  288.      */
  289.     public function getCity()
  290.     {
  291.         return $this->city;
  292.     }
  293.     /**
  294.      * Set mail
  295.      *
  296.      * @param string $mail
  297.      *
  298.      * @return Address
  299.      */
  300.     public function setMail($mail)
  301.     {
  302.         $this->mail $mail;
  303.         return $this;
  304.     }
  305.     /**
  306.      * Get mail
  307.      *
  308.      * @return string
  309.      */
  310.     public function getMail()
  311.     {
  312.         return $this->mail;
  313.     }
  314.     /**
  315.      * Set telephone
  316.      *
  317.      * @param string $telephone
  318.      *
  319.      * @return Address
  320.      */
  321.     public function setTelephone($telephone)
  322.     {
  323.         $this->telephone $telephone;
  324.         return $this;
  325.     }
  326.     /**
  327.      * Get telephone
  328.      *
  329.      * @return string
  330.      */
  331.     public function getTelephone()
  332.     {
  333.         return $this->telephone;
  334.     }
  335.     /**
  336.      * Set country
  337.      *
  338.      * @param string $country
  339.      *
  340.      * @return Address
  341.      */
  342.     public function setCountry($country)
  343.     {
  344.         $this->country $country;
  345.         return $this;
  346.     }
  347.     /**
  348.      * Get country
  349.      *
  350.      * @return string
  351.      */
  352.     public function getCountry()
  353.     {
  354.         return $this->country;
  355.     }
  356.     /**
  357.      * Set user
  358.      *
  359.      * @param \App\Entity\User $user
  360.      *
  361.      * @return Address
  362.      */
  363.     public function setUser(\App\Entity\User $user null)
  364.     {
  365.         $this->user $user;
  366.         return $this;
  367.     }
  368.     /**
  369.      * Get user
  370.      *
  371.      * @return \App\Entity\User
  372.      */
  373.     public function getUser()
  374.     {
  375.         return $this->user;
  376.     }
  377.     /**
  378.      * Get id
  379.      *
  380.      * @return integer
  381.      */
  382.     public function getId()
  383.     {
  384.         return $this->id;
  385.     }
  386.     /**
  387.      * Set streetHousenum
  388.      *
  389.      * @param string $streetHousenum
  390.      *
  391.      * @return Address
  392.      */
  393.     public function setStreetHousenum($streetHousenum)
  394.     {
  395.         $this->streetHousenum $streetHousenum;
  396.         return $this;
  397.     }
  398.     /**
  399.      * Get streetHousenum
  400.      *
  401.      * @return string
  402.      */
  403.     public function getStreetHousenum()
  404.     {
  405.         return $this->streetHousenum;
  406.     }
  407.     /**
  408.      * Set streetFlatnum
  409.      *
  410.      * @param string $streetFlatnum
  411.      *
  412.      * @return Address
  413.      */
  414.     public function setStreetFlatnum($streetFlatnum)
  415.     {
  416.         $this->streetFlatnum $streetFlatnum;
  417.         return $this;
  418.     }
  419.     /**
  420.      * Get streetFlatnum
  421.      *
  422.      * @return string
  423.      */
  424.     public function getStreetFlatnum()
  425.     {
  426.         return $this->streetFlatnum;
  427.     }
  428.     /**
  429.      * Set email
  430.      *
  431.      * @param string $email
  432.      *
  433.      * @return Address
  434.      */
  435.     public function setEmail($email)
  436.     {
  437.         $this->email $email;
  438.         return $this;
  439.     }
  440.     /**
  441.      * Get email
  442.      *
  443.      * @return string
  444.      */
  445.     public function getEmail()
  446.     {
  447.         return $this->email;
  448.     }
  449.     /**
  450.      * Set isDefault
  451.      *
  452.      * @param boolean $isDefault
  453.      *
  454.      * @return Address
  455.      */
  456.     public function setIsDefault($isDefault)
  457.     {
  458.         $this->isDefault $isDefault;
  459.         return $this;
  460.     }
  461.     /**
  462.      * Get isDefault
  463.      *
  464.      * @return boolean
  465.      */
  466.     public function getIsDefault()
  467.     {
  468.         return $this->isDefault;
  469.     }
  470.     /**
  471.      * Set companyName
  472.      *
  473.      * @param string $companyName
  474.      *
  475.      * @return Address
  476.      */
  477.     public function setCompanyName($companyName)
  478.     {
  479.         $this->companyName $companyName;
  480.         return $this;
  481.     }
  482.     /**
  483.      * Get companyName
  484.      *
  485.      * @return string
  486.      */
  487.     public function getCompanyName()
  488.     {
  489.         return $this->companyName;
  490.     }
  491.     /**
  492.      * Set vatId
  493.      *
  494.      * @param string $vatId
  495.      *
  496.      * @return Address
  497.      */
  498.     public function setVatId($vatId)
  499.     {
  500.         $this->vatId $vatId;
  501.         return $this;
  502.     }
  503.     /**
  504.      * Get vatId
  505.      *
  506.      * @return string
  507.      */
  508.     public function getVatId()
  509.     {
  510.         return $this->vatId;
  511.     }
  512.     /**
  513.      * Set addressType
  514.      *
  515.      * @param string $addressType
  516.      *
  517.      * @return Address
  518.      */
  519.     public function setAddressType($addressType)
  520.     {
  521.         $this->addressType $addressType;
  522.         return $this;
  523.     }
  524.     /**
  525.      * Get addressType
  526.      *
  527.      * @return string
  528.      */
  529.     public function getAddressType()
  530.     {
  531.         return $this->addressType;
  532.     }
  533.     /**
  534.      * Set firstname
  535.      *
  536.      * @param string $firstname
  537.      *
  538.      * @return Address
  539.      */
  540.     public function setFirstname($firstname)
  541.     {
  542.         $this->firstname $firstname;
  543.         return $this;
  544.     }
  545.     /**
  546.      * Get firstname
  547.      *
  548.      * @return string
  549.      */
  550.     public function getFirstname()
  551.     {
  552.         return $this->firstname;
  553.     }
  554.     /**
  555.      * Set surname
  556.      *
  557.      * @param string $surname
  558.      *
  559.      * @return Address
  560.      */
  561.     public function setSurname($surname)
  562.     {
  563.         $this->surname $surname;
  564.         return $this;
  565.     }
  566.     /**
  567.      * Get surname
  568.      *
  569.      * @return string
  570.      */
  571.     public function getSurname()
  572.     {
  573.         return $this->surname;
  574.     }
  575.     /**
  576.      * @return string
  577.      */
  578.     public function getRegon()
  579.     {
  580.         return $this->regon;
  581.     }
  582.     /**
  583.      * @param string $regon
  584.      */
  585.     public function setRegon($regon)
  586.     {
  587.         $this->regon $regon;
  588.     }
  589.     /**
  590.      * @return string
  591.      */
  592.     public function getBankAccount()
  593.     {
  594.         return $this->bankAccount;
  595.     }
  596.     /**
  597.      * @param string $bankAccount
  598.      */
  599.     public function setBankAccount($bankAccount)
  600.     {
  601.         $this->bankAccount $bankAccount;
  602.     }
  603.     /**
  604.      * @return string
  605.      */
  606.     public function getIban()
  607.     {
  608.         return $this->iban;
  609.     }
  610.     /**
  611.      * @param string $iban
  612.      */
  613.     public function setIban($iban)
  614.     {
  615.         $this->iban $iban;
  616.     }
  617.     /**
  618.      * Set roJudet
  619.      *
  620.      * @param \App\Entity\RoJudet $roJudet
  621.      *
  622.      * @return Address
  623.      */
  624.     public function setRoJudet(\App\Entity\RoJudet $roJudet null)
  625.     {
  626.         $this->roJudet $roJudet;
  627.         return $this;
  628.     }
  629.     /**
  630.      * Get roJudet
  631.      *
  632.      * @return \App\Entity\RoJudet
  633.      */
  634.     public function getRoJudet()
  635.     {
  636.         return $this->roJudet;
  637.     }
  638.     public function getOrder(): ?Order
  639.     {
  640.         return $this->order;
  641.     }
  642.     public function setOrder(?Order $order): self
  643.     {
  644.         $this->order $order;
  645.         return $this;
  646.     }
  647. }