return $this->executeDynamicMethod('render<EntityName>Template', ['sortable', "@LcShop/backend/default/sortable.html.twig", $parameters]); | return $this->executeDynamicMethod('render<EntityName>Template', ['sortable', "@LcShop/backend/default/sortable.html.twig", $parameters]); | ||||
} | } | ||||
public function createEntityFormBuilder($entity, $view) | |||||
public function createEntityFormBuilder($entity, $view, $override = true) | |||||
{ | { | ||||
$formBuilder = parent::createEntityFormBuilder($entity, $view); | $formBuilder = parent::createEntityFormBuilder($entity, $view); | ||||
if($override)$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view); | |||||
return $formBuilder; | |||||
} | |||||
public function overrideFormBuilder($formBuilder, $entity, $view){ | |||||
$id = (null !== $entity->getId()) ? $entity->getId() : 0; | $id = (null !== $entity->getId()) ? $entity->getId() : 0; | ||||
if ($entity instanceof StatusInterface) { | if ($entity instanceof StatusInterface) { | ||||
$formBuilder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) { | $formBuilder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) { | ||||
$form = $event->getForm(); | $form = $event->getForm(); | ||||
$allChilds = $form->all(); | |||||
foreach ($allChilds as $child) { | |||||
$statusInterface = false; | |||||
$treeInterface = false; | |||||
$type = $child->getConfig()->getType()->getInnerType(); | |||||
if ($type instanceof EntityType) { | |||||
$passedOptions = $child->getConfig()->getOptions(); | |||||
$classImplements = class_implements($passedOptions['class']); | |||||
$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements) ; | |||||
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements) ; | |||||
if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) { | |||||
if (in_array('Lc\ShopBundle\Context\StatusInterface', $classImplements)) { | |||||
$statusInterface = true; | |||||
} | |||||
if (in_array('Lc\ShopBundle\Context\TreeInterface', $classImplements)) { | |||||
$treeInterface = true; | |||||
} | |||||
$propertyMerchant = 'merchant'; | |||||
if($isFilterMultipleMerchantsInterface) { | |||||
$propertyMerchant .= 's' ; | |||||
} | |||||
$form->add($child->getName(), EntityType::class, array( | |||||
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | |||||
'label' => $passedOptions['label'], | |||||
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, | |||||
'placeholder' => '--', | |||||
'translation_domain'=> 'lcshop', | |||||
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) { | |||||
$queryBuilder = $repo->createQueryBuilder('e'); | |||||
$propertyMerchant = 'e.' . $propertyMerchant; | |||||
if ($passedOptions['class'] == 'App\Entity\PointSale') { | |||||
$queryBuilder->where(':currentMerchant MEMBER OF ' . $propertyMerchant); | |||||
} else { | |||||
$queryBuilder->where($propertyMerchant . ' = :currentMerchant'); | |||||
} | |||||
if($statusInterface){ | |||||
$queryBuilder->andWhere('e.status >= 0'); | |||||
} | |||||
if($treeInterface && $child->getName() =='parent'){ | |||||
$queryBuilder->andWhere('e.parent is null'); | |||||
} | |||||
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); | |||||
return $queryBuilder; | |||||
}, | |||||
'choice_label' => function($choice) { | |||||
if($choice instanceof StatusInterface && $choice->getStatus() == 0){ | |||||
return $choice.' [hors ligne]'; | |||||
} | |||||
return $choice; | |||||
}, | |||||
'required' => $passedOptions['required'], | |||||
) | |||||
); | |||||
$childrens = $form->all(); | |||||
$this->loopFormField($form, $childrens); | |||||
}); | |||||
return $formBuilder; | |||||
} | |||||
private function loopFormField($form, $childrens){ | |||||
foreach ($childrens as $child) { | |||||
$statusInterface = false; | |||||
$treeInterface = false; | |||||
$type = $child->getConfig()->getType()->getInnerType();; | |||||
if ($type instanceof EntityType) { | |||||
$passedOptions = $child->getConfig()->getOptions(); | |||||
$classImplements = class_implements($passedOptions['class']); | |||||
$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements) ; | |||||
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements) ; | |||||
if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) { | |||||
if (in_array('Lc\ShopBundle\Context\StatusInterface', $classImplements)) { | |||||
$statusInterface = true; | |||||
} | |||||
if (in_array('Lc\ShopBundle\Context\TreeInterface', $classImplements)) { | |||||
$treeInterface = true; | |||||
} | } | ||||
$propertyMerchant = 'merchant'; | |||||
if($isFilterMultipleMerchantsInterface) { | |||||
$propertyMerchant .= 's' ; | |||||
} | |||||
$form->add($child->getName(), EntityType::class, array( | |||||
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | |||||
'label' => $passedOptions['label'], | |||||
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, | |||||
'placeholder' => '--', | |||||
'translation_domain'=> 'lcshop', | |||||
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) { | |||||
$queryBuilder = $repo->createQueryBuilder('e'); | |||||
$propertyMerchant = 'e.' . $propertyMerchant; | |||||
if ($passedOptions['class'] == 'App\Entity\PointSale') { | |||||
$queryBuilder->where(':currentMerchant MEMBER OF ' . $propertyMerchant); | |||||
} else { | |||||
$queryBuilder->where($propertyMerchant . ' = :currentMerchant'); | |||||
} | |||||
if($statusInterface){ | |||||
$queryBuilder->andWhere('e.status >= 0'); | |||||
} | |||||
if($treeInterface && $child->getName() =='parent'){ | |||||
$queryBuilder->andWhere('e.parent is null'); | |||||
} | |||||
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); | |||||
return $queryBuilder; | |||||
}, | |||||
'choice_label' => function($choice) { | |||||
if($choice instanceof StatusInterface && $choice->getStatus() == 0){ | |||||
return $choice.' [hors ligne]'; | |||||
} | |||||
return $choice; | |||||
}, | |||||
'required' => $passedOptions['required'], | |||||
) | |||||
); | |||||
} | |||||
}else{ | |||||
$subChildrens = $child->all(); | |||||
if(count($subChildrens)){ | |||||
$this->loopFormField($child, $subChildrens); | |||||
} | } | ||||
} | } | ||||
}); | |||||
return $formBuilder; | |||||
} | |||||
} | } | ||||
} | } | ||||
parent::persistEntity($entity); | parent::persistEntity($entity); | ||||
} | } | ||||
public function createEntityFormBuilder($entity, $view) | |||||
public function createEntityFormBuilder($entity, $view, $override=true) | |||||
{ | { | ||||
$formBuilder = parent::createEntityFormBuilder($entity, $view); | $formBuilder = parent::createEntityFormBuilder($entity, $view); | ||||
namespace Lc\ShopBundle\Controller\Admin; | namespace Lc\ShopBundle\Controller\Admin; | ||||
use App\Entity\Product; | use App\Entity\Product; | ||||
use App\Entity\ReductionCatalog; | |||||
use Doctrine\DBAL\Types\FloatType; | use Doctrine\DBAL\Types\FloatType; | ||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | ||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | use Lc\ShopBundle\Context\ProductCategoryInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
use Lc\ShopBundle\Context\ProductInterface; | use Lc\ShopBundle\Context\ProductInterface; | ||||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||||
use Lc\ShopBundle\Context\TaxRateInterface; | use Lc\ShopBundle\Context\TaxRateInterface; | ||||
use Lc\ShopBundle\Context\UnitInterface; | use Lc\ShopBundle\Context\UnitInterface; | ||||
use Lc\ShopBundle\Form\ProductFamilyCategoriesType; | use Lc\ShopBundle\Form\ProductFamilyCategoriesType; | ||||
private $choicesTaxRateParam; | private $choicesTaxRateParam; | ||||
private $choicesSupplierTaxRateParam; | private $choicesSupplierTaxRateParam; | ||||
public function createEntityFormBuilder($entity, $view) | |||||
public function createEntityFormBuilder($entity, $view, $override = true) | |||||
{ | { | ||||
$formBuilder = parent::createEntityFormBuilder($entity, $view); | |||||
$formBuilder = parent::createEntityFormBuilder($entity, $view, false); | |||||
$class = $this->em->getClassMetadata(ProductCategoryInterface::class); | $class = $this->em->getClassMetadata(ProductCategoryInterface::class); | ||||
$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( | |||||
'class' => $this->em->getClassMetadata(TaxRateInterface::class)->name, | |||||
'required' =>false, | |||||
'placeholder'=> 'Tva par défaut ('.$this->getUser()->getMerchant()->getTaxRate()->getValue().'%)' | |||||
));*/ | |||||
$reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class); | |||||
$reductionCatalogClass = $this->em->getClassMetadata(ReductionCatalogInterface::class); | |||||
$reductionCatalog = $reductionCatalogRepo->findOneByProductFamily($entity); | |||||
if($reductionCatalog == null)$reductionCatalog = new $reductionCatalogClass->name; | |||||
$formBuilder->add('reductionCatalog', ReductionCatalogType::class,array( | |||||
'mapped'=>false, | |||||
'data'=> $reductionCatalog | |||||
)); | |||||
$formBuilder->add('warningMessageType', ChoiceType::class, array( | $formBuilder->add('warningMessageType', ChoiceType::class, array( | ||||
) | ) | ||||
); | ); | ||||
$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view); | |||||
return $formBuilder; | return $formBuilder; | ||||
} | } | ||||
public function updateEntity($entity) | |||||
public function updateEntity($entity, $editForm) | |||||
{ | { | ||||
$productFamilyRequest = $this->request->request->get('productfamily'); | |||||
/*$unitId = intval($productFamilyRequest['unit']); | |||||
if ($unitId > 0) { | |||||
$repo = $this->em->getRepository(UnitInterface::class); | |||||
$entity->setUnit($repo->find($unitId)); | |||||
}*/ | |||||
//$reductionCatalogInfo = $productFamilyRequest['reductionCatalog']; | |||||
$this->processReductionCatalog($entity, $editForm); | |||||
$this->processCategories($entity); | $this->processCategories($entity); | ||||
$this->processProducts($entity); | $this->processProducts($entity); | ||||
$this->processPrice($entity); | $this->processPrice($entity); | ||||
/* dump($reductionCatalog); | |||||
dump($productFamilyRequest);*/ | |||||
parent::updateEntity($entity); | parent::updateEntity($entity); | ||||
} | } | ||||
public function persistEntity($entity) | |||||
public function persistEntity($entity, $newForm) | |||||
{ | { | ||||
$this->processReductionCatalog($entity, $newForm); | |||||
$this->processCategories($entity); | $this->processCategories($entity); | ||||
$this->processProducts($entity); | $this->processProducts($entity); | ||||
$this->processPrice($entity); | |||||
parent::persistEntity($entity); | |||||
$this->em->persist($entity); | |||||
$this->em->flush(); | |||||
} | |||||
protected function processReductionCatalog($entity, $editForm){ | |||||
$reductionCatalog = $editForm->get('reductionCatalog')->getData(); | |||||
if($reductionCatalog instanceof ReductionCatalogInterface ) { | |||||
if($reductionCatalog->getValue() && $reductionCatalog->getBehaviorTaxRate() && $reductionCatalog->getUnit()){ | |||||
$reductionCatalog->setMerchant($entity->getMerchant()); | |||||
$reductionCatalog->setStatus($editForm->get('activeReductionCatalog')->getData()); | |||||
$reductionCatalog->setProductFamily($entity); | |||||
$this->em->persist($reductionCatalog); | |||||
} | |||||
} | |||||
} | } | ||||
protected function processPrice($entity){ | protected function processPrice($entity){ |
namespace Lc\ShopBundle\Form; | namespace Lc\ShopBundle\Form; | ||||
use App\Entity\Supplier; | |||||
use Lc\ShopBundle\Context\GroupUserInterface; | |||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | |||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | use Lc\ShopBundle\Context\ReductionCatalogInterface; | ||||
use Lc\ShopBundle\Context\UserInterface; | |||||
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; | ||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$userClass = $this->em->getClassMetadata(UserInterface::class); | |||||
$groupUserClass = $this->em->getClassMetadata(GroupUserInterface::class); | |||||
$supplierClass = Supplier::class; | |||||
$productFamilyClass = $this->em->getClassMetadata(ProductFamilyInterface::class); | |||||
$productCategoryClass = $this->em->getClassMetadata(ProductCategoryInterface::class); | |||||
$builder | $builder | ||||
->add('title', TextType::class, ['label' => 'Titre']) | |||||
->add('title', TextType::class, [ | |||||
'label' => 'Titre', | |||||
'required' => false, | |||||
]) | |||||
->add('behaviorTaxRate', ChoiceType::class, [ | ->add('behaviorTaxRate', ChoiceType::class, [ | ||||
'required'=> true, | |||||
'required' => false, | |||||
'choices' => [ | 'choices' => [ | ||||
'field.default.taxIncluded'=> 'tax-included', | |||||
'field.default.taxExcluded'=> 'tax-excluded' | |||||
'field.default.taxIncluded' => 'tax-included', | |||||
'field.default.taxExcluded' => 'tax-excluded' | |||||
] | ] | ||||
]) | ]) | ||||
->add('unit', ChoiceType::class, [ | ->add('unit', ChoiceType::class, [ | ||||
'required'=> true, | |||||
'required' => false, | |||||
'choices' => [ | 'choices' => [ | ||||
'field.default.percent'=> 'percent', | |||||
'field.default.amount'=> 'amount' | |||||
'field.default.percent' => 'percent', | |||||
'field.default.amount' => 'amount' | |||||
] | ] | ||||
]) | ]) | ||||
->add('value', NumberType::class, [ | |||||
'required' => false | |||||
]) | |||||
->add('permanent', CheckboxType::class, array( | |||||
'required'=>false | |||||
)) | |||||
->add('dateStart', DateTimeType::class, | |||||
['widget' => 'single_text', | |||||
'required'=>false, | |||||
]) | |||||
->add('dateEnd', DateTimeType::class, [ | |||||
'widget' => 'single_text', | |||||
'required'=>false, | |||||
]) | |||||
->add('usersActive', CheckboxType::class, array( | |||||
'label' => 'field.ReductionCatalog.usersActive', | |||||
'mapped' => false, | |||||
'required'=>false, | |||||
'attr' => ['class' => 'big'] | |||||
)) | |||||
->add('users', EntityType::class, array( | |||||
'class' => $userClass->name, | |||||
'required'=>false, | |||||
'multiple'=>true | |||||
)) | |||||
->add('groupUsersActive', CheckboxType::class, array( | |||||
'label' => 'field.ReductionCatalog.groupUsersActive', | |||||
'mapped' => false, | |||||
'required'=>false, | |||||
'attr' => ['class' => 'big'] | |||||
)) | |||||
->add('groupUsers', EntityType::class, array( | |||||
'class' => $groupUserClass->name, | |||||
'required'=>false, | |||||
'multiple'=>true | |||||
)); | |||||
/* ->add('productFamiliesActive', CheckboxType::class, array( | |||||
'label' => 'field.ReductionCatalog.productFamiliesActive', | |||||
'mapped' => false, | |||||
'required'=>false, | |||||
'attr' => ['class' => 'big'] | |||||
)) | |||||
->add('productFamilies', EntityType::class, array( | |||||
'class' => $productFamilyClass->name, | |||||
'required'=>false, | |||||
'multiple'=>true | |||||
)) | |||||
->add('productCategoriesActive', CheckboxType::class, array( | |||||
'label' => 'field.ReductionCatalog.productCategoriesActive', | |||||
'mapped' => false, | |||||
'required'=>false, | |||||
'attr' => ['class' => 'big'] | |||||
)) | |||||
->add('productCategories', EntityType::class, array( | |||||
'class' => $productCategoryClass->name, | |||||
'required'=>false, | |||||
'multiple'=>true | |||||
)) | |||||
->add('suppliersActive', CheckboxType::class, array( | |||||
'label' => 'field.ReductionCatalog.suppliersActive', | |||||
'mapped' => false, | |||||
'required'=>false, | |||||
'attr' => ['class' => 'big'] | |||||
)) | |||||
->add('suppliers', EntityType::class, array( | |||||
'class' => $supplierClass, | |||||
'required'=>false, | |||||
'multiple'=>true | |||||
));*/ | |||||
->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) | public function configureOptions(OptionsResolver $resolver) | ||||
{ | { | ||||
$resolver->setDefaults([ | $resolver->setDefaults([ | ||||
'label' => false, | 'label' => false, | ||||
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName() | |||||
//'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(), | |||||
'translation_domain'=> 'lcshop' | |||||
]); | ]); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
protected $productFamilies; | protected $productFamilies; | ||||
/** | |||||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface") | |||||
*/ | |||||
protected $productFamily; | |||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface") | * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface") | ||||
*/ | */ | ||||
*/ | */ | ||||
protected $users; | protected $users; | ||||
/* | |||||
* @ORM\Column(type="smallint") | |||||
*/ | |||||
// protected $fromQuantity = 1; | |||||
public function __construct() | public function __construct() | ||||
} | } | ||||
public function getProductFamily(): ?ProductFamily | |||||
{ | |||||
return $this->productFamily; | |||||
} | |||||
public function setProductFamily(?ProductFamily $productFamily): self | |||||
{ | |||||
$this->productFamily = $productFamily; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* @return Collection|GroupUser[] | * @return Collection|GroupUser[] | ||||
*/ | */ |
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
}; | |||||
let mixinReduction = { | |||||
data() { | |||||
log(window.mixinReductionValues); | |||||
return Object.assign({ | |||||
reductionActive: true, | |||||
reductionPermanent: true, | |||||
reductionUsersActive: false, | |||||
reductionGroupUsersActive: false, | |||||
reductionSuppliersActive: false, | |||||
reductionProductCategoriesActive: false, | |||||
reductionProductFamiliesActive:false | |||||
}, window.mixinReductionValues); | |||||
} | |||||
}; |
appProductFamily = new Vue({ | appProductFamily = new Vue({ | ||||
el: '#lc-product-family-edit', | el: '#lc-product-family-edit', | ||||
mixins: [mixinReduction], | |||||
delimiters: ['${', '}'], | delimiters: ['${', '}'], | ||||
computed: { | computed: { | ||||
productFamily: function () { | productFamily: function () { | ||||
activeProducts:false, | activeProducts:false, | ||||
formProductArray: [], | formProductArray: [], | ||||
currentSection: 'price', | |||||
currentSection: 'general', | |||||
sectionsArray: [ | sectionsArray: [ | ||||
{ | { | ||||
name: 'general', | name: 'general', | ||||
name: 'property', | name: 'property', | ||||
nameDisplay: 'Caractéristiques' | nameDisplay: 'Caractéristiques' | ||||
}, | }, | ||||
{ | |||||
name: 'reduction', | |||||
nameDisplay: 'Réduction' | |||||
}, | |||||
{ | { | ||||
name: 'note', | name: 'note', | ||||
nameDisplay: 'Note interne' | nameDisplay: 'Note interne' |
appProductFamily = new Vue({ | appProductFamily = new Vue({ | ||||
el: '#lc-reduction-catalog-edit', | el: '#lc-reduction-catalog-edit', | ||||
delimiters: ['${', '}'], | delimiters: ['${', '}'], | ||||
computed: { | |||||
}, | |||||
data() { | |||||
return Object.assign( | |||||
{ | |||||
permanent: true, | |||||
usersActive: false, | |||||
groupUsersActive: false, | |||||
suppliersActive: false, | |||||
productCategoriesActive: false, | |||||
productFamiliesActive:false | |||||
}, window.appReductionCatalogValues); | |||||
}, | |||||
mounted: function () { | |||||
}, | |||||
methods: { | |||||
}, | |||||
watch: { | |||||
} | |||||
mixins: [mixinReduction] | |||||
}); | }); |
propertySecondary: Caractéristiques secondaires | propertySecondary: Caractéristiques secondaires | ||||
note: Note interne | note: Note interne | ||||
parameters: Paramètres | parameters: Paramètres | ||||
initReduction: Réduction | |||||
ReductionCatalog: | ReductionCatalog: | ||||
info: Informations principal | info: Informations principal | ||||
conditions: Condictions d'application | conditions: Condictions d'application | ||||
subscribeNewsletter: S'inscrire à la newsletter | subscribeNewsletter: S'inscrire à la newsletter | ||||
send: Envoyer | send: Envoyer | ||||
isSent: Envoyée | isSent: Envoyée | ||||
behaviorTaxRate: Avec ou sans TVA | |||||
behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC | |||||
PointSale: | PointSale: | ||||
code: Code | code: Code | ||||
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | ||||
behaviorAddToCartOptions: | behaviorAddToCartOptions: | ||||
simple: Simple | simple: Simple | ||||
multiple: Multiple | multiple: Multiple | ||||
activeReductionCatalog: Appliquer une réduction sur ce produit | |||||
ReductionCatalog: | ReductionCatalog: | ||||
fromQuantity: À partir de la quantité | fromQuantity: À partir de la quantité | ||||
fromQuantityHelp: Par défaut une réduction est apliqué à partir de 1 | fromQuantityHelp: Par défaut une réduction est apliqué à partir de 1 | ||||
behaviorTaxRate: Avec ou sans TVA | |||||
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 | ||||
permanent: Réduction permanante | permanent: Réduction permanante |
{% if fieldDisplay == false %}{% set fieldDisplay = fieldName %}{% endif %} | {% if fieldDisplay == false %}{% set fieldDisplay = fieldName %}{% endif %} | ||||
<td {{ attr|raw }} colspan="{{ colspan }}" class="{{ fieldName }}" > | |||||
<td {{ attr|raw }} colspan="{{ colspan }}" class="{{ fieldName }}"> | |||||
<div class="value" v-show="{{ fieldName }}Inherited == false" v-on:click="{{ fieldName }}Inherited = true"> | <div class="value" v-show="{{ fieldName }}Inherited == false" v-on:click="{{ fieldName }}Inherited = true"> | ||||
<div v-if="{{ fieldName }}"> | <div v-if="{{ fieldName }}"> | ||||
{% verbatim %}{{ {% endverbatim %}{{ fieldDisplay }} {% verbatim %}}}{% endverbatim %}{{ displaySuffix }} | {% verbatim %}{{ {% endverbatim %}{{ fieldDisplay }} {% verbatim %}}}{% endverbatim %}{{ displaySuffix }} | ||||
<div v-show="{{ fieldName }}Inherited == true"> | <div v-show="{{ fieldName }}Inherited == true"> | ||||
{{ form_widget(field, {'attr' : {'v-model' : fieldName , 'v-on:focusout': fieldName~'Inherited = false', '@change' : fieldName~'Updated'}}) }} | {{ form_widget(field, {'attr' : {'v-model' : fieldName , 'v-on:focusout': fieldName~'Inherited = false', '@change' : fieldName~'Updated'}}) }} | ||||
</div> | </div> | ||||
<button v-show="{{ fieldName }}" v-on:click="{{ fieldName }} = null; {{ fieldName }}Inherited = false; " class="btn btn-empty-field" type="button"> <i class="fa fa-undo"></i> </button> | |||||
<button v-show="{{ fieldName }}" v-on:click="{{ fieldName }} = null; {{ fieldName }}Inherited = false; " | |||||
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button> | |||||
</td> | </td> | ||||
{% endmacro %} | {% endmacro %} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
{% endmacro %} | |||||
{% endmacro %} | |||||
{% macro reductionCatalogForm(form) %} | |||||
{{ _self.startCard(6, 'ReductionCatalog.info') }} | |||||
<div class="col-12"> | |||||
{{ form_row(form.title) }} | |||||
</div> | |||||
{# <div class="col-12"> | |||||
{{ form_row(form.fromQuantity) }} | |||||
</div> | |||||
#} | |||||
<div class="col-12"> | |||||
{{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive"}}) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.unit, {"attr" : {":required": "reductionActive"}}) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.value, {"attr" : {":required": "reductionActive"}}) }} | |||||
</div> | |||||
{{ _self.endCard() }} | |||||
{{ _self.startCard(6, 'ReductionCatalog.conditions','success') }} | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.permanent, {"attr" : {'v-model' : 'reductionPermanent' } }) }} | |||||
</div> | |||||
<div class="input-group" v-show="reductionPermanent == false"> | |||||
<div class="input-group-prepend"> | |||||
<span class="input-group-text"><i class="far fa-clock"></i></span> | |||||
</div> | |||||
<input type="text" class="form-control float-right date-time-range"> | |||||
<div class="hidden date-time-range-fields" style="display: none;"> | |||||
{{ form_widget(form.dateStart, {"attr" : {'class' : 'date-start'}}) }} | |||||
{{ form_widget(form.dateEnd, {"attr" : {'class' : 'date-end'}}) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.usersActive, {"attr" : {'v-model' : 'reductionUsersActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="reductionUsersActive == true"> | |||||
{{ form_widget(form.users) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.groupUsersActive, {"attr" : {'v-model' : 'reductionGroupUsersActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="reductionGroupUsersActive == true"> | |||||
{{ form_widget(form.groupUsers) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% if form.suppliers is defined %} | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.suppliersActive, {"attr" : {'v-model' : 'reductionSuppliersActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="reductionSuppliersActive == true"> | |||||
{{ form_widget(form.suppliers) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endif %} | |||||
{% if form.productCategories is defined %} | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.productCategoriesActive, {"attr" : {'v-model' : 'reductionProductCategoriesActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="reductionProductCategoriesActive == true"> | |||||
{{ form_widget(form.productCategories) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endif %} | |||||
{% if form.productFamilies is defined %} | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.productFamiliesActive, {"attr" : {'v-model' : 'reductionProductFamiliesActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="reductionProductFamiliesActive == true"> | |||||
{{ form_widget(form.productFamilies) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endif %} | |||||
{{ _self.endCard() }} | |||||
{% endmacro %} | |||||
{% macro reductionCatalogFormValues(formValues, isProductFamilyForm= false) %} | |||||
<script> | |||||
window.mixinReductionValues = { | |||||
{% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %} | |||||
{% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %} | |||||
{% if formValues.users is not empty %}reductionUsersActive: true,{% endif %} | |||||
{% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %} | |||||
{% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %} | |||||
{% if formValues.productCategories is not empty %}reductionProductCategoriesActive: true,{% endif %} | |||||
{% if formValues.suppliers is not empty %}reductionSuppliersActive: true,{% endif %} | |||||
} | |||||
</script> | |||||
{% endmacro %} |
{% include '@LcShop/backend/productfamily/form.html.twig' %} | {% include '@LcShop/backend/productfamily/form.html.twig' %} | ||||
{% endblock entity_form %} | {% endblock entity_form %} | ||||
{% block head_stylesheets %} | |||||
{{ parent() }} | |||||
<link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/daterange/daterangepicker.css') }}"> | |||||
{% endblock %} | |||||
{% block plugin_javascript %} | |||||
{{ parent() }} | |||||
<script src="{{ asset('bundles/lcshop/js/backend/plugin/daterange/moment.min.js')}}"></script> | |||||
<script src="{{ asset('bundles/lcshop/js/backend/plugin/daterange/daterangepicker.js')}}"></script> | |||||
{% endblock %} | |||||
{% block script_javascript %} | {% block script_javascript %} | ||||
{{ parent() }} | {{ parent() }} | ||||
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %} | {% include '@LcShop/backend/default/block/script-vuejs.html.twig' %} |
{% include '@LcShop/backend/productfamily/panel_property.html.twig' %} | {% include '@LcShop/backend/productfamily/panel_property.html.twig' %} | ||||
</div> | </div> | ||||
<div v-show="currentSection == 'reduction'" class="panel panel-default"> | |||||
{% include '@LcShop/backend/productfamily/panel_reduction.html.twig' %} | |||||
</div> | |||||
<div v-show="currentSection == 'note'" class="panel panel-default"> | <div v-show="currentSection == 'note'" class="panel panel-default"> | ||||
<div class="row"> | <div class="row"> |
{% trans_default_domain 'lcshop' %} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{% set formValues = form.reductionCatalog.vars.value %} | |||||
{{ macros.reductionCatalogFormValues(formValues, true) }} | |||||
<div class="row"> | |||||
{{ macros.startCard(12, 'ProductFamily.initReduction', 'light') }} | |||||
<div class="col-12"> | |||||
{{ form_row(form.activeReductionCatalog, {'attr': {'v-model' : 'reductionActive'}}) }} | |||||
</div> | |||||
{{ macros.endCard() }} | |||||
<div class="col-12"> | |||||
<div class="row" v-show="reductionActive == true"> | |||||
{{ macros.reductionCatalogForm(form.reductionCatalog) }} | |||||
</div> | |||||
</div> | |||||
</div> |
{% 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 %} | ||||
{{ macros.reductionCatalogFormValues(formValues) }} | |||||
<script> | |||||
window.appReductionCatalogValues = { | |||||
{% 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> | |||||
<div id="lc-reduction-catalog-edit" class="row"> | <div id="lc-reduction-catalog-edit" class="row"> | ||||
{{ macros.startCard(6, 'ReductionCatalog.info') }} | |||||
<div class="col-12"> | |||||
{{ form_row(form.title) }} | |||||
</div> | |||||
{# <div class="col-12"> | |||||
{{ form_row(form.fromQuantity) }} | |||||
</div> | |||||
#} | |||||
<div class="col-12"> | |||||
{{ form_row(form.behaviorTaxRate) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.unit) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.value) }} | |||||
</div> | |||||
{{ macros.endCard() }} | |||||
{{ macros.startCard(6, 'ReductionCatalog.conditions','success') }} | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.permanent, {"attr" : {'v-model' : 'permanent' } }) }} | |||||
</div> | |||||
<div class="input-group" v-show="permanent == false"> | |||||
<div class="input-group-prepend"> | |||||
<span class="input-group-text"><i class="far fa-clock"></i></span> | |||||
</div> | |||||
<input type="text" class="form-control float-right date-time-range"> | |||||
<div class="hidden date-time-range-fields" style="display: none;"> | |||||
{{ form_widget(form.dateStart, {"attr" : {'class' : 'date-start'}}) }} | |||||
{{ form_widget(form.dateEnd, {"attr" : {'class' : 'date-end'}}) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.usersActive, {"attr" : {'v-model' : 'usersActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="usersActive == true"> | |||||
{{ form_widget(form.users) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.groupUsersActive, {"attr" : {'v-model' : 'groupUsersActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="groupUsersActive == true"> | |||||
{{ form_widget(form.groupUsers) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.suppliersActive, {"attr" : {'v-model' : 'suppliersActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="suppliersActive == true"> | |||||
{{ form_widget(form.suppliers) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.productCategoriesActive, {"attr" : {'v-model' : 'productCategoriesActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="productCategoriesActive == true"> | |||||
{{ form_widget(form.productCategories) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-12"> | |||||
<div class="form-group"> | |||||
<div class="form-group"> | |||||
{{ form_widget(form.productFamiliesActive, {"attr" : {'v-model' : 'productFamiliesActive' } }) }} | |||||
</div> | |||||
<div class="form-widget" v-show="productFamiliesActive == true"> | |||||
{{ form_widget(form.productFamilies) }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{{ macros.endCard() }} | |||||
{{ macros.reductionCatalogForm(form) }} | |||||
</div> | </div> | ||||
{{ form_end(form) }} | {{ form_end(form) }} |