Guillaume 3 лет назад
Родитель
Сommit
89ac0bae97
34 измененных файлов: 429 добавлений и 257 удалений
  1. +9
    -17
      Controller/Credit/CreditHistoryAdminController.php
  2. +37
    -0
      Controller/Product/ProductCategoryAdminController.php
  3. +21
    -0
      Controller/Product/ProductFamilyAdminController.php
  4. +0
    -2
      Controller/Site/PageAdminController.php
  5. +7
    -5
      Controller/Ticket/TicketAdminController.php
  6. +1
    -0
      Controller/User/UserMerchantAdminController.php
  7. +41
    -39
      Doctrine/Extension/ReductionTrait.php
  8. +9
    -3
      Factory/Product/ProductFamilyFactory.php
  9. +0
    -2
      Factory/Site/PageFactory.php
  10. +12
    -0
      Model/Config/TaxRateModel.php
  11. +13
    -0
      Model/Config/UnitModel.php
  12. +1
    -17
      Model/Newsletter/NewsletterModel.php
  13. +2
    -21
      Model/Order/OrderShopModel.php
  14. +17
    -35
      Model/Product/ProductCategoryModel.php
  15. +104
    -50
      Model/Product/ProductFamilyModel.php
  16. +0
    -12
      Model/Reminder/ReminderModel.php
  17. +4
    -23
      Model/Site/PageModel.php
  18. +21
    -1
      Repository/Config/TaxRateStore.php
  19. +16
    -0
      Repository/Config/UnitStore.php
  20. +2
    -3
      Repository/MerchantRepositoryQueryTrait.php
  21. +17
    -0
      Repository/MerchantStoreTrait.php
  22. +0
    -1
      Repository/Order/OrderShopRepositoryQuery.php
  23. +5
    -1
      Repository/Product/ProductCategoryRepositoryQuery.php
  24. +13
    -0
      Repository/Product/ProductCategoryStore.php
  25. +0
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  26. +15
    -0
      Repository/Reduction/ReductionCatalogRepositoryQuery.php
  27. +8
    -0
      Repository/Reduction/ReductionCatalogStore.php
  28. +4
    -16
      Repository/Reminder/ReminderStore.php
  29. +1
    -3
      Repository/SectionRepositoryQueryTrait.php
  30. +17
    -0
      Repository/SectionStoreTrait.php
  31. +0
    -1
      Repository/Site/PageRepositoryQuery.php
  32. +1
    -1
      Resources/assets/app/admin/switchmerchant/switchmerchant_admin.scss
  33. +9
    -2
      Resources/translations/admin.fr.yaml
  34. +22
    -1
      Twig/StoreTwigExtension.php

+ 9
- 17
Controller/Credit/CreditHistoryAdminController.php Просмотреть файл

@@ -30,16 +30,7 @@ use Lc\SovBundle\Translation\TranslatorAdmin;
abstract class CreditHistoryAdminController extends AbstractAdminController
{
use AdminControllerTrait;

protected $em;
protected $translatorAdmin;

public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin)
{
$this->em = $entityManager;
$this->translatorAdmin = $translatorAdmin;
}

public function overrideGlobalActions(?ActionCollection $actions): void
{
parent::overrideGlobalActions($actions);
@@ -98,16 +89,17 @@ abstract class CreditHistoryAdminController extends AbstractAdminController

public function configureFields(string $pageName): iterable
{
$translatorAdmin = $this->get('translator_admin');
return [
IdField::new('id')->hideOnForm(),
ChoiceField::new('type')->setChoices(
array(
$this->translatorAdmin->transField(
$translatorAdmin->transField(
'typeOptions.'.CreditHistoryModel::TYPE_CREDIT,
'CreditHistory'
) => CreditHistoryModel::TYPE_CREDIT,

$this->translatorAdmin->transField(
$translatorAdmin->transField(
'typeOptions.'.CreditHistoryModel::TYPE_DEBIT,
'CreditHistory'
) => CreditHistoryModel::TYPE_DEBIT,
@@ -117,27 +109,27 @@ abstract class CreditHistoryAdminController extends AbstractAdminController
DateField::new('paidAt'),
ChoiceField::new('meanPayment')->setChoices(
array(
$this->translatorAdmin->transField(
$translatorAdmin->transField(
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CASH,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CASH,

$this->translatorAdmin->transField(
$translatorAdmin->transField(
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CHEQUE,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CHEQUE,

$this->translatorAdmin->transField(
$translatorAdmin->transField(
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT,

$this->translatorAdmin->transField(
$translatorAdmin->transField(
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD,

$this->translatorAdmin->transField(
$translatorAdmin->transField(
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_TRANSFER,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER,

+ 37
- 0
Controller/Product/ProductCategoryAdminController.php Просмотреть файл

@@ -0,0 +1,37 @@
<?php

namespace Lc\CaracoleBundle\Controller\Product;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;

abstract class ProductCategoryAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function configureFields(string $pageName): iterable
{
return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
AssociationField::new('parent'),
CKEditorField::new('description'),
BooleanField::new('saleStatus'),
StatusField::new('status'),

],
$this->getSeoPanel(),
$this->getConfPanel()
);
}

}

+ 21
- 0
Controller/Product/ProductFamilyAdminController.php Просмотреть файл

@@ -0,0 +1,21 @@
<?php

namespace Lc\CaracoleBundle\Controller\Product;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;

abstract class ProductFamilyAdminController extends AbstractAdminController
{
use AdminControllerTrait;


}

+ 0
- 2
Controller/Site/PageAdminController.php Просмотреть файл

@@ -13,9 +13,7 @@ abstract class PageAdminController extends SovPageAdminController
public function createEntity(string $entityFqcn)
{
$factory = new PageFactory();
$currentMerchant = $this->get('merchant_resolver')->getCurrent();
$currentSection = $this->get('section_resolver')->getCurrent();
$factory->setMerchant($currentMerchant);
$factory->setSection($currentSection);
return $factory->create();
}

+ 7
- 5
Controller/Ticket/TicketAdminController.php Просмотреть файл

@@ -2,18 +2,20 @@

namespace Lc\CaracoleBundle\Controller\Ticket;

use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController;
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory;

class TicketAdminController extends SovTicketAdminController
{
use AdminControllerTrait;

public function createEntityFromFactory()
public function createEntity(string $entityFqcn)
{
return $this->ticketFactory
->setMerchant($this->get('merchant_resolver')->getCurrent())
->create();
$merchantResolver = $this->get('merchant_resolver');
$factory = new TicketFactory();
$factory->setMerchant($merchantResolver->getCurrent());
return $factory->create();
}

}

+ 1
- 0
Controller/User/UserMerchantAdminController.php Просмотреть файл

@@ -28,6 +28,7 @@ use Lc\CaracoleBundle\Form\Credit\CreditHistoryFormType;
use Lc\CaracoleBundle\Form\User\UserMerchantFormType;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

+ 41
- 39
Doctrine/Extension/ReductionTrait.php Просмотреть файл

@@ -7,55 +7,57 @@ use Doctrine\ORM\Mapping as ORM;
trait ReductionTrait
{

/**
* @ORM\Column(type="float", nullable=true)
*/
protected $value;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $unit;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $behaviorTaxRate;
/**
* @ORM\Column(type="float", nullable=true)
*/
protected $value;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $unit;

public function getValue(): ?float
{
return $this->value;
}
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $behaviorTaxRate;

public function setValue(?float $value): self
{
$this->value = $value;

return $this;
}
public function getValue(): ?float
{
return $this->value;
}

public function getUnit(): ?string
{
return $this->unit;
}
public function setValue(?float $value): self
{
$this->value = $value;

public function setUnit(?string $unit): self
{
$this->unit = $unit;
return $this;
}

return $this;
}
public function getUnit(): ?string
{
return $this->unit;
}

public function getBehaviorTaxRate(): ?string
{
return $this->behaviorTaxRate;
}
public function setUnit(?string $unit): self
{
$this->unit = $unit;

public function setBehaviorTaxRate(?string $behaviorTaxRate): self
{
$this->behaviorTaxRate = $behaviorTaxRate;
return $this;
}

return $this;
}
public function getBehaviorTaxRate(): ?string
{
return $this->behaviorTaxRate;
}

public function setBehaviorTaxRate(?string $behaviorTaxRate): self
{
$this->behaviorTaxRate = $behaviorTaxRate;

return $this;
}
}

+ 9
- 3
Factory/Product/ProductFamilyFactory.php Просмотреть файл

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Product;

use App\Entity\Product\ProductFamily;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
@@ -11,12 +12,17 @@ use Lc\SovBundle\Factory\AbstractFactory;
class ProductFamilyFactory extends AbstractFactory
{

public function create(MerchantInterface $merchant, SectionInterface $section): ProductFamilyInterface
use SectionFactoryTrait;

public function create(SectionInterface $section = null): ProductFamilyInterface
{
$productFamily = new ProductFamily();

$productFamily->setMerchant($merchant);
$productFamily->setSection($section);
if(is_null($section)) {
$productFamily->setSection($this->section);
}else{
$productFamily->setSection($section);
}

return $productFamily;
}

+ 0
- 2
Factory/Site/PageFactory.php Просмотреть файл

@@ -9,14 +9,12 @@ use Lc\SovBundle\Model\Site\PageInterface;

class PageFactory extends SovPageFactory
{
use MerchantFactoryTrait;
use SectionFactoryTrait;

public function create(): PageInterface
{
$page = parent::create();

$page->setMerchant($this->merchant);
$page->setSection($this->section);

return $page;

+ 12
- 0
Model/Config/TaxRateModel.php Просмотреть файл

@@ -11,6 +11,18 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
abstract class TaxRateModel extends AbstractLightEntity
{

const BEHAVIOR_TAX_RATE_INCLUDED = 'tax-included';
const BEHAVIOR_TAX_RATE_EXCLUDED = 'tax-excluded';

public function getBehaviorTaxRateChoices(): array
{
return [
self::BEHAVIOR_TAX_RATE_EXCLUDED,
self::BEHAVIOR_TAX_RATE_INCLUDED,
];
}


/**
* @ORM\Column(type="string", length=255)
*/

+ 13
- 0
Model/Config/UnitModel.php Просмотреть файл

@@ -10,6 +10,19 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
*/
abstract class UnitModel extends AbstractLightEntity
{

const UNIT_PERCENT = 'percent';
const UNIT_AMOUNT = 'amount';


public function getUnitAmountChoices(): array
{
return [
self::UNIT_PERCENT,
self::UNIT_AMOUNT,
];
}

/**
* @ORM\Column(type="string", length=32)
*/

+ 1
- 17
Model/Newsletter/NewsletterModel.php Просмотреть файл

@@ -12,29 +12,13 @@ use Lc\SovBundle\Model\Newsletter\NewsletterModel as SovNewsletterModel;
/**
* @ORM\MappedSuperclass()
*/
abstract class NewsletterModel extends SovNewsletterModel implements FilterMerchantInterface, FilterSectionInterface
abstract class NewsletterModel extends SovNewsletterModel implements FilterSectionInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="newsletters")
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="newsletters")
*/
protected $section;

public function getMerchant(): ?MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getSection(): ?SectionInterface
{

+ 2
- 21
Model/Order/OrderShopModel.php Просмотреть файл

@@ -6,12 +6,11 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
@@ -21,14 +20,8 @@ use Lc\SovBundle\Model\User\UserInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class OrderShopModel extends AbstractLightEntity implements FilterMerchantInterface
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="productFamilies")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orders", fetch="EAGER")
*/
@@ -253,18 +246,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterMerch
return null;
}

public function getMerchant(): ?MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getUser(): ?UserInterface
{
return $this->user;

+ 17
- 35
Model/Product/ProductCategoryModel.php Просмотреть файл

@@ -5,8 +5,7 @@ namespace Lc\CaracoleBundle\Model\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Extension\TreeInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
@@ -14,14 +13,14 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
/**
* @ORM\MappedSuperclass()
*/
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterMerchantInterface
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterSectionInterface
{

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="productCategories")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;
protected $section;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="childrens")
@@ -45,12 +44,6 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn
protected $saleStatus;


/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="productCategories")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

public function __construct()
{
$this->childrens = new ArrayCollection();
@@ -65,6 +58,19 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn
return $title;
}

public function getSection(): SectionInterface
{
return $this->section;
}

public function setSection(SectionInterface $section): self
{
$this->section = $section;

return $this;
}


public function getParent(): ?self
{
return $this->parent;
@@ -165,18 +171,6 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn
return $count;
}

public function getMerchant(): ?MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getSaleStatus(): ?bool
{
return $this->saleStatus;
@@ -189,16 +183,4 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn
return $this;
}

public function getSection(): ?SectionInterface
{
return $this->section;
}

public function setSection(?SectionInterface $section): self
{
$this->section = $section;

return $this;
}

}

+ 104
- 50
Model/Product/ProductFamilyModel.php Просмотреть файл

@@ -5,12 +5,11 @@ namespace Lc\CaracoleBundle\Model\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface;
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
@@ -20,7 +19,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
* @ORM\MappedSuperclass()
*/
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface,
FilterMerchantInterface
FilterSectionInterface
{

use ProductPropertyTrait;
@@ -30,38 +29,123 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family';
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT = 'by-product';

public function getBehaviorCountStockChoices(): array
{
return [
self::BEHAVIOR_COUNT_STOCK_BY_MEASURE,
self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT,
self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY,
self::BEHAVIOR_COUNT_STOCK_UNLIMITED,
];
}



const BEHAVIOR_DISPLAY_SALE_BY_MEASURE = 'by-measure';
const BEHAVIOR_DISPLAY_SALE_BY_QUANTITY = 'by-quantity';

public function getBehaviorDisplaySaleChoices(): array
{
return [
self::BEHAVIOR_DISPLAY_SALE_BY_MEASURE,
self::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY,
];
}


const BEHAVIOR_STOCK_WEEK_RENEWABLE = 'renewable';
const BEHAVIOR_STOCK_WEEK_RENEWABLE_VALIDATION = 'renewable-with-validation';
const BEHAVIOR_STOCK_WEEK_NON_RENEWABLE = 'non-renewable';

public function getBehaviorStockWeekChoices(): array
{
return [
self::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE,
self::BEHAVIOR_STOCK_WEEK_RENEWABLE,
self::BEHAVIOR_STOCK_WEEK_RENEWABLE_VALIDATION,
];
}


const WARNING_MESSAGE_TYPE_SUCCESS = 'success';
const WARNING_MESSAGE_TYPE_ERROR = 'error';
const WARNING_MESSAGE_TYPE_WARNING = 'warning';
const WARNING_MESSAGE_TYPE_INFO = 'info';

public function getWaringMessageTypeChoices(): array
{
return [
self::WARNING_MESSAGE_TYPE_ERROR,
self::WARNING_MESSAGE_TYPE_INFO,
self::WARNING_MESSAGE_TYPE_SUCCESS,
self::WARNING_MESSAGE_TYPE_WARNING,
];
}
const BEHAVIOR_ADD_TO_CART_SIMPLE = 'simple';
const BEHAVIOR_ADD_TO_CART_MULTIPLE = 'multiple';

public function getBehaviorAddToCartChoices(): array
{
return [
self::BEHAVIOR_ADD_TO_CART_MULTIPLE,
self::BEHAVIOR_ADD_TO_CART_SIMPLE,
];
}
const BEHAVIOR_PRICE_BY_PIECE = 'by-piece';
const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit';

public function getBehaviorPriceChoices(): array
{
return [
self::BEHAVIOR_PRICE_BY_PIECE,
self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT,
];
}
const PROPERTY_ORGANIC_LABEL_AB = 'ab';
const PROPERTY_ORGANIC_LABEL_NP = 'nature-progres';
const PROPERTY_ORGANIC_LABEL_HVE = 'hve';
const PROPERTY_ORGANIC_LABEL_TRVR = 'trvr';

public function getPropertyOrganicLabelChoices(): array
{
return [
self::PROPERTY_ORGANIC_LABEL_AB,
self::PROPERTY_ORGANIC_LABEL_NP,
self::PROPERTY_ORGANIC_LABEL_HVE,
self::PROPERTY_ORGANIC_LABEL_TRVR,
];
}


const TYPE_EXPIRATION_DATE_DLC = 'dlc';
const TYPE_EXPIRATION_DATE_DDM = 'ddm';
const TYPE_EXPIRATION_DATE_DLUO = 'dluo';

public function getTypeExpirationDateChoices(): array
{
return [
self::TYPE_EXPIRATION_DATE_DLC,
self::TYPE_EXPIRATION_DATE_DDM,
self::TYPE_EXPIRATION_DATE_DLUO,
];
}


const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family';
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product';

public function getBehaviorExpirationDateChoices():array{
return [
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY,
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT
];
}


//Champ hydraté par ProductFamilyUtils
protected $reductionCatalog;


/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
@@ -76,12 +160,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
*/
protected $updatedBy;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="productFamilies")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="productFamilies")
*/
@@ -234,10 +312,12 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
*/
protected $saleStatus;


/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="productFamilies")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $sections;
protected $section;

public function __construct()
{
@@ -250,6 +330,18 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
return $this->getTitle();
}

public function getSection(): SectionInterface
{
return $this->section;
}

public function setSection(SectionInterface $section): self
{
$this->section = $section;

return $this;
}

public function getAvailableQuantityInherited()
{
$availableQuantity = 0;
@@ -281,22 +373,9 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
if ($this->getTaxRate()) {
return $this->getTaxRate();
} else {
return $this->getMerchant()->getTaxRate();
return $this->getSection()->getMerchant()->getTaxRate();
}
}

public function getMerchant(): ?MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getActiveProducts(): ?bool
{
return $this->activeProducts;
@@ -868,31 +947,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
return $this;
}

/**
* @return Collection|SectionInterface[]
*/
public function getSections(): Collection
{
return $this->sections;
}

public function addSection(SectionInterface $section): self
{
if (!$this->sections->contains($section)) {
$this->sections[] = $section;
}

return $this;
}

public function removeSection(SectionInterface $section): self
{
if ($this->sections->contains($section)) {
$this->sections->removeElement($section);
}

return $this;
}

public function getFieldBuyingPrice()
{

+ 0
- 12
Model/Reminder/ReminderModel.php Просмотреть файл

@@ -25,18 +25,6 @@ abstract class ReminderModel extends SovReminderModel implements FilterMerchantI
*/
protected $section;

public function getMerchant(): MerchantInterface
{
return $this->merchant;
}

public function setMerchant(MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getSection(): ?SectionInterface
{
return $this->section;

+ 4
- 23
Model/Site/PageModel.php Просмотреть файл

@@ -3,48 +3,29 @@
namespace Lc\CaracoleBundle\Model\Site;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Site\PageModel as SovPageModel;

/**
* @ORM\MappedSuperclass()
*/
abstract class PageModel extends SovPageModel implements FilterMerchantInterface, FilterSectionInterface
abstract class PageModel extends SovPageModel implements FilterSectionInterface
{

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pages")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;


public function getMerchant(): ?MerchantInterface
{
return $this->merchant;
}

public function setMerchant(?MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getSection(): ?SectionInterface
public function getSection(): SectionInterface
{
return $this->section;
}

public function setSection(?SectionInterface $section): self
public function setSection(SectionInterface $section): self
{
$this->section = $section;


+ 21
- 1
Repository/Config/TaxRateStore.php Просмотреть файл

@@ -2,14 +2,34 @@

namespace Lc\CaracoleBundle\Repository\Config;

use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Repository\AbstractStore;

class TaxRateStore extends AbstractStore
{
protected TaxRateRepositoryQuery $query;
protected MerchantResolver $merchantResolver;

public function __construct(TaxRateRepositoryQuery $query)
public function __construct(TaxRateRepositoryQuery $query, MerchantResolver $merchantResolver)
{
$this->query = $query;
$this->merchantResolver = $merchantResolver;
}


public function getAsArray()
{
$query = $this->query->create();

$taxRatesList = array();
foreach ($query->find() as $taxRate) {
$taxRatesList[$taxRate->getId()]['title'] = $taxRate->getTitle();
$taxRatesList[$taxRate->getId()]['value'] = $taxRate->getValue();
}

$taxRatesList['default']['title'] = $this->merchantResolver->getCurrent()->getTaxRate()->getTitle();
$taxRatesList['default']['value'] = $this->merchantResolver->getCurrent()->getTaxRate()->getValue();

return $taxRatesList;
}
}

+ 16
- 0
Repository/Config/UnitStore.php Просмотреть файл

@@ -12,4 +12,20 @@ class UnitStore extends AbstractStore
{
$this->query = $query;
}

public function getAsArray(){
$query = $this->query->create();

foreach ($query->find() as $unit) {
$unitsList[$unit->getId()]['unit'] = $unit->getUnit();
$unitsList[$unit->getId()]['wordingUnit'] = $unit->getWordingUnit();
$unitsList[$unit->getId()]['wording'] = $unit->getWording();
$unitsList[$unit->getId()]['wordingShort'] = $unit->getWordingShort();
$unitsList[$unit->getId()]['coefficient'] = $unit->getCoefficient();
$unitsList[$unit->getId()]['unitReference'] = $unit->getUnitReference()->getId();
}

return $unitsList;

}
}

+ 2
- 3
Repository/MerchantRepositoryQueryTrait.php Просмотреть файл

@@ -3,13 +3,12 @@
namespace Lc\CaracoleBundle\Repository;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait MerchantRepositoryQueryTrait
{
public function filterByMerchant(MerchantInterface $merchant)
{
return $this
->andWhere('.merchant = :merchant')
->setParameter(':merchant', $merchant);
return $this->andWhere('.merchant = :merchant')->setParameter(':merchant', $merchant);
}
}

+ 17
- 0
Repository/MerchantStoreTrait.php Просмотреть файл

@@ -0,0 +1,17 @@
<?php

namespace Lc\CaracoleBundle\Repository;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

trait MerchantStoreTrait
{
protected MerchantInterface $merchant;

public function setMerchant(MerchantInterface $merchant):self
{
$this->merchant = $merchant;

return $this;
}
}

+ 0
- 1
Repository/Order/OrderShopRepositoryQuery.php Просмотреть файл

@@ -9,7 +9,6 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class OrderShopRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator)

+ 5
- 1
Repository/Product/ProductCategoryRepositoryQuery.php Просмотреть файл

@@ -9,11 +9,15 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}

public function filterIsParent(){
return $this->andWhere('.parent is NULL');

}
}

+ 13
- 0
Repository/Product/ProductCategoryStore.php Просмотреть файл

@@ -2,14 +2,27 @@

namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;

class ProductCategoryStore extends AbstractStore
{
use SectionStoreTrait;

protected ProductCategoryRepositoryQuery $query;

public function __construct(ProductCategoryRepositoryQuery $query)
{
$this->query = $query;
}

public function getParents(){

$query = $this->query->create();
if($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsParent();
return $query->find();
}
}

+ 0
- 1
Repository/Product/ProductFamilyRepositoryQuery.php Просмотреть файл

@@ -9,7 +9,6 @@ use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator)

+ 15
- 0
Repository/Reduction/ReductionCatalogRepositoryQuery.php Просмотреть файл

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Reduction;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

@@ -14,4 +15,18 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
{
parent::__construct($repository, 'r', $paginator);
}

public function filterProductFamily(ProductFamilyInterface $productFamily)
{
return $this
->andWhere('.productFamily = :productFamily')
->setParameter(':productFamily', $productFamily);
}

public function filterStatus(bool $status)
{
return $this
->andWhere('.status = :status')
->setParameter(':status', $status);
}
}

+ 8
- 0
Repository/Reduction/ReductionCatalogStore.php Просмотреть файл

@@ -12,4 +12,12 @@ class ReductionCatalogStore extends AbstractStore
{
$this->query = $query;
}

public function getByProductFamily($productFamily){
$query = $this->query->create();
$query->filterProductFamily($productFamily);
$query->filterStatus(true);
return $query->findOne();

}
}

+ 4
- 16
Repository/Reminder/ReminderStore.php Просмотреть файл

@@ -4,26 +4,14 @@ namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore;

class ReminderStore extends SovReminderStore
{
protected MerchantInterface $merchant;
protected SectionInterface $section;

public function setMerchant(MerchantInterface $merchant)
{
$this->merchant = $merchant;

return $this;
}

public function setSection(SectionInterface $section)
{
$this->section = $section;

return $this;
}
use SectionStoreTrait;
use MerchantStoreTrait;

public function get($params = [], $query = null)
{

+ 1
- 3
Repository/SectionRepositoryQueryTrait.php Просмотреть файл

@@ -8,8 +8,6 @@ trait SectionRepositoryQueryTrait
{
public function filterBySection(SectionInterface $section)
{
return $this
->andWhere('.section = :section')
->setParameter(':section', $section);
$this->andWhere('.section = :section')->setParameter(':section', $section);
}
}

+ 17
- 0
Repository/SectionStoreTrait.php Просмотреть файл

@@ -0,0 +1,17 @@
<?php

namespace Lc\CaracoleBundle\Repository;

use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait SectionStoreTrait
{
protected SectionInterface $section;

public function setSection(SectionInterface $section):self
{
$this->section = $section;

return $this;
}
}

+ 0
- 1
Repository/Site/PageRepositoryQuery.php Просмотреть файл

@@ -8,7 +8,6 @@ use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery;

class PageRepositoryQuery extends SovPageRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

}

+ 1
- 1
Resources/assets/app/admin/switchmerchant/switchmerchant_admin.scss Просмотреть файл

@@ -6,7 +6,7 @@

.fa {
position: relative;
top: -4px;
top: 3px;
right: 7px;
}


+ 9
- 2
Resources/translations/admin.fr.yaml Просмотреть файл

@@ -1,9 +1,10 @@

menu:
pointsale: Points de vente
product_category: Catégories
setting: Paramètres
setting_merchant: Marchand
setting_section: Section
setting_merchant: Marchands
setting_section: Sections
section_openings: Ouvertures
admin: Administration
admin_merchant: Marchands
@@ -40,6 +41,9 @@ entity:
panels:
address: Adresse
fields:
parent: Parent
saleStatus: En vente
subtitle: Sous-titre
address: Adresse
merchant: Marchand
taxRate: Règle de taxe
@@ -123,6 +127,9 @@ entity:
fields:
timeStart: Heure d'ouverture
timeEnd: Heure de fermeture
ProductCategory:
label: Catégorie
label_plurial: Catégories

form:
user_merchant:

+ 22
- 1
Twig/StoreTwigExtension.php Просмотреть файл

@@ -2,6 +2,8 @@

namespace Lc\CaracoleBundle\Twig;

use Lc\CaracoleBundle\Repository\Config\TaxRateStore;
use Lc\CaracoleBundle\Repository\Config\UnitStore;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
@@ -9,6 +11,7 @@ use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\ShopBundle\Context\UnitInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

@@ -19,19 +22,25 @@ class StoreTwigExtension extends AbstractExtension
protected ReminderStore $reminderStore;
protected MerchantResolver $merchantResolver;
protected SectionResolver $sectionResolver;
protected UnitStore $unitStore;
protected TaxRateStore $taxRateStore;

public function __construct(
MerchantResolver $merchantResolver,
SectionResolver $sectionResolver,
MerchantRepositoryQuery $merchantRepositoryQuery,
SectionRepositoryQuery $sectionRepositoryQuery,
ReminderStore $reminderStore
ReminderStore $reminderStore,
UnitStore $unitStore,
TaxRateStore $taxRateStore
) {
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
$this->merchantRepositoryQuery = $merchantRepositoryQuery;
$this->sectionRepositoryQuery = $sectionRepositoryQuery;
$this->reminderStore = $reminderStore;
$this->unitStore = $unitStore;
$this->taxRateStore = $taxRateStore;
}

public function getFunctions()
@@ -40,6 +49,8 @@ class StoreTwigExtension extends AbstractExtension
new TwigFunction('carac_sections', [$this, 'getSections']),
new TwigFunction('carac_merchants', [$this, 'getMerchants']),
new TwigFunction('carac_reminders', [$this, 'getReminders']),
new TwigFunction('carac_units', [$this, 'getUnits']),
new TwigFunction('carac_tax_rates', [$this, 'getTaxRates']),
);
}

@@ -63,4 +74,14 @@ class StoreTwigExtension extends AbstractExtension
->get($params);
}

public function getUnits(){

return $this->unitStore->getAsArray();
}

public function getTaxRates(){

return $this->taxRateStore->getAsArray();
}

}

Загрузка…
Отмена
Сохранить