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.

59 líneas
2.1KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Product;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
  4. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  5. use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
  6. use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
  7. use Lc\CaracoleBundle\Controller\AbstractAdminController;
  8. use Lc\CaracoleBundle\Resolver\SectionResolver;
  9. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  10. use Symfony\Component\HttpFoundation\Response;
  11. abstract class ProductFamilyAdminController extends AbstractAdminController
  12. {
  13. public function getRepositoryQuery() :RepositoryQueryInterface
  14. {
  15. return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
  16. }
  17. public function createEntity(string $entityFqcn)
  18. {
  19. return $this->getProductFamilyContainer()
  20. ->getFactory()
  21. ->create($this->getMerchantCurrent());
  22. }
  23. public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
  24. {
  25. $responseParameters = parent::configureResponseParameters($responseParameters);
  26. // affichage du filtre sur section
  27. $responseParameters->set('display_switch_section', true);
  28. return $responseParameters;
  29. }
  30. public function showSalesStatistic(AdminContext $context)
  31. {
  32. $productFamily = $context->getEntity()->getInstance();
  33. $currentSection = $this->get(SectionResolver::class)->getCurrent();
  34. $productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
  35. $parameters = array(
  36. 'productFamily' => $productFamily,
  37. 'productsSalesStatistic' => $productsSalesStatistic
  38. );
  39. //TODO flashMessages ???
  40. $response['flashMessages'] = [];//$this->utils->getFlashMessages();
  41. $response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
  42. $response['statistics'] = $productsSalesStatistic;
  43. return new Response(json_encode($response));
  44. }
  45. }