|
|
@@ -95,11 +95,11 @@ class ReductionCatalogFieldDefinition extends AbstractFieldDefinition |
|
|
|
} |
|
|
|
|
|
|
|
if(is_null($this->usersArray)) { |
|
|
|
//$this->usersArray = $this->userStore->setMerchant($this->merchant)->getJoinGroupUsers(); |
|
|
|
$this->usersArray = $this->userStore->setMerchant($this->merchant)->getJoinGroupUsers(); |
|
|
|
} |
|
|
|
|
|
|
|
if(is_null($this->productFamilyArray)) { |
|
|
|
//$this->productFamilyArray = $this->productFamilyStore->setMerchant($this->merchant)->get(); |
|
|
|
$this->productFamilyArray = $this->productFamilyStore->setMerchant($this->merchant)->get(); |
|
|
|
} |
|
|
|
|
|
|
|
if(is_null($this->productCategoryArray)) { |
|
|
@@ -140,7 +140,22 @@ class ReductionCatalogFieldDefinition extends AbstractFieldDefinition |
|
|
|
|
|
|
|
'usersActive' => BooleanField::new('usersActive')->setFormTypeOption('mapped', false), |
|
|
|
|
|
|
|
'users' => ChoiceField::new('users') |
|
|
|
'users' => AssociationField::new('users') |
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
|
->setFormTypeOption('choices', $this->usersArray) |
|
|
|
->setFormTypeOption( |
|
|
|
'choice_attr', |
|
|
|
function ($choice, $key, $value) { |
|
|
|
$data = array(); |
|
|
|
foreach ($choice->getGroupUsers() as $groupUser) { |
|
|
|
$data[] = '_' . $groupUser->getId() . '_'; |
|
|
|
} |
|
|
|
|
|
|
|
return ['data-group-users' => json_encode($data)]; |
|
|
|
}, |
|
|
|
), |
|
|
|
|
|
|
|
/*ChoiceField::new('users') |
|
|
|
->setChoices([null]) |
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
|
->setFormTypeOption('attr', [ |
|
|
@@ -148,7 +163,7 @@ class ReductionCatalogFieldDefinition extends AbstractFieldDefinition |
|
|
|
'url' => $this->urlGenerator->generate('app_admin_ajax_users'), |
|
|
|
'dataType' => 'json' |
|
|
|
]) |
|
|
|
]), |
|
|
|
]),*/ |
|
|
|
'productCategoriesActive' => BooleanField::new('productCategoriesActive')->setFormTypeOption('mapped', false), |
|
|
|
'productCategories' => AssociationField::new('productCategories') |
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
@@ -166,15 +181,31 @@ class ReductionCatalogFieldDefinition extends AbstractFieldDefinition |
|
|
|
|
|
|
|
|
|
|
|
'productFamiliesActive' => BooleanField::new('productFamiliesActive')->setFormTypeOption('mapped', false), |
|
|
|
'productFamilies' => ChoiceField::new('productFamilies') |
|
|
|
->setChoices([null]) |
|
|
|
'productFamilies' => /*ChoiceField::new('productFamilies') |
|
|
|
->setChoices([null]) |
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
|
->setFormTypeOption('attr', [ |
|
|
|
'data-ajax' => json_encode([ |
|
|
|
'url' => $this->urlGenerator->generate('app_admin_ajax_products'), |
|
|
|
'dataType' => 'json' |
|
|
|
]) |
|
|
|
]), |
|
|
|
]),*/ |
|
|
|
AssociationField::new('productFamilies') |
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
|
->setFormTypeOption('choices', $this->productFamilyArray) |
|
|
|
->setFormTypeOption( |
|
|
|
'choice_attr', |
|
|
|
function ($choice, $key, $value) { |
|
|
|
$data = array(); |
|
|
|
foreach ($choice->getProductCategories() as $category) { |
|
|
|
$data[] = '_' . $category->getId() . '_'; |
|
|
|
} |
|
|
|
return [ |
|
|
|
'data-product-categories' => json_encode($data), |
|
|
|
'data-supplier' => $choice->getSupplier()->getId() |
|
|
|
]; |
|
|
|
} |
|
|
|
), |
|
|
|
'productFamily' => AssociationField::new('productFamily') |
|
|
|
->setFormTypeOption('choices', $this->productFamilyArray) |
|
|
|
]; |