|
|
|
|
|
|
|
|
use Lc\CaracoleBundle\Repository\User\UserStore; |
|
|
use Lc\CaracoleBundle\Repository\User\UserStore; |
|
|
use Lc\SovBundle\Field\BooleanField; |
|
|
use Lc\SovBundle\Field\BooleanField; |
|
|
use Lc\SovBundle\Translation\TranslatorAdmin; |
|
|
use Lc\SovBundle\Translation\TranslatorAdmin; |
|
|
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
|
|
|
|
|
|
|
class ReductionCatalogFieldDefinition extends AbstractFieldDefinition |
|
|
class ReductionCatalogFieldDefinition extends AbstractFieldDefinition |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
protected UserStore $userStore; |
|
|
protected UserStore $userStore; |
|
|
protected ProductFamilyStore $productFamilyStore; |
|
|
protected ProductFamilyStore $productFamilyStore; |
|
|
protected ProductCategoryStore $productCategoryStore; |
|
|
protected ProductCategoryStore $productCategoryStore; |
|
|
|
|
|
protected UrlGeneratorInterface $urlGenerator; |
|
|
|
|
|
|
|
|
protected ?array $groupUserArray = null; |
|
|
protected ?array $groupUserArray = null; |
|
|
protected ?array $usersArray= null; |
|
|
protected ?array $usersArray= null; |
|
|
|
|
|
|
|
|
GroupUserStore $groupUserStore, |
|
|
GroupUserStore $groupUserStore, |
|
|
UserStore $userStore, |
|
|
UserStore $userStore, |
|
|
ProductFamilyStore $productFamilyStore, |
|
|
ProductFamilyStore $productFamilyStore, |
|
|
ProductCategoryStore $productCategoryStore |
|
|
|
|
|
|
|
|
ProductCategoryStore $productCategoryStore, |
|
|
|
|
|
UrlGeneratorInterface $urlGenerator |
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
parent::__construct($translatorAdmin); |
|
|
parent::__construct($translatorAdmin); |
|
|
|
|
|
|
|
|
$this->userStore = $userStore; |
|
|
$this->userStore = $userStore; |
|
|
$this->productFamilyStore = $productFamilyStore; |
|
|
$this->productFamilyStore = $productFamilyStore; |
|
|
$this->productCategoryStore = $productCategoryStore; |
|
|
$this->productCategoryStore = $productCategoryStore; |
|
|
|
|
|
$this->urlGenerator = $urlGenerator; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function configureIndex(): array |
|
|
public function configureIndex(): array |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(is_null($this->usersArray)) { |
|
|
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)) { |
|
|
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)) { |
|
|
if(is_null($this->productCategoryArray)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'usersActive' => BooleanField::new('usersActive')->setFormTypeOption('mapped', false), |
|
|
'usersActive' => BooleanField::new('usersActive')->setFormTypeOption('mapped', false), |
|
|
|
|
|
|
|
|
'users' => AssociationField::new('users') |
|
|
|
|
|
|
|
|
'users' => ChoiceField::new('users') |
|
|
|
|
|
->setChoices([null]) |
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
->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)]; |
|
|
|
|
|
}, |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
->setFormTypeOption('attr', [ |
|
|
|
|
|
'data-ajax' => json_encode([ |
|
|
|
|
|
'url' => $this->urlGenerator->generate('app_admin_ajax_users'), |
|
|
|
|
|
'dataType' => 'json' |
|
|
|
|
|
]) |
|
|
|
|
|
]), |
|
|
'productCategoriesActive' => BooleanField::new('productCategoriesActive')->setFormTypeOption('mapped', false), |
|
|
'productCategoriesActive' => BooleanField::new('productCategoriesActive')->setFormTypeOption('mapped', false), |
|
|
'productCategories' => AssociationField::new('productCategories') |
|
|
'productCategories' => AssociationField::new('productCategories') |
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'productFamiliesActive' => BooleanField::new('productFamiliesActive')->setFormTypeOption('mapped', false), |
|
|
'productFamiliesActive' => BooleanField::new('productFamiliesActive')->setFormTypeOption('mapped', false), |
|
|
'productFamilies' => AssociationField::new('productFamilies') |
|
|
|
|
|
|
|
|
'productFamilies' => ChoiceField::new('productFamilies') |
|
|
|
|
|
->setChoices([null]) |
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
->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() |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
->setFormTypeOption('attr', [ |
|
|
|
|
|
'data-ajax' => json_encode([ |
|
|
|
|
|
'url' => $this->urlGenerator->generate('app_admin_ajax_products'), |
|
|
|
|
|
'dataType' => 'json' |
|
|
|
|
|
]) |
|
|
|
|
|
]), |
|
|
'productFamily' => AssociationField::new('productFamily') |
|
|
'productFamily' => AssociationField::new('productFamily') |
|
|
->setFormTypeOption('choices', $this->productFamilyArray) |
|
|
->setFormTypeOption('choices', $this->productFamilyArray) |
|
|
]; |
|
|
]; |