<?php
namespace App\Entity\Gos;
use App\Entity\ContactSegmentationableInterface;
use App\Repository\Gos\NewsletterTemplateRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinTable;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=NewsletterTemplateRepository::class)
* @ORM\HasLifecycleCallbacks
* @Vich\Uploadable
*/
class NewsletterTemplate implements ContactSegmentationableInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $message;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $messageNewUser;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $colorBg;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $colorButton;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $colorFont;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $parameterA;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $parameterF;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $reginfo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $parameterC;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $parameterChc;
/**
* @ORM\OneToMany(targetEntity=Newsletter::class, mappedBy="newsletterTemplate")
*/
private $newsletters;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $gratisUrl;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $sender;
/**
* @Vich\UploadableField(mapping="newsletter_gratis_files", fileNameProperty="gratisFilename")
*/
private $gratis;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $gratisFilename;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $messageConfirmed;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $messageConfirmedNewUser;
/**
* @ORM\ManyToOne(targetEntity=EmailTemplate::class, inversedBy="newsletterTemplates")
*/
private $emailTemplate;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fromEmail;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $attachmentName;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $oneTimePassword;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $oneTimePasswordMessage;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":0})
*/
private $isFileNewsletter;
/**
* @ORM\OneToOne(targetEntity=LeadReminders::class, cascade={"persist", "remove"})
*/
private $reminder;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $useAlternativeForm;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":1})
*/
private $hideLastName;
/**
* @ORM\OneToMany(targetEntity=LeadFormResponseItem::class, mappedBy="newsletterTemplate")
*/
private $leadFormResponseItems;
/**
* @ORM\OneToMany(targetEntity=NewsletterTemplateWhitelist::class, mappedBy="newsletterTemplate", orphanRemoval=true)
*/
private $newsletterTemplateWhitelist;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $emailValidationType;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $reginfoValidation;
/**
* @ORM\ManyToMany(targetEntity=ProductVariant::class, inversedBy="newsletterTemplateValidations")
*/
private $productVariantsValidation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $emailValidationErrorMessage;
/**
* @ORM\ManyToMany(targetEntity=Term::class, inversedBy="newsletterTemplates")
*/
private $terms;
/**
* @ORM\OneToOne(targetEntity=LeadFormResponseAddress::class, inversedBy="newsletterTemplate", cascade={"persist", "remove"})
*/
private $leadFormResponseAddress;
/**
* @ORM\OneToOne(targetEntity=LeadFormResponsePosition::class, inversedBy="newsletterTemplate", cascade={"persist", "remove"})
*/
private $leadFormResponsePosition;
/**
* @ORM\ManyToMany(targetEntity=ProductVariant::class)
* @JoinTable(name="newsletter_template_product_variant_access")
*/
private $productVariants;
/**
* @ORM\ManyToOne(targetEntity=LeadGroup::class, inversedBy="newsletterTemplates")
*/
private $leadGroup;
/**
* @ORM\ManyToMany(targetEntity=ProductVariant::class)
* @ORM\JoinTable(name="newsletter_template_related_product_variants")
*/
private $relatedProductVariants;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $actionNumbers;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $requiredNPWZ;
/**
* @ORM\Column(type="boolean", options={"default":0})
*/
private $isPhoneRequired = false;
/**
* @ORM\Column(type="boolean", options={"default":0})
*/
private $isPhoneHidden = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $overrideActionNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $actionNumber;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $legalRule;
/**
* @ORM\ManyToMany(targetEntity=SalesManagoTagGroup::class, mappedBy="newsletterTemplate")
*/
private $salesManagoTagGroups;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $useCustomColors;
/**
* @ORM\ManyToMany(targetEntity=ContactSegmentation::class)
*/
private $contactSegmentations;
public function __construct()
{
$this->newsletters = new ArrayCollection();
$this->leadFormResponseItems = new ArrayCollection();
$this->newsletterTemplateWhitelist = new ArrayCollection();
$this->productVariantsValidation = new ArrayCollection();
$this->terms = new ArrayCollection();
$this->productVariants = new ArrayCollection();
$this->relatedProductVariants = new ArrayCollection();
$this->salesManagoTagGroups = new ArrayCollection();
$this->contactSegmentations = new ArrayCollection();
}
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __clone() {
if ($this->id) {
$this->id = null;
}
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): self
{
$this->message = $message;
return $this;
}
public function getMessageNewUser(): ?string
{
return $this->messageNewUser;
}
public function setMessageNewUser(?string $messageNewUser): self
{
$this->messageNewUser = $messageNewUser;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getIsName(): ?bool
{
return $this->isName;
}
public function setIsName(?bool $isName): self
{
$this->isName = $isName;
return $this;
}
public function getColorBg(): ?string
{
return $this->colorBg;
}
public function setColorBg(?string $colorBg): self
{
$this->colorBg = $colorBg;
return $this;
}
public function getColorButton(): ?string
{
return $this->colorButton;
}
public function setColorButton(?string $colorButton): self
{
$this->colorButton = $colorButton;
return $this;
}
public function getColorFont(): ?string
{
return $this->colorFont;
}
public function setColorFont(?string $colorFont): self
{
$this->colorFont = $colorFont;
return $this;
}
public function getParameterA(): ?string
{
return $this->parameterA;
}
public function setParameterA(?string $parameterA): self
{
$this->parameterA = $parameterA;
return $this;
}
public function getParameterF(): ?string
{
return $this->parameterF;
}
public function setParameterF(?string $parameterF): self
{
$this->parameterF = $parameterF;
return $this;
}
public function getReginfo(): ?string
{
return $this->reginfo;
}
public function setReginfo(?string $reginfo): self
{
$this->reginfo = $reginfo;
return $this;
}
public function getParameterC(): ?string
{
return $this->parameterC;
}
public function setParameterC(?string $parameterC): self
{
$this->parameterC = $parameterC;
return $this;
}
public function getParameterChc(): ?string
{
return $this->parameterChc;
}
public function setParameterChc(?string $parameterChc): self
{
$this->parameterChc = $parameterChc;
return $this;
}
/**
* @return Collection|Newsletter[]
*/
public function getNewsletters(): Collection
{
return $this->newsletters;
}
public function addNewsletter(Newsletter $newsletter): self
{
if (!$this->newsletters->contains($newsletter)) {
$this->newsletters[] = $newsletter;
$newsletter->setNewsletterTemplate($this);
}
return $this;
}
public function removeNewsletter(Newsletter $newsletter): self
{
if ($this->newsletters->contains($newsletter)) {
$this->newsletters->removeElement($newsletter);
// set the owning side to null (unless already changed)
if ($newsletter->getNewsletterTemplate() === $this) {
$newsletter->setNewsletterTemplate(null);
}
}
return $this;
}
public function getGratisUrl(): ?string
{
return $this->gratisUrl;
}
public function setGratisUrl(?string $gratisUrl): self
{
$this->gratisUrl = $gratisUrl;
return $this;
}
public function getSender(): ?string
{
return $this->sender;
}
public function setSender(?string $sender): self
{
$this->sender = $sender;
return $this;
}
public function getGratis():?File
{
return $this->gratis;
}
public function setGratis(?File $gratis): self
{
$this->gratis = $gratis;
if($gratis){
$this->updatedAt = new \DateTime();
}
return $this;
}
public function getGratisFilename(): ?string
{
return $this->gratisFilename;
}
public function setGratisFilename(?string $gratisFilename): self
{
$this->gratisFilename = $gratisFilename;
return $this;
}
public function getMessageConfirmed(): ?string
{
return $this->messageConfirmed;
}
public function setMessageConfirmed(?string $messageConfirmed): self
{
$this->messageConfirmed = $messageConfirmed;
return $this;
}
public function getMessageConfirmedNewUser(): ?string
{
return $this->messageConfirmedNewUser;
}
public function setMessageConfirmedNewUser(?string $messageConfirmedNewUser): self
{
$this->messageConfirmedNewUser = $messageConfirmedNewUser;
return $this;
}
public function getEmailTemplate(): ?EmailTemplate
{
return $this->emailTemplate;
}
public function setEmailTemplate(?EmailTemplate $emailTemplate): self
{
$this->emailTemplate = $emailTemplate;
return $this;
}
public function getFromEmail(): ?string
{
return $this->fromEmail;
}
public function setFromEmail(?string $fromEmail): self
{
$this->fromEmail = $fromEmail;
return $this;
}
public function getAttachmentName(): ?string
{
return $this->attachmentName;
}
public function setAttachmentName(?string $attachmentName): self
{
$this->attachmentName = $attachmentName;
return $this;
}
public function getOneTimePassword(): ?bool
{
return $this->oneTimePassword;
}
public function setOneTimePassword(?bool $oneTimePassword): self
{
$this->oneTimePassword = $oneTimePassword;
return $this;
}
public function getOneTimePasswordMessage(): ?string
{
return $this->oneTimePasswordMessage;
}
public function setOneTimePasswordMessage(?string $oneTimePasswordMessage): self
{
$this->oneTimePasswordMessage = $oneTimePasswordMessage;
return $this;
}
public function getIsFileNewsletter(): ?bool
{
return $this->isFileNewsletter;
}
public function setIsFileNewsletter(bool $isFileNewsletter): self
{
$this->isFileNewsletter = $isFileNewsletter;
return $this;
}
public function getReminder(): ?LeadReminders
{
return $this->reminder;
}
public function setReminder(?LeadReminders $reminder): self
{
$this->reminder = $reminder;
return $this;
}
public function getUseAlternativeForm(): ?bool
{
return $this->useAlternativeForm;
}
public function setUseAlternativeForm(?bool $useAlternativeForm): self
{
$this->useAlternativeForm = $useAlternativeForm;
return $this;
}
public function getHideLastName(): ?bool
{
return $this->hideLastName;
}
public function setHideLastName(?bool $hideLastName): self
{
$this->hideLastName = $hideLastName;
return $this;
}
/**
* @return Collection|LeadFormResponseItem[]
*/
public function getLeadFormResponseItems(): Collection
{
return $this->leadFormResponseItems;
}
public function addLeadFormResponseItem(LeadFormResponseItem $leadFormResponseItem): self
{
if (!$this->leadFormResponseItems->contains($leadFormResponseItem)) {
$this->leadFormResponseItems[] = $leadFormResponseItem;
$leadFormResponseItem->setNewsletterTemplate($this);
}
return $this;
}
public function removeLeadFormResponseItem(LeadFormResponseItem $leadFormResponseItem): self
{
if ($this->leadFormResponseItems->contains($leadFormResponseItem)) {
$this->leadFormResponseItems->removeElement($leadFormResponseItem);
// set the owning side to null (unless already changed)
if ($leadFormResponseItem->getNewsletterTemplate() === $this) {
$leadFormResponseItem->setNewsletterTemplate(null);
}
}
return $this;
}
/**
* @return Collection|newsletterTemplateWhitelist[]
*/
public function getNewsletterTemplateWhitelist(): Collection
{
return $this->newsletterTemplateWhitelist;
}
public function addNewsletterTemplateWhitelist(newsletterTemplateWhitelist $newsletterTemplateWhitelist): self
{
if (!$this->newsletterTemplateWhitelist->contains($newsletterTemplateWhitelist)) {
$this->newsletterTemplateWhitelist[] = $newsletterTemplateWhitelist;
$newsletterTemplateWhitelist->setNewsletterTemplate($this);
}
return $this;
}
public function removeNewsletterTemplateWhitelist(newsletterTemplateWhitelist $newsletterTemplateWhitelist): self
{
if ($this->newsletterTemplateWhitelist->contains($newsletterTemplateWhitelist)) {
$this->newsletterTemplateWhitelist->removeElement($newsletterTemplateWhitelist);
// set the owning side to null (unless already changed)
if ($newsletterTemplateWhitelist->getNewsletterTemplate() === $this) {
$newsletterTemplateWhitelist->setNewsletterTemplate(null);
}
}
return $this;
}
public function getEmailValidationType(): ?int
{
return $this->emailValidationType;
}
public function setEmailValidationType(?int $emailValidationType): self
{
$this->emailValidationType = $emailValidationType;
return $this;
}
public function getReginfoValidation(): ?string
{
return $this->reginfoValidation;
}
public function setReginfoValidation(?string $reginfoValidation): self
{
$this->reginfoValidation = $reginfoValidation;
return $this;
}
public function addProductVariantsValidation(ProductVariant $productVariantsValidation): self
{
if (!$this->productVariantsValidation->contains($productVariantsValidation)) {
$this->productVariantsValidation[] = $productVariantsValidation;
$productVariantsValidation->getNewsletterTemplateValidations()->add($this);
}
return $this;
}
public function removeProductVariantsValidation(ProductVariant $productVariantsValidation): self
{
if ($this->productVariantsValidation->contains($productVariantsValidation)) {
$this->productVariantsValidation->removeElement($productVariantsValidation);
if ($productVariantsValidation->getNewsletterTemplateValidations()->contains($this)) {
$productVariantsValidation->getNewsletterTemplateValidations()->removeElement($this);
}
}
return $this;
}
public function getProductVariantsValidation(): Collection
{
return $this->productVariantsValidation;
}
public function getEmailValidationErrorMessage(): ?string
{
return $this->emailValidationErrorMessage;
}
public function setEmailValidationErrorMessage(?string $emailValidationErrorMessage): self
{
$this->emailValidationErrorMessage = $emailValidationErrorMessage;
return $this;
}
/**
* @return Collection|Term[]
*/
public function getTerms(): Collection
{
return $this->terms;
}
public function addTerm(Term $term): self
{
if (!$this->terms->contains($term)) {
$this->terms[] = $term;
}
return $this;
}
public function removeTerm(Term $term): self
{
if ($this->terms->contains($term)) {
$this->terms->removeElement($term);
}
return $this;
}
public function getLeadFormResponseAddress(): ?LeadFormResponseAddress
{
return $this->leadFormResponseAddress;
}
public function setLeadFormResponseAddress(?LeadFormResponseAddress $leadFormResponseAddress): self
{
$this->leadFormResponseAddress = $leadFormResponseAddress;
return $this;
}
public function getLeadFormResponsePosition(): ?LeadFormResponsePosition
{
return $this->leadFormResponsePosition;
}
public function setLeadFormResponsePosition(?LeadFormResponsePosition $leadFormResponsePosition): self
{
$this->leadFormResponsePosition = $leadFormResponsePosition;
return $this;
}
public function isIncludingPosition(): bool
{
return $this->getLeadFormResponsePosition() && $this->getLeadFormResponsePosition()->getIncludePosition();
}
public function isIncludingAddress(): bool
{
return $this->getLeadFormResponseAddress() && $this->getLeadFormResponseAddress()->getIncludeAddress();
}
/**
* @return Collection|ProductVariant[]
*/
public function getProductVariants(): Collection
{
return $this->productVariants;
}
public function addProductVariant(ProductVariant $productVariant): self
{
if (!$this->productVariants->contains($productVariant)) {
$this->productVariants[] = $productVariant;
}
return $this;
}
public function removeProductVariant(ProductVariant $productVariant): self
{
if ($this->productVariants->contains($productVariant)) {
$this->productVariants->removeElement($productVariant);
}
return $this;
}
public function getLeadGroup(): ?LeadGroup
{
return $this->leadGroup;
}
public function setLeadGroup(?LeadGroup $leadGroup): self
{
$this->leadGroup = $leadGroup;
return $this;
}
/**
* @return Collection|ProductVariant[]
*/
public function getRelatedProductVariants(): Collection
{
return $this->relatedProductVariants;
}
public function addRelatedProductVariant(ProductVariant $relatedProductVariant): self
{
if (!$this->relatedProductVariants->contains($relatedProductVariant)) {
$this->relatedProductVariants[] = $relatedProductVariant;
}
return $this;
}
public function removeRelatedProductVariant(ProductVariant $relatedProductVariant): self
{
if ($this->relatedProductVariants->contains($relatedProductVariant)) {
$this->relatedProductVariants->removeElement($relatedProductVariant);
}
return $this;
}
public function getActionNumbers(): ?string
{
return $this->actionNumbers;
}
public function setActionNumbers(?string $actionNumbers): self
{
$this->actionNumbers = $actionNumbers;
return $this;
}
public function getRequiredNPWZ(): ?bool
{
return $this->requiredNPWZ;
}
public function setRequiredNPWZ(?bool $requiredNPWZ): self
{
$this->requiredNPWZ = $requiredNPWZ;
return $this;
}
public function getIsPhoneRequired(): ?bool
{
return $this->isPhoneRequired;
}
public function setIsPhoneRequired(bool $isPhoneRequired): self
{
$this->isPhoneRequired = $isPhoneRequired;
return $this;
}
public function isPhoneHidden(): ?bool
{
return $this->isPhoneHidden;
}
public function setIsPhoneHidden(bool $isPhoneHidden): self
{
$this->isPhoneHidden = $isPhoneHidden;
return $this;
}
public function getOverrideActionNumber(): ?bool
{
return $this->overrideActionNumber;
}
public function setOverrideActionNumber(?bool $overrideActionNumber): self
{
$this->overrideActionNumber = $overrideActionNumber;
return $this;
}
public function getActionNumber(): ?string
{
return $this->actionNumber;
}
public function setActionNumber(?string $actionNumber): self
{
$this->actionNumber = $actionNumber;
return $this;
}
public function getLegalRule(): ?string
{
return $this->legalRule;
}
public function setLegalRule(?string $legalRule): self
{
$this->legalRule = $legalRule;
return $this;
}
/**
* @return Collection|SalesManagoTagGroup[]
*/
public function getSalesManagoTagGroups(): Collection
{
return $this->salesManagoTagGroups;
}
public function addSalesManagoTagGroup(SalesManagoTagGroup $salesManagoTagGroup): self
{
if (!$this->salesManagoTagGroups->contains($salesManagoTagGroup)) {
$this->salesManagoTagGroups[] = $salesManagoTagGroup;
$salesManagoTagGroup->addNewsletterTemplate($this);
}
return $this;
}
public function removeSalesManagoTagGroup(SalesManagoTagGroup $salesManagoTagGroup): self
{
if ($this->salesManagoTagGroups->contains($salesManagoTagGroup)) {
$this->salesManagoTagGroups->removeElement($salesManagoTagGroup);
$salesManagoTagGroup->removeNewsletterTemplate($this);
}
return $this;
}
public function getUseCustomColors(): ?bool
{
return $this->useCustomColors;
}
public function setUseCustomColors(?bool $useCustomColors): self
{
$this->useCustomColors = $useCustomColors;
return $this;
}
/**
* @return Collection|ContactSegmentation[]
*/
public function getContactSegmentations(): Collection
{
return $this->contactSegmentations;
}
public function addContactSegmentation(ContactSegmentation $contactSegmentation): self
{
if (!$this->contactSegmentations->contains($contactSegmentation)) {
$this->contactSegmentations[] = $contactSegmentation;
}
return $this;
}
public function removeContactSegmentation(ContactSegmentation $contactSegmentation): self
{
if ($this->contactSegmentations->contains($contactSegmentation)) {
$this->contactSegmentations->removeElement($contactSegmentation);
}
return $this;
}
public function getSalesmanagoTags(): array
{
return array_values(
$this->contactSegmentations
->map(function (ContactSegmentation $seg) {
return $seg->getSalesmanagoTag();
})
->filter(function (?string $tag) {
return $tag !== null && $tag !== '';
})
->toArray()
);
}
public function getSalesManagoSourceTag(): ?string
{
return $this->getIsFileNewsletter() ? 'FILE_FORM' : 'NEWSLETTER_FORM';
}
}