interface ReductionInterface | interface ReductionInterface | ||||
{ | { | ||||
/** | |||||
* Retourne le merchant courant en fonction du user ou du cookie du visitor | |||||
* | |||||
* @return MerchantInterface | |||||
*/ | |||||
public function getUnit(); | |||||
public function getValue(); | |||||
public function getBehaviorTaxRate(); | |||||
} | } |
use Lc\ShopBundle\Context\UnitInterface; | use Lc\ShopBundle\Context\UnitInterface; | ||||
use Lc\ShopBundle\Form\ProductFamilyCategoriesType; | use Lc\ShopBundle\Form\ProductFamilyCategoriesType; | ||||
use Lc\ShopBundle\Form\ProductType; | use Lc\ShopBundle\Form\ProductType; | ||||
use Lc\ShopBundle\Form\ReductionCatalogType; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||||
$this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class); | $this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class); | ||||
$formBuilder->add('productCategories', ProductFamilyCategoriesType::class); | $formBuilder->add('productCategories', ProductFamilyCategoriesType::class); | ||||
//$formBuilder->add('reductionCatalog', ReductionCatalogType::class); | |||||
/*$formBuilder->add('taxRate', EntityType::class, array( | /*$formBuilder->add('taxRate', EntityType::class, array( | ||||
'class' => $this->em->getClassMetadata(TaxRateInterface::class)->name, | 'class' => $this->em->getClassMetadata(TaxRateInterface::class)->name, | ||||
$entity->setUnit($repo->find($unitId)); | $entity->setUnit($repo->find($unitId)); | ||||
} | } | ||||
//$reductionCatalogInfo = $productFamilyRequest['reductionCatalog']; | |||||
$this->processCategories($entity); | $this->processCategories($entity); | ||||
$this->processProducts($entity); | $this->processProducts($entity); | ||||
/* dump($reductionCatalog); | |||||
dump($productFamilyRequest);*/ | |||||
die(); | |||||
parent::updateEntity($entity); | parent::updateEntity($entity); | ||||
} | } | ||||
public function persistEntity($entity) | public function persistEntity($entity) | ||||
{ | { | ||||
$this->processCategories($entity); | $this->processCategories($entity); | ||||
$this->processProducts($entity); | $this->processProducts($entity); | ||||
//si il existe un et un seul produit pour ce product family n'ajoute rien supprime rien | //si il existe un et un seul produit pour ce product family n'ajoute rien supprime rien | ||||
if (count($entity->getProducts()) == 0) { | if (count($entity->getProducts()) == 0) { | ||||
$product = new Product(); | $product = new Product(); | ||||
$product->setCreatedBy($this->getUser()); | |||||
$product->setUpdatedBy($this->getUser()); | |||||
$product->setProductFamily($entity); | $product->setProductFamily($entity); | ||||
$this->em->persist($product); | $this->em->persist($product); | ||||
foreach ($entity->getProducts() as $product) { | foreach ($entity->getProducts() as $product) { | ||||
$product->setProductFamily($entity); | $product->setProductFamily($entity); | ||||
$product->setCreatedBy($this->getUser()); | |||||
$product->setUpdatedBy($this->getUser()); | |||||
$this->em->persist($product); | $this->em->persist($product); | ||||
$entity->addProduct($product); | $entity->addProduct($product); | ||||
class AddressType extends AbstractType | class AddressType extends AbstractType | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $security; | |||||
public function __construct(EntityManagerInterface $entityManager, Security $security) | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
{ | { | ||||
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->security = $security ; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$resolver->setDefaults([ | $resolver->setDefaults([ | ||||
'label' => false, | 'label' => false, | ||||
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName(), | |||||
'createdBy' => $this->security->getUser(), | |||||
'updatedBy' => $this->security->getUser(), | |||||
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName() | |||||
]); | ]); | ||||
} | } | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Form; | |||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | |||||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||||
class ReductionCatalogType extends AbstractType | |||||
{ | |||||
protected $em; | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
{ | |||||
$this->em = $entityManager; | |||||
} | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
$builder | |||||
->add('title', TextType::class, ['label' => 'Titre']) | |||||
->add('behaviorTaxRate', ChoiceType::class, [ | |||||
'required'=> true, | |||||
'choices' => [ | |||||
'field.default.taxIncluded'=> 'tax-included', | |||||
'field.default.taxExcluded'=> 'tax-excluded' | |||||
] | |||||
]) | |||||
->add('unit', ChoiceType::class, [ | |||||
'required'=> true, | |||||
'choices' => [ | |||||
'field.default.percent'=> 'percent', | |||||
'field.default.amount'=> 'amount' | |||||
] | |||||
]) | |||||
->add('value', NumberType::class, ['required' => true]) | |||||
->add('permanent', CheckboxType::class, ['required' => true]) | |||||
->add('dateStart', DateTimeType::class, ['widget' => 'single_text']) | |||||
->add('dateEnd', DateTimeType::class, ['widget' => 'single_text']); | |||||
} | |||||
public function configureOptions(OptionsResolver $resolver) | |||||
{ | |||||
$resolver->setDefaults([ | |||||
'label' => false, | |||||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName() | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Model ; | |||||
namespace Lc\ShopBundle\Model; | |||||
use Lc\ShopBundle\Context\ReductionInterface; | |||||
use Lc\ShopBundle\Context\UnitInterface; | use Lc\ShopBundle\Context\UnitInterface; | ||||
trait PriceTrait | trait PriceTrait | ||||
public function getPriceInherited(): ?float | public function getPriceInherited(): ?float | ||||
{ | { | ||||
return $this->getPrice() ; | |||||
return $this->getPrice(); | |||||
} | } | ||||
public function getUnitInherited(): ?Unit | public function getUnitInherited(): ?Unit | ||||
{ | { | ||||
return $this->getUnit() ; | |||||
return $this->getUnit(); | |||||
} | } | ||||
public function getTaxRateInherited(): ?TaxRate | public function getTaxRateInherited(): ?TaxRate | ||||
{ | { | ||||
return $this->getTaxRate() ; | |||||
return $this->getTaxRate(); | |||||
} | } | ||||
public function getPriceWithTax(): ?float | public function getPriceWithTax(): ?float | ||||
{ | { | ||||
return $this->calculatePriceWithTax($this->getPriceInherited(), $this->getTaxRateInherited()->getValue()) ; | |||||
return $this->calculatePriceWithTax($this->getPriceInherited(), $this->getTaxRateInherited()->getValue()); | |||||
} | } | ||||
public function getPriceByUnitRef(): ?float | public function getPriceByUnitRef(): ?float | ||||
{ | { | ||||
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ; | |||||
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited(); | |||||
} | } | ||||
public function getPriceByUnitRefWithTax(): ?float | public function getPriceByUnitRefWithTax(): ?float | ||||
{ | { | ||||
return $this->calculatePriceWithTax($this->getPriceByUnitRef(), $this->getTaxRateInherited()->getValue()) ; | |||||
return $this->calculatePriceWithTax($this->getPriceByUnitRef(), $this->getTaxRateInherited()->getValue()); | |||||
} | |||||
public function getPriceWithTaxAndReduction(): ?float | |||||
{ | |||||
if ($this->reductionCatalog) { | |||||
return $this->getPriceWithTaxAndReductionCatalog($this->reductionCatalog); | |||||
} else { | |||||
return null; | |||||
} | |||||
} | |||||
public function getPriceWithTaxAndReductionCatalog(ReductionInterface $reductionCatalog): ?float | |||||
{ | |||||
if ($reductionCatalog->getUnit() == 'percent') { | |||||
//Théoriquement que la réduction s'applique sur le prixHT ou le prixTTC le résultat est le même,j'ai laisser mon code au cas où ;) | |||||
return $this->calculatePriceWithReductionPercent($this->getPriceWithTax(), $reductionCatalog->getValue()); | |||||
/*if ($reductionCatalog->getBehaviorTaxRate() == 'tax-excluded') { | |||||
$priceReductionHT = $this->calculatePriceWithReductionPercent($this->getPriceInherited(), $reductionCatalog->getValue()); | |||||
return $this->calculatePriceWithTax($priceReductionHT, $this->getTaxRateInherited()->getValue()); | |||||
} else if ($reductionCatalog->getBehaviorTaxRate() == 'tax-included') { | |||||
return $this->calculatePriceWithReductionPercent($this->getPriceWithTax(), $reductionCatalog->getValue()); | |||||
}*/ | |||||
}elseif ($reductionCatalog->getUnit() == 'amount') { | |||||
if ($reductionCatalog->getBehaviorTaxRate() == 'tax-excluded') { | |||||
$priceReductionHT = $this->calculatePriceWithReductionAmount($this->getPriceInherited(), $reductionCatalog->getValue()); | |||||
return $this->calculatePriceWithTax($priceReductionHT, $this->getTaxRateInherited()->getValue()); | |||||
}else if ($reductionCatalog->getBehaviorTaxRate() == 'tax-included') { | |||||
return $this->calculatePriceWithReductionAmount($this->getPriceWithTax(), $reductionCatalog->getValue()); | |||||
} | |||||
} | |||||
} | } | ||||
public function setPrice(float $price): self | public function setPrice(float $price): self | ||||
private function calculatePriceWithTax($priceWithoutTax, $taxRateValue): ?float | private function calculatePriceWithTax($priceWithoutTax, $taxRateValue): ?float | ||||
{ | { | ||||
$price = floatval($priceWithoutTax) * ($taxRateValue/100 + 1) ; | |||||
$price = round(( ($price * 100)) / 100, 2) ; | |||||
return $price ; | |||||
$price = floatval($priceWithoutTax) * ($taxRateValue / 100 + 1); | |||||
$price = round((($price * 100)) / 100, 2); | |||||
return $price; | |||||
} | |||||
public function calculatePriceWithReductionPercent($price, $percentValue): ?float | |||||
{ | |||||
$price = floatval($price) * (1 - $percentValue / 100); | |||||
$price = round((($price * 100)) / 100, 2); | |||||
return $price; | |||||
} | |||||
public function calculatePriceWithReductionAmount($price, $amountValue): ?float | |||||
{ | |||||
$price = floatval($price) - $amountValue; | |||||
$price = round((($price * 100)) / 100, 2); | |||||
return $price; | |||||
} | } | ||||
} | } |
{ | { | ||||
use ProductPropertyTrait; | use ProductPropertyTrait; | ||||
//Champ hydraté par ProductFamilyUtils | |||||
protected $reductionCatalog; | |||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies") | * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies") | ||||
*/ | */ | ||||
protected $productCategories; | protected $productCategories; | ||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ReductionCatalogInterface", mappedBy="reductionCatalogs") | |||||
*/ | |||||
protected $reductionCatalogs; | |||||
/** | /** | ||||
* @ORM\Column(type="boolean") | * @ORM\Column(type="boolean") | ||||
*/ | */ | ||||
protected $behaviorAddToCart; | protected $behaviorAddToCart; | ||||
//Champ hydraté par ProductFamilyUtils | |||||
public $reductionCatalog; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return Collection|ReductionCatalog[] | |||||
*/ | |||||
public function getReductionCatalogs(): Collection | |||||
{ | |||||
return $this->reductionCatalogs; | |||||
} | |||||
public function initReductionCatalogs() | |||||
{ | |||||
$this->reductionCatalogs = new ArrayCollection(); | |||||
} | |||||
public function addReductionCatalog(ReductionCatalog $reductionCatalog): self | |||||
public function getReductionCatalog(): ?ReductionCatalog | |||||
{ | { | ||||
if (!$this->reductionCatalogs->contains($reductionCatalog)) { | |||||
$this->reductionCatalogs[] = $reductionCatalog; | |||||
} | |||||
return $this; | |||||
return $this->reductionCatalog; | |||||
} | } | ||||
public function removeReductionCatalog(ReductionCatalog $reductionCatalog): self | |||||
public function setReductionCatalog(?ReductionCatalog $reductionCatalog): self | |||||
{ | { | ||||
if ($this->reductionCatalogs->contains($reductionCatalog)) { | |||||
$this->reductionCatalogs->removeElement($reductionCatalog); | |||||
} | |||||
$this->reductionCatalog = $reductionCatalog; | |||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* @return Collection|ProductCategory[] | * @return Collection|ProductCategory[] | ||||
*/ | */ |
protected $merchant; | protected $merchant; | ||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", inversedBy="reductionCatalogs") | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface") | |||||
*/ | */ | ||||
protected $productFamilies; | protected $productFamilies; | ||||
*/ | */ | ||||
protected $users; | protected $users; | ||||
/** | |||||
/* | |||||
* @ORM\Column(type="smallint") | * @ORM\Column(type="smallint") | ||||
*/ | */ | ||||
protected $fromQuantity = 1; | |||||
// protected $fromQuantity = 1; | |||||
public function __construct() | public function __construct() | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getFromQuantity(): ?int | |||||
/*public function getFromQuantity(): ?int | |||||
{ | { | ||||
return $this->fromQuantity; | return $this->fromQuantity; | ||||
} | } | ||||
$this->fromQuantity = $fromQuantity; | $this->fromQuantity = $fromQuantity; | ||||
return $this; | return $this; | ||||
} | |||||
}*/ | |||||
} | } |
*/ | */ | ||||
protected $behaviorTaxRate; | protected $behaviorTaxRate; | ||||
/** | |||||
* @ORM\Column(type="boolean") | |||||
*/ | |||||
protected $permanent; | |||||
public function getDateStart(): ?\DateTimeInterface | public function getDateStart(): ?\DateTimeInterface | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPermanent(): ?bool | |||||
{ | |||||
return $this->permanent; | |||||
} | |||||
public function setPermanent(bool $permanent): self | |||||
{ | |||||
$this->permanent = $permanent; | |||||
return $this; | |||||
} | |||||
} | } |
} | } | ||||
public function getProductFamiliesByNovelties(){ | |||||
public function getProductFamiliesNovelties(){ | |||||
$query = $this->findByMerchantQuery() ; | $query = $this->findByMerchantQuery() ; | ||||
$query->andWhere('e.status = 1'); | $query->andWhere('e.status = 1'); | ||||
$query->andWhere(':now <= e.propertyNoveltyExpirationDate') | $query->andWhere(':now <= e.propertyNoveltyExpirationDate') | ||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } | ||||
/**************************** OLD *********************************/ | |||||
public function findNovelties() | |||||
{ | |||||
public function getProductFamiliesLargeVolumes(){ | |||||
$query = $this->findByMerchantQuery() ; | $query = $this->findByMerchantQuery() ; | ||||
$query->andWhere('e.status = 1'); | |||||
$query->andWhere('e.propertyLargeVolume = 1'); | |||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } | ||||
public function findNoveltiesByParentCategories() | |||||
{ | |||||
return $this->_productsByParentCategories($this->findNovelties()) ; | |||||
} | |||||
public function findOrganics() | |||||
{ | |||||
public function getProductFamiliesOrganics(){ | |||||
$query = $this->findByMerchantQuery() ; | $query = $this->findByMerchantQuery() ; | ||||
$query->andWhere('e.status = 1'); | |||||
$query->andWhere('e.propertyOrganicLabel IS NOT NULL'); | $query->andWhere('e.propertyOrganicLabel IS NOT NULL'); | ||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } | ||||
public function findOrganicsByParentCategories() | |||||
{ | |||||
return $this->_productsByParentCategories($this->findOrganics()) ; | |||||
} | |||||
public function _productsByParentCategories($products) | |||||
{ | |||||
$categoriesArray = [] ; | |||||
foreach($products as $product) { | |||||
$productCategories = $product->getProductCategories() ; | |||||
$category = $productCategories[0]->getParentCategory() ; | |||||
if(!isset($categoriesArray[$category->getId()])) { | |||||
$categoriesArray[$category->getId()] = [ | |||||
'category' => $category, | |||||
'products' => [] | |||||
] ; | |||||
} | |||||
$categoriesArray[$category->getId()]['products'][] = $product ; | |||||
} | |||||
return $categoriesArray; | |||||
} | |||||
} | } |
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | use Lc\ShopBundle\Context\DefaultRepositoryInterface; | ||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | use Lc\ShopBundle\Context\ReductionCatalogInterface; | ||||
use Symfony\Component\Validator\Constraints\DateTime; | |||||
/** | /** | ||||
* @method ReductionCatalogInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method ReductionCatalogInterface|null find($id, $lockMode = null, $lockVersion = null) | ||||
public function getReductionCatalogByProductFamilyConditions($productFamilyIds, $user) | public function getReductionCatalogByProductFamilyConditions($productFamilyIds, $user) | ||||
{ | { | ||||
dump($user); | |||||
$query = $this->findByMerchantQuery(); | $query = $this->findByMerchantQuery(); | ||||
$query->andWhere('e.status = 1'); | $query->andWhere('e.status = 1'); | ||||
$query->andWhere(':user MEMBER OF e.users OR e.users is empty'); | |||||
$query->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty'); | |||||
$query->andWhere('e.permanent = 1 OR (e.dateStart <= :now AND e.dateEnd >= :now)'); | |||||
if($user){ | |||||
$query->andWhere(':user MEMBER OF e.users OR e.users is empty'); | |||||
$query->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty'); | |||||
$query->setParameter('user', $user); | |||||
$query->setParameter('groupUser', $user->getGroupUsers()); | |||||
} | |||||
$query->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty'); | $query->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty'); | ||||
$query->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty'); | $query->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty'); | ||||
$query->andWhere(':supplier MEMBER OF e.suppliers OR e.suppliers is empty'); | $query->andWhere(':supplier MEMBER OF e.suppliers OR e.suppliers is empty'); | ||||
$query->setParameter('user', $user); | |||||
$query->setParameter('groupUser', $user->getGroupUsers()); | |||||
$query->setParameter('productFamily', $productFamilyIds['ids']); | $query->setParameter('productFamily', $productFamilyIds['ids']); | ||||
$query->setParameter('productCategory', $productFamilyIds['categories']); | $query->setParameter('productCategory', $productFamilyIds['categories']); | ||||
$query->setParameter('supplier', $productFamilyIds['suppliers']); | $query->setParameter('supplier', $productFamilyIds['suppliers']); | ||||
$query->setParameter(':now', new \DateTime()); | |||||
return $query->getQuery()->getResult(); | return $query->getQuery()->getResult(); | ||||
table th input{width: auto} | table th input{width: auto} | ||||
table th .select2-container--default .select2-selection--single{padding:0.3rem 0.4rem; } | table th .select2-container--default .select2-selection--single{padding:0.3rem 0.4rem; } | ||||
/************************ LOGIN PAGE *********************/ | |||||
.login-logo{display: block; margin: auto;} | |||||
/************************ form error *********************/ | /************************ form error *********************/ | ||||
.form-sent .form-control:invalid{border-color: #dc3545; padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23dc3545' viewBox='-2 -2 7 7'%3e%3cpath stroke='%23dc3545' d='M0 0l3 3m0-3L0 3'/%3e%3ccircle r='.5'/%3e%3ccircle cx='3' r='.5'/%3e%3ccircle cy='3' r='.5'/%3e%3ccircle cx='3' cy='3' r='.5'/%3e%3c/svg%3E");background-repeat: no-repeat;background-position: center right calc(.375em + .1875rem); background-size: calc(.75em + .375rem) calc(.75em + .375rem);} | .form-sent .form-control:invalid{border-color: #dc3545; padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23dc3545' viewBox='-2 -2 7 7'%3e%3cpath stroke='%23dc3545' d='M0 0l3 3m0-3L0 3'/%3e%3ccircle r='.5'/%3e%3ccircle cx='3' r='.5'/%3e%3ccircle cy='3' r='.5'/%3e%3ccircle cx='3' cy='3' r='.5'/%3e%3c/svg%3E");background-repeat: no-repeat;background-position: center right calc(.375em + .1875rem); background-size: calc(.75em + .375rem) calc(.75em + .375rem);} |
$('.date-time-range').each(function (i, picker) { | $('.date-time-range').each(function (i, picker) { | ||||
$(picker).daterangepicker({ | |||||
//log(moment('2020-04-05 20:00:00').format( "DD/MM/YYYY HH:mm")) | |||||
options = { | |||||
timePicker: true, | timePicker: true, | ||||
timePickerIncrement: 30, | timePickerIncrement: 30, | ||||
timePicker24Hour: true, | timePicker24Hour: true, | ||||
"format": "DD/MM/YYYY HH:mm", | "format": "DD/MM/YYYY HH:mm", | ||||
"separator": " - ", | "separator": " - ", | ||||
"applyLabel": "Appliquer", | "applyLabel": "Appliquer", | ||||
"cancelLabel": "Cancel", | |||||
"fromLabel": "From", | |||||
"toLabel": "To", | |||||
"cancelLabel": "Annuler", | |||||
"fromLabel": "Du", | |||||
"toLabel": "au", | |||||
"customRangeLabel": "Custom", | "customRangeLabel": "Custom", | ||||
"daysOfWeek": [ | |||||
"Su", | |||||
"Mo", | |||||
"Tu", | |||||
"We", | |||||
"Th", | |||||
"Fr", | |||||
"Sa" | |||||
], | |||||
"monthNames": [ | |||||
"January", | |||||
"February", | |||||
"March", | |||||
"Avril", | |||||
"Mai", | |||||
"June", | |||||
"July", | |||||
"August", | |||||
"September", | |||||
"October", | |||||
"November", | |||||
"December" | |||||
], | |||||
"daysOfWeek": ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"], | |||||
"monthNames": ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Decembre"], | |||||
"firstDay": 1 | "firstDay": 1 | ||||
} | } | ||||
}; | |||||
}); | |||||
if($(picker).nextAll('.date-time-range-fields').find('.date-start').val()){ | |||||
options.startDate = new Date($(picker).nextAll('.date-time-range-fields').find('.date-start').val()); | |||||
} | |||||
if($(picker).nextAll('.date-time-range-fields').find('.date-end').val()){ | |||||
options.endDate = new Date($(picker).nextAll('.date-time-range-fields').find('.date-end').val()); | |||||
} | |||||
$(picker).daterangepicker(options); | |||||
$(picker).on('apply.daterangepicker', function(ev, pickerElm) { | $(picker).on('apply.daterangepicker', function(ev, pickerElm) { | ||||
$(picker).nextAll('.date-time-range-fields').find('.date-start').val(pickerElm.startDate.format('YYYY-MM-DD HH:mm')); | $(picker).nextAll('.date-time-range-fields').find('.date-start').val(pickerElm.startDate.format('YYYY-MM-DD HH:mm')); | ||||
$(picker).nextAll('.date-time-range-fields').find('.date-end').val(pickerElm.endDate.format('YYYY-MM-DD HH:mm')); | $(picker).nextAll('.date-time-range-fields').find('.date-end').val(pickerElm.endDate.format('YYYY-MM-DD HH:mm')); |
return Object.assign( | return Object.assign( | ||||
{ | { | ||||
dateActive: true, | |||||
usersActive: true, | |||||
groupUsersActive: true, | |||||
suppliersActive: true, | |||||
productCategoriesActive: true, | |||||
productFamiliesActive:true | |||||
permanent: true, | |||||
usersActive: false, | |||||
groupUsersActive: false, | |||||
suppliersActive: false, | |||||
productCategoriesActive: false, | |||||
productFamiliesActive:false | |||||
}, window.appReductionCatalogValues); | }, window.appReductionCatalogValues); | ||||
}, | }, |
behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC | behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC | ||||
unit: Unité | unit: Unité | ||||
value: Montant ou valeur | value: Montant ou valeur | ||||
usersActive: Appliquer la réduction à tout les utilisateurs | |||||
permanent: Réduction permanante | |||||
dateRange: Date de but et date de fin | |||||
usersActive: Filtrer sur les utilisateurs | |||||
users: Appliquer aux utilisateurs | users: Appliquer aux utilisateurs | ||||
groupUsersActive: Appliquer la réduction à tout les groupes d'utilisateurs | |||||
groupUsersActive: Filtrer sur les groupes d'utilisateurs | |||||
groupUsers: Appliquer aux groupes d'utilisateurs | groupUsers: Appliquer aux groupes d'utilisateurs | ||||
suppliersActive: Appliquer la réduction à tout les producteurs | |||||
suppliersActive: Filtrer sur les producteurs | |||||
suppliers: Appliquer aux producteurs | suppliers: Appliquer aux producteurs | ||||
productCategoriesActive: Appliquer la réduction à toutes les catégories | |||||
productCategoriesActive: Filtrer sur les catégories | |||||
productCategories: Appliquer aux catégories | productCategories: Appliquer aux catégories | ||||
productFamiliesActive: Appliquer la réduction à tout les produits | |||||
productFamiliesActive: Filtrer sur les produits | |||||
productFamilies: Appliquer aux produits | productFamilies: Appliquer aux produits | ||||
action: | action: |
{% extends _entity_config.templates.layout %} | {% extends _entity_config.templates.layout %} | ||||
{% block body_id 'easyadmin-edit-' ~ _entity_config.name ~ '-' ~ _entity_id %} | {% block body_id 'easyadmin-edit-' ~ _entity_config.name ~ '-' ~ _entity_id %} | ||||
{% block body_class 'edit edit-' ~ _entity_config.name|lower %} | |||||
{% block content_title %} | {% block content_title %} | ||||
{% apply spaceless %} | {% apply spaceless %} |
</head> | </head> | ||||
{% block body %} | {% block body %} | ||||
<body class="layout-navbar-fixed sidebar-mini"> | |||||
<body class="{% block body_class %}layout-navbar-fixed sidebar-mini{% endblock %}"> | |||||
{# <script> | {# <script> | ||||
document.body.classList.add( | document.body.classList.add( | ||||
'easyadmin-content-width-' + (localStorage.getItem('easyadmin/content/width') || 'normal'), | 'easyadmin-content-width-' + (localStorage.getItem('easyadmin/content/width') || 'normal'), | ||||
{% endif %} | {% endif %} | ||||
{% endif %} | {% endif %} | ||||
</li> | </li> | ||||
<li> | |||||
<a target="_blank" class="btn btn-outline-success" href="{{ path('frontend_home') }}">Afficher le site</a> | |||||
</li> | |||||
</ul> | </ul> | ||||
{% endblock navbar %} | {% endblock navbar %} | ||||
</nav> | </nav> |
{% set _has_filters = _entity_config.list.filters|default(false) %} | {% set _has_filters = _entity_config.list.filters|default(false) %} | ||||
{% block body_id 'easyadmin-list-' ~ _entity_config.name %} | {% block body_id 'easyadmin-list-' ~ _entity_config.name %} | ||||
{% block body_class 'list list-' ~ _entity_config.name|lower %} | |||||
{% block content_title %} | {% block content_title %} | ||||
{% apply spaceless %} | {% apply spaceless %} |
{% extends _entity_config.templates.layout %} | {% extends _entity_config.templates.layout %} | ||||
{% block body_id 'easyadmin-new-' ~ _entity_config.name %} | {% block body_id 'easyadmin-new-' ~ _entity_config.name %} | ||||
{% block body_class 'new new-' ~ _entity_config.name|lower %} | |||||
{% block content_title %} | {% block content_title %} | ||||
{% apply spaceless %} | {% apply spaceless %} |
{% trans_default_domain easyadmin_config('translation_domain') %} | |||||
{% extends easyadmin_config('design.templates.layout') %} | |||||
{% block body_class 'login-page' %} | |||||
{% block wrapper_wrapper %} | |||||
{% set _username_label = username_label is defined ? username_label|trans : 'login.username'|trans({}, 'EasyAdminBundle') %} | |||||
{% set _password_label = password_label is defined ? password_label|trans : 'login.password'|trans({}, 'EasyAdminBundle') %} | |||||
{% set _sign_in_label = sign_in_label is defined ? sign_in_label|trans : 'login.sign_in'|trans({}, 'EasyAdminBundle') %} | |||||
<div class="login-box"> | |||||
{% block header_logo %} | |||||
<a class="login-logo {{ easyadmin_config('site_name')|length > 14 ? 'logo-long' }}" title="{{ easyadmin_config('site_name')|striptags }}" href="{{ path('easyadmin') }}"> | |||||
{{ easyadmin_config('site_name')|raw }} | |||||
</a> | |||||
{% endblock header_logo %} | |||||
{% if error|default(false) %} | |||||
<div class="w-100 alert alert-danger"> | |||||
{{ error.messageKey|trans(error.messageData, 'security') }} | |||||
</div> | |||||
{% endif %} | |||||
<section class="content"> | |||||
<form method="post" action="{{ action|default('') }}"> | |||||
{% if csrf_token_intention|default(false) %} | |||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token(csrf_token_intention) }}"> | |||||
{% endif %} | |||||
<input type="hidden" name="{{ target_path_parameter|default('_target_path') }}" value="{{ target_path|default(path('easyadmin')) }}" /> | |||||
<div class="form-group field-text"> | |||||
<label for="username" class="sr-only form-control-label required">{{ _username_label }}</label> | |||||
<div class="form-widget form-widget-with-icon"> | |||||
<i class="fa fa-fw fa-user"></i> | |||||
<input type="text" id="username" name="{{ username_parameter|default('_username') }}" class="form-control" placeholder="{{ _username_label }}" value="{{ last_username|default('') }}" required autofocus> | |||||
</div> | |||||
</div> | |||||
<div class="form-group field-password"> | |||||
<label for="password" class="sr-only form-control-label required">{{ _password_label }}</label> | |||||
<div class="form-widget form-widget-with-icon"> | |||||
<i class="fa fa-fw fa-lock"></i> | |||||
<input type="password" id="password" name="{{ password_parameter|default('_password') }}" class="form-control" placeholder="{{ _password_label }}" required> | |||||
</div> | |||||
</div> | |||||
<div class="form-group field-button"> | |||||
<button type="submit" class="btn btn-primary btn-lg btn-block" onclick="this.form.submit(); this.disabled=true;">{{ _sign_in_label }}</button> | |||||
</div> | |||||
</form> | |||||
</section> | |||||
</div> | |||||
{% endblock %} |
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | {% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | ||||
{% set formValues = form.vars.value %} | {% set formValues = form.vars.value %} | ||||
<script> | <script> | ||||
window.appReductionCatalogValues = { | window.appReductionCatalogValues = { | ||||
{% if formValues.users is not empty %}usersActive: false,{% endif %} | |||||
{% if formValues.groupUsers is not empty %}groupUsersActive: false,{% endif %} | |||||
{% if formValues.productFamilies is not empty %}productFamiliesActive: false,{% endif %} | |||||
{% if formValues.productCategories is not empty %}productCategoriesActive: false,{% endif %} | |||||
{% if formValues.suppliers is not empty %}suppliersActive: false,{% endif %} | |||||
{% if formValues.permanent is not null and formValues.permanent == false %}permanent: false,{% endif %} | |||||
{% if formValues.users is not empty %}usersActive: true,{% endif %} | |||||
{% if formValues.groupUsers is not empty %}groupUsersActive: true,{% endif %} | |||||
{% if formValues.productFamilies is not empty %}productFamiliesActive: true,{% endif %} | |||||
{% if formValues.productCategories is not empty %}productCategoriesActive: true,{% endif %} | |||||
{% if formValues.suppliers is not empty %}suppliersActive: true,{% endif %} | |||||
} | } | ||||
</script> | </script> | ||||
<div id="lc-reduction-catalog-edit" class="row"> | <div id="lc-reduction-catalog-edit" class="row"> | ||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.title) }} | {{ form_row(form.title) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{# <div class="col-12"> | |||||
{{ form_row(form.fromQuantity) }} | {{ form_row(form.fromQuantity) }} | ||||
</div> | </div> | ||||
#} | |||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.behaviorTaxRate) }} | {{ form_row(form.behaviorTaxRate) }} | ||||
</div> | </div> | ||||
{{ macros.endCard() }} | {{ macros.endCard() }} | ||||
{{ macros.startCard(6, 'ReductionCatalog.conditions','secondary') }} | |||||
{{ macros.startCard(6, 'ReductionCatalog.conditions','success') }} | |||||
<div class="col-12"> | <div class="col-12"> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
{{ form_widget(form.dateActive, {"attr" : {'v-model' : 'dateActive' } }) }} | |||||
{{ form_widget(form.permanent, {"attr" : {'v-model' : 'permanent' } }) }} | |||||
</div> | </div> | ||||
<div class="input-group" v-show="dateActive == false"> | |||||
<div class="input-group" v-show="permanent == false"> | |||||
<div class="input-group-prepend"> | <div class="input-group-prepend"> | ||||
<span class="input-group-text"><i class="far fa-clock"></i></span> | <span class="input-group-text"><i class="far fa-clock"></i></span> | ||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
{{ form_widget(form.usersActive, {"attr" : {'v-model' : 'usersActive' } }) }} | {{ form_widget(form.usersActive, {"attr" : {'v-model' : 'usersActive' } }) }} | ||||
</div> | </div> | ||||
<div v-show="usersActive == false"> | |||||
{{ form_row(form.users) }} | |||||
<div class="form-widget" v-show="usersActive == true"> | |||||
{{ form_widget(form.users) }} | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
{{ form_widget(form.groupUsersActive, {"attr" : {'v-model' : 'groupUsersActive' } }) }} | {{ form_widget(form.groupUsersActive, {"attr" : {'v-model' : 'groupUsersActive' } }) }} | ||||
</div> | </div> | ||||
<div class="form-widget" v-show="groupUsersActive == false"> | |||||
<div class="form-widget" v-show="groupUsersActive == true"> | |||||
{{ form_widget(form.groupUsers) }} | {{ form_widget(form.groupUsers) }} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
{{ form_widget(form.suppliersActive, {"attr" : {'v-model' : 'suppliersActive' } }) }} | {{ form_widget(form.suppliersActive, {"attr" : {'v-model' : 'suppliersActive' } }) }} | ||||
</div> | </div> | ||||
<div class="form-widget" v-show="suppliersActive == false"> | |||||
<div class="form-widget" v-show="suppliersActive == true"> | |||||
{{ form_widget(form.suppliers) }} | {{ form_widget(form.suppliers) }} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
{{ form_widget(form.productCategoriesActive, {"attr" : {'v-model' : 'productCategoriesActive' } }) }} | {{ form_widget(form.productCategoriesActive, {"attr" : {'v-model' : 'productCategoriesActive' } }) }} | ||||
</div> | </div> | ||||
<div class="form-widget" v-show="productCategoriesActive == false"> | |||||
<div class="form-widget" v-show="productCategoriesActive == true"> | |||||
{{ form_widget(form.productCategories) }} | {{ form_widget(form.productCategories) }} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
{{ form_widget(form.productFamiliesActive, {"attr" : {'v-model' : 'productFamiliesActive' } }) }} | {{ form_widget(form.productFamiliesActive, {"attr" : {'v-model' : 'productFamiliesActive' } }) }} | ||||
</div> | </div> | ||||
<div class="form-widget" v-show="productFamiliesActive == false"> | |||||
<div class="form-widget" v-show="productFamiliesActive == true"> | |||||
{{ form_widget(form.productFamilies) }} | {{ form_widget(form.productFamilies) }} | ||||
</div> | </div> | ||||
</div> | </div> |