<?php
namespace App\Entity\Gos;
use App\Entity\Gos\AdditionalAccess\AdditionalAccessBeneficiary;
use App\Entity\Gos\AdditionalAccess\UserAdditionalAccessOffer;
use App\Entity\Gos\VirtualCurrency\VirtualCurrencyTransaction;
use App\Entity\OrdersInterface;
use App\Enum\DocumentDistributionChannels;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Orders
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\OrdersRepository")
* @ORM\HasLifecycleCallbacks
*/
class Orders implements OrdersInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=150, unique=true, nullable=true)
*/
private $ordTran;
/**
* @ORM\Column(type="text", length=1000, nullable=true)
*/
private $comment;
/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $couponCode;
/**
* @var float
*
* @ORM\Column(type="float", precision=18, scale=2, nullable=true)
*/
private $totalPriceGross;
/**
* @var float
*
* @ORM\Column(type="float", precision=18, scale=2, nullable=true)
*/
private $totalPriceNet;
/**
* @var float
*
* @ORM\Column(type="float", precision=18, scale=2, nullable=true)
*/
private $totalPriceBeforeCouponGross;
/**
* @var float
*
* @ORM\Column(type="float", precision=18, scale=2, nullable=true)
*/
private $totalPriceBeforeCouponNet;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":0})
*/
private $receiveAdvertising;
/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
private $actionNumber;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $fromSource;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $campaign;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $campaignChannel;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $buttonParameters;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderPart", mappedBy="orders", cascade={"persist"})
*/
private $orderPart;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\Participants", mappedBy="orders", cascade={"persist"})
*/
private $participants;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\Address", inversedBy="orders")
* @ORM\JoinColumn()
*/
private $address;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\User", inversedBy="orders")
* @ORM\JoinColumn()
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\PortalSettings", inversedBy="orders")
* @ORM\JoinColumn()
*/
private $portalSettings;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\OrderType", inversedBy="orders")
* @ORM\JoinColumn()
*/
private $orderType;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\OrderTerm", mappedBy="orders")
*/
private $orderTerms;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\SalesManagoEvent", mappedBy="orders")
*/
private $salesManagoEvent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\UserTerms", mappedBy="orders")
*/
private $userTerms;
/**
* @ORM\Column(type="string", length=15, nullable=true)
*/
private $client_ipv4;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $client_host;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Gos\NoTaxType", inversedBy="orders")
*/
private $noTaxType;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $noTaxPublicSectorUnit;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Gos\TouchPoint", mappedBy="order")
*/
private $touchPoint;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Gos\TouchPointAll", mappedBy="order")
*/
private $touchPointAll;
/**
* @ORM\OneToMany(targetEntity="Gift", mappedBy="buyerOrder", cascade={"persist"})
*/
private $buyerGift;
/**
* @ORM\OneToOne(targetEntity="Gift", mappedBy="recipientOrder")
*/
private $recipientGift;
/**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="orders")
* @ORM\JoinColumn()
*/
private $country;
/**
* @ORM\ManyToOne(targetEntity="PaymentSystem", inversedBy="orders")
* @ORM\JoinColumn()
*/
private $paymentSystem;
/**
* @ORM\OneToMany(targetEntity="BraintreeResponse", mappedBy="order")
*/
private $braintreeResponse;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $infoline;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $postOrder;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Gos\User", mappedBy="orderDuringRegistration")
*/
private $userFirstOrder;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $marketing;
/**
* @ORM\OneToOne(targetEntity="TeleOrder", mappedBy="mainOrder", cascade={"persist", "remove"})
*/
private $teleOrder;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $foExportetAt;
/**
* @ORM\OneToMany(targetEntity=FoLog::class, mappedBy="orders")
*/
private $foLogs;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":0})
*/
private $isTest;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isGATransactionSent;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lab;
/**
* @ORM\Column(type="boolean", options={"default":0})
*/
private $isSbExportNeeded = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $sbExportAt;
/**
* @ORM\Column(type="integer", options={"default": 0})
*/
private $extendedPaymentTime = 0;
/**
* @ORM\ManyToOne(targetEntity=ShippingType::class)
*/
private $shippingType;
/**
* @ORM\OneToOne(targetEntity=OrderTeleConsultant::class, cascade={"persist", "remove"})
*/
private $teleConsultant;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $exportedToSbBy;
/**
* @ORM\OneToMany(targetEntity=UserCard::class, mappedBy="orders")
*/
private $userCards;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $fromSourceAll;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $actionNumberAll;
/**
* @ORM\OneToOne(targetEntity=ProductVariantReviewNotification::class, mappedBy="orders")
*/
private $productVariantsReviewNotification;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $paymentRewardDeadline;
/**
* @ORM\ManyToOne(targetEntity=UserAdditionalAccessOffer::class, inversedBy="orders")
*/
private $userAdditionalAccessOffer;
/**
* @ORM\OneToMany(targetEntity=AdditionalAccessBeneficiary::class, mappedBy="orders", orphanRemoval=true)
*/
private $additionalAccessBeneficiaries;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $teleOrderSplit;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $burAssignedSupportId;
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string)$this->ordTran;
}
public function getObjectVars()
{
return get_object_vars($this);
}
public function getTotalShippingCost($returnNet = true)
{
$totalShippingCostNet = 0;
$totalShippingCostGross = 0;
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderPart $orderPart */
$totalShippingCostNet += $orderPart->getTotalShippingCostNet();
$totalShippingCostGross += $orderPart->getTotalShippingCostGross();
}
return $returnNet ? $totalShippingCostNet : $totalShippingCostGross;
}
public function getTotalPriceGrossWithShipping()
{
return $this->getTotalPriceGross() + $this->getTotalShippingCost(false);
}
public function getTotalPriceNetWithShipping()
{
return $this->getTotalPriceNet() + $this->getTotalShippingCost();
}
public function hasTestProduct()
{
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
if ($orderPart->hasTestProduct())
{
return true;
}
}
return false;
}
//------------------------------ setters & getters
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set ordTran
*
* @param string $ordTran
*
* @return Orders
*/
public function setOrdTran($ordTran)
{
$this->ordTran = $ordTran;
return $this;
}
/**
* Get ordTran
*
* @return string
*/
public function getOrdTran()
{
return $this->ordTran;
}
public function getOrdTranForSummaryLink()
{
foreach ($this->orderPart as $orderPart)
{
if (!empty($orderPart->getOrdTran()) && strpos($orderPart->getOrdTran(), 'WF') !== false)
{
return $orderPart->getOrdTran();
}
}
return $this->ordTran;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Orders
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Orders
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set user
*
* @param \App\Entity\Gos\User $user
*
* @return Orders
*/
public function setUser(\App\Entity\Gos\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \App\Entity\Gos\User
*/
public function getUser()
{
return $this->user;
}
/**
* Set orderType
*
* @param \App\Entity\Gos\OrderType $orderType
*
* @return Orders
*/
public function setOrderType(\App\Entity\Gos\OrderType $orderType = null)
{
$this->orderType = $orderType;
return $this;
}
/**
* Get orderType
*
* @return \App\Entity\Gos\OrderType
*/
public function getOrderType()
{
return $this->orderType;
}
/**
* Set comment
*
* @param string $comment
*
* @return Orders
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set address
*
* @param \App\Entity\Gos\Address $address
*
* @return Orders
*/
public function setAddress(\App\Entity\Gos\Address $address = null)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return \App\Entity\Gos\Address
*/
public function getAddress()
{
return $this->address;
}
/**
* Set receiveAdvertising
*
* @param boolean $receiveAdvertising
*
* @return Orders
*/
public function setReceiveAdvertising($receiveAdvertising)
{
$this->receiveAdvertising = $receiveAdvertising;
return $this;
}
/**
* Get receiveAdvertising
*
* @return boolean
*/
public function getReceiveAdvertising()
{
return $this->receiveAdvertising;
}
/**
* Set totalPriceGross
*
* @param float $totalPriceGross
*
* @return Orders
*/
public function setTotalPriceGross($totalPriceGross)
{
$this->totalPriceGross = round($totalPriceGross, 2);
return $this;
}
/**
* Get totalPriceGross
*
* @return float
*/
public function getTotalPriceGross()
{
return $this->totalPriceGross;
}
/**
* Set totalPriceNet
*
* @param float $totalPriceNet
*
* @return Orders
*/
public function setTotalPriceNet($totalPriceNet)
{
$this->totalPriceNet = round($totalPriceNet,2);
return $this;
}
/**
* Get totalPriceNet
*
* @return float
*/
public function getTotalPriceNet()
{
return $this->totalPriceNet;
}
/**
* Set totalPriceBeforeCouponGross
*
* @param float $totalPriceBeforeCouponGross
*
* @return Orders
*/
public function setTotalPriceBeforeCouponGross($totalPriceBeforeCouponGross)
{
$this->totalPriceBeforeCouponGross = round($totalPriceBeforeCouponGross,2 );
return $this;
}
/**
* Get totalPriceBeforeCouponGross
*
* @return float
*/
public function getTotalPriceBeforeCouponGross()
{
return $this->totalPriceBeforeCouponGross;
}
/**
* Set totalPriceBeforeCouponNet
*
* @param float $totalPriceBeforeCouponNet
*
* @return Orders
*/
public function setTotalPriceBeforeCouponNet($totalPriceBeforeCouponNet)
{
$this->totalPriceBeforeCouponNet = round($totalPriceBeforeCouponNet,2);
return $this;
}
/**
* Get totalPriceBeforeCouponNet
*
* @return float
*/
public function getTotalPriceBeforeCouponNet()
{
return $this->totalPriceBeforeCouponNet;
}
/**
* Set couponCode
*
* @param string $couponCode
*
* @return Orders
*/
public function setCouponCode($couponCode)
{
$this->couponCode = $couponCode;
return $this;
}
/**
* Get couponCode
*
* @return string
*/
public function getCouponCode()
{
return $this->couponCode;
}
/**
* Constructor
*/
public function __construct()
{
$this->orderProductVariant = new ArrayCollection();
$this->orderPart = new ArrayCollection();
$this->participants = new ArrayCollection();
$this->orderTerms = new ArrayCollection();
$this->salesManagoEvent = new ArrayCollection();
$this->userTerms = new ArrayCollection();
$this->buyerGift = new ArrayCollection();
$this->braintreeResponse = new ArrayCollection();
$this->foLogs = new ArrayCollection();
$this->userCards = new ArrayCollection();
$this->additionalAccessBeneficiaries = new ArrayCollection();
}
/**
* Set actionNumber
*
* @param string $actionNumber
*
* @return Orders
*/
public function setActionNumber($actionNumber)
{
$this->actionNumber = $actionNumber;
return $this;
}
/**
* Get actionNumber
*
* @return string
*/
public function getActionNumber()
{
return $this->actionNumber;
}
/**
* Set fromSource
*
* @param string $fromSource
*
* @return Orders
*/
public function setFromSource($fromSource)
{
$this->fromSource = $fromSource;
return $this;
}
/**
* Get fromSource
*
* @return string
*/
public function getFromSource()
{
return $this->fromSource;
}
/**
* Set campaign
*
* @param string $campaign
* @return Orders
*/
public function setCampaign($campaign)
{
$this->campaign = $campaign;
return $this;
}
/**
* Get campaign
*
* @return string
*/
public function getCampaign()
{
return $this->campaign;
}
/**
* Set campaignChannel
*
* @param string $campaignChannel
* @return Orders
*/
public function setCampaignChannel($campaignChannel)
{
$this->campaignChannel = $campaignChannel;
return $this;
}
/**
* Get campaignChannel
*
* @return string
*/
public function getCampaignChannel()
{
return $this->campaignChannel;
}
/**
* Add orderPart
*
* @param \App\Entity\Gos\OrderPart $orderPart
*
* @return Orders
*/
public function addOrderPart(\App\Entity\Gos\OrderPart $orderPart)
{
$this->orderPart[] = $orderPart;
return $this;
}
/**
* Remove orderPart
*
* @param \App\Entity\Gos\OrderPart $orderPart
*/
public function removeOrderPart(\App\Entity\Gos\OrderPart $orderPart)
{
$this->orderPart->removeElement($orderPart);
}
/**
* Get orderPart
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getOrderPart()
{
return $this->orderPart;
}
/**
* Set portalSettings
*
* @param \App\Entity\Gos\PortalSettings $portalSettings
*
* @return Orders
*/
public function setPortalSettings(\App\Entity\Gos\PortalSettings $portalSettings = null)
{
$this->portalSettings = $portalSettings;
return $this;
}
/**
* Get portalSettings
*
* @return \App\Entity\Gos\PortalSettings
*/
public function getPortalSettings()
{
return $this->portalSettings;
}
/**
* Add orderTerm
*
* @param \App\Entity\Gos\OrderTerm $orderTerm
*
* @return Orders
*/
public function addOrderTerm(\App\Entity\Gos\OrderTerm $orderTerm)
{
$this->orderTerms[] = $orderTerm;
return $this;
}
/**
* Remove orderTerm
*
* @param \App\Entity\Gos\OrderTerm $orderTerm
*/
public function removeOrderTerm(\App\Entity\Gos\OrderTerm $orderTerm)
{
$this->orderTerms->removeElement($orderTerm);
}
/**
* Get orderTerms
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getOrderTerms()
{
return $this->orderTerms;
}
/**
* Set clientIpv4
*
* @param string $clientIpv4
*
* @return Orders
*/
public function setClientIpv4($clientIpv4)
{
$this->client_ipv4 = $clientIpv4;
return $this;
}
/**
* Get clientIpv4
*
* @return string
*/
public function getClientIpv4()
{
return $this->client_ipv4;
}
/**
* Set clientHost
*
* @param string $clientHost
*
* @return Orders
*/
public function setClientHost($clientHost)
{
$this->client_host = $clientHost;
return $this;
}
/**
* Get clientHost
*
* @return string
*/
public function getClientHost()
{
return $this->client_host;
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return Orders
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Add userTerm
*
* @param \App\Entity\Gos\UserTerms $userTerm
*
* @return Orders
*/
public function addUserTerm(\App\Entity\Gos\UserTerms $userTerm)
{
$this->userTerms[] = $userTerm;
return $this;
}
/**
* Remove userTerm
*
* @param \App\Entity\Gos\UserTerms $userTerm
*/
public function removeUserTerm(\App\Entity\Gos\UserTerms $userTerm)
{
$this->userTerms->removeElement($userTerm);
}
/**
* Get userTerms
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getUserTerms()
{
return $this->userTerms;
}
/**
* Add salesManagoEvent
*
* @param \App\Entity\Gos\SalesManagoEvent $salesManagoEvent
*
* @return Orders
*/
public function addSalesManagoEvent(\App\Entity\Gos\SalesManagoEvent $salesManagoEvent)
{
$this->salesManagoEvent[] = $salesManagoEvent;
return $this;
}
/**
* Remove salesManagoEvent
*
* @param \App\Entity\Gos\SalesManagoEvent $salesManagoEvent
*/
public function removeSalesManagoEvent(\App\Entity\Gos\SalesManagoEvent $salesManagoEvent)
{
$this->salesManagoEvent->removeElement($salesManagoEvent);
}
/**
* Get salesManagoEvent
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSalesManagoEvent()
{
return $this->salesManagoEvent;
}
public function getInfoline(): ?string
{
return $this->infoline;
}
public function setInfoline(?string $infoline): self
{
$this->infoline = $infoline;
return $this;
}
public function getPostOrder(): ?string
{
return $this->postOrder;
}
public function setPostOrder(?string $postOrder): self
{
$this->postOrder = $postOrder;
return $this;
}
public function getNoTaxPublicSectorUnit(): ?string
{
return $this->noTaxPublicSectorUnit;
}
public function setNoTaxPublicSectorUnit(?string $noTaxPublicSectorUnit): self
{
$this->noTaxPublicSectorUnit = $noTaxPublicSectorUnit;
return $this;
}
public function getNoTaxType(): ?NoTaxType
{
return $this->noTaxType;
}
public function setNoTaxType(?NoTaxType $noTaxType): self
{
$this->noTaxType = $noTaxType;
return $this;
}
public function getTouchPoint(): ?TouchPoint
{
return $this->touchPoint;
}
public function setTouchPoint(?TouchPoint $touchPoint): self
{
$this->touchPoint = $touchPoint;
// set (or unset) the owning side of the relation if necessary
$newOrder = $touchPoint === null ? null : $this;
if ($newOrder !== $touchPoint->getOrder()) {
$touchPoint->setOrder($newOrder);
}
return $this;
}
public function getBuyerGift(): ?Collection
{
return $this->buyerGift;
}
public function setBuyerGift(?Gift $buyerGift): self
{
$this->buyerGift = $buyerGift;
// set (or unset) the owning side of the relation if necessary
$newBuyerOrder = $buyerGift === null ? null : $this;
if ($newBuyerOrder !== $buyerGift->getBuyerOrder()) {
$buyerGift->setBuyerOrder($newBuyerOrder);
}
return $this;
}
public function getRecipientGift(): ?Gift
{
return $this->recipientGift;
}
public function setRecipientGift(?Gift $recipientGift): self
{
$this->recipientGift = $recipientGift;
// set (or unset) the owning side of the relation if necessary
$newRecipientOrder = $recipientGift === null ? null : $this;
if ($newRecipientOrder !== $recipientGift->getRecipientOrder()) {
$recipientGift->setRecipientOrder($newRecipientOrder);
}
return $this;
}
public function addBuyerGift(Gift $buyerGift): self
{
if (!$this->buyerGift->contains($buyerGift)) {
$this->buyerGift[] = $buyerGift;
$buyerGift->setBuyerOrder($this);
}
return $this;
}
public function removeBuyerGift(Gift $buyerGift): self
{
if ($this->buyerGift->contains($buyerGift)) {
$this->buyerGift->removeElement($buyerGift);
// set the owning side to null (unless already changed)
if ($buyerGift->getBuyerOrder() === $this) {
$buyerGift->setBuyerOrder(null);
}
}
return $this;
}
public function getTouchPointAll(): ?TouchPointAll
{
return $this->touchPointAll;
}
public function setTouchPointAll(?TouchPointAll $touchPointAll): self
{
$this->touchPointAll = $touchPointAll;
// set (or unset) the owning side of the relation if necessary
$newOrder = $touchPointAll === null ? null : $this;
if ($newOrder !== $touchPointAll->getOrder()) {
$touchPointAll->setOrder($newOrder);
}
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getUserFirstOrder(): ?User
{
return $this->userFirstOrder;
}
public function setUserFirstOrder(?User $user): self
{
$this->userFirstOrder = $user;
return $this;
}
public function checkIsCorrect(): bool
{
foreach ($this->orderPart as $orderPart)
{
/** @var OrderPart $orderPart */
if (!$orderPart->getIsCorrect()) return false;
}
return true;
}
public function mustBeHiddenInSB(): bool
{
/** @var OrderPart $orderPart */
foreach ($this->orderPart as $orderPart)
{
if ($orderPart->checkIfToHideInSB()) return true;
}
return false;
}
public function getProductsWithInvoicePayment(): array
{
$products = [];
/** @var OrderPart $orderPart */
foreach ($this->orderPart as $orderPart)
{
if (!$orderPart->getPaymentMethod())
{
continue;
}
if ($orderPart->getPaymentMethod()->getSlug() === 'invoice')
{
foreach ($orderPart->getOrderProductVariant() as $opv)
{
$products[] = $opv;
}
}
}
return $products;
}
public function omittedShippingCostsInAllProducts(): bool
{
/** @var OrderPart $orderPart */
foreach ($this->orderPart as $orderPart)
{
if (!$orderPart->omittedShippingCostsInAllProducts())
{
return false;
}
}
return true;
}
public function getProductsWithProformaPayment(): array
{
$products = [];
/** @var OrderPart $orderPart */
foreach ($this->orderPart as $orderPart)
{
/** @var OrderProductVariant $opv */
if (!$orderPart->getPaymentMethod())
{
continue;
}
if ($orderPart->getPaymentMethod()->getSlug() === 'proforma-invoice')
{
foreach ($orderPart->getOrderProductVariant() as $opv)
{
$products[] = $opv;
}
}
}
return $products;
}
public function canBePaidForWithOnline(): bool
{
/** @var OrderPart $orderPart */
foreach ($this->orderPart as $orderPart)
{
if (!$orderPart->checkIfPayOnlineIsActive())
{
return false;
}
}
return true;
}
public function hasRecurringPaymentProducts(): bool
{
foreach ($this->orderPart as $orderPart)
{
if ($orderPart->hasRecurringPaymentProducts()) return true;
}
return false;
}
public function hasUniqskillsProducts()
{
foreach ($this->orderPart as $orderPart)
{
if ($orderPart->hasUniqskillsProducts())
return true;
}
return false;
}
public function hasOnlyUniqskillsProducts()
{
foreach ($this->orderPart as $orderPart)
{
if (!$orderPart->hasOnlyUniqskillsProducts())
return false;
}
return true;
}
public function getOrderedCourse()
{
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderProductVariant $opv */
foreach ($orderPart->getOrderProductVariant() as $opv)
{
if ($opv->getProductVariant() === null)
{
return null;
}
if (!$opv->getProductVariant()->getCourses()->isEmpty())
{
return $opv->getProductVariant()->getCourses()->first();
}
}
}
return null;
}
public function getPaymentSystem(): ?PaymentSystem
{
return $this->paymentSystem;
}
public function setPaymentSystem(?PaymentSystem $paymentSystem): self
{
$this->paymentSystem = $paymentSystem;
return $this;
}
public function hasEventProducts()
{
foreach ($this->orderPart as $orderPart)
{
if ($orderPart->hasEventProduct())
return true;
}
return false;
}
public function hasDelayedProformaProducts()
{
foreach ($this->orderPart as $orderPart)
{
if ($orderPart->hasDelayedProformaProducts())
return true;
}
return false;
}
/**
* @return Collection|BraintreeResponse[]
*/
public function getBraintreeResponse(): Collection
{
return $this->braintreeResponse;
}
public function addBraintreeResponse(BraintreeResponse $braintreeResponse): self
{
if (!$this->braintreeResponse->contains($braintreeResponse)) {
$this->braintreeResponse[] = $braintreeResponse;
$braintreeResponse->setOrder($this);
}
return $this;
}
public function removeBraintreeResponse(BraintreeResponse $braintreeResponse): self
{
if ($this->braintreeResponse->contains($braintreeResponse)) {
$this->braintreeResponse->removeElement($braintreeResponse);
// set the owning side to null (unless already changed)
if ($braintreeResponse->getOrder() === $this) {
$braintreeResponse->setOrder(null);
}
}
return $this;
}
public function getIsTele()
{
if (strpos($this->getComment(), 'TELE ') && $this->getClientHost() == 'www.gos.e-firma.pl')
{
return true;
}
return false;
}
public function getButtonParameters(): ?string
{
return $this->buttonParameters;
}
public function setButtonParameters(?string $buttonParameters): self
{
$this->buttonParameters = $buttonParameters;
return $this;
}
public function getMarketing(): ?string
{
return $this->marketing;
}
public function setMarketing(?string $marketing): self
{
$this->marketing = $marketing;
return $this;
}
public function addParticipant(Participants $participant)
{
$this->participants[] = $participant;
return $this;
}
public function removeParticipant(Participants $participant)
{
$this->participants->removeElement($participant);
}
public function getParticipants()
{
return $this->participants;
}
public function hasAllProductsTaxFreeForBudgetUnit()
{
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderProductVariant $opv */
foreach ($orderPart->getOrderProductVariant() as $opv)
{
if (!$opv->getProductVariant()->getTaxFreeForBudgetUnit())
{
return false;
}
}
}
return true;
}
/**
* @return Collection|ProductVariant[]
*/
public function getAllProductVariants(): ?Collection
{
$variants = new ArrayCollection();
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderProductVariant $opv */
foreach ($orderPart->getOrderProductVariant() as $opv)
{
$variants->add($opv->getProductVariant());
}
}
return $variants;
}
public function getAllPrimaryProductVariants(): Collection
{
$variants = new ArrayCollection();
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderProductVariant $opv */
foreach ($orderPart->getOrderProductVariant() as $opv)
{
if ($opv->getPrimaryVariant() === null) {
$variants->add($opv->getProductVariant());
}
}
}
return $variants;
}
public function getAllOrderProductVariants(): ?Collection
{
$orderProductVariants = new ArrayCollection();
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderProductVariant $opv */
foreach ($orderPart->getOrderProductVariant() as $opv)
{
$orderProductVariants->add($opv);
}
}
return $orderProductVariants;
}
public function isEmailInvoiceEnabled(): bool
{
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart)
{
/** @var OrderProductVariant $opv */
foreach ($orderPart->getOrderProductVariant() as $opv)
{
if (
is_null($opv->getProductVariant()->getDocumentDistributionChannel())
||
$opv->getProductVariant()->getDocumentDistributionChannel() === DocumentDistributionChannels::PAPER)
{
return false;
}
}
}
return true;
}
public function getTeleOrder(): ?TeleOrder
{
return $this->teleOrder;
}
public function setTeleOrder(?TeleOrder $teleOrder): self
{
$this->teleOrder = $teleOrder;
return $this;
}
public function getFoExportetAt(): ?\DateTimeInterface
{
return $this->foExportetAt;
}
public function setFoExportetAt(?\DateTimeInterface $foExportetAt): self
{
$this->foExportetAt = $foExportetAt;
return $this;
}
/**
* @return Collection|FoLog[]
*/
public function getFoLogs(): Collection
{
return $this->foLogs;
}
public function addFoLog(FoLog $foLog): self
{
if (!$this->foLogs->contains($foLog)) {
$this->foLogs[] = $foLog;
$foLog->setOrders($this);
}
return $this;
}
public function removeFoLog(FoLog $foLog): self
{
if ($this->foLogs->contains($foLog)) {
$this->foLogs->removeElement($foLog);
// set the owning side to null (unless already changed)
if ($foLog->getOrders() === $this) {
$foLog->setOrders(null);
}
}
return $this;
}
public function getIsTest(): ?bool
{
return $this->isTest;
}
public function setIsTest(?bool $isTest): self
{
$this->isTest = $isTest;
return $this;
}
public function getIsGATransactionSent(): ?bool
{
return $this->isGATransactionSent;
}
public function setIsGATransactionSent(?bool $isGATransactionSent): self
{
$this->isGATransactionSent = $isGATransactionSent;
return $this;
}
public function getLab(): ?string
{
return $this->lab;
}
public function setLab(?string $lab): self
{
$this->lab = $lab;
return $this;
}
public function getIsSbExportNeeded(): ?bool
{
return $this->isSbExportNeeded;
}
public function setIsSbExportNeeded(bool $isSbExportNeeded): self
{
$this->isSbExportNeeded = $isSbExportNeeded;
return $this;
}
public function getSbExportAt(): ?\DateTimeInterface
{
return $this->sbExportAt;
}
public function setSbExportAt(?\DateTimeInterface $sbExportAt): self
{
$this->sbExportAt = $sbExportAt;
return $this;
}
public function getExtendedPaymentTime(): ?int
{
return $this->extendedPaymentTime;
}
public function setExtendedPaymentTime(int $extendedPaymentTime): self
{
$this->extendedPaymentTime = $extendedPaymentTime;
return $this;
}
public function getShippingType(): ?ShippingType
{
return $this->shippingType;
}
public function setShippingType(?ShippingType $shippingType): self
{
$this->shippingType = $shippingType;
return $this;
}
public function getTeleConsultant(): ?OrderTeleConsultant
{
return $this->teleConsultant;
}
public function setTeleConsultant(?OrderTeleConsultant $teleConsultant): self
{
$this->teleConsultant = $teleConsultant;
return $this;
}
/**
* @return Collection|UserCard[]
*/
public function getUserCards(): Collection
{
return $this->userCards;
}
public function addUserCard(UserCard $userCard): self
{
if (!$this->userCards->contains($userCard)) {
$this->userCards[] = $userCard;
$userCard->setOrders($this);
}
return $this;
}
public function removeUserCard(UserCard $userCard): self
{
if ($this->userCards->contains($userCard)) {
$this->userCards->removeElement($userCard);
// set the owning side to null (unless already changed)
if ($userCard->getOrders() === $this) {
$userCard->setOrders(null);
}
}
return $this;
}
public function getExportedToSbBy(): ?string
{
return $this->exportedToSbBy;
}
public function setExportedToSbBy(?string $exportedToSbBy): self
{
$this->exportedToSbBy = $exportedToSbBy;
return $this;
}
/**
* Checks the notifies of each orderPart
* Returns true if all have status: COMPLETED
*
* @return bool
*/
public function hasOnlinePaymentCompleted(): bool
{
if ($this->orderPart->isEmpty())
{
return false;
}
/** @var OrderPart $orderPart */
foreach ($this->orderPart as $orderPart)
{
if (
$orderPart->getMasterNotify() === null
|| !$orderPart->getMasterNotify()->isSuccessfullyPaid()
)
{
return false;
}
}
return true;
}
public function getFromSourceAll(): ?string
{
return $this->fromSourceAll;
}
public function setFromSourceAll(?string $fromSourceAll): self
{
$this->fromSourceAll = $fromSourceAll;
return $this;
}
public function getActionNumberAll(): ?string
{
return $this->actionNumberAll;
}
public function setActionNumberAll(?string $actionNumberAll): self
{
$this->actionNumberAll = $actionNumberAll;
return $this;
}
public function getProductVariantsReviewNotification(): ?ProductVariantReviewNotification
{
return $this->productVariantsReviewNotification;
}
public function getPaymentRewardDeadline(): ?\DateTimeInterface
{
return $this->paymentRewardDeadline;
}
public function setPaymentRewardDeadline(?\DateTimeInterface $paymentRewardDeadline): self
{
$this->paymentRewardDeadline = $paymentRewardDeadline;
return $this;
}
public function getUserAdditionalAccessOffer(): ?UserAdditionalAccessOffer
{
return $this->userAdditionalAccessOffer;
}
public function setUserAdditionalAccessOffer(?UserAdditionalAccessOffer $userAdditionalAccessOffer): self
{
$this->userAdditionalAccessOffer = $userAdditionalAccessOffer;
return $this;
}
/**
* @return Collection|AdditionalAccessBeneficiary[]
*/
public function getAdditionalAccessBeneficiaries(): Collection
{
return $this->additionalAccessBeneficiaries;
}
public function addAdditionalAccessBeneficiary(AdditionalAccessBeneficiary $additionalAccessBeneficiary): self
{
if (!$this->additionalAccessBeneficiaries->contains($additionalAccessBeneficiary)) {
$this->additionalAccessBeneficiaries[] = $additionalAccessBeneficiary;
$additionalAccessBeneficiary->setOrders($this);
}
return $this;
}
public function removeAdditionalAccessBeneficiary(AdditionalAccessBeneficiary $additionalAccessBeneficiary): self
{
if ($this->additionalAccessBeneficiaries->contains($additionalAccessBeneficiary)) {
$this->additionalAccessBeneficiaries->removeElement($additionalAccessBeneficiary);
// set the owning side to null (unless already changed)
if ($additionalAccessBeneficiary->getOrders() === $this) {
$additionalAccessBeneficiary->setOrders(null);
}
}
return $this;
}
public function getTeleOrderSplit(): ?bool
{
return $this->teleOrderSplit;
}
public function setTeleOrderSplit(?bool $teleOrderSplit): self
{
$this->teleOrderSplit = $teleOrderSplit;
return $this;
}
public function getBurAssignedSupportId(): ?string
{
return $this->burAssignedSupportId;
}
public function setBurAssignedSupportId(?string $burAssignedSupportId): self
{
$this->burAssignedSupportId = $burAssignedSupportId;
return $this;
}
public function isOnboardingActive(): bool
{
$isActive = false;
$portalSettings = $this->getPortalSettings();
if ($portalSettings !== null) {
$onboardingSettings = $portalSettings->getOnboardingSettings();
if ($onboardingSettings !== null) {
$isActive = $onboardingSettings->getIsActive() === true;
}
}
return $isActive;
}
public function getOnboardingEmailTemplate(): ?EmailTemplate
{
$emailTemplate = null;
$portalSettings = $this->getPortalSettings();
if ($portalSettings !== null) {
$onboardingSettings = $portalSettings->getOnboardingSettings();
if ($onboardingSettings !== null) {
$emailTemplate = $onboardingSettings->getEmailTemplate();
}
}
return $emailTemplate;
}
public function getSalesManago2PurchaseTags(): array
{
$tags = [];
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart) {
/** @var OrderProductVariant $orderProductVariant */
foreach ($orderPart->getOrderProductVariant() as $orderProductVariant) {
$productVariant = $orderProductVariant->getProductVariant();
$product = $productVariant->getMasterProduct();
$tags[] = 'ZAKUP_P' . $product->getProductNo() . 'END';
}
}
return $tags;
}
public function getSalesmanago2Funnels(): array
{
$funnels = [];
/** @var OrderPart $orderPart */
foreach ($this->getOrderPart() as $orderPart) {
/** @var OrderProductVariant $orderProductVariant */
foreach ($orderPart->getOrderProductVariant() as $orderProductVariant) {
$productVariant = $orderProductVariant->getProductVariant();
$product = $productVariant->getMasterProduct();
$funnels[$product->getProductNo()] = $product->getSalesmanagoTags(true);
}
}
return $funnels;
}
}