src/Admin/Modules/Contract/Entity/ContractClient.php line 15

  1. <?php
  2. namespace App\Admin\Modules\Contract\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Modules\User\Entity\User;
  8. /**
  9.  * @ORM\Table(name="contract_client", indexes={@ORM\Index(columns={"first_name"}), @ORM\Index(columns={"last_name"}),  @ORM\Index(columns={"email"}), @ORM\Index(columns={"pesel"}), @ORM\Index(columns={"id_card_number"}), @ORM\Index(columns={"status"})})
  10.  * @ORM\Entity(repositoryClass="App\Admin\Modules\Contract\Repository\ContractClientRepository")
  11.  */
  12. class ContractClient
  13. {
  14.     const STATUS_POTENTIAL 1// potencjalny
  15.     const STATUS_OFFERED 2;   // zaofertowany
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     protected $id;
  24.     
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(name="first_name", type="string", length=255, nullable=true, options={"collation"="utf8_unicode_ci"})
  29.      */
  30.     private $firstName;    
  31.     
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(name="last_name", type="string", length=255, nullable=true, options={"collation"="utf8_unicode_ci"})
  36.      */
  37.     private $lastName;    
  38.     
  39.     /**
  40.      * @var string
  41.      *
  42.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  43.      */
  44.     private $email
  45.     
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="phone", type="string", length=25, nullable=true)
  50.      */
  51.     private $phone
  52.     /**
  53.      * @var string
  54.      *
  55.      * @ORM\Column(name="pesel", type="string", length=25, nullable=true)
  56.      */
  57.     private $pesel;    
  58.     /**
  59.      * @var string
  60.      *
  61.      * @ORM\Column(name="id_card_number", type="string", length=25, nullable=true)
  62.      */
  63.     private $idCardNumber;    
  64.     /**
  65.      * @var string
  66.      *
  67.      * @ORM\Column(name="street", type="string", length=255, nullable=true)
  68.      */
  69.     private $street;
  70.     /**
  71.      * @var string
  72.      *
  73.      * @ORM\Column(name="building_number", type="string", length=10, nullable=true)
  74.      */
  75.     private $buildingNumber;
  76.     /**
  77.      * @var string
  78.      *
  79.      * @ORM\Column(name="apartment_number", type="string", length=10, nullable=true)
  80.      */
  81.     private $apartmentNumber;
  82.     /**
  83.      * @var string
  84.      *
  85.      * @ORM\Column(name="postal_code", type="string", length=10, nullable=true)
  86.      */
  87.     private $postalCode;
  88.     /**
  89.      * @var string
  90.      *
  91.      * @ORM\Column(name="city", type="string", length=255, nullable=true)
  92.      */
  93.     private $city;
  94.     /**
  95.      * @var \App\Modules\User\Entity\User
  96.      *
  97.      * @ORM\ManyToOne(targetEntity="App\Modules\User\Entity\User")
  98.      * @ORM\JoinColumns({
  99.      *   @ORM\JoinColumn(name="id_admin_user", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  100.      * })
  101.      */
  102.     private $adminUser;
  103.     /**
  104.      * @var int
  105.      *
  106.      * @ORM\Column(name="status", type="smallint", nullable=false)
  107.      */
  108.     private $status;
  109.     /**
  110.      * @var \App\Admin\Modules\Contract\Entity\Contract
  111.      *
  112.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\Contract\Entity\Contract", mappedBy="client", cascade={"persist"}, orphanRemoval=true)
  113.      * @ORM\OrderBy({"addedAt"="DESC"})
  114.      */
  115.     private $contracts;
  116.     public function __construct()
  117.     {
  118.         $this->status self::STATUS_POTENTIAL;
  119.         $this->contracts = new ArrayCollection();
  120.     }
  121.     public function getId(): ?string
  122.     {
  123.         return $this->id;
  124.     }
  125.     
  126.     public function getNameWithId()
  127.     {
  128.         return ($this->firstName != '' $this->firstName ' ' $this->lastName '-') . ' (#' $this->id ')';
  129.     }
  130.     
  131.     public function getFullAddress()
  132.     {
  133.         $addr null;
  134.         if ($this->getStreet() != '')
  135.             $addr $this->getStreet() . ' ' $this->getBuildingNumber() . ($this->apartmentNumber != '' '/' $this->apartmentNumber '');
  136.         
  137.         $str $this->getPostalCode();
  138.         
  139.         if ($this->getCity() != '')
  140.             $str .= ($str != '' ' ' '') . $this->getCity();
  141.         
  142.         if ($str != '')
  143.             $addr .= ($addr != '' ', ' '') . $str;
  144.         
  145.         return $addr;
  146.     }
  147.     public function getFirstName(): ?string
  148.     {
  149.         return $this->firstName;
  150.     }
  151.     public function setFirstName(?string $firstName): self
  152.     {
  153.         $this->firstName $firstName;
  154.         return $this;
  155.     }
  156.     public function getLastName(): ?string
  157.     {
  158.         return $this->lastName;
  159.     }
  160.     public function setLastName(?string $lastName): self
  161.     {
  162.         $this->lastName $lastName;
  163.         return $this;
  164.     }
  165.     public function getPesel(): ?string
  166.     {
  167.         return $this->pesel;
  168.     }
  169.     public function setPesel(?string $pesel): self
  170.     {
  171.         $this->pesel $pesel;
  172.         return $this;
  173.     }
  174.     public function getIdCardNumber(): ?string
  175.     {
  176.         return $this->idCardNumber;
  177.     }
  178.     public function setIdCardNumber(?string $idCardNumber): self
  179.     {
  180.         $this->idCardNumber $idCardNumber;
  181.         return $this;
  182.     }
  183.     public function getStreet(): ?string
  184.     {
  185.         return $this->street;
  186.     }
  187.     public function setStreet(?string $street): self
  188.     {
  189.         $this->street $street;
  190.         return $this;
  191.     }
  192.     public function getBuildingNumber(): ?string
  193.     {
  194.         return $this->buildingNumber;
  195.     }
  196.     public function setBuildingNumber(?string $buildingNumber): self
  197.     {
  198.         $this->buildingNumber $buildingNumber;
  199.         return $this;
  200.     }
  201.     public function getApartmentNumber(): ?string
  202.     {
  203.         return $this->apartmentNumber;
  204.     }
  205.     public function setApartmentNumber(?string $apartmentNumber): self
  206.     {
  207.         $this->apartmentNumber $apartmentNumber;
  208.         return $this;
  209.     }
  210.     public function getPostalCode(): ?string
  211.     {
  212.         return $this->postalCode;
  213.     }
  214.     public function setPostalCode(?string $postalCode): self
  215.     {
  216.         $this->postalCode $postalCode;
  217.         return $this;
  218.     }
  219.     public function getCity(): ?string
  220.     {
  221.         return $this->city;
  222.     }
  223.     public function setCity(?string $city): self
  224.     {
  225.         $this->city $city;
  226.         return $this;
  227.     }
  228.     public function getAdminUser(): ?User
  229.     {
  230.         return $this->adminUser;
  231.     }
  232.     public function setAdminUser(?User $adminUser): self
  233.     {
  234.         $this->adminUser $adminUser;
  235.         return $this;
  236.     }
  237.     public function getEmail(): ?string
  238.     {
  239.         return $this->email;
  240.     }
  241.     public function setEmail(?string $email): self
  242.     {
  243.         $this->email $email;
  244.         return $this;
  245.     }
  246.     /**
  247.      * @return Collection<int, Contract>
  248.      */
  249.     public function getContracts(): Collection
  250.     {
  251.         return $this->contracts;
  252.     }
  253.     public function addContract(Contract $contract): self
  254.     {
  255.         if (!$this->contracts->contains($contract)) {
  256.             $this->contracts->add($contract);
  257.             $contract->setClient($this);
  258.         }
  259.         return $this;
  260.     }
  261.     public function removeContract(Contract $contract): self
  262.     {
  263.         if ($this->contracts->removeElement($contract)) {
  264.             // set the owning side to null (unless already changed)
  265.             if ($contract->getClient() === $this) {
  266.                 $contract->setClient(null);
  267.             }
  268.         }
  269.         return $this;
  270.     }
  271.     public function getPhone(): ?string
  272.     {
  273.         return $this->phone;
  274.     }
  275.     public function setPhone(?string $phone): self
  276.     {
  277.         $this->phone $phone;
  278.         return $this;
  279.     }
  280.     public function getStatus(): ?int
  281.     {
  282.         return $this->status;
  283.     }
  284.     public function setStatus(int $status): self
  285.     {
  286.         $this->status $status;
  287.         return $this;
  288.     }    
  289. }