<?php
namespace AdminBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Company
*/
#[ORM\Table(name: 'company')]
#[ORM\Entity(repositoryClass: \AdminBundle\Repository\CompanyRepository::class)]
class Company extends BaseEntity
{
const PAYMENT_TYPE_CASH = 1;
const PAYMENT_TYPE_CARD = 2;
const PAYMENT_TYPE_DEPOSIT = 3;
const PAYMENT_TYPE_ACCOUNT = 6;
const PAYMENT_TYPE = [
self::PAYMENT_TYPE_CASH => 'Cash',
self::PAYMENT_TYPE_CARD => 'Card',
self::PAYMENT_TYPE_DEPOSIT => 'Deposit + Cash',
self::PAYMENT_TYPE_ACCOUNT => 'Account'
];
const CONFIG_BOOKING_EMAIL_NONE = 0; // don't send any copy of emails
const CONFIG_BOOKING_EMAIL_CONFIRMATION = 1; // send copy of booking confirmation emails
const CONFIG_BOOKING_EMAIL_ALL = 99; // send copy of all booking types of emails
const CONFIG_BOOKING_EMAIL = [
self::CONFIG_BOOKING_EMAIL_NONE => 'N\A',
self::CONFIG_BOOKING_EMAIL_CONFIRMATION => 'Just confirmation emails',
self::CONFIG_BOOKING_EMAIL_ALL => 'All emails'
];
const INVOICE_TYPE_WEEKLY = 1;
const INVOICE_TYPE_MONTHLY = 2;
const INVOICE_TYPE = [
self::INVOICE_TYPE_WEEKLY => 'Weekly',
self::INVOICE_TYPE_MONTHLY => 'Monthly',
];
/**
* @var int
*/
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
/**
* @var string
*/
#[ORM\Column(name: 'business_name', type: 'string', length: 255)]
private $businessName;
/**
* @var string
*/
#[ORM\Column(name: 'ref', type: 'string', length: 255)]
private $ref;
/**
* @var string
*/
#[ORM\Column(name: 'organization_name', type: 'string', length: 255)]
private $organizationName;
/**
* @var string
*/
#[ORM\Column(name: 'main_contact_name', type: 'string', length: 255)]
private $mainContactName;
/**
* @var string
*/
#[ORM\Column(name: 'ba_address1', type: 'string', length: 255)]
private $baAddress1;
/**
* @var string
*/
#[ORM\Column(name: 'ba_address2', type: 'string', length: 255, nullable: true)]
private $baAddress2;
/**
* @var string
*/
#[ORM\Column(name: 'ba_door_number', type: 'string', length: 255, nullable: true)]
private $baDoorNumber;
/**
* @var string
*/
#[ORM\Column(name: 'ba_store_apt', type: 'string', length: 255, nullable: true)]
private $baStoreApt;
/**
* @var string
*/
#[ORM\Column(name: 'ba_city', type: 'string', length: 255)]
private $baCity;
/**
* @var string
*/
#[ORM\Column(name: 'ba_postcode', type: 'string', length: 255)]
private $baPostcode;
/**
* @var string
*/
#[ORM\Column(name: 'ba_country', type: 'string', length: 255)]
private $baCountry;
/**
* @var string
*/
#[ORM\Column(name: 'vat_id', type: 'string', length: 255)]
private $vatId;
/**
* @var string
*/
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private $notes;
/**
* @var int
*/
#[ORM\Column(name: 'config_booking_emails', type: 'smallint', options: ['default' => 0])]
private $configBookingEmails = self::CONFIG_BOOKING_EMAIL_NONE;
/**
* @var float
*/
#[ORM\Column(name: 'price_discount', type: 'float')]
private $priceDiscount;
/**
* @var bool
*/
#[ORM\Column(name: 'price_discount_fixed', type: 'boolean')]
private $priceDiscountFixed = false;
/**
* @var integer
*/
#[ORM\Column(name: 'payment_type', type: 'smallint', length: 20)]
private $paymentType;
/**
* @var ArrayCollection
*/
#[ORM\OneToMany(targetEntity: \Account::class, mappedBy: 'company', cascade: ['persist'], orphanRemoval: true)]
private $accounts;
/**
* @var User
*/
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
#[ORM\OneToOne(targetEntity: \User::class, inversedBy: 'company', cascade: ['all'])]
protected $user;
/**
* @var ClientInvoices
*/
#[ORM\OneToMany(targetEntity: \AdminBundle\Entity\ClientInvoices::class, mappedBy: 'company', cascade: ['persist', 'remove'], orphanRemoval: true)]
protected $clientInvoices;
/**
* @var Company
*/
#[ORM\OneToMany(targetEntity: \AdminBundle\Entity\CompanyInvoice::class, mappedBy: 'company', cascade: ['persist', 'remove'], orphanRemoval: true)]
private $companyInvoices;
/**
* @var integer
*/
#[ORM\Column(name: 'company_invoice_type', type: 'smallint', length: 20, options: ['default' => 1])]
private $companyInvoiceType = self::INVOICE_TYPE_WEEKLY;
public function __construct()
{
$this->accounts = new ArrayCollection();
$this->clientInvoices = new ArrayCollection();
$this->companyInvoices = new ArrayCollection();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return ArrayCollection
*/
public function getAccounts()
{
return $this->accounts;
}
/**
* @param ArrayCollection $accounts
* @return Company
*/
public function setAccounts($accounts)
{
$this->accounts = $accounts;
return $this;
}
/**
* @param Account $account
* @return $this
*/
public function addAccount($account) {
$this->accounts->add($account);
return $this;
}
/**
* @param Account $account
* @return $this
*/
public function removeAccount(Account $account) {
$this->accounts->remove($account);
return $this;
}
/**
* Set businessName
*
* @param string $businessName
*
* @return Company
*/
public function setBusinessName($businessName)
{
$this->businessName = $businessName;
return $this;
}
/**
* Get businessName
*
* @return string
*/
public function getBusinessName()
{
return $this->businessName;
}
/**
* Set ref
*
* @param string $ref
*
* @return Company
*/
public function setRef($ref)
{
$this->ref = $ref;
return $this;
}
/**
* Get ref
*
* @return string
*/
public function getRef()
{
return $this->ref;
}
/**
* @return int
*/
public function getPaymentType()
{
return $this->paymentType;
}
/**
* @param int $paymentType
*/
public function setPaymentType($paymentType)
{
$this->paymentType = $paymentType;
}
/**
* Set organizationName
*
* @param string $organizationName
*
* @return Company
*/
public function setOrganizationName($organizationName)
{
$this->organizationName = $organizationName;
return $this;
}
/**
* Get organizationName
*
* @return string
*/
public function getOrganizationName()
{
return $this->organizationName;
}
/**
* Set mainContactName
*
* @param string $mainContactName
*
* @return Company
*/
public function setMainContactName($mainContactName)
{
$this->mainContactName = $mainContactName;
return $this;
}
/**
* Get mainContactName
*
* @return string
*/
public function getMainContactName()
{
return $this->mainContactName;
}
/**
* Set baAddress1
*
* @param string $baAddress1
*
* @return Company
*/
public function setBaAddress1($baAddress1)
{
$this->baAddress1 = $baAddress1;
return $this;
}
/**
* Get baAddress1
*
* @return string
*/
public function getBaAddress1()
{
return $this->baAddress1;
}
/**
* Set baAddress2
*
* @param string $baAddress2
*
* @return Company
*/
public function setBaAddress2($baAddress2)
{
$this->baAddress2 = $baAddress2;
return $this;
}
/**
* Get baAddress2
*
* @return string
*/
public function getBaAddress2()
{
return $this->baAddress2;
}
/**
* Set baDoorNumber
*
* @param string $baDoorNumber
*
* @return Company
*/
public function setBaDoorNumber($baDoorNumber)
{
$this->baDoorNumber = $baDoorNumber;
return $this;
}
/**
* Get baDoorNumber
*
* @return string
*/
public function getBaDoorNumber()
{
return $this->baDoorNumber;
}
/**
* Set baStoreApt
*
* @param string $baStoreApt
*
* @return Company
*/
public function setBaStoreApt($baStoreApt)
{
$this->baStoreApt = $baStoreApt;
return $this;
}
/**
* Get baStoreApt
*
* @return string
*/
public function getBaStoreApt()
{
return $this->baStoreApt;
}
/**
* Set baCity
*
* @param string $baCity
*
* @return Company
*/
public function setBaCity($baCity)
{
$this->baCity = $baCity;
return $this;
}
/**
* Get baCity
*
* @return string
*/
public function getBaCity()
{
return $this->baCity;
}
/**
* Set baPostcode
*
* @param string $baPostcode
*
* @return Company
*/
public function setBaPostcode($baPostcode)
{
$this->baPostcode = $baPostcode;
return $this;
}
/**
* Get baPostcode
*
* @return string
*/
public function getBaPostcode()
{
return $this->baPostcode;
}
/**
* Set baCountry
*
* @param string $baCountry
*
* @return Company
*/
public function setBaCountry($baCountry)
{
$this->baCountry = $baCountry;
return $this;
}
/**
* Get baCountry
*
* @return string
*/
public function getBaCountry()
{
return $this->baCountry;
}
/**
* Set vatId
*
* @param string $vatId
*
* @return Company
*/
public function setVatId($vatId)
{
$this->vatId = $vatId;
return $this;
}
/**
* Get vatId
*
* @return string
*/
public function getVatId()
{
return $this->vatId;
}
/**
* Set notes
*
* @param string $notes
*
* @return Company
*/
public function setNotes($notes)
{
$this->notes = $notes;
return $this;
}
/**
* Get notes
*
* @return string
*/
public function getNotes()
{
return $this->notes;
}
/**
* Set priceDiscount
*
* @param float $priceDiscount
*
* @return Company
*/
public function setPriceDiscount($priceDiscount)
{
$this->priceDiscount = $priceDiscount;
return $this;
}
/**
* Get priceDiscount
*
* @return float
*/
public function getPriceDiscount()
{
return $this->priceDiscount;
}
/**
* Set priceDiscountFixed
*
* @param boolean $priceDiscountFixed
*
* @return Company
*/
public function setPriceDiscountFixed($priceDiscountFixed)
{
$this->priceDiscountFixed = $priceDiscountFixed;
return $this;
}
/**
* Get priceDiscountFixed
*
* @return bool
*/
public function getPriceDiscountFixed()
{
return $this->priceDiscountFixed;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
* @return Company
*/
public function setUser($user)
{
$this->user = $user;
return $this;
}
/**
* @return int
*/
public function getConfigBookingEmails()
{
return $this->configBookingEmails;
}
/**
* @param $configBookingEmails
* @return Company
*/
public function setConfigBookingEmails($configBookingEmails)
{
$this->configBookingEmails = $configBookingEmails;
return $this;
}
public function getPriceDiscountDisplay($currencySymbol = '£')
{
return $this->priceDiscount.($this->priceDiscountFixed ? $currencySymbol : '%' );
}
public function __toString()
{
return '['.$this->getId().']['.$this->vatId.']'.$this->getBusinessName().' - '. $this->getOrganizationName().
' ( '. $this->getRef() .' )';
}
public function getClientInvoices()
{
return $this->clientInvoices;
}
public function addClientInvoices(ClientInvoices $clientInvoices)
{
$this->clientInvoices->add($clientInvoices);
}
public function getCompanyInvoices()
{
return $this->companyInvoices;
}
public function addCompanyInvoice(CompanyInvoice $companyInvoice)
{
$this->companyInvoices->add($companyInvoice);
}
/**
* @return int
*/
public function getCompanyInvoiceType()
{
return $this->companyInvoiceType;
}
/**
* @param int $companyInvoiceType
*/
public function setCompanyInvoiceType($companyInvoiceType)
{
$this->companyInvoiceType = $companyInvoiceType;
}
}