return array_merge(parent::configureFields(), [ | return array_merge(parent::configureFields(), [ | ||||
'type' => ChoiceField::new('type') | 'type' => ChoiceField::new('type') | ||||
->autocomplete() | ->autocomplete() | ||||
->setSortable(true) | |||||
->setChoices( | ->setChoices( | ||||
$this->translatorAdmin->transChoices( | $this->translatorAdmin->transChoices( | ||||
TicketSolver::getTypeChoices(), | TicketSolver::getTypeChoices(), |
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; | ||||
use Doctrine\ORM\QueryBuilder; | use Doctrine\ORM\QueryBuilder; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | ||||
use Lc\ShopBundle\Context\TreeInterface; | |||||
use Lc\SovBundle\Field\Filter\AssociationFilter; | use Lc\SovBundle\Field\Filter\AssociationFilter; | ||||
use Lc\SovBundle\Field\Filter\FilterTrait; | use Lc\SovBundle\Field\Filter\FilterTrait; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
{ | { | ||||
$fieldProperty = $this->getFieldProperty($fieldDto); | $fieldProperty = $this->getFieldProperty($fieldDto); | ||||
if ($filteredValue !== null) { | if ($filteredValue !== null) { | ||||
$repositoryQuery->filterByProductCategory($filteredValue); | |||||
if ($filteredValue->getParent() == null) { | |||||
$param = array_merge(array($filteredValue), $filteredValue->getChildrens()->toArray()); | |||||
} else { | |||||
$param = array($filteredValue); | |||||
} | |||||
$repositoryQuery->filterByProductCategoryArray($param); | |||||
} | } | ||||
} | } |
->setParameter('category', $category->getId()); | ->setParameter('category', $category->getId()); | ||||
} | } | ||||
public function filterByProductCategoryArray(Array $categoryArray): self | |||||
{ | |||||
$this->joinProductCategories(); | |||||
return $this | |||||
->andWhere(':categoryArray MEMBER OF .productCategories') | |||||
->setParameter('categoryArray', $categoryArray); | |||||
} | |||||
public function filterByPropertyNoveltyExpirationDate($dateTime = null): self | public function filterByPropertyNoveltyExpirationDate($dateTime = null): self | ||||
{ | { |
$query->joinProductFamily(); | $query->joinProductFamily(); | ||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterAvailableQuantityNegative(); | $query->filterAvailableQuantityNegative(); | ||||
$query->groupBy('pf.id'); | |||||
$query->groupBy('productFamily.id'); | |||||
$productListAvailableQuantityNegative = $query->find(); | $productListAvailableQuantityNegative = $query->find(); | ||||
foreach ($productListAvailableQuantityNegative as $i=>$product) { | foreach ($productListAvailableQuantityNegative as $i=>$product) { | ||||
$query->joinProductFamily(); | $query->joinProductFamily(); | ||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterAvailableQuantitySupplierNegative(); | $query->filterAvailableQuantitySupplierNegative(); | ||||
$query->groupBy('pf.id'); | |||||
$query->groupBy('productFamily.id'); | |||||
$productListAvailableQuantityNegative = $query->find(); | $productListAvailableQuantityNegative = $query->find(); | ||||
foreach ($productListAvailableQuantityNegative as $i=>$product) { | foreach ($productListAvailableQuantityNegative as $i=>$product) { |