<?php
namespace App\AtechNet\CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OrderBy;
use Doctrine\ORM\Mapping\Table as Table;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity as UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Table(name="customers")
* @Entity(repositoryClass="App\AtechNet\CoreBundle\Repository\CustomerRepository")
* @UniqueEntity(
* fields={"domain","email"},
* errorPath="email",
* message="This e-mail is already in use."
* )
* @HasLifecycleCallbacks
*/
class Customer extends AbstractSignedEntity implements UserInterface, PasswordAuthenticatedUserInterface
{
public const string Gender_Women = 'Women';
public const string Gender_Men = 'Men';
public const int SOURCE_SIGN_UP = 0;
public const int SOURCE_NEWSLETTER = 1;
public const int SOURCE_USER = 2;
public const int SOURCE_IMPORT = 3;
public const int SOURCE_NEWSLETTER_EBOOK = 4;
public const int SOURCE_NEWSLETTER_GIFT = 5;
public const int SOURCE_UNAS_EXPANSION = 6;
public const int BAZOS_ID1 = 18822;
public const int BAZOS_ID2 = 22122;
public const int BAZOS_ID3 = 43793;
public const int ATECHCOMP_INTERNAL_ID = 20982;
public const int AMAZON_COMMISSION_ID = 33977;
public const int FURBIFY_PC_SHOP_ID = 6370;
public const int AMAZON_ID = 33978;
public const int AMAZON_GB_ID = 108995;
public const BASE_ID = null;
public const int EMAG_ID = 38585;
public const int ANDREASHOP_ID = 22579;
public const int BACKMARKET_ID = 37165;
public const int BACKMARKET_UK_ID = 106755;
public const int REFURBED_ID = 37898;
public const int REFURBED_CH_ID = 106011;
public const int REFURBED_GB_ID = 106012;
public const int EBAY_ID = 57361;
public const int KAUFLAND_ID = 55727;
public const int VATERA_ID = 92012;
public const int UNAS_ID = 108137;
public const int MEDIAMARKT_ID = 108045;
public const int PC_COMPONENTES_ID = 108748;
public const int MAXMEDIA_KFT_ID = 17785;
public const int TYPE_NORMAL = 0;
public const int TYPE_BUSINESS = 1;
public const int TYPE_SCHOOL = 2;
public const int TYPE_HOSPITAL = 3;
public const int TYPE_INSTITUTION = 4;
public const int SALES_MANAGER_WS_SK1_ID = 224;
public const int SALES_MANAGER_NIKI_ID = 231;
public const int SALES_MANAGER_DENISA_ID = 222;
public const int TEST_CUSTOMER_RT_HU = 94189;
public const int TEST_CUSTOMER_RT_SK = 94187;
public const int TEST_CUSTOMER_RT_CZ = 94190;
public static function getBazosIDs(): array
{
return [
self::BAZOS_ID1,
self::BAZOS_ID2,
self::BAZOS_ID3,
];
}
public static function genderChoices(): array
{
return [
1 => self::Gender_Women,
2 => self::Gender_Men,
];
}
public static function sourceChoices(): array
{
return [
self::SOURCE_SIGN_UP => 'Sign up',
self::SOURCE_NEWSLETTER => 'Newsletter',
self::SOURCE_USER => 'User',
self::SOURCE_IMPORT => 'Import',
self::SOURCE_NEWSLETTER_EBOOK => 'Newsletter ebook',
self::SOURCE_NEWSLETTER_GIFT => 'Newsletter gift',
self::SOURCE_UNAS_EXPANSION => 'Unas expansion',
];
}
/**
* @return array<int, string>
*/
public static function getTypeChoices(): array
{
return [
self::TYPE_NORMAL => 'Normal',
self::TYPE_BUSINESS => 'Business',
self::TYPE_SCHOOL => 'School',
self::TYPE_HOSPITAL => 'Hospital',
self::TYPE_INSTITUTION => 'Institution',
];
}
public static function getMarketplaceList(): array
{
return [
self::BACKMARKET_ID => 'Back Market',
self::REFURBED_ID => 'Refurbed',
self::EBAY_ID => 'Ebay',
self::AMAZON_ID => 'Amazon',
User::USER_ID_UNAS => 'Unas',
];
}
/**
* @var Domain
*
* @ManyToOne(targetEntity="Domain", inversedBy="customers")
* @JoinColumn(name="domain_id", referencedColumnName="id")
*/
private $domain;
/**
* @var \DateTIme
*
* @Column(name="verified", type="datetime", nullable=true)
*/
private $verified = null;
/**
* @var int
*
* @Column(name="old_user_id", type="integer", nullable=true)
*/
private $oldUserId;
/**
* @var bool
*
* @Column(name="active", type="boolean", nullable=false)
*/
private $active = false;
/**
* @var bool
*
* @Column(name="guest", type="boolean", nullable=false)
*/
private $guest = false;
/**
* @var string
*
* @Column(name="username", type="string", nullable=true)
*/
private $userName;
/**
* @var string
*
* @Column(name="degree", type="string", nullable=true)
*/
private $degree;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="first_name", type="string")
*/
private $firstName;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="last_name", type="string")
*/
private $lastName;
/**
* @var string
*
* @Column(name="business_name", type="string", nullable=true)
*/
private $businessName;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="email", type="string")
*/
private $email;
/**
* @var string
*
* @Column(name="phone_number", type="string", nullable=true)
*/
private $phone;
/**
* @var string
*
* @Column(name="business_id", type="string", nullable=true)
*/
private $businessId;
/**
* @var string
*
* @Column(name="tax_id", type="string", nullable=true)
*/
private $taxId;
/**
* @var string
*
* @Column(name="vat_id", type="string", nullable=true)
*/
private $vatId;
/**
* @var \DateTime
*
* @Column(name="since", type="datetime", nullable=true)
*/
private $since;
/**
* @var string
*
* @Column(name="gender", type="string", nullable=true)
*/
private $gender;
/**
* @var User
*
* @ManyToOne(targetEntity="User")
* @JoinColumn(name="sales_manager_id", referencedColumnName="id")
*/
private $salesManager;
/**
* @var bool
*
* @Column(name="wants_newsletter", type="boolean", nullable=false)
*/
private $wantsNewsletter;
/**
* @var string
*
* @Column(name="logo", type="string", nullable=true)
*/
private $logo;
/**
* @var string
*
* @Column(name="iban", type="string", length=64, nullable=true)
*/
private $iban;
/**
* @var string
*
* @Column(name="swift", type="string", length=12, nullable=true)
*/
private $swift;
/**
* @var string
*
* @Column(name="password", type="string", nullable=true)
*/
private $password;
/**
* @var string
*
* @Column(name="salt", type="text")
*/
private $salt;
/**
* @var \DateTime
*
* @Column(name="last_reset", type="datetime", nullable=true)
*/
private $lastReset;
/**
* @var \DateTime
*
* @Column(name="last_login", type="datetime", nullable=true)
*/
private $lastLogin;
/**
* @var string
*
* @Column(name="last_login_ip", type="text", nullable=true)
*/
private $lastLoginIp;
/**
* @var string
*
* @Column(name="remember_key", type="text", nullable=true)
*/
private $rememberKey;
/**
* @var int
*
* @Column(name="source", type="integer")
*/
private $source = 0;
/**
* @var bool
*
* @Column(name="admin_login", type="boolean")
*/
private $adminLogin = false;
/**
* @var int
*
* @Column(name="all_orders_quantity", type="integer")
*/
private $allOrdersQuantity = 0;
/**
* @var float
*
* @Column(name="all_orders_full_price", type="decimal", precision=12, scale=2)
*/
private $allOrdersFullPrice = 0;
/**
* @var \DateTime|null
*
* @Column(name="last_order_date", type="datetime", nullable=true)
*/
private $lastOrderDate = null;
/**
* @var \DateTime|null
*
* @Column(name="second_last_order_date", type="datetime", nullable=true)
*/
private $secondLastOrderDate = null;
/**
* @var \DateTime|null
*
* @Column(name="first_order_date", type="datetime", nullable=true)
*/
private $firstOrderDate = null;
/**
* @var int
*
* @Column(name="billingo_id", type="bigint", nullable=true)
*/
private $billingoId;
/**
* @var int
*
* @Column(name="billingo_v3_id", type="bigint", nullable=true)
*/
private $billingoV3Id;
/**
* @var string
*
* @Column(name="billingo_invoices", type="text", nullable=true)
*/
private $billingoInvoices;
/**
* @var int
*
* @Column(name="type", type="integer")
*/
private $type = self::TYPE_NORMAL;
/**
* @var int
*
* @Column(name="default_due_days", type="integer")
*/
private $defaultDueDays = 0;
/**
* @var string
*
* @Column(name="finance_email", type="string", nullable=true)
*/
private $financeEmail;
/**
* @var string
*
* @Column(name="rolling_order_message", type="text", nullable=true)
*/
private $rollingOrderMessage;
/**
* @var User
*
* @ManyToOne(targetEntity="User")
* @JoinColumn(name="rolling_order_message_updated_by", referencedColumnName="id", nullable=true)
*/
private $rollingOrderMessageUpdatedBy;
/**
* @var ?\DateTime
*
* @Column(name="rolling_order_message_updated_at", type="datetime", nullable=true)
*/
private $rollingOrderMessageUpdatedAt;
/**
* @var ArrayCollection
*
* @Assert\Valid
*
* @OneToMany(targetEntity="Basket", mappedBy="customer", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $baskets;
/**
* @var ArrayCollection
*
* @Assert\Valid
*
* @OneToMany(targetEntity="Order", mappedBy="customer", orphanRemoval=true, fetch="EXTRA_LAZY")
**/
private $orders;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerAddress", mappedBy="customer", orphanRemoval=true)
**/
private $addresses;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerLink", mappedBy="customer", orphanRemoval=true)
**/
private $links;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerContactPerson", mappedBy="customer", orphanRemoval=true)
**/
private $contactPersons;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerEmail", mappedBy="customer", orphanRemoval=true)
**/
private $emails;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerSentEmail", mappedBy="customer", orphanRemoval=true)
**/
private $sentEmails;
private $allEmails = [];
private $allPhones = [];
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerNotification", mappedBy="customer", orphanRemoval=true)
*/
private $notifications;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerData", mappedBy="customer", orphanRemoval=true)
**/
private $datas;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerNote", mappedBy="customer", orphanRemoval=true)
**/
private $notes;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerViewLog", mappedBy="customer", orphanRemoval=true)
**/
private $viewLogs;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="ProductCommission", mappedBy="customer", orphanRemoval=true)
**/
private $commissions;
/**
* @var bool
*
* @Column(name="was_unregistered", type="boolean", nullable=true)
*/
private $wasUnregistered;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="StockMovement", mappedBy="merchant", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $movements;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="Document", mappedBy="customer", orphanRemoval=true, fetch="EXTRA_LAZY")
* @OrderBy({"created" = "DESC"})
**/
private $documents;
/**
* @var ArrayCollection
* @OneToMany(targetEntity="Claim", mappedBy="customer", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $claims;
/**
* @OneToMany(targetEntity="CustomerBillingoData", mappedBy="customer", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $billingoDocuments;
/**
* @var bool
*
* @Column(name="billing_address_modifiable", type="boolean")
*/
private $billingAddressModifiable = false;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="Review", mappedBy="customer", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $reviews;
/**
* @var string
*
* @Column(name="country", type="string", length=32, nullable=true)
*/
private $country;
/**
* @var User|null
*
* @ManyToOne(targetEntity="User")
* @JoinColumn(name="payment_approver_id", referencedColumnName="id", nullable=true)
*/
private $paymentApprover = null;
/**
* @var \DateTime|null
*
* @Column(name="commission_confirmation_mail_sent_date", type="datetime", nullable=true)
*/
private $commissionConfirmationMailSentDate = null;
/**
* @var User|null
*
* @ManyToOne(targetEntity="User")
* @JoinColumn(name="commission_confirmation_mail_sent_by", referencedColumnName="id", nullable=true)
*/
private $commissionConfirmationMailSentBy = null;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerSalesManagerChangelog", mappedBy="customer", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
*/
private $salesManagerChangelog;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerPaymentType", mappedBy="customer", orphanRemoval=true)
*/
private $paymentTypes;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerClaimProduct", mappedBy="customer")
*/
private $customerClaimProducts;
/**
* @var string
*
* @Column(name="daktela_id", type="string", length=30, nullable=true)
*/
private ?string $daktelaId = null;
public function __construct()
{
parent::__construct();
$this->customerClaimProducts = new ArrayCollection();
$this->salt = md5(uniqid(null, true));
$this->orders = new ArrayCollection();
$this->movements = new ArrayCollection();
$this->reviews = new ArrayCollection();
$this->salesManagerChangelog = new ArrayCollection();
}
/**
* @return ArrayCollection
*/
public function getCustomerClaimProducts(): ArrayCollection
{
return $this->customerClaimProducts;
}
public function addCustomerClaimProduct(CustomerClaimProduct $customerClaimProduct): self
{
if (!$this->customerClaimProducts->contains($customerClaimProduct)) {
$this->customerClaimProducts[] = $customerClaimProduct;
$customerClaimProduct->setCustomer($this);
}
return $this;
}
public function removeCustomerClaimProduct(CustomerClaimProduct $customerClaimProduct): self
{
if ($this->customerClaimProducts->removeElement($customerClaimProduct)) {
if ($customerClaimProduct->getCustomer() === $this) {
$customerClaimProduct->setCustomer(null);
}
}
return $this;
}
/**
* @return string
*/
public function getUserIdentifier()
{
return $this->email;
}
/**
* @return Domain
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param Domain $domain
*/
public function setDomain($domain)
{
$this->domain = $domain;
}
/**
* @return int
*/
public function getOldUserId()
{
return $this->oldUserId;
}
/**
* @param int $oldUserId
*/
public function setOldUserId($oldUserId)
{
$this->oldUserId = $oldUserId;
}
/**
* @return boolean
*/
public function isActive()
{
return $this->active;
}
/**
* @param boolean $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return boolean
*/
public function isGuest()
{
return $this->guest;
}
/**
* @param boolean $guest
*/
public function setGuest(bool $guest)
{
$this->guest = $guest;
}
/**
* @return string
*/
public function getUserName()
{
return $this->userName;
}
/**
* @param string $userName
*/
public function setUserName($userName)
{
$this->userName = $userName;
}
/**
* @return string
*/
public function getDegree()
{
return $this->degree;
}
/**
* @param string $degree
*/
public function setDegree($degree)
{
$this->degree = $degree;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = ucfirst($firstName);
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = ucfirst($lastName);
}
/**
* @param bool $inverted
* @return string
*/
public function getFullName($inverted = false)
{
if ($inverted) {
return $this->getLastName() . ' ' . $this->getFirstName();
}
return $this->getFirstName() . ' ' . $this->getLastName();
}
/**
* @return string
*/
public function getBusinessName()
{
return $this->businessName;
}
/**
* @param string $businessName
*/
public function setBusinessName($businessName)
{
$this->businessName = $businessName;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
public function getAllEmails()
{
if ($this->getEmail() != '') {
$this->allEmails[] = $this->getEmail();
}
foreach ($this->emails as $email) {
if (!in_array($email->getEmail(), $this->allEmails)) {
$this->allEmails[] = $email->getEmail();
}
}
foreach ($this->addresses as $address) {
if (!in_array($address->getEmail(), $this->allEmails)) {
$this->allEmails[] = $address->getEmail();
}
}
foreach ($this->contactPersons as $contactPerson) {
if (!in_array($contactPerson->getEmail(), $this->allEmails)) {
$this->allEmails[] = $contactPerson->getEmail();
}
}
return $this->allEmails;
}
/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
public function getAllPhoneNumbers()
{
if ($this->getPhone() != '') {
$this->allPhones[] = $this->getPhone();
}
foreach ($this->addresses as $address) {
if (!in_array($address->getPhone(), $this->allPhones)) {
$this->allPhones[] = $address->getPhone();
}
}
foreach ($this->contactPersons as $contactPerson) {
if (!in_array($contactPerson->getPhone(), $this->allPhones)) {
$this->allPhones[] = $contactPerson->getPhone();
}
}
return $this->allPhones;
}
/**
* @return string
*/
public function getBusinessId()
{
return $this->businessId;
}
/**
* @param string $businessId
*/
public function setBusinessId($businessId)
{
$this->businessId = $businessId;
}
/**
* @return string
*/
public function getTaxId()
{
return $this->taxId;
}
/**
* @param string $taxId
*/
public function setTaxId($taxId)
{
$this->taxId = $taxId;
}
/**
* @return string
*/
public function getVatId()
{
return $this->vatId;
}
/**
* @param string $vatId
*/
public function setVatId($vatId)
{
$this->vatId = $vatId;
}
/**
* @return \DateTime
*/
public function getSince()
{
return $this->since;
}
/**
* @param \DateTime $since
*/
public function setSince($since)
{
$this->since = $since;
}
/**
* @return string
*/
public function getGender()
{
return $this->gender;
}
/**
* @param string $gender
*/
public function setGender($gender)
{
$this->gender = $gender;
}
/**
* @return ?User
*/
public function getSalesManager()
{
return $this->salesManager;
}
/**
* @param User $salesManager
*/
public function setSalesManager($salesManager)
{
$this->salesManager = $salesManager;
}
/**
* @return boolean
*/
public function isWantsNewsletter()
{
return $this->wantsNewsletter;
}
/**
* @param boolean $wantsNewsletter
*/
public function setWantsNewsletter($wantsNewsletter)
{
$this->wantsNewsletter = $wantsNewsletter;
}
/**
* @return string
*/
public function getLogo()
{
return $this->logo;
}
/**
* @param string $logo
*/
public function setLogo($logo)
{
$this->logo = $logo;
}
/**
* @return string|null
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* @param string $password
*/
public function setPassword($password)
{
$this->password = $password;
}
/**
* @return string
*/
public function getSalt()
{
return $this->salt;
}
/**
* @return \DateTime
*/
public function getLastReset()
{
return $this->lastReset;
}
/**
* @param \DateTime $lastReset
*/
public function setLastReset($lastReset)
{
$this->lastReset = $lastReset;
}
/**
* @return \DateTime
*/
public function getLastLogin()
{
return $this->lastLogin;
}
/**
* @param \DateTime $lastLogin
*/
public function setLastLogin($lastLogin)
{
$this->lastLogin = $lastLogin;
}
/**
* @return string
*/
public function getLastLoginIp()
{
return $this->lastLoginIp;
}
/**
* @param string $lastLoginIp
*/
public function setLastLoginIp($lastLoginIp)
{
$this->lastLoginIp = $lastLoginIp;
}
/**
* @return ArrayCollection
*/
public function getOrders()
{
return $this->orders;
}
public function getOrdersByCriteria(int $firstResult, int $maxResult)
{
$criteria = Criteria::create()
->setFirstResult($firstResult)
->setMaxResults($maxResult)
->andWhere(Criteria::expr()->notIn('status', [Order::STATUS_FINISHED]));
return $this->orders->matching($criteria);
}
/**
* @return ArrayCollection
*/
public function getAddresses()
{
return $this->addresses;
}
/**
* @param ArrayCollection $addresses
*/
public function setAddresses($addresses)
{
$this->addresses = $addresses;
}
/**
* @return ArrayCollection
*/
public function getLinks()
{
return $this->links;
}
/**
* @param ArrayCollection $links
*/
public function setLinks($links)
{
$this->links = $links;
}
/**
* @return ArrayCollection
*/
public function getContactPersons()
{
return $this->contactPersons;
}
/**
* @param ArrayCollection $contactPersons
*/
public function setContactPersons($contactPersons)
{
$this->contactPersons = $contactPersons;
}
/**
* @return ArrayCollection
*/
public function getEmails()
{
return $this->emails;
}
/**
* @param ArrayCollection $emails
*/
public function setEmails($emails)
{
$this->emails = $emails;
}
/**
* @return CustomerData
*/
public function getData()
{
if (!is_null($this->datas) && $this->datas->count() > 0) {
return $this->datas->first();
}
return null;
}
/**
* @return ArrayCollection
*/
public function getNotes()
{
return $this->notes;
}
/**
* @param ArrayCollection $notes
*/
public function setNotes($notes)
{
$this->notes = $notes;
}
/**
* @return ArrayCollection
*/
public function getDatas()
{
return $this->datas;
}
/**
* @param ArrayCollection $datas
*/
public function setDatas($datas)
{
$this->datas = $datas;
}
/**
* @return ArrayCollection
*/
public function getViewLogs()
{
return $this->viewLogs;
}
/**
* @param ArrayCollection $viewLogs
*/
public function setViewLogs($viewLogs)
{
$this->viewLogs = $viewLogs;
}
/**
* @return string
*/
public function getRememberKey()
{
return $this->rememberKey;
}
/**
* @param string $rememberKey
*/
public function setRememberKey($rememberKey)
{
$this->rememberKey = $rememberKey;
}
/**
* @return int
*/
public function getSource()
{
return $this->source;
}
/**
* @param int $source
*/
public function setSource($source)
{
$this->source = $source;
}
/**
* @return boolean
*/
public function isAdminLogin()
{
return $this->adminLogin;
}
/**
* @param boolean $adminLogin
*/
public function setAdminLogin($adminLogin)
{
$this->adminLogin = $adminLogin;
}
/**
* @return ArrayCollection
*/
public function getBaskets()
{
return $this->baskets;
}
/**
* @return ArrayCollection
*/
public function getSentEmails()
{
return $this->sentEmails;
}
/**
* @return ArrayCollection
*/
public function getNotifications()
{
return $this->notifications;
}
/**
* @return boolean
*/
public function isWasUnregistered()
{
return $this->wasUnregistered;
}
/**
* @return ArrayCollection
*/
public function getCommissions()
{
return $this->commissions;
}
/**
* @return int
*/
public function getAllOrdersQuantity()
{
return $this->allOrdersQuantity;
}
/**
* @internal param int $allOrdersQuantity
*/
public function setAllOrdersQuantity()
{
$quantity = 0;
foreach ($this->orders as $order) {
if ($order->getStatus() != Order::STATUS_CANCELED) {
$quantity++;
}
}
$this->allOrdersQuantity = $quantity;
}
/**
* @return float
*/
public function getAllOrdersFullPrice()
{
return $this->allOrdersFullPrice;
}
/**
* @internal param float $allOrdersFullPrice
*/
public function setAllOrdersFullPrice()
{
$ordersValue = 0;
foreach ($this->orders as $order) {
if ($order->getStatus() != Order::STATUS_CANCELED) {
$ordersValue += $order->getFullPrice();
}
}
$this->allOrdersFullPrice = $ordersValue;
}
/**
* Returns the the value of orders by this customer
*/
public function getOrdersValue()
{
$ordersValue = 0;
foreach ($this->orders as $order) {
$ordersValue += $order->getFullPrice();
}
return $ordersValue;
}
/**
* Returns the the quantity of orders by this customer
*/
public function getOrdersQuantity()
{
return $this->orders->count();
}
/**
* Update the quantity and full price for current customer
*/
public function updateAllOrderPriceAndQuantity()
{
$this->setAllOrdersQuantity();
$this->setAllOrdersFullPrice();
$this->updateOrderDates();
}
public function getLastOrderDate(): ?\DateTime
{
return $this->lastOrderDate;
}
public function getSecondLastOrderDate(): ?\DateTime
{
return $this->secondLastOrderDate;
}
public function getFirstOrderDate(): ?\DateTime
{
return $this->firstOrderDate;
}
public function updateOrderDates(): void
{
$dates = [];
foreach ($this->orders as $order) {
$dates[] = $order->getCreated();
}
usort($dates, fn (\DateTime $a, \DateTime $b) => $a <=> $b);
$count = count($dates);
$this->firstOrderDate = $count >= 1 ? $dates[0] : null;
$this->lastOrderDate = $count >= 1 ? $dates[$count - 1] : null;
$this->secondLastOrderDate = $count >= 2 ? $dates[$count - 2] : null;
}
/**
* @return ArrayCollection
*/
public function getMovements()
{
return $this->movements;
}
/**
* @param ArrayCollection $movements
*/
public function setMovements($movements)
{
$this->movements = $movements;
}
/**
* @return ArrayCollection
*/
public function getSalesManagerChangeLogs()
{
return $this->salesManagerChangelog;
}
/**
* @return ArrayCollection
*/
public function getDocuments()
{
return $this->documents;
}
public function getCurrency(): ?string
{
return $this->getDomain()?->getCurrency();
}
/**
* @param string $vatId
* @param null|int $date
* @return bool
*
* $date Date format: 'YmdHi'
*/
public function useZeroVat($vatId = 'not set', $date = null)
{
if (in_array($vatId, ['HU27955422', 'HU14120204'])) {
return true;
} elseif ($vatId == 'HU11511810') {
return false;
}
if (!is_null($date) && ($date < Domain::HU_VAT_CHANGE_DATE || $date > Domain::HU_VAT_CHANGE_BACK_DATE)) {
if ((is_null($this->getDomain()->getLanguage()) || $this->getDomain()->getLanguage()->getCode() == 'sk') && !in_array($this->getDomain()->getId(), [Domain::DOMAIN_ID_WS_EU, Domain::DOMAIN_ID_OTHER])) {
return false;
} else {
return $this->hasProperVatId($vatId);
}
} else {
if (date('YmdHi') < Domain::HU_VAT_CHANGE_BACK_DATE) {
if (in_array($this->domain->getLanguage()->getCode(), ['sk', 'hu']) && !in_array($this->getDomain()->getId(), [Domain::DOMAIN_ID_WS_EU,Domain::DOMAIN_ID_OTHER])) {
return !is_null($this->getId()) && in_array($this->getId(), self::getBazosIDs());
} else {
return $this->hasProperVatId($vatId);
}
} else {
if ($this->domain->getLanguage()->getCode() == 'sk' && $this->domain->getId() != Domain::DOMAIN_ID_WS_EU) {
return !is_null($this->getId()) && in_array($this->getId(), self::getBazosIDs());
} else {
return $this->hasProperVatId($vatId);
}
}
}
}
/**
* @param string $vatId
* @return bool
*/
public function hasProperVatId($vatId = 'not set')
{
$vatIdToCheck = $vatId == 'not set' ? $this->vatId : $vatId;
return !is_null($vatIdToCheck) && strlen($vatIdToCheck) > 3;
}
/**
* @return string
*/
public function getIban()
{
return $this->iban;
}
/**
* @param string $iban
*/
public function setIban($iban)
{
$this->iban = $iban;
}
/**
* @return string
*/
public function getSwift()
{
return $this->swift;
}
/**
* @param string $swift
*/
public function setSwift($swift)
{
$this->swift = $swift;
}
/**
* @return int
*/
public function getBillingoId()
{
return $this->billingoId;
}
/**
* @param int $billingoId
*/
public function setBillingoId($billingoId)
{
$this->billingoId = $billingoId;
}
/**
* @return int|null
*/
public function getBillingoV3Id(): ?int
{
return $this->billingoV3Id;
}
/**
* @param int|null $billingoV3Id
*/
public function setBillingoV3Id(?int $billingoV3Id): void
{
$this->billingoV3Id = $billingoV3Id;
}
/**
* @return string
*/
public function getBillingoInvoices()
{
return $this->billingoInvoices;
}
/**
* @param string $billingoInvoices
*/
public function setBillingoInvoices($billingoInvoices)
{
$this->billingoInvoices = $billingoInvoices;
}
/**
* @return mixed|string
*/
public function getBillingoInvoicesUnserialized()
{
return !is_null($this->billingoInvoices) && count(unserialize($this->billingoInvoices)) > 0 ? unserialize($this->billingoInvoices) : null;
}
/**
* @param int $orderId
* @return mixed|string
*/
public function getBillingoInvoicesUnserializedByOrder($orderId)
{
$billingInvoices = $this->getBillingoInvoicesUnserialized();
return !is_null($billingInvoices) && isset($billingInvoices[$orderId]) ? $billingInvoices[$orderId] : null;
}
/**
* @return ArrayCollection
*/
public function getClaims()
{
return $this->claims;
}
/**
* @return ArrayCollection
*/
public function getBillingoDocuments()
{
return $this->billingoDocuments;
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param int $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return int
*/
public function getDefaultDueDays()
{
return $this->defaultDueDays;
}
/**
* @param int $defaultDueDays
*/
public function setDefaultDueDays($defaultDueDays)
{
$this->defaultDueDays = $defaultDueDays;
}
/**
* @return string
*/
public function getFinanceEmail()
{
return $this->financeEmail;
}
/**
* @param string $financeEmail
*/
public function setFinanceEmail($financeEmail)
{
$this->financeEmail = $financeEmail;
}
/**
* @return bool
*/
public function isBillingAddressModifiable()
{
return $this->billingAddressModifiable;
}
/**
* @param bool $billingAddressModifiable
*/
public function setBillingAddressModifiable($billingAddressModifiable)
{
$this->billingAddressModifiable = $billingAddressModifiable;
}
public function isBusiness(): bool
{
return !is_null($this->getBusinessName()) && trim($this->getBusinessName()) != '';
}
/**
* @return ArrayCollection
*/
public function getReviews()
{
return $this->reviews;
}
/**
* @param string $country
* @return Customer
*/
public function setCountry($country): Customer
{
$this->country = $country;
return $this;
}
/**
* @return string
*/
public function getCountry(): ?string
{
return $this->country;
}
/**
* @return User|null
*/
public function getPaymentApprover(): ?User
{
return $this->paymentApprover;
}
/**
* @param User|null $paymentApprover
*/
public function setPaymentApprover(?User $paymentApprover): void
{
$this->paymentApprover = $paymentApprover;
}
/**
* @return \DateTime|null
*/
public function getCommissionConfirmationMailSentDate(): ?\DateTime
{
return $this->commissionConfirmationMailSentDate;
}
/**
* @param \DateTime|null $commissionConfirmationMailSentDate
*/
public function setCommissionConfirmationMailSentDate(?\DateTime $commissionConfirmationMailSentDate): void
{
$this->commissionConfirmationMailSentDate = $commissionConfirmationMailSentDate;
}
/**
* @return User|null
*/
public function getCommissionConfirmationMailSentBy(): ?User
{
return $this->commissionConfirmationMailSentBy;
}
/**
* @param User|null $commissionConfirmationMailSentBy
*/
public function setCommissionConfirmationMailSentBy(?User $commissionConfirmationMailSentBy): void
{
$this->commissionConfirmationMailSentBy = $commissionConfirmationMailSentBy;
}
/**
* @return ArrayCollection
*/
public function getPaymentTypes()
{
return $this->paymentTypes;
}
/**
* @param int $domainId
* @return string|null
*/
public static function getCountryCodeByDomainId(int $domainId): ?string
{
switch ($domainId) {
case Domain::DOMAIN_ID_RT_SK:
case Domain::DOMAIN_ID_WS_SK:
return 'SK';
case Domain::DOMAIN_ID_RT_HU:
case Domain::DOMAIN_ID_WS_HU:
return 'HU';
case Domain::DOMAIN_ID_RT_CZ:
case Domain::DOMAIN_ID_WS_CZ:
return 'CZ';
}
return null;
}
/**
* @return bool
*/
public function isB2B(): bool
{
return $this->domain->getType() == 'retail'
&& !is_null($this->getSalesManager())
&& in_array($this->getSalesManager()->getId(), [
User::USER_ID_MARTIN_RIECICIAR,
User::USER_ID_BEATA_SEDLAROVA,
User::USER_ID_B2B_SK,
User::USER_ID_B2B_CZ,
User::USER_ID_B2B_HU,
User::USER_ID_GERHARD_SZABO,
]);
}
public function getRoles()
{
return ['ROLE_USER'];
}
public function eraseCredentials()
{
}
public function __call($name, $arguments)
{
}
/**
* @return string|null
*/
public function getRollingOrderMessage(): ?string
{
return $this->rollingOrderMessage;
}
/**
* @param string|null $rollingOrderMessage
* @return void
*/
public function setRollingOrderMessage(?string $rollingOrderMessage): void
{
$this->rollingOrderMessage = $rollingOrderMessage;
}
/**
* @param User|null $user
* @return void
*/
public function setRollingOrderMessageUpdatedBy(?User $user): void
{
$this->rollingOrderMessageUpdatedBy = $user;
}
/**
* @return ?User
*/
public function getRollingOrderMessageUpdatedBy(): ?User
{
return $this->rollingOrderMessageUpdatedBy;
}
/**
* @return ?\DateTime
*/
public function getRollingOrderMessageUpdatedAt(): ?\DateTime
{
return $this->rollingOrderMessageUpdatedAt;
}
/**
* @param \DateTime|null $rollingOrderMessage
* @return void
*/
public function setRollingOrderMessageUpdatedAt(?\DateTime $dateTime): void
{
$this->rollingOrderMessageUpdatedAt = $dateTime;
}
/**
* @return bool
*/
public function isCompany(): bool
{
if ($this->taxId || $this->vatId || $this->businessId || $this->businessName) {
return true;
} else {
return false;
}
}
/**
* @return string|null
*/
public function getDaktelaId(): ?string
{
return $this->daktelaId;
}
/**
* @param string|null $daktelaId
*
* @return void
*/
public function setDaktelaId(?string $daktelaId): void
{
$this->daktelaId = $daktelaId;
}
}