Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ProductFamilyAdminController.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Product;
  3. use Doctrine\ORM\QueryBuilder;
  4. use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
  5. use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
  7. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  8. use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
  9. use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
  10. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  11. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  12. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  13. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  14. use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
  15. use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
  16. use Lc\CaracoleBundle\Controller\AdminControllerTrait;
  17. use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
  18. use Lc\CaracoleBundle\Field\Address\AddressField;
  19. use Lc\CaracoleBundle\Resolver\SectionResolver;
  20. use Lc\SovBundle\Controller\AbstractAdminController;
  21. use Lc\SovBundle\Field\BooleanField;
  22. use Lc\SovBundle\Field\CKEditorField;
  23. use Lc\SovBundle\Field\StatusField;
  24. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  25. use Symfony\Component\HttpFoundation\RequestStack;
  26. use Symfony\Component\HttpFoundation\Response;
  27. abstract class ProductFamilyAdminController extends AbstractAdminController
  28. {
  29. use AdminControllerTrait;
  30. public function getRepositoryQuery() :RepositoryQueryInterface
  31. {
  32. return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
  33. }
  34. // public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
  35. // {
  36. // $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
  37. //
  38. // $queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp');
  39. // $queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent());
  40. // $queryBuilder->addOrderBy('entity.id');
  41. // return $queryBuilder;
  42. // }
  43. public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
  44. {
  45. $responseParameters = parent::configureResponseParameters($responseParameters);
  46. // affichage du filtre sur section
  47. $responseParameters->set('display_switch_section', true);
  48. return $responseParameters;
  49. }
  50. public function showSalesStatistic(AdminContext $context)
  51. {
  52. $productFamily = $context->getEntity()->getInstance();
  53. $currentSection = $this->get(SectionResolver::class)->getCurrent();
  54. $productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
  55. $parameters = array(
  56. 'productFamily' => $productFamily,
  57. 'productsSalesStatistic' => $productsSalesStatistic
  58. );
  59. //TODO flashMessages ???
  60. $response['flashMessages'] = [];//$this->utils->getFlashMessages();
  61. $response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
  62. $response['statistics'] = $productsSalesStatistic;
  63. return new Response(json_encode($response));
  64. }
  65. }