|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Product;
-
- use Doctrine\ORM\QueryBuilder;
- use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
- use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
- use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
- use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
- use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
- use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
- use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
- use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
- use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
- use Lc\CaracoleBundle\Controller\AdminControllerTrait;
- use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
- use Lc\CaracoleBundle\Field\Address\AddressField;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\SovBundle\Controller\AbstractAdminController;
- use Lc\SovBundle\Field\BooleanField;
- use Lc\SovBundle\Field\CKEditorField;
- use Lc\SovBundle\Field\StatusField;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Symfony\Component\HttpFoundation\Response;
-
- abstract class ProductFamilyAdminController extends AbstractAdminController
- {
- use AdminControllerTrait;
-
-
- public function getRepositoryQuery() :RepositoryQueryInterface
- {
- return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
- }
-
- // public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
- // {
- // $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
- //
- // $queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp');
- // $queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent());
- // $queryBuilder->addOrderBy('entity.id');
- // return $queryBuilder;
- // }
-
- public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
- {
- $responseParameters = parent::configureResponseParameters($responseParameters);
-
- // affichage du filtre sur section
- $responseParameters->set('display_switch_section', true);
-
- return $responseParameters;
- }
-
- public function showSalesStatistic(AdminContext $context)
- {
- $productFamily = $context->getEntity()->getInstance();
-
- $currentSection = $this->get(SectionResolver::class)->getCurrent();
- $productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
- $parameters = array(
- 'productFamily' => $productFamily,
- 'productsSalesStatistic' => $productsSalesStatistic
- );
-
- //TODO flashMessages ???
- $response['flashMessages'] = [];//$this->utils->getFlashMessages();
- $response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
- $response['statistics'] = $productsSalesStatistic;
- return new Response(json_encode($response));
- }
-
- }
|