<?php
namespace App\Entity;
use App\Entity\Abstract\Entity;
use App\Repository\EnterpriseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Gedmo\Loggable\Loggable;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: EnterpriseRepository::class)]
class Enterprise extends Entity
{
#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank]
private ?string $name = null;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: Discount::class, cascade: ['persist', 'remove'])]
private Collection $discounts;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: Admin::class, cascade: ['persist', 'remove'])]
private Collection $users;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: Company::class)]
private Collection $companies;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: Employee::class, cascade: ['persist', 'remove'])]
private Collection $employees;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: ProcessedPaymentPeriod::class, cascade: ['persist', 'remove'])]
private Collection $processedPaymentPeriods;
#[ORM\Column(length: 255)]
#[Assert\NotBlank]
private ?string $uidNumber = null;
#[ORM\Column(length: 20)]
#[Assert\NotBlank]
private ?string $numberOfEmployees = null;
/**
* 0: Firma in Prüfung
* 1: Firma aktiv in Beobachtung
* 2: Firma aktiv
* 3: Firma gesperrt
*
*
* @var int|null
*/
#[ORM\Column(nullable: true)]
private ?int $status = null;
#[ORM\ManyToOne(inversedBy: 'enterprises')]
private ?Seller $seller = null;
#[ORM\ManyToMany(targetEntity: Institution::class, mappedBy: 'participation')]
private Collection $participations;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: Contact::class, cascade: ['persist', 'remove'])]
#[Assert\NotBlank]
#[Assert\Valid]
private Collection $contacts;
#[Assert\NotBlank(message: 'persona.error.agb',groups: ['registration'])]
private bool $agb = false;
#[ORM\Column(nullable: true)]
private ?bool $noVerification = null;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: CompanyDidok::class, cascade: ['persist', 'remove'])]
#[Assert\Valid]
private Collection $companyDidoks;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: Report::class, cascade: ['persist', 'remove'])]
private Collection $reports;
#[ORM\Column(nullable: true)]
private ?bool $cashPurchaseOption = null;
#[ORM\Column(nullable: true)]
private ?bool $stackPurchaseOption = null;
#[ORM\Column(nullable: true)]
private ?bool $eSavOption = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $extendedParicipation = null;
#[ORM\Column(nullable: true)]
private ?bool $contractOption = null;
#[ORM\Column(nullable: true)]
private ?int $invitationLinkExpiresAt = null;
#[ORM\Column(nullable: true)]
private ?bool $verificationForNewEmployees = null;
#[ORM\Column(nullable: true)]
private ?bool $suppressPurchaseEmailsOption = null;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: RegistrationLink::class, cascade: ['persist', 'remove'])]
private Collection $registrationLinks;
#[ORM\Column(length: 255, nullable: true)]
private ?string $locale = null;
#[ORM\Column(nullable: true)]
private ?bool $createSwissPassOption = null;
#[ORM\Column(length: 10, nullable: true)]
private ?string $district = null;
#[ORM\Column(nullable: true)]
private ?bool $remainingBalanceOption = null;
#[ORM\Column(nullable: true)]
private ?bool $remainingBalanceRenewalOption = null;
#[ORM\Column(nullable: true)]
private ?bool $documentUploadOption = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $remainingBalanceStartDate = null;
#[ORM\Column(nullable: true)]
private ?bool $startRemainingBalanceOnPurchase = null;
#[ORM\Column(nullable: true)]
private ?bool $reminderOption = null;
#[ORM\ManyToOne(inversedBy: 'enterprises')]
private ?Tu $tu = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $customerNumber = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logoFilename = null;
#[ORM\Column(length: 100, nullable: true)]
private ?string $logoMimeType = null;
#[ORM\ManyToMany(targetEntity: PricingModel::class)]
private Collection $pricingModels;
#[ORM\Column(nullable: true)]
private ?bool $allZonesOption = null;
#[ORM\OneToMany(mappedBy: 'enterprise', targetEntity: ModuleSubscription::class, cascade: ['persist', 'remove'])]
private Collection $moduleSubscriptions;
#[ORM\Column(nullable: true)]
private ?array $countryRestriction = null;
#[ORM\Column(nullable: true)]
private ?int $supportedClass = null;
#[ORM\Column(nullable: true)]
private ?array $allowedProducts = null;
#[ORM\ManyToOne(targetEntity: Admin::class)]
private ?Admin $kam = null;
public function __construct()
{
$this->discounts = new ArrayCollection();
$this->users = new ArrayCollection();
$this->companies = new ArrayCollection();
$this->employees = new ArrayCollection();
$this->participations = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->companyDidoks = new ArrayCollection();
$this->reports = new ArrayCollection();
$this->registrationLinks = new ArrayCollection();
$this->pricingModels = new ArrayCollection();
$this->processedPaymentPeriods = new ArrayCollection();
$this->moduleSubscriptions = new ArrayCollection();
}
public function getId(): ?Uuid
{
return $this->id;
}
public function getKam(): ?Admin
{
return $this->kam;
}
public function setKam(?Admin $kam): self
{
$this->kam = $kam;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Discount>
*/
public function getDiscounts(): Collection
{
return $this->discounts;
}
public function addDiscount(Discount $discount): self
{
if (!$this->discounts->contains($discount)) {
$this->discounts->add($discount);
$discount->setEnterprise($this);
}
return $this;
}
public function removeDiscount(Discount $discount): self
{
if ($this->discounts->removeElement($discount)) {
// set the owning side to null (unless already changed)
if ($discount->getEnterprise() === $this) {
$discount->setEnterprise(null);
}
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setEnterprise($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getEnterprise() === $this) {
$user->setEnterprise(null);
}
}
return $this;
}
/**
* @return Collection<int, Company>
*/
public function getCompanies(): Collection
{
return $this->companies;
}
public function addCompany(Company $company): self
{
if (!$this->companies->contains($company)) {
$this->companies->add($company);
$company->setEnterprise($this);
}
return $this;
}
public function removeCompany(Company $company): self
{
if ($this->companies->removeElement($company)) {
// set the owning side to null (unless already changed)
if ($company->getEnterprise() === $this) {
$company->setEnterprise(null);
}
}
return $this;
}
/**
* @return Collection<int, Employee>
*/
public function getEmployees(): Collection
{
return $this->employees;
}
public function addEmployee(Employee $employee): self
{
if (!$this->employees->contains($employee)) {
$this->employees->add($employee);
$employee->setEnterprise($this);
}
return $this;
}
public function removeEmployee(Employee $employee): self
{
if ($this->employees->removeElement($employee)) {
// set the owning side to null (unless already changed)
if ($employee->getEnterprise() === $this) {
$employee->setEnterprise(null);
}
}
return $this;
}
public function getUidNumber(): ?string
{
return $this->uidNumber;
}
public function setUidNumber(string $uidNumber): self
{
$this->uidNumber = $uidNumber;
return $this;
}
public function getNumberOfEmployees(): ?string
{
return $this->numberOfEmployees;
}
public function setNumberOfEmployees(string $numberOfEmployees): self
{
$this->numberOfEmployees = $numberOfEmployees;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
/**
* @return bool
*/
public function isActive(): bool
{
if($this->status == 1 || $this->status == 2){
return true;
} else {
return false;
}
}
public function getSeller(): ?Seller
{
return $this->seller;
}
public function setSeller(?Seller $seller): self
{
$this->seller = $seller;
return $this;
}
/**
* @return Collection<int, Institution>
*/
public function getParticipations(): Collection
{
return $this->participations;
}
public function addParticipation(Institution $participation): self
{
if (!$this->participations->contains($participation)) {
$this->participations->add($participation);
$participation->addParticipation($this);
}
return $this;
}
public function removeParticipation(Institution $participation): self
{
if ($this->participations->removeElement($participation)) {
$participation->removeParticipation($this);
}
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts->add($contact);
$contact->setEnterprise($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->removeElement($contact)) {
// set the owning side to null (unless already changed)
if ($contact->getEnterprise() === $this) {
$contact->setEnterprise(null);
}
}
return $this;
}
/**
* @param int $type
* @return Contact|null
*/
public function getFirstContactByType(int $type): ?Contact
{
if(!empty($this->contacts)){
/** @var Contact $contact */
foreach($this->contacts as $contact){
if($contact->getType() == $type){
return $contact;
}
}
}
return null;
}
/**
* @return bool
*/
public function isAgb(): bool
{
return $this->agb;
}
/**
* @param bool $agb
*/
public function setAgb(bool $agb): void
{
$this->agb = $agb;
}
public function isNoVerification(): ?bool
{
return $this->noVerification;
}
public function setNoVerification(?bool $noVerification): static
{
$this->noVerification = $noVerification;
return $this;
}
/**
* @return Collection<int, CompanyDidok>
*/
public function getCompanyDidoks(): Collection
{
return $this->companyDidoks;
}
public function getCompanyDidoksAsArray(): array
{
$didoks = [];
$companyDidoks = $this->getCompanyDidoks();
if(!empty($companyDidoks)){
foreach($companyDidoks as $companyDidok){
if($companyDidok instanceof CompanyDidok){
$didoks[$companyDidok->getName()] = $companyDidok->getDidok();
}
}
}
return $didoks;
}
public function addCompanyDidok(CompanyDidok $companyDidok): static
{
if (!$this->companyDidoks->contains($companyDidok)) {
$this->companyDidoks->add($companyDidok);
$companyDidok->setEnterprise($this);
}
return $this;
}
public function removeCompanyDidok(CompanyDidok $companyDidok): static
{
if ($this->companyDidoks->removeElement($companyDidok)) {
// set the owning side to null (unless already changed)
if ($companyDidok->getEnterprise() === $this) {
$companyDidok->setEnterprise(null);
}
}
return $this;
}
/**
* @return Collection<int, Report>
*/
public function getReports(): Collection
{
return $this->reports;
}
public function addReport(Report $report): static
{
if (!$this->reports->contains($report)) {
$this->reports->add($report);
$report->setEnterprise($this);
}
return $this;
}
public function removeReport(Report $report): static
{
if ($this->reports->removeElement($report)) {
// set the owning side to null (unless already changed)
if ($report->getEnterprise() === $this) {
$report->setEnterprise(null);
}
}
return $this;
}
public function isCashPurchaseOption(): ?bool
{
return $this->cashPurchaseOption;
}
public function setCashPurchaseOption(?bool $cashPurchaseOption): static
{
$this->cashPurchaseOption = $cashPurchaseOption;
return $this;
}
public function isStackPurchaseOption(): ?bool
{
return $this->stackPurchaseOption;
}
public function setStackPurchaseOption(?bool $stackPurchaseOption): static
{
$this->stackPurchaseOption = $stackPurchaseOption;
return $this;
}
public function isESavOption(): ?bool
{
return $this->eSavOption;
}
public function setESavOption(?bool $eSavOption): static
{
$this->eSavOption = $eSavOption;
return $this;
}
public function getExtendedParicipation(): ?string
{
return $this->extendedParicipation;
}
public function setExtendedParicipation(?string $extendedParicipation): static
{
$this->extendedParicipation = $extendedParicipation;
return $this;
}
public function isContractOption(): ?bool
{
return $this->contractOption;
}
public function setContractOption(bool $contractOption): static
{
$this->contractOption = $contractOption;
return $this;
}
public function getInvitationLinkExpiresAt(): ?int
{
return $this->invitationLinkExpiresAt;
}
public function setInvitationLinkExpiresAt(?int $invitationLinkExpiresAt): static
{
$this->invitationLinkExpiresAt = $invitationLinkExpiresAt;
return $this;
}
/**
* @return bool|null
*/
public function getVerificationForNewEmployees(): ?bool
{
return $this->verificationForNewEmployees;
}
/**
* @param bool|null $verificationForNewEmployees
*/
public function setVerificationForNewEmployees(?bool $verificationForNewEmployees): void
{
$this->verificationForNewEmployees = $verificationForNewEmployees;
}
public function isSuppressPurchaseEmailsOption(): ?bool
{
return $this->suppressPurchaseEmailsOption;
}
public function setSuppressPurchaseEmailsOption(?bool $suppressPurchaseEmailsOption): void
{
$this->suppressPurchaseEmailsOption = $suppressPurchaseEmailsOption;
}
/**
* @return Collection<int, RegistrationLink>
*/
public function getRegistrationLinks(): Collection
{
return $this->registrationLinks;
}
public function addRegistrationLink(RegistrationLink $registrationLink): static
{
if (!$this->registrationLinks->contains($registrationLink)) {
$this->registrationLinks->add($registrationLink);
$registrationLink->setEnterprise($this);
}
return $this;
}
public function removeRegistrationLink(RegistrationLink $registrationLink): static
{
if ($this->registrationLinks->removeElement($registrationLink)) {
// set the owning side to null (unless already changed)
if ($registrationLink->getEnterprise() === $this) {
$registrationLink->setEnterprise(null);
}
}
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): static
{
$this->locale = $locale;
return $this;
}
/**
* @return Collection<int, ProcessedPaymentPeriod>
*/
public function getProcessedPaymentPeriods(): Collection
{
return $this->processedPaymentPeriods;
}
public function addProcessedPaymentPeriod(ProcessedPaymentPeriod $processedPaymentPeriod): static
{
if (!$this->processedPaymentPeriods->contains($processedPaymentPeriod)) {
$this->processedPaymentPeriods->add($processedPaymentPeriod);
$processedPaymentPeriod->setEnterprise($this);
}
return $this;
}
public function removeProcessedPaymentPeriod(ProcessedPaymentPeriod $processedPaymentPeriod): static
{
if ($this->processedPaymentPeriods->removeElement($processedPaymentPeriod)) {
if ($processedPaymentPeriod->getEnterprise() === $this) {
$processedPaymentPeriod->setEnterprise(null);
}
}
return $this;
}
public function isCreateSwissPassOption(): ?bool
{
return $this->createSwissPassOption;
}
public function setCreateSwissPassOption(?bool $createSwissPassOption): static
{
$this->createSwissPassOption = $createSwissPassOption;
return $this;
}
public function getDistrict(): ?string
{
return $this->district;
}
public function setDistrict(?string $district): static
{
$this->district = $district;
return $this;
}
public function isRemainingBalanceOption(): ?bool
{
return $this->remainingBalanceOption;
}
public function setRemainingBalanceOption(?bool $remainingBalanceOption): static
{
$this->remainingBalanceOption = $remainingBalanceOption;
return $this;
}
public function isReminderOrRemainingBalanceRenewalOption(): ?bool
{
if($this->reminderOption || $this->remainingBalanceRenewalOption){
return true;
}
return false;
}
public function getRemainingBalanceRenewalOption(): ?bool
{
return $this->remainingBalanceRenewalOption;
}
public function setRemainingBalanceRenewalOption(?bool $remainingBalanceRenewalOption): void
{
$this->remainingBalanceRenewalOption = $remainingBalanceRenewalOption;
}
public function getDocumentUploadOption(): ?bool
{
return $this->documentUploadOption;
}
public function setDocumentUploadOption(?bool $documentUploadOption): void
{
$this->documentUploadOption = $documentUploadOption;
}
public function getRemainingBalanceStartDate(): ?\DateTimeInterface
{
return $this->remainingBalanceStartDate;
}
public function setRemainingBalanceStartDate(?\DateTimeInterface $remainingBalanceStartDate): static
{
$this->remainingBalanceStartDate = $remainingBalanceStartDate;
return $this;
}
public function isStartRemainingBalanceOnPurchase(): ?bool
{
return $this->startRemainingBalanceOnPurchase;
}
public function setStartRemainingBalanceOnPurchase(?bool $startRemainingBalanceOnPurchase): static
{
$this->startRemainingBalanceOnPurchase = $startRemainingBalanceOnPurchase;
return $this;
}
public function isReminderOption(): ?bool
{
return $this->reminderOption;
}
public function setReminderOption(?bool $reminderOption): static
{
$this->reminderOption = $reminderOption;
return $this;
}
public function getTu(): ?Tu
{
return $this->tu;
}
public function setTu(?Tu $tu): static
{
$this->tu = $tu;
return $this;
}
public function getCustomerNumber(): ?string
{
return $this->customerNumber;
}
public function setCustomerNumber(?string $customerNumber): static
{
$this->customerNumber = $customerNumber;
return $this;
}
public function getLogoFilename(): ?string
{
return $this->logoFilename;
}
public function setLogoFilename(?string $logoFilename): static
{
$this->logoFilename = $logoFilename;
return $this;
}
public function getLogoMimeType(): ?string
{
return $this->logoMimeType;
}
public function setLogoMimeType(?string $logoMimeType): static
{
$this->logoMimeType = $logoMimeType;
return $this;
}
public function hasLogo(): bool
{
return !empty($this->logoFilename);
}
/**
* @return Collection<int, PricingModel>
*/
public function getPricingModels(): Collection
{
return $this->pricingModels;
}
public function addPricingModel(PricingModel $pricingModel): static
{
if (!$this->pricingModels->contains($pricingModel)) {
$this->pricingModels->add($pricingModel);
}
return $this;
}
public function removePricingModel(PricingModel $pricingModel): static
{
$this->pricingModels->removeElement($pricingModel);
return $this;
}
public function isAllZonesOption(): ?bool
{
return $this->allZonesOption;
}
public function setAllZonesOption(?bool $allZonesOption): static
{
$this->allZonesOption = $allZonesOption;
return $this;
}
/**
* @return Collection<int, ModuleSubscription>
*/
public function getModuleSubscriptions(): Collection
{
return $this->moduleSubscriptions;
}
public function addModuleSubscription(ModuleSubscription $moduleSubscription): self
{
if (!$this->moduleSubscriptions->contains($moduleSubscription)) {
$this->moduleSubscriptions->add($moduleSubscription);
$moduleSubscription->setEnterprise($this);
}
return $this;
}
public function removeModuleSubscription(ModuleSubscription $moduleSubscription): self
{
if ($this->moduleSubscriptions->removeElement($moduleSubscription)) {
// set the owning side to null (unless already changed)
if ($moduleSubscription->getEnterprise() === $this) {
$moduleSubscription->setEnterprise(null);
}
}
return $this;
}
public function getCountryRestriction(): ?array
{
return $this->countryRestriction;
}
public function setCountryRestriction(?array $countryRestriction): static
{
$this->countryRestriction = $countryRestriction;
return $this;
}
public function getCountryRestrictionAsUrlParams(): string
{
if (empty($this->countryRestriction)) {
$this->countryRestriction = ['CH'];
}
return json_encode(
['countries' => $this->countryRestriction],
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP
);
}
public function getSupportedClass(): ?int
{
return $this->supportedClass;
}
public function setSupportedClass(?int $supportedClass): static
{
$this->supportedClass = $supportedClass;
return $this;
}
public function getAllowedProducts(): ?array
{
return $this->allowedProducts;
}
public function setAllowedProducts(?array $allowedProducts): static
{
$this->allowedProducts = $allowedProducts;
return $this;
}
}