src/Admin/Modules/Contract/Entity/ContractTemplate.php line 16

  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 Gedmo\Mapping\Annotation as Gedmo;
  8. use App\Modules\User\Entity\User;
  9. /**
  10.  * @ORM\Table(name="contract_template", indexes={@ORM\Index(columns={"name"}), @ORM\Index(columns={"short_name"}), @ORM\Index(columns={"in_documents_set"}), @ORM\Index(columns={"is_active"}), @ORM\Index(columns={"is_deleted"}), @ORM\Index(columns={"updated_at"}), @ORM\Index(columns={"added_at"})})
  11.  * @ORM\Entity(repositoryClass="App\Admin\Modules\Contract\Repository\ContractTemplateRepository")
  12.  */
  13. class ContractTemplate
  14. {
  15.     /**
  16.      * @var int
  17.      *
  18.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      */
  22.     protected $id;
  23.     
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="name", type="string", length=255, nullable=false, options={"collation"="utf8_unicode_ci"})
  28.      */
  29.     private $name;
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="short_name", type="string", length=50, nullable=false, options={"collation"="utf8_unicode_ci"})
  34.      */
  35.     private $shortName;
  36.     
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(name="tags", type="text", length=65535, nullable=false)
  41.      */
  42.     private $tags;
  43.     /**
  44.      * @var string
  45.      *
  46.      * @ORM\Column(name="content", type="text", nullable=false)
  47.      */
  48.     private $content;
  49.     
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(name="new_contract_message_to_client", type="text", length=65535, nullable=true)
  54.      */
  55.     private $newContractMessageToClient;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(name="contract_paid_message_to_client", type="text", length=65535, nullable=true)
  60.      */
  61.     private $contractPaidMessageToClient;
  62.     /**
  63.      * @var string
  64.      *
  65.      * @ORM\Column(name="price", type="decimal", precision=14, scale=2, nullable=true)
  66.      */
  67.     private $price;    
  68.     /**
  69.      * @var bool
  70.      *
  71.      * @ORM\Column(name="in_documents_set", type="boolean", nullable=false)
  72.      */
  73.     private $inDocumentsSet;
  74.     
  75.     /**
  76.      * @var bool
  77.      *
  78.      * @ORM\Column(name="is_active", type="boolean", nullable=false)
  79.      */
  80.     private $isActive;
  81.     /**
  82.      * @var bool
  83.      *
  84.      * @ORM\Column(name="is_deleted", type="boolean", nullable=false)
  85.      */
  86.     private $isDeleted;
  87.     /**
  88.      * @var \App\Modules\User\Entity\User
  89.      *
  90.      * @ORM\ManyToOne(targetEntity="App\Modules\User\Entity\User")
  91.      * @ORM\JoinColumns({
  92.      *   @ORM\JoinColumn(name="id_added_by", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  93.      * })
  94.      */
  95.     private $addedBy;    
  96.     
  97.     /**
  98.      * @var \DateTime
  99.      *
  100.      * @ORM\Column(name="updated_at", type="datetime", nullable=false)
  101.      * @Gedmo\Timestampable(on="update")
  102.      */
  103.     private $updatedAt;
  104.     
  105.     /**
  106.      * @var \DateTime
  107.      *
  108.      * @ORM\Column(name="added_at", type="datetime", nullable=false)
  109.      * @Gedmo\Timestampable(on="create")
  110.      */
  111.     private $addedAt;
  112.     
  113.     /**
  114.      * @var \App\Admin\Modules\Contract\Entity\ContractTasksTemplate
  115.      *
  116.      * @ORM\ManyToMany(targetEntity="App\Admin\Modules\Contract\Entity\ContractTasksTemplate")
  117.      * @ORM\JoinTable(name="contract_template_tasks_template",
  118.      *      joinColumns={@ORM\JoinColumn(name="id_contract_template", referencedColumnName="id", onDelete="CASCADE")},
  119.      *      inverseJoinColumns={@ORM\JoinColumn(name="id_contract_tasks_template", referencedColumnName="id", onDelete="CASCADE")}
  120.      *    )
  121.      * @ORM\OrderBy({"name"="ASC"})
  122.      **/
  123.     private $tasksTemplates;
  124.     
  125.     /**
  126.      * @var \App\Admin\Modules\Contract\Entity\Contract
  127.      *
  128.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\Contract\Entity\Contract", mappedBy="template")
  129.      **/
  130.     private $contracts;  
  131.     
  132.     /**
  133.      * @var \App\Admin\Modules\Contract\Entity\Contract
  134.      *
  135.      * @ORM\ManyToMany(targetEntity="App\Admin\Modules\Contract\Entity\Contract", mappedBy="documentTemplates")
  136.      **/
  137.     private $documentTemplatesContracts;    
  138.     public function __construct()
  139.     {
  140.         $this->isDeleted false;
  141.         $this->tasksTemplates = new ArrayCollection();
  142.         $this->documentTemplatesContracts = new ArrayCollection();
  143.         $this->contracts = new ArrayCollection();
  144.     }
  145.     
  146.     public function __toString()
  147.     {
  148.         return $this->getNameWithShortName();
  149.     }
  150.     
  151.     public function getId(): ?string
  152.     {
  153.         return $this->id;
  154.     }
  155.     
  156.     public function getNameWithShortName()
  157.     {
  158.         return $this->name ' (' $this->shortName ')';
  159.     }
  160.     public function getName(): ?string
  161.     {
  162.         return $this->name;
  163.     }
  164.     public function setName(string $name): self
  165.     {
  166.         $this->name $name;
  167.         return $this;
  168.     }
  169.     public function getShortName(): ?string
  170.     {
  171.         return $this->shortName;
  172.     }
  173.     public function setShortName(string $shortName): self
  174.     {
  175.         $this->shortName $shortName;
  176.         return $this;
  177.     }
  178.     public function getTags(): ?string
  179.     {
  180.         return $this->tags;
  181.     }
  182.     public function setTags(string $tags): self
  183.     {
  184.         $this->tags $tags;
  185.         return $this;
  186.     }
  187.     public function getContent(): ?string
  188.     {
  189.         return $this->content;
  190.     }
  191.     public function setContent(string $content): self
  192.     {
  193.         $this->content $content;
  194.         return $this;
  195.     }
  196.     public function getIsActive(): ?bool
  197.     {
  198.         return $this->isActive;
  199.     }
  200.     public function setIsActive(bool $isActive): self
  201.     {
  202.         $this->isActive $isActive;
  203.         return $this;
  204.     }
  205.     public function getUpdatedAt(): ?\DateTimeInterface
  206.     {
  207.         return $this->updatedAt;
  208.     }
  209.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  210.     {
  211.         $this->updatedAt $updatedAt;
  212.         return $this;
  213.     }
  214.     public function getAddedAt(): ?\DateTimeInterface
  215.     {
  216.         return $this->addedAt;
  217.     }
  218.     public function setAddedAt(\DateTimeInterface $addedAt): self
  219.     {
  220.         $this->addedAt $addedAt;
  221.         return $this;
  222.     }
  223.     public function getAddedBy(): ?User
  224.     {
  225.         return $this->addedBy;
  226.     }
  227.     public function setAddedBy(?User $addedBy): self
  228.     {
  229.         $this->addedBy $addedBy;
  230.         return $this;
  231.     }
  232.     public function getIsDeleted(): ?bool
  233.     {
  234.         return $this->isDeleted;
  235.     }
  236.     public function setIsDeleted(bool $isDeleted): self
  237.     {
  238.         $this->isDeleted $isDeleted;
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, ContractTasksTemplate>
  243.      */
  244.     public function getTasksTemplates(): Collection
  245.     {
  246.         return $this->tasksTemplates;
  247.     }
  248.     public function addTasksTemplate(ContractTasksTemplate $tasksTemplate): self
  249.     {
  250.         if (!$this->tasksTemplates->contains($tasksTemplate)) {
  251.             $this->tasksTemplates->add($tasksTemplate);
  252.         }
  253.         return $this;
  254.     }
  255.     public function removeTasksTemplate(ContractTasksTemplate $tasksTemplate): self
  256.     {
  257.         $this->tasksTemplates->removeElement($tasksTemplate);
  258.         return $this;
  259.     }
  260.     public function getPrice(): ?string
  261.     {
  262.         return $this->price;
  263.     }
  264.     public function setPrice(?string $price): self
  265.     {
  266.         $this->price $price;
  267.         return $this;
  268.     }
  269.     public function getNewContractMessageToClient(): ?string
  270.     {
  271.         return $this->newContractMessageToClient;
  272.     }
  273.     public function setNewContractMessageToClient(?string $newContractMessageToClient): self
  274.     {
  275.         $this->newContractMessageToClient $newContractMessageToClient;
  276.         return $this;
  277.     }
  278.     public function getContractPaidMessageToClient(): ?string
  279.     {
  280.         return $this->contractPaidMessageToClient;
  281.     }
  282.     public function setContractPaidMessageToClient(?string $contractPaidMessageToClient): self
  283.     {
  284.         $this->contractPaidMessageToClient $contractPaidMessageToClient;
  285.         return $this;
  286.     }
  287.     public function getInDocumentsSet(): ?bool
  288.     {
  289.         return $this->inDocumentsSet;
  290.     }
  291.     public function setInDocumentsSet(bool $inDocumentsSet): self
  292.     {
  293.         $this->inDocumentsSet $inDocumentsSet;
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return Collection<int, Contract>
  298.      */
  299.     public function getDocumentTemplatesContracts(): Collection
  300.     {
  301.         return $this->documentTemplatesContracts;
  302.     }
  303.     public function addDocumentTemplatesContract(Contract $documentTemplatesContract): self
  304.     {
  305.         if (!$this->documentTemplatesContracts->contains($documentTemplatesContract)) {
  306.             $this->documentTemplatesContracts->add($documentTemplatesContract);
  307.             $documentTemplatesContract->addDocumentTemplate($this);
  308.         }
  309.         return $this;
  310.     }
  311.     public function removeDocumentTemplatesContract(Contract $documentTemplatesContract): self
  312.     {
  313.         if ($this->documentTemplatesContracts->removeElement($documentTemplatesContract)) {
  314.             $documentTemplatesContract->removeDocumentTemplate($this);
  315.         }
  316.         return $this;
  317.     }
  318.     /**
  319.      * @return Collection<int, Contract>
  320.      */
  321.     public function getContracts(): Collection
  322.     {
  323.         return $this->contracts;
  324.     }
  325.     public function addContract(Contract $contract): self
  326.     {
  327.         if (!$this->contracts->contains($contract)) {
  328.             $this->contracts->add($contract);
  329.             $contract->setTemplate($this);
  330.         }
  331.         return $this;
  332.     }
  333.     public function removeContract(Contract $contract): self
  334.     {
  335.         if ($this->contracts->removeElement($contract)) {
  336.             // set the owning side to null (unless already changed)
  337.             if ($contract->getTemplate() === $this) {
  338.                 $contract->setTemplate(null);
  339.             }
  340.         }
  341.         return $this;
  342.     }
  343. }