No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

70 líneas
2.9KB

  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\Controller\AdminControllerTrait;
  16. use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
  17. use Lc\CaracoleBundle\Field\Address\AddressField;
  18. use Lc\CaracoleBundle\Resolver\SectionResolver;
  19. use Lc\SovBundle\Controller\AbstractAdminController;
  20. use Lc\SovBundle\Field\BooleanField;
  21. use Lc\SovBundle\Field\CKEditorField;
  22. use Lc\SovBundle\Field\StatusField;
  23. use Symfony\Component\HttpFoundation\RequestStack;
  24. use Symfony\Component\HttpFoundation\Response;
  25. abstract class ProductFamilyAdminController extends AbstractAdminController
  26. {
  27. use AdminControllerTrait;
  28. public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
  29. {
  30. $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
  31. $queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp');
  32. $queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent());
  33. return $queryBuilder;
  34. }
  35. public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
  36. {
  37. $responseParameters = parent::configureResponseParameters($responseParameters);
  38. // affichage du filtre sur section
  39. $responseParameters->set('display_switch_section', true);
  40. return $responseParameters;
  41. }
  42. public function showSalesStatistic(AdminContext $context)
  43. {
  44. $productFamily = $context->getEntity()->getInstance();
  45. $currentSection = $this->get(SectionResolver::class)->getCurrent();
  46. $productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
  47. $parameters = array(
  48. 'productFamily' => $productFamily,
  49. 'productsSalesStatistic' => $productsSalesStatistic
  50. );
  51. //TODO flashMessages ???
  52. $response['flashMessages'] = [];//$this->utils->getFlashMessages();
  53. $response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
  54. $response['statistics'] = $productsSalesStatistic;
  55. return new Response(json_encode($response));
  56. }
  57. }