/** | /** | ||||
* @ORM\Column(type="string", length=255, nullable=true) | * @ORM\Column(type="string", length=255, nullable=true) | ||||
*/ | */ | ||||
private $codeUsed; | |||||
protected $codeUsed; | |||||
public function __toString() | public function __toString() | ||||
{ | { |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | use Lc\CaracoleBundle\Model\Address\AddressInterface; | ||||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | |||||
use Lc\CaracoleBundle\Model\Config\TaxRateInterface; | |||||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | use Lc\CaracoleBundle\Model\File\DocumentInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | use Lc\SovBundle\Model\Ticket\TicketInterface; | ||||
{ | { | ||||
use BlameableNullableTrait; | use BlameableNullableTrait; | ||||
const DELIVERY_TYPE_HOME = 'home'; | |||||
const DELIVERY_TYPE_POINTSALE = 'point-sale'; | |||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER") | * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER") | ||||
*/ | */ | ||||
*/ | */ | ||||
protected $cycleId; | protected $cycleId; | ||||
/** | |||||
* @ORM\Column(type="integer", nullable=true) | |||||
*/ | |||||
protected $cycleNumber; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="App\Entity\Address\Address") | |||||
*/ | |||||
protected $deliveryAddress; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="App\Entity\PointSale\PointSale") | |||||
*/ | |||||
protected $deliveryPointSale; | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $deliveryAddressText; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $deliveryType; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $deliveryPrice; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="App\Entity\Config\TaxRate") | |||||
*/ | |||||
protected $deliveryTaxRate; | |||||
/** | |||||
* @ORM\Column(type="string", length=20, nullable=true) | |||||
*/ | |||||
protected $reference; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="App\Entity\Order\OrderShop", inversedBy="complementaryOrderShops") | |||||
*/ | |||||
protected $mainOrderShop; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="App\Entity\Order\OrderShop", mappedBy="mainOrderShop") | |||||
*/ | |||||
protected $complementaryOrderShops; | |||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $declineComplementaryOrderShop; | |||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $orderAllowByAdmin; | |||||
/** | |||||
* @ORM\Column(type="integer", nullable=true) | |||||
*/ | |||||
protected $hasReach; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statTotal; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statTotalWithTax; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statTotalOrderProductsWithReductions; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statTotalOrderProductsWithTaxAndReductions; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statMarginOrderProductsWithReductions; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statDeliveryPriceWithReduction; | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | |||||
*/ | |||||
protected $statDeliveryPriceWithTaxAndReduction; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->orderStatusHistories = new ArrayCollection(); | $this->orderStatusHistories = new ArrayCollection(); | ||||
$this->orderReductionCarts = new ArrayCollection(); | $this->orderReductionCarts = new ArrayCollection(); | ||||
$this->orderReductionCredits = new ArrayCollection(); | $this->orderReductionCredits = new ArrayCollection(); | ||||
$this->documents = new ArrayCollection(); | $this->documents = new ArrayCollection(); | ||||
$this->complementaryOrderShops = new ArrayCollection(); | |||||
$this->tickets = new ArrayCollection(); | |||||
} | } | ||||
public function __toString() | public function __toString() | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCycleNumber(): ?int | |||||
{ | |||||
return $this->cycleNumber; | |||||
} | |||||
public function setCycleNumber(?int $cycleNumber): self | |||||
{ | |||||
$this->cycleNumber = $cycleNumber; | |||||
return $this; | |||||
} | |||||
public function getDeliveryAddress(): ?AddressInterface | |||||
{ | |||||
return $this->deliveryAddress; | |||||
} | |||||
public function setDeliveryAddress(?AddressInterface $deliveryAddress): self | |||||
{ | |||||
$this->deliveryAddress = $deliveryAddress; | |||||
return $this; | |||||
} | |||||
public function getDeliveryAddressText(): ?string | |||||
{ | |||||
return $this->deliveryAddressText; | |||||
} | |||||
public function setDeliveryAddressText(string $deliveryAddressText): self | |||||
{ | |||||
$this->deliveryAddressText = $deliveryAddressText; | |||||
return $this; | |||||
} | |||||
public function getDeliveryPointSale(): ?PointSaleInterface | |||||
{ | |||||
return $this->deliveryPointSale; | |||||
} | |||||
public function setDeliveryPointSale(?PointSaleInterface $deliveryPointSale): self | |||||
{ | |||||
$this->deliveryPointSale = $deliveryPointSale; | |||||
return $this; | |||||
} | |||||
public function getDeliveryType(): ?string | |||||
{ | |||||
return $this->deliveryType; | |||||
} | |||||
public function setDeliveryType(?string $deliveryType): self | |||||
{ | |||||
$this->deliveryType = $deliveryType; | |||||
return $this; | |||||
} | |||||
public function getDeliveryPrice(): ?float | |||||
{ | |||||
return $this->deliveryPrice; | |||||
} | |||||
public function setDeliveryPrice(?float $deliveryPrice): self | |||||
{ | |||||
$this->deliveryPrice = $deliveryPrice; | |||||
return $this; | |||||
} | |||||
public function getDeliveryTaxRate(): ?TaxRateInterface | |||||
{ | |||||
return $this->deliveryTaxRate; | |||||
} | |||||
public function setDeliveryTaxRate(?TaxRateInterface $deliveryTaxRate): self | |||||
{ | |||||
$this->deliveryTaxRate = $deliveryTaxRate; | |||||
return $this; | |||||
} | |||||
public function getReference(): ?string | |||||
{ | |||||
return $this->reference; | |||||
} | |||||
public function setReference(?string $reference): self | |||||
{ | |||||
$this->reference = $reference; | |||||
return $this; | |||||
} | |||||
public function getMainOrderShop(): ?self | |||||
{ | |||||
return $this->mainOrderShop; | |||||
} | |||||
public function setMainOrderShop(?self $mainOrderShop): self | |||||
{ | |||||
$this->mainOrderShop = $mainOrderShop; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|OrderShopInterface[] | |||||
*/ | |||||
public function getComplementaryOrderShops(): Collection | |||||
{ | |||||
$arrayComplementaryOrderShops = new ArrayCollection(); | |||||
foreach ($this->complementaryOrderShops as $complementaryOrderShop) { | |||||
if ($complementaryOrderShop->isValid()) { | |||||
$arrayComplementaryOrderShops[] = $complementaryOrderShop; | |||||
} | |||||
} | |||||
return $arrayComplementaryOrderShops; | |||||
} | |||||
public function addComplementaryOrderShop(self $complementaryOrderShop): self | |||||
{ | |||||
if (!$this->complementaryOrderShops->contains($complementaryOrderShop)) { | |||||
$this->complementaryOrderShops[] = $complementaryOrderShop; | |||||
$complementaryOrderShop->setMainOrderShop($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeComplementaryOrderShop(self $complementaryOrderShop): self | |||||
{ | |||||
if ($this->complementaryOrderShops->contains($complementaryOrderShop)) { | |||||
$this->complementaryOrderShops->removeElement($complementaryOrderShop); | |||||
// set the owning side to null (unless already changed) | |||||
if ($complementaryOrderShop->getMainOrderShop() === $this) { | |||||
$complementaryOrderShop->setMainOrderShop(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
public function getDeclineComplementaryOrderShop(): ?bool | |||||
{ | |||||
return $this->declineComplementaryOrderShop; | |||||
} | |||||
public function setDeclineComplementaryOrderShop(?bool $declineComplementaryOrderShop): self | |||||
{ | |||||
$this->declineComplementaryOrderShop = $declineComplementaryOrderShop; | |||||
return $this; | |||||
} | |||||
public function getOrderAllowByAdmin(): ?bool | |||||
{ | |||||
return $this->orderAllowByAdmin; | |||||
} | |||||
public function setOrderAllowByAdmin(?bool $orderAllowByAdmin): self | |||||
{ | |||||
$this->orderAllowByAdmin = $orderAllowByAdmin; | |||||
return $this; | |||||
} | |||||
public function getHasReach(): ?int | |||||
{ | |||||
return $this->hasReach; | |||||
} | |||||
public function setHasReach(?int $hasReach): self | |||||
{ | |||||
$this->hasReach = $hasReach; | |||||
return $this; | |||||
} | |||||
public function getStatTotal(): ?float | |||||
{ | |||||
return $this->statTotal; | |||||
} | |||||
public function setStatTotal(?float $statTotal): self | |||||
{ | |||||
$this->statTotal = $statTotal; | |||||
return $this; | |||||
} | |||||
public function getStatTotalWithTax(): ?float | |||||
{ | |||||
return $this->statTotalWithTax; | |||||
} | |||||
public function setStatTotalWithTax(?float $statTotalWithTax): self | |||||
{ | |||||
$this->statTotalWithTax = $statTotalWithTax; | |||||
return $this; | |||||
} | |||||
public function getStatTotalOrderProductsWithReductions(): ?float | |||||
{ | |||||
return $this->statTotalOrderProductsWithReductions; | |||||
} | |||||
public function setStatTotalOrderProductsWithReductions(?float $statTotalOrderProductsWithReductions): self | |||||
{ | |||||
$this->statTotalOrderProductsWithReductions = $statTotalOrderProductsWithReductions; | |||||
return $this; | |||||
} | |||||
public function getStatTotalOrderProductsWithTaxAndReductions(): ?float | |||||
{ | |||||
return $this->statTotalOrderProductsWithTaxAndReductions; | |||||
} | |||||
public function setStatTotalOrderProductsWithTaxAndReductions(?float $statTotalOrderProductsWithTaxAndReductions): self | |||||
{ | |||||
$this->statTotalOrderProductsWithTaxAndReductions = $statTotalOrderProductsWithTaxAndReductions; | |||||
return $this; | |||||
} | |||||
public function getStatMarginOrderProductsWithReductions(): ?float | |||||
{ | |||||
return $this->statMarginOrderProductsWithReductions; | |||||
} | |||||
public function setStatMarginOrderProductsWithReductions(?float $statMarginOrderProductsWithReductions): self | |||||
{ | |||||
$this->statMarginOrderProductsWithReductions = $statMarginOrderProductsWithReductions; | |||||
return $this; | |||||
} | |||||
public function getStatDeliveryPriceWithReduction(): ?float | |||||
{ | |||||
return $this->statDeliveryPriceWithReduction; | |||||
} | |||||
public function setStatDeliveryPriceWithReduction(?float $statDeliveryPriceWithReduction): self | |||||
{ | |||||
$this->statDeliveryPriceWithReduction = $statDeliveryPriceWithReduction; | |||||
return $this; | |||||
} | |||||
public function getStatDeliveryPriceWithTaxAndReduction(): ?float | |||||
{ | |||||
return $this->statDeliveryPriceWithTaxAndReduction; | |||||
} | |||||
public function setStatDeliveryPriceWithTaxAndReduction(?float $statDeliveryPriceWithTaxAndReduction): self | |||||
{ | |||||
$this->statDeliveryPriceWithTaxAndReduction = $statDeliveryPriceWithTaxAndReduction; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $alias; | protected $alias; | ||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $color; | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->title . ' [' . $this->alias . ']'; | return $this->title . ' [' . $this->alias . ']'; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getColor(): ?string | |||||
{ | |||||
return $this->color; | |||||
} | |||||
public function setColor(?string $color): self | |||||
{ | |||||
$this->color = $color; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $code; | protected $code; | ||||
/** | |||||
* @ORM\Column(type="float") | |||||
*/ | |||||
protected $deliveryPrice; | |||||
/** | |||||
* @ORM\Column(type="boolean") | |||||
*/ | |||||
protected $isPublic; | |||||
/** | /** | ||||
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"}) | * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"}) | ||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getDeliveryPrice(): ?float | |||||
{ | |||||
return $this->deliveryPrice; | |||||
} | |||||
public function setDeliveryPrice(float $deliveryPrice): self | |||||
{ | |||||
$this->deliveryPrice = $deliveryPrice; | |||||
return $this; | |||||
} | |||||
public function getIsPublic(): ?bool | |||||
{ | |||||
return $this->isPublic; | |||||
} | |||||
public function setIsPublic(bool $isPublic): self | |||||
{ | |||||
$this->isPublic = $isPublic; | |||||
return $this; | |||||
} | |||||
public function getAddress(): ?AddressInterface | public function getAddress(): ?AddressInterface | ||||
{ | { | ||||
return $this->address; | return $this->address; |
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | ||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
/** | /** | ||||
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family'; | const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family'; | ||||
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product'; | const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product'; | ||||
public function getBehaviorExpirationDateChoices():array{ | |||||
public function getBehaviorExpirationDateChoices(): array | |||||
{ | |||||
return [ | return [ | ||||
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | ||||
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT | self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT | ||||
*/ | */ | ||||
protected $behaviorCountStock; | protected $behaviorCountStock; | ||||
/** | |||||
* @ORM\Column(type="string", length=255) | |||||
*/ | |||||
protected $behaviorStockWeek; | |||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $availabilityRenewedThisWeek; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=255) | * @ORM\Column(type="string", length=255) | ||||
*/ | */ | ||||
protected $behaviorDisplaySale; | protected $behaviorDisplaySale; | ||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $exportTitle; | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $exportNote; | |||||
/** | /** | ||||
* @ORM\Column(type="date", nullable=true) | * @ORM\Column(type="date", nullable=true) | ||||
*/ | */ | ||||
*/ | */ | ||||
protected $section; | protected $section; | ||||
/** | |||||
* @ORM\ManyToOne((targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $image; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->productCategories = new ArrayCollection(); | $this->productCategories = new ArrayCollection(); | ||||
return $this; | return $this; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getAvailableQuantityInherited() | public function getAvailableQuantityInherited() | ||||
{ | { | ||||
return $availableQuantity; | return $availableQuantity; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getTaxRateInherited() | public function getTaxRateInherited() | ||||
{ | { | ||||
{ | { | ||||
return $this->products; | return $this->products; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getProductsOnline(): Collection | public function getProductsOnline(): Collection | ||||
{ | { | ||||
{ | { | ||||
return $this->reductionCatalog; | return $this->reductionCatalog; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getReductionCatalogInherited(): ?ReductionCatalogInterface | public function getReductionCatalogInherited(): ?ReductionCatalogInterface | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getProductCategoryParent() | public function getProductCategoryParent() | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getExportTitle(): ?string | |||||
{ | |||||
return $this->exportTitle; | |||||
} | |||||
public function setExportTitle(?string $exportTitle): self | |||||
{ | |||||
$this->exportTitle = $exportTitle; | |||||
return $this; | |||||
} | |||||
public function getExportNote(): ?string | |||||
{ | |||||
return $this->exportNote; | |||||
} | |||||
public function setExportNote(?string $exportNote): self | |||||
{ | |||||
$this->exportNote = $exportNote; | |||||
return $this; | |||||
} | |||||
public function getBehaviorStockWeek(): ?string | |||||
{ | |||||
return $this->behaviorStockWeek; | |||||
} | |||||
public function setBehaviorStockWeek(string $behaviorStockWeek): self | |||||
{ | |||||
$this->behaviorStockWeek = $behaviorStockWeek; | |||||
return $this; | |||||
} | |||||
public function getAvailabilityRenewedThisWeek(): ?bool | |||||
{ | |||||
return $this->availabilityRenewedThisWeek; | |||||
} | |||||
public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek): self | |||||
{ | |||||
$this->availabilityRenewedThisWeek = $availabilityRenewedThisWeek; | |||||
return $this; | |||||
} | |||||
public function getBehaviorDisplaySale(): ?string | public function getBehaviorDisplaySale(): ?string | ||||
{ | { | ||||
return $this->behaviorDisplaySale; | return $this->behaviorDisplaySale; | ||||
return $this; | return $this; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function isPropertyNoveltyOnline(): ?bool | public function isPropertyNoveltyOnline(): ?bool | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function countProperties(): bool | public function countProperties(): bool | ||||
{ | { | ||||
{ | { | ||||
return $this->behaviorPrice; | return $this->behaviorPrice; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getBehaviorPriceInherited() | public function getBehaviorPriceInherited() | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getProductsGroupByTitle() | public function getProductsGroupByTitle() | ||||
{ | { | ||||
return $arrayProductsGroupByTitle; | return $arrayProductsGroupByTitle; | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getOriginProduct() | public function getOriginProduct() | ||||
{ | { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function getOriginProductOnline() | public function getOriginProductOnline() | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
//TODO move | //TODO move | ||||
public function hasOneProductOnline() | public function hasOneProductOnline() | ||||
{ | { | ||||
return 'priceByRefUnit'; | return 'priceByRefUnit'; | ||||
} | } | ||||
} | } | ||||
public function getImage(): ?FileInterface | |||||
{ | |||||
return $this->image; | |||||
} | |||||
public function setImage(?FileInterface $image): self | |||||
{ | |||||
$this->image = $image; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $originProduct; | protected $originProduct; | ||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $exportTitle; | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $exportNote; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->orderProducts = new ArrayCollection(); | $this->orderProducts = new ArrayCollection(); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getExportTitle(): ?string | |||||
{ | |||||
return $this->exportTitle; | |||||
} | |||||
//TODO move | |||||
public function getExportTitleInherited(): ?string | |||||
{ | |||||
$exportTitle = $this->getExportTitle(); | |||||
if ($exportTitle && strlen($exportTitle)) { | |||||
return $exportTitle; | |||||
} else { | |||||
$productFamily = $this->getProductFamily(); | |||||
if ($productFamily) { | |||||
return $productFamily->getExportTitle(); | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public function setExportTitle(?string $exportTitle): self | |||||
{ | |||||
$this->exportTitle = $exportTitle; | |||||
return $this; | |||||
} | |||||
public function getExportNote(): ?string | |||||
{ | |||||
return $this->exportNote; | |||||
} | |||||
//TODO move | |||||
public function getExportNoteInherited(): ?string | |||||
{ | |||||
$exportNote = $this->getExportNote(); | |||||
if ($exportNote && strlen($exportNote)) { | |||||
return $exportNote; | |||||
} else { | |||||
$productFamily = $this->getProductFamily(); | |||||
if ($productFamily) { | |||||
return $productFamily->getExportNote(); | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public function setExportNote(?string $exportNote): self | |||||
{ | |||||
$this->exportNote = $exportNote; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $owner; | protected $owner; | ||||
/** | |||||
* @ORM\Column(type="datetime", nullable=true) | |||||
*/ | |||||
protected $activationDate; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $ownerName; | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $ownerMessage; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->users = new ArrayCollection(); | $this->users = new ArrayCollection(); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getActivationDate(): ?\DateTimeInterface | |||||
{ | |||||
return $this->activationDate; | |||||
} | |||||
public function setActivationDate(?\DateTimeInterface $activationDate): self | |||||
{ | |||||
$this->activationDate = $activationDate; | |||||
return $this; | |||||
} | |||||
public function getOwnerName(): ?string | |||||
{ | |||||
return $this->ownerName; | |||||
} | |||||
public function setOwnerName(?string $ownerName): self | |||||
{ | |||||
$this->ownerName = $ownerName; | |||||
return $this; | |||||
} | |||||
public function getOwnerMessage(): ?string | |||||
{ | |||||
return $this->ownerMessage; | |||||
} | |||||
public function setOwnerMessage(?string $ownerMessage): self | |||||
{ | |||||
$this->ownerMessage = $ownerMessage; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $behaviorDisplayPrice; | protected $behaviorDisplayPrice; | ||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $isSaleAlwaysOpen; | |||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | ||||
*/ | */ | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct(); | |||||
$this->addresses = new ArrayCollection(); | $this->addresses = new ArrayCollection(); | ||||
$this->orderShops = new ArrayCollection(); | $this->orderShops = new ArrayCollection(); | ||||
$this->groupUsers = new ArrayCollection(); | $this->groupUsers = new ArrayCollection(); | ||||
} | } | ||||
public function getPhone(): ?string | |||||
public function getBehaviorDisplayPrice(): ?string | |||||
{ | { | ||||
return $this->phone; | |||||
return $this->behaviorDisplayPrice; | |||||
} | } | ||||
public function setPhone(?string $phone): self | |||||
public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self | |||||
{ | { | ||||
$this->phone = $phone; | |||||
$this->behaviorDisplayPrice = $behaviorDisplayPrice; | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getBehaviorDisplayPrice(): ?string | |||||
public function getIsSaleAlwaysOpen(): ?bool | |||||
{ | { | ||||
return $this->behaviorDisplayPrice; | |||||
return $this->isSaleAlwaysOpen; | |||||
} | } | ||||
public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self | |||||
public function setIsSaleAlwaysOpen(?bool $isSaleAlwaysOpen): self | |||||
{ | { | ||||
$this->behaviorDisplayPrice = $behaviorDisplayPrice; | |||||
$this->isSaleAlwaysOpen = $isSaleAlwaysOpen; | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getFavoriteMerchant(): ?MerchantInterface | public function getFavoriteMerchant(): ?MerchantInterface | ||||
{ | { | ||||
return $this->favoriteMerchant; | return $this->favoriteMerchant; |
public function getAsArray(MerchantInterface $merchant) | public function getAsArray(MerchantInterface $merchant) | ||||
{ | { | ||||
$taxRates = $this->query->create()->find(); | $taxRates = $this->query->create()->find(); | ||||
$taxRatesList = []; | $taxRatesList = []; | ||||
foreach ($taxRates as $taxRate) { | foreach ($taxRates as $taxRate) { |
use App\Entity\Merchant\Merchant; | use App\Entity\Merchant\Merchant; | ||||
use App\Entity\User\UserMerchant; | use App\Entity\User\UserMerchant; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
use DateTime; | use DateTime; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | use Lc\CaracoleBundle\Model\Address\AddressInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class DocumentRepositoryQuery extends AbstractRepositoryQuery | class DocumentRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | |||||
use SectionRepositoryQueryTrait; | |||||
public function __construct(DocumentRepository $repository, PaginatorInterface $paginator) | public function __construct(DocumentRepository $repository, PaginatorInterface $paginator) | ||||
{ | { |
use App\Entity\Address\Address; | use App\Entity\Address\Address; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
class DocumentStore extends AbstractStore | class DocumentStore extends AbstractStore | ||||
{ | { | ||||
use MerchantStoreTrait; | |||||
use SectionStoreTrait; | |||||
protected DocumentRepositoryQuery $query; | protected DocumentRepositoryQuery $query; | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getOneByDevAlias(string $devAlias): ?MerchantInterface | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterByDevAlias($devAlias); | |||||
return $query->findOne(); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository; | namespace Lc\CaracoleBundle\Repository; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
trait MerchantRepositoryQueryTrait | trait MerchantRepositoryQueryTrait | ||||
{ | { | ||||
public function filterByMerchant(MerchantInterface $merchant) | public function filterByMerchant(MerchantInterface $merchant) | ||||
{ | { | ||||
return $this->andWhere('.merchant = :merchant')->setParameter(':merchant', $merchant); | |||||
return $this->andWhereMerchant($this->id, $merchant); | |||||
} | } | ||||
} | } |
{ | { | ||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
protected $isJoinOrderReductionCredits = false; | |||||
protected $isJoinOrderReductionCarts = false; | |||||
protected $isJoinOrderStatus = false; | |||||
protected $isJoinComplementaryOrderShops = false; | |||||
protected $isJoinDeliveryPointSale = false; | |||||
protected $isJoinDeliveryAvailabilityZone = false; | |||||
protected $isJoinDeliverySlotZone = false; | |||||
protected $isJoinDeliveryAvailabilityPointSale = false; | |||||
protected $isJoinDeliverySlotPointSale = false; | |||||
protected $isHorsTournee = false; | |||||
protected $isGiftVoucher = false; | |||||
protected bool $isJoinProduct = false; | |||||
protected bool $isJoinOrderProduct = false; | |||||
protected bool $isJoinOrderReductionCredits = false; | |||||
protected bool $isJoinOrderReductionCarts = false; | |||||
protected bool $isJoinOrderStatus = false; | |||||
protected bool $isJoinComplementaryOrderShops = false; | |||||
protected bool $isJoinDeliveryPointSale = false; | |||||
public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator) | public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
// @TODO : nécessaire ? | |||||
public function selectParam($select): self | public function selectParam($select): self | ||||
{ | { | ||||
return $this | return $this | ||||
->setParameter('dateEnd', $dateEnd); | ->setParameter('dateEnd', $dateEnd); | ||||
} | } | ||||
public function filterByEstimatedDeliveryDateStart(string $dateStart): self | |||||
{ | |||||
return $this | |||||
->andWhere('.estimatedDeliveryDateTime >= :deliveryDateStart') | |||||
->setParameter('deliveryDateStart', $dateStart); | |||||
} | |||||
public function filterByEstimatedDeliveryDateEnd(string $dateEnd): self | |||||
{ | |||||
return $this | |||||
->andWhere('.estimatedDeliveryDateTime < :deliveryDateEnd') | |||||
->setParameter('deliveryDateEnd', $dateEnd); | |||||
} | |||||
public function filterByDeliveryDateStart(string $dateStart): self | |||||
{ | |||||
return $this | |||||
->andWhere('.deliveryDate >= :deliveryDateStart') | |||||
->setParameter('deliveryDateStart', $dateStart); | |||||
} | |||||
public function filterByDeliveryDateEnd(string $dateEnd): self | |||||
{ | |||||
return $this | |||||
->andWhere('.deliveryDate < :deliveryDateEnd') | |||||
->setParameter('deliveryDateEnd', $dateEnd); | |||||
} | |||||
public function filterByVisitor(VisitorInterface $visitor): self | public function filterByVisitor(VisitorInterface $visitor): self | ||||
{ | { | ||||
return $this | return $this | ||||
->setParameter('address', $address); | ->setParameter('address', $address); | ||||
} | } | ||||
public function filterByWeekDeliveryTruck(string $weekDeliveryTrucks): self | |||||
{ | |||||
return $this | |||||
->andWhere('.weekDeliveryTruck IN (:weekDeliveryTrucks)') | |||||
->setParameter('weekDeliveryTrucks', $weekDeliveryTrucks); | |||||
} | |||||
public function filterByStatus(array $statusArray): self | public function filterByStatus(array $statusArray): self | ||||
{ | { | ||||
$this->joinOrderStatus(); | $this->joinOrderStatus(); | ||||
->setParameter('reductionCart', $reductionCart); | ->setParameter('reductionCart', $reductionCart); | ||||
} | } | ||||
public function filterByAvailabilityPointZone(DeliveryAvailabilityPointSale $deliveryAvailabilityPointSale): self | |||||
{ | |||||
return $this | |||||
->andWhere('.deliveryAvailabilityPointSale = :deliveryAvailabilityPointSale') | |||||
->setParameter('deliveryAvailabilityPointSale', $deliveryAvailabilityPointSale); | |||||
} | |||||
public function filterByAvailabilityPointSale(DeliveryAvailabilityPointSale $deliveryAvailabilityPointSale): self | |||||
{ | |||||
return $this | |||||
->andWhere('.deliveryAvailabilityPointSale = :deliveryAvailabilityPointSale') | |||||
->setParameter('deliveryAvailabilityPointSale', $deliveryAvailabilityPointSale); | |||||
} | |||||
public function filterByCycleNumber(int $cycleNumber): self | public function filterByCycleNumber(int $cycleNumber): self | ||||
{ | { | ||||
return $this | return $this | ||||
->andWhere('.mainOrderShop IS NULL'); | ->andWhere('.mainOrderShop IS NULL'); | ||||
} | } | ||||
public function filterIsNullDeliveryPointSale(): self | |||||
{ | |||||
$this | |||||
->joinDeliveryPointSale() | |||||
->andWhere( | |||||
'.deliveryPointSale IS NULL OR (pointSale.isDepository = 0 AND (pointSale.devAlias IS NULL OR (pointSale.devAlias != :devAliasHorsTournee AND pointSale.devAlias != :devAliasGiftVoucher)))' | |||||
) | |||||
->setParameterGiftVoucher() | |||||
->setParameterHorsTournee(); | |||||
return $this; | |||||
} | |||||
public function filterIsNotNullDeliveryPointSale(): self | |||||
{ | |||||
$this | |||||
->joinDeliveryPointSale() | |||||
->andWhere( | |||||
'pointSale IS NOT NULL AND pointSale.isDepository = 1 AND (pointSale.devAlias IS NULL OR (pointSale.devAlias != :devAliasHorsTournee AND pointSale.devAlias != :devAliasGiftVoucher))' | |||||
) | |||||
->setParameterGiftVoucher() | |||||
->setParameterHorsTournee(); | |||||
return $this; | |||||
} | |||||
public function filterIsPointSale(string $devAlias = 'devAliasHorsTournee'): self | |||||
{ | |||||
$this | |||||
->joinDeliveryPointSale() | |||||
->andWhere('pointSale IS NOT NULL AND pointSale.devAlias = :' . $devAlias); | |||||
if($devAlias == 'devAliasHorsTournee'){ | |||||
$this->setParameterHorsTournee(); | |||||
} elseif($devAlias == 'devAliasGiftVoucher') { | |||||
$this->setParameterGiftVoucher(); | |||||
} | |||||
return $this; | |||||
} | |||||
public function selectOrderReductionCarts(): self | public function selectOrderReductionCarts(): self | ||||
{ | { | ||||
$this->joinOrderReductionCarts(); | $this->joinOrderReductionCarts(); | ||||
return $this->addSelect('orcart'); | return $this->addSelect('orcart'); | ||||
} | } | ||||
public function setParameterGiftVoucher(): self | |||||
{ | |||||
if (!$this->isGiftVoucher) { | |||||
$this->isGiftVoucher = true; | |||||
return $this | |||||
->setParameter('devAliasGiftVoucher', PointSale::DEV_ALIAS_GIFT_VOUCHER); | |||||
} | |||||
return $this; | |||||
} | |||||
public function setParameterHorsTournee(): self | |||||
{ | |||||
if (!$this->isHorsTournee) { | |||||
$this->isHorsTournee = true; | |||||
return $this | |||||
->setParameter('devAliasHorsTournee', PointSale::DEV_ALIAS_OFF_CIRCUIT); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinOrderReductionCredits(): self | public function joinOrderReductionCredits(): self | ||||
{ | { | ||||
if (!$this->isJoinOrderReductionCredits) { | if (!$this->isJoinOrderReductionCredits) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function joinDeliveryAvailabilityZone(): self | |||||
{ | |||||
if (!$this->isJoinDeliveryAvailabilityZone) { | |||||
$this->isJoinDeliveryAvailabilityZone = true; | |||||
return $this | |||||
->leftJoin('.deliveryAvailabilityZone', 'deliveryAvailabilityZone'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinDeliverySlotZone(): self | |||||
{ | |||||
$this->joinDeliveryAvailabilityZone(); | |||||
if (!$this->isJoinDeliverySlotZone) { | |||||
$this->isJoinDeliverySlotZone = true; | |||||
return $this | |||||
->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinDeliveryAvailabilityPointSale(): self | |||||
{ | |||||
if (!$this->isJoinDeliveryAvailabilityPointSale) { | |||||
$this->isJoinDeliveryAvailabilityPointSale = true; | |||||
return $this | |||||
->leftJoin('.deliveryAvailabilityPointSale', 'deliveryAvailabilityPointSale'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinDeliverySlotPointSale(): self | |||||
{ | |||||
$this->joinDeliveryAvailabilityPointSale(); | |||||
if (!$this->isJoinDeliverySlotPointSale) { | |||||
$this->isJoinDeliverySlotPointSale = true; | |||||
return $this | |||||
->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinOrderStatus(): self | public function joinOrderStatus(): self | ||||
{ | { | ||||
if (!$this->isJoinOrderStatus) { | if (!$this->isJoinOrderStatus) { |
namespace Lc\CaracoleBundle\Repository\Order; | namespace Lc\CaracoleBundle\Repository\Order; | ||||
use App\Entity\Delivery\DeliveryAvailabilityPointSale; | |||||
use App\Entity\Delivery\DeliveryAvailabilityZone; | |||||
use App\Entity\Order\OrderStatus; | |||||
use App\Entity\Section\Section; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface; | use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface; | use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | ||||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; | use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; | ||||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | use Lc\CaracoleBundle\Repository\Section\SectionStore; | ||||
use Lc\CaracoleBundle\Resolver\OpeningResolver; | use Lc\CaracoleBundle\Resolver\OpeningResolver; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | |||||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
protected OpeningResolver $openingResolver; | protected OpeningResolver $openingResolver; | ||||
protected ParameterBagInterface $parameterBag; | protected ParameterBagInterface $parameterBag; | ||||
protected UrlGeneratorInterface $router; | protected UrlGeneratorInterface $router; | ||||
protected OrderShopSolver $orderShopSolver; | |||||
public function __construct( | public function __construct( | ||||
OrderShopRepositoryQuery $query, | OrderShopRepositoryQuery $query, | ||||
FlashBagInterface $flashBag, | FlashBagInterface $flashBag, | ||||
OpeningResolver $openingResolver, | OpeningResolver $openingResolver, | ||||
ParameterBagInterface $parameterBag, | ParameterBagInterface $parameterBag, | ||||
UrlGeneratorInterface $router | |||||
UrlGeneratorInterface $router, | |||||
OrderShopSolver $orderShopSolver | |||||
) { | ) { | ||||
$this->query = $query; | $this->query = $query; | ||||
$this->entityManager = $entityManager; | $this->entityManager = $entityManager; | ||||
$this->openingResolver = $openingResolver; | $this->openingResolver = $openingResolver; | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
$this->router = $router; | $this->router = $router; | ||||
$this->orderShopSolver = $orderShopSolver; | |||||
} | } | ||||
// getOrderShopsOfWeek | // getOrderShopsOfWeek | ||||
array_merge( | array_merge( | ||||
[ | [ | ||||
'user' => $user, | 'user' => $user, | ||||
'weekNumber' => $this->getCycleNumberCurrentOrder($section), | |||||
'cycleNumber' => $this->getCycleNumberCurrentOrder($section), | |||||
'excludeComplementaryOrderShops' => true | 'excludeComplementaryOrderShops' => true | ||||
], | ], | ||||
$params | $params | ||||
} | } | ||||
// getNextWeekId | // getNextWeekId | ||||
public function getNextCycleId(SectionInterface $section, int $cycleNumber): int | |||||
public function getNextCycleId(int $cycleNumber): int | |||||
{ | { | ||||
$lastOrder = $this->getOneLastOrderValidOfCycle($section, $cycleNumber); | |||||
$lastOrder = $this->getOneLastValidOfCycle($cycleNumber); | |||||
if ($lastOrder) { | if ($lastOrder) { | ||||
return intval($lastOrder->getCycleId() + 1); | return intval($lastOrder->getCycleId() + 1); | ||||
} else { | } else { | ||||
} | } | ||||
} | } | ||||
public function getNextIdValidOrder(Section $section) | |||||
public function getNextIdValidOrder(): int | |||||
{ | { | ||||
$lastOrder = $this->getOneLastValid($section); | |||||
$lastOrder = $this->getOneLastValid(); | |||||
if ($lastOrder) { | if ($lastOrder) { | ||||
return intval($lastOrder->getIdValidOrder() + 1); | return intval($lastOrder->getIdValidOrder() + 1); | ||||
} | } | ||||
// countValidOrderShopByUserAllMerchant | // countValidOrderShopByUserAllMerchant | ||||
public function countValidByUserAllMerchant($user) | |||||
public function countValidByUserAllMerchant($user): int | |||||
{ | { | ||||
$totalOrder = 0; | $totalOrder = 0; | ||||
return $totalOrder; | return $totalOrder; | ||||
} | } | ||||
public function countValidByUser(UserInterface $user, MerchantInterface $merchant = null) | |||||
public function countValidByUser(UserInterface $user, MerchantInterface $merchant = null): int | |||||
{ | { | ||||
return $this->getBy( | return $this->getBy( | ||||
[ | [ | ||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
->filterByReductionCredit($reductionCredit) | ->filterByReductionCredit($reductionCredit) | ||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
return $query->count(); | return $query->count(); | ||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
->filterByReductionCart($reductionCart) | ->filterByReductionCart($reductionCart) | ||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
return $query->count(); | return $query->count(); | ||||
->selectCount() | ->selectCount() | ||||
->filterByUser($user) | ->filterByUser($user) | ||||
->filterByReductionCart($reductionCart) | ->filterByReductionCart($reductionCart) | ||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
return $query->count(); | return $query->count(); | ||||
$query | $query | ||||
->selectOrderReductionCarts() | ->selectOrderReductionCarts() | ||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
$results = $query->find(); | $results = $query->find(); | ||||
$query | $query | ||||
->filterByCycleNumber($cycleNumber) | ->filterByCycleNumber($cycleNumber) | ||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterIsNotMainOrderShop() | ->filterIsNotMainOrderShop() | ||||
->orderBy('.weekId', 'DESC') | ->orderBy('.weekId', 'DESC') | ||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
$query = $this->query->create(); | $query = $this->query->create(); | ||||
$query | $query | ||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterIsNotMainOrderShop() | ->filterIsNotMainOrderShop() | ||||
->orderBy('.idValidOrder', 'DESC') | ->orderBy('.idValidOrder', 'DESC') | ||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
// @TODO : Fonction à tester | |||||
public function countBy(array $params = []) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->selectCount(); | |||||
$query = $this->applyGetByFilters($query); | |||||
return $query->count(); | |||||
} | |||||
// findAllBy | |||||
public function getBy(array $params = []) | |||||
public function getBy(array $params = []): array | |||||
{ | { | ||||
$query = $this->query->create(); | $query = $this->query->create(); | ||||
$query = $this->applyGetByFilters($query); | |||||
$orderShops = $query->find(); | |||||
if (isset($params['mergeComplementaryOrderShops'])) { | |||||
foreach ($orderShops as $orderShop) { | |||||
$this->orderShopSolver->mergeComplentaryOrderShops($orderShop); | |||||
} | |||||
} | |||||
return $orderShops; | |||||
} | |||||
protected function applyGetByFilters($query) | |||||
{ | |||||
if (isset($params['section'])) { | if (isset($params['section'])) { | ||||
$query->filterBySection($params['section']); | $query->filterBySection($params['section']); | ||||
} else { | } else { | ||||
$query->filterBySection($this->section); | $query->filterBySection($this->section); | ||||
} | } | ||||
if (isset($params['count']) && $params['count']) { | |||||
$query->selectCount(); | |||||
} else { | |||||
if (isset($params['select'])) { | |||||
$query->selectParam($params['select']); | |||||
} | |||||
if (isset($params['select'])) { | |||||
$query->selectParam($params['select']); | |||||
} | } | ||||
if (isset($params['dateStart']) || isset($params['dateEnd'])) { | if (isset($params['dateStart']) || isset($params['dateEnd'])) { | ||||
} | } | ||||
if (isset($params['isCart'])) { | if (isset($params['isCart'])) { | ||||
$query->filterByStatus(OrderStatus::$statusAliasAsCart); | |||||
$query->filterByStatus(OrderStatusModel::$statusAliasAsCart); | |||||
} | } | ||||
if (isset($params['isValid'])) { | if (isset($params['isValid'])) { | ||||
$query->filterByStatus(OrderStatus::$statusAliasAsValid); | |||||
$query->filterByStatus(OrderStatusModel::$statusAliasAsValid); | |||||
} | } | ||||
if (isset($params['isWaitingDelivery'])) { | if (isset($params['isWaitingDelivery'])) { | ||||
$query->filterByStatus(OrderStatus::$statusAliasWaitingDelivery); | |||||
$query->filterByStatus(OrderStatusModel::$statusAliasWaitingDelivery); | |||||
} | } | ||||
if (isset($params['orderStatus'])) { | if (isset($params['orderStatus'])) { | ||||
$query->filterByAddress($params['address']); | $query->filterByAddress($params['address']); | ||||
} | } | ||||
if (isset($params['weekDeliveryTrucks'])) { | |||||
$query->filterByWeekDeliveryTruck($params['weekDeliveryTrucks']); | |||||
} | |||||
if (isset($params['estimatedDeliveryDateTime'])) { | |||||
$date = clone $params['estimatedDeliveryDateTime']; | |||||
$query | |||||
->filterByEstimatedDeliveryDateStart($date->format('Y-m-d 00:00:00')) | |||||
->filterByEstimatedDeliveryDateEnd($date->modify('+1 day')->format('Y-m-d 00:00:00')); | |||||
} | |||||
if (isset($params['deliveryDate'])) { | |||||
$date = clone $params['deliveryDate']; | |||||
$query | |||||
->filterByDeliveryDateStart($date->format('Y-m-d 00:00:00')) | |||||
->filterByDeliveryDateEnd($date->modify('+1 day')->format('Y-m-d 00:00:00')); | |||||
} | |||||
if (isset($params['mergeComplementaryOrderShops'])) { | if (isset($params['mergeComplementaryOrderShops'])) { | ||||
$query | $query | ||||
->joinComplementaryOrderShops(); | ->joinComplementaryOrderShops(); | ||||
$query->filterIsNullMainOrderShop(); | $query->filterIsNullMainOrderShop(); | ||||
} | } | ||||
if (isset($params['isCircuit'])) { | |||||
$query->filterIsNullDeliveryPointSale(); | |||||
} | |||||
if (isset($params['isDepository'])) { | |||||
$query->filterIsNotNullDeliveryPointSale(); | |||||
} | |||||
if (isset($params['isOffCircuit'])) { | |||||
$query->filterIsPointSale('devAliasHorsTournee'); | |||||
} | |||||
if (isset($params['isGiftVoucher'])) { | |||||
$query->filterIsPointSale('devAliasGiftVoucher'); | |||||
} | |||||
if (isset($params['deliveryAvailability'])) { | |||||
$deliveryAvailability = $params['deliveryAvailability']; | |||||
$deliveryAvailabilityZone = ($deliveryAvailability instanceof DeliveryAvailabilityZone) ? $deliveryAvailability : false; | |||||
$deliveryAvailabilityPointSale = ($deliveryAvailability instanceof DeliveryAvailabilityPointSale) ? $deliveryAvailability : false; | |||||
if ($deliveryAvailabilityZone) { | |||||
$query->filterByAvailabilityPointZone($deliveryAvailabilityZone); | |||||
} | |||||
if ($deliveryAvailabilityPointSale) { | |||||
$query->filterByAvailabilityPointZone($deliveryAvailabilityPointSale); | |||||
} | |||||
} else { | |||||
$query->joinDeliverySlotZone(); | |||||
$query->joinDeliverySlotPointSale(); | |||||
} | |||||
if (isset($params['orderBy'])) { | if (isset($params['orderBy'])) { | ||||
$sort = isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC'; | $sort = isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC'; | ||||
$query->orderBy($params['orderBy'], $sort); | $query->orderBy($params['orderBy'], $sort); | ||||
if (isset($params['groupBy'])) { | if (isset($params['groupBy'])) { | ||||
$query->groupBy($params['groupBy']); | $query->groupBy($params['groupBy']); | ||||
} | } | ||||
return $query; | |||||
} | |||||
if (isset($params['count']) && $params['count']) { | |||||
return $query->count(); | |||||
} | |||||
return $query->find(); | |||||
} | |||||
/* | /* | ||||
public function getCartCurrent(SectionInterface $section, UserInterface $user = null, VisitorInterface $visitor = null) | public function getCartCurrent(SectionInterface $section, UserInterface $user = null, VisitorInterface $visitor = null) |
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class PointSaleRepositoryQuery extends AbstractRepositoryQuery | class PointSaleRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use StatusRepositoryQueryTrait; | |||||
public function __construct(PointSaleRepository $repository, PaginatorInterface $paginator) | public function __construct(PointSaleRepository $repository, PaginatorInterface $paginator) | ||||
{ | { |
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\TreeRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
use StatusRepositoryQueryTrait; | |||||
use TreeRepositoryQueryTrait; | |||||
protected $isJoinProductFamilies = false; | protected $isJoinProductFamilies = false; | ||||
public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use SectionRepositoryQueryTrait; | |||||
use StatusRepositoryQueryTrait; | |||||
public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator) | ||||
{ | { |
namespace Lc\CaracoleBundle\Repository; | namespace Lc\CaracoleBundle\Repository; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Doctrine\Persistence\ManagerRegistry; | use Doctrine\Persistence\ManagerRegistry; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | use Lc\CaracoleBundle\Resolver\MerchantResolver; | ||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\SovBundle\Repository\AbstractRepository as SovAbstractRepository; | |||||
// @TODO : à supprimer à terme, certainement | |||||
trait RepositoryTrait | trait RepositoryTrait | ||||
{ | { | ||||
protected $merchantResolver; | |||||
protected $sectionResolver; | |||||
protected MerchantResolver $merchantResolver; | |||||
protected SectionResolver $sectionResolver; | |||||
public function __construct( | public function __construct( | ||||
ManagerRegistry $managerRegistry, | ManagerRegistry $managerRegistry, | ||||
$this->sectionResolver = $sectionResolver; | $this->sectionResolver = $sectionResolver; | ||||
} | } | ||||
protected function setCriteria(array $criteria) :array | |||||
/*protected function setCriteria(array $criteria) :array | |||||
{ | { | ||||
$criteria = parent::setCriteria($criteria); | |||||
$className = $this->getClassMetadata()->getName(); | $className = $this->getClassMetadata()->getName(); | ||||
$entity = new $className; | $entity = new $className; | ||||
} | } | ||||
} | } | ||||
return $criteria; | return $criteria; | ||||
} | |||||
}*/ | |||||
} | } |
{ | { | ||||
public function filterBySection(SectionInterface $section) | public function filterBySection(SectionInterface $section) | ||||
{ | { | ||||
$this->andWhereSection($this->id, $section); | |||||
return $this->andWhereSection($this->id, $section); | |||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Site; | namespace Lc\CaracoleBundle\Repository\Site; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery; | use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery; | ||||
class PageRepositoryQuery extends SovPageRepositoryQuery | class PageRepositoryQuery extends SovPageRepositoryQuery | ||||
{ | { | ||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
use StatusRepositoryQueryTrait; | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Repository; | |||||
trait StatusRepositoryQueryTrait | |||||
{ | |||||
public function filterByStatus(int $status):self | |||||
{ | |||||
return $this->andWhere('.status = :status')->setParameter(':status', $status); | |||||
} | |||||
public function filterIsOffline():self | |||||
{ | |||||
return $this->andWhere('.status = :status')->setParameter(':status', 0); | |||||
} | |||||
public function filterIsOnline():self | |||||
{ | |||||
return $this->andWhere('.status = :status')->setParameter(':status', 1); | |||||
} | |||||
public function filterIsOnlineAndOffline():self | |||||
{ | |||||
return $this->andWhere('.status >= 0'); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Repository; | |||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
trait TreeRepositoryQueryTrait | |||||
{ | |||||
public function filterIsParent(){ | |||||
return $this->andWhere('.parent is NULL'); | |||||
} | |||||
public function filterIsChildren(){ | |||||
return $this->andWhere('.parent is NOT NULL'); | |||||
} | |||||
public function filterByParent(EntityInterface $parent){ | |||||
return $this->andWhere('.parent = :parent')->setParameter('parent', $parent); | |||||
} | |||||
} |
namespace Lc\CaracoleBundle\Solver\Order; | namespace Lc\CaracoleBundle\Solver\Order; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | use Lc\CaracoleBundle\Model\File\DocumentInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentModel; | use Lc\CaracoleBundle\Model\File\DocumentModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
class OrderShopSolver | class OrderShopSolver | ||||
{ | { | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
protected EntityManagerInterface $entityManager; | |||||
public function __construct(PriceSolver $priceSolver) | |||||
public function __construct(PriceSolver $priceSolver, EntityManagerInterface $entityManager) | |||||
{ | { | ||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$this->entityManager = $entityManager; | |||||
} | } | ||||
public function countQuantities(OrderShopInterface $orderShop): int | public function countQuantities(OrderShopInterface $orderShop): int | ||||
return null; | return null; | ||||
} | } | ||||
public function isDeliveryHome(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return $orderShop->getDeliveryType() == OrderShopModel::DELIVERY_TYPE_HOME; | |||||
} | |||||
public function isDeliveryPointSale(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return $orderShop->getDeliveryType() == OrderShopModel::DELIVERY_TYPE_POINTSALE; | |||||
} | |||||
public function isComplementaryOrderShop(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return (bool) $orderShop->getMainOrderShop() ; | |||||
} | |||||
public function mergeComplentaryOrderShops(OrderShopInterface $orderShop, bool $combineProducts = true) :OrderShopInterface | |||||
{ | |||||
$this->entityManager->refresh($orderShop); | |||||
if ($orderShop->getComplementaryOrderShops()) { | |||||
foreach ($orderShop->getComplementaryOrderShops() as $complementaryOrderShop) { | |||||
foreach ($complementaryOrderShop->getOrderProducts() as $orderProductAdd) { | |||||
$updated = false; | |||||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||||
if ($combineProducts && $orderProduct->getProduct()->getId() == $orderProductAdd->getProduct( | |||||
)->getId() | |||||
&& (string)$orderProduct->getPrice() == (string)$orderProductAdd->getPrice() | |||||
) { | |||||
$orderProduct->setUpdatedOnMergeComplementaryOrderShop(true); | |||||
$orderProduct->setQuantityOrder( | |||||
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder() | |||||
); | |||||
$updated = true; | |||||
} | |||||
} | |||||
if (!$updated) { | |||||
$orderProductAdd->setOnMergeComplementaryOrderShop($complementaryOrderShop); | |||||
$orderProductAdd->setCreatedOnMergeComplementaryOrderShop(true); | |||||
$orderShop->addOrderProduct($orderProductAdd); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return $orderShop; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Solver\PointSale; | |||||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | |||||
class PointSaleSolver | |||||
{ | |||||
public function labelAdminChoice(PointSaleInterface $pointSale): string | |||||
{ | |||||
if ($pointSale->getIsPublic()) { | |||||
return '[Public] ' . $pointSale->getTitle(); | |||||
} else { | |||||
return '[Privée] ' . $pointSale->getTitle(); | |||||
} | |||||
} | |||||
public function getSummary(PointSaleInterface $pointSale): string | |||||
{ | |||||
$html = ''; | |||||
if ($pointSale->getTitle()) { | |||||
$html .= $pointSale->getTitle() . '<br />'; | |||||
} | |||||
if ($pointSale->getAddress()) { | |||||
$html .= $pointSale->getAddress()->getAddress() . '<br />'; | |||||
} | |||||
if ($pointSale->getAddress()->getZip() || $pointSale->getAddress()->getCity()) { | |||||
$html .= $pointSale->getAddress()->getZip() . ' ' . $pointSale->getAddress()->getCity() . '<br />'; | |||||
} | |||||
return $html; | |||||
} | |||||
} |
return false; | return false; | ||||
} | } | ||||
public function getAge(UserInterface $user): ?int | |||||
{ | |||||
if ($user->getBirthdate()) { | |||||
$now = new \DateTime(); | |||||
$interval = $now->diff($user->getBirthdate()); | |||||
return $interval->y; | |||||
} else { | |||||
return null; | |||||
} | |||||
} | |||||
} | } |