Переглянути джерело

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

feature/export_comptable
Guillaume 4 роки тому
джерело
коміт
b7c55cabdf
14 змінених файлів з 423 додано та 250 видалено
  1. +80
    -67
      ShopBundle/Controller/Admin/AdminController.php
  2. +1
    -1
      ShopBundle/Controller/Admin/OrderController.php
  3. +37
    -26
      ShopBundle/Controller/Admin/ProductFamilyController.php
  4. +96
    -12
      ShopBundle/Form/ReductionCatalogType.php
  5. +17
    -4
      ShopBundle/Model/ReductionCatalog.php
  6. +17
    -1
      ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js
  7. +6
    -2
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  8. +1
    -24
      ShopBundle/Resources/public/js/backend/script/reductioncatalog/vuejs-reduction-catalog.js
  9. +4
    -2
      ShopBundle/Resources/translations/lcshop.fr.yaml
  10. +124
    -3
      ShopBundle/Resources/views/backend/default/block/macros.html.twig
  11. +13
    -0
      ShopBundle/Resources/views/backend/productfamily/edit.html.twig
  12. +4
    -0
      ShopBundle/Resources/views/backend/productfamily/form.html.twig
  13. +21
    -0
      ShopBundle/Resources/views/backend/productfamily/panel_reduction.html.twig
  14. +2
    -108
      ShopBundle/Resources/views/backend/reductioncatalog/form.html.twig

+ 80
- 67
ShopBundle/Controller/Admin/AdminController.php Переглянути файл

@@ -240,11 +240,17 @@ class AdminController extends EasyAdminController
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);

if($override)$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);

return $formBuilder;
}

public function overrideFormBuilder($formBuilder, $entity, $view){
$id = (null !== $entity->getId()) ? $entity->getId() : 0;

if ($entity instanceof StatusInterface) {
@@ -277,75 +283,82 @@ class AdminController extends EasyAdminController

$formBuilder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
$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;
}
}
}


+ 1
- 1
ShopBundle/Controller/Admin/OrderController.php Переглянути файл

@@ -77,7 +77,7 @@ class OrderController extends AdminController
parent::persistEntity($entity);
}

public function createEntityFormBuilder($entity, $view)
public function createEntityFormBuilder($entity, $view, $override=true)
{
$formBuilder = parent::createEntityFormBuilder($entity, $view);


+ 37
- 26
ShopBundle/Controller/Admin/ProductFamilyController.php Переглянути файл

@@ -3,12 +3,15 @@
namespace Lc\ShopBundle\Controller\Admin;

use App\Entity\Product;
use App\Entity\ReductionCatalog;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\UnitInterface;
use Lc\ShopBundle\Form\ProductFamilyCategoriesType;
@@ -29,21 +32,26 @@ class ProductFamilyController extends AdminController
private $choicesTaxRateParam;
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);
$this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::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(
@@ -144,39 +152,42 @@ class ProductFamilyController extends AdminController
)
);

$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);

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->processProducts($entity);
$this->processPrice($entity);
/* dump($reductionCatalog);
dump($productFamilyRequest);*/

parent::updateEntity($entity);
}

public function persistEntity($entity)
public function persistEntity($entity, $newForm)
{
$this->processReductionCatalog($entity, $newForm);
$this->processCategories($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){

+ 96
- 12
ShopBundle/Form/ReductionCatalogType.php Переглянути файл

@@ -2,7 +2,13 @@

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\UserInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
@@ -25,34 +31,112 @@ class ReductionCatalogType extends AbstractType

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
->add('title', TextType::class, ['label' => 'Titre'])
->add('title', TextType::class, [
'label' => 'Titre',
'required' => false,
])
->add('behaviorTaxRate', ChoiceType::class, [
'required'=> true,
'required' => false,
'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, [
'required'=> true,
'required' => false,
'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)
{
$resolver->setDefaults([
'label' => false,
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName()
//'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

+ 17
- 4
ShopBundle/Model/ReductionCatalog.php Переглянути файл

@@ -29,6 +29,11 @@ abstract class ReductionCatalog extends AbstractDocumentEntity implements Reduct
*/
protected $productFamilies;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
*/
protected $productFamily;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface")
*/
@@ -44,10 +49,6 @@ abstract class ReductionCatalog extends AbstractDocumentEntity implements Reduct
*/
protected $users;

/*
* @ORM\Column(type="smallint")
*/
// protected $fromQuantity = 1;


public function __construct()
@@ -98,6 +99,18 @@ abstract class ReductionCatalog extends AbstractDocumentEntity implements Reduct
}


public function getProductFamily(): ?ProductFamily
{
return $this->productFamily;
}

public function setProductFamily(?ProductFamily $productFamily): self
{
$this->productFamily = $productFamily;

return $this;
}

/**
* @return Collection|GroupUser[]
*/

+ 17
- 1
ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js Переглянути файл

@@ -336,4 +336,20 @@ let mixinTemplate = {
}
}
}
}
};


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);
}
};

+ 6
- 2
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js Переглянути файл

@@ -215,6 +215,7 @@ Vue.component('product-form', {

appProductFamily = new Vue({
el: '#lc-product-family-edit',
mixins: [mixinReduction],
delimiters: ['${', '}'],
computed: {
productFamily: function () {
@@ -289,7 +290,7 @@ appProductFamily = new Vue({
activeProducts:false,

formProductArray: [],
currentSection: 'price',
currentSection: 'general',
sectionsArray: [
{
name: 'general',
@@ -311,7 +312,10 @@ appProductFamily = new Vue({
name: 'property',
nameDisplay: 'Caractéristiques'
},

{
name: 'reduction',
nameDisplay: 'Réduction'
},
{
name: 'note',
nameDisplay: 'Note interne'

+ 1
- 24
ShopBundle/Resources/public/js/backend/script/reductioncatalog/vuejs-reduction-catalog.js Переглянути файл

@@ -3,28 +3,5 @@
appProductFamily = new Vue({
el: '#lc-reduction-catalog-edit',
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]
});

+ 4
- 2
ShopBundle/Resources/translations/lcshop.fr.yaml Переглянути файл

@@ -35,6 +35,7 @@ group:
propertySecondary: Caractéristiques secondaires
note: Note interne
parameters: Paramètres
initReduction: Réduction
ReductionCatalog:
info: Informations principal
conditions: Condictions d'application
@@ -130,6 +131,8 @@ field:
subscribeNewsletter: S'inscrire à la newsletter
send: Envoyer
isSent: Envoyée
behaviorTaxRate: Avec ou sans TVA
behaviorTaxRateHelp: Appliquer la réduction sur le prix HT ou le prix TTC
PointSale:
code: Code
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)
@@ -179,11 +182,10 @@ field:
behaviorAddToCartOptions:
simple: Simple
multiple: Multiple
activeReductionCatalog: Appliquer une réduction sur ce produit
ReductionCatalog:
fromQuantity: À partir de la quantité
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é
value: Montant ou valeur
permanent: Réduction permanante

+ 124
- 3
ShopBundle/Resources/views/backend/default/block/macros.html.twig Переглянути файл

@@ -23,7 +23,7 @@

{% 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 v-if="{{ fieldName }}">
{% verbatim %}{{ {% endverbatim %}{{ fieldDisplay }} {% verbatim %}}}{% endverbatim %}{{ displaySuffix }}
@@ -35,7 +35,8 @@
<div v-show="{{ fieldName }}Inherited == true">
{{ form_widget(field, {'attr' : {'v-model' : fieldName , 'v-on:focusout': fieldName~'Inherited = false', '@change' : fieldName~'Updated'}}) }}
</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>
{% endmacro %}

@@ -71,4 +72,124 @@
</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 %}

+ 13
- 0
ShopBundle/Resources/views/backend/productfamily/edit.html.twig Переглянути файл

@@ -4,6 +4,19 @@
{% include '@LcShop/backend/productfamily/form.html.twig' %}
{% 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 %}
{{ parent() }}
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %}

+ 4
- 0
ShopBundle/Resources/views/backend/productfamily/form.html.twig Переглянути файл

@@ -82,6 +82,10 @@
{% include '@LcShop/backend/productfamily/panel_property.html.twig' %}
</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 class="row">

+ 21
- 0
ShopBundle/Resources/views/backend/productfamily/panel_reduction.html.twig Переглянути файл

@@ -0,0 +1,21 @@
{% 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>

+ 2
- 108
ShopBundle/Resources/views/backend/reductioncatalog/form.html.twig Переглянути файл

@@ -3,116 +3,10 @@
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

{% 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">

{{ 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>
{{ form_end(form) }}

Завантаження…
Відмінити
Зберегти