You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.0KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\Order;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
  8. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  9. use Lc\CaracoleBundle\Context\MerchantContextTrait;
  10. use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
  11. use Lc\CaracoleBundle\Field\AssociationField;
  12. use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserEmailFilter;
  13. use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserFirstnameFilter;
  14. use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserLastnameFilter;
  15. use Lc\CaracoleBundle\Repository\Section\SectionStore;
  16. use Lc\SovBundle\Translation\TranslatorAdmin;
  17. use Symfony\Component\Form\Extension\Core\Type\TextType;
  18. class OrderShopFieldDefinition extends AbstractFieldDefinition
  19. {
  20. use MerchantContextTrait;
  21. protected SectionStore $sectionStore;
  22. public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
  23. {
  24. parent::__construct($translatorAdmin);
  25. $this->sectionStore = $sectionStore;
  26. }
  27. public function configureFieldsIndex(): array
  28. {
  29. return ['id'];
  30. }
  31. public function configurePanels(): array
  32. {
  33. return [];
  34. }
  35. public function configureFields(): array
  36. {
  37. return [
  38. 'id' => IntegerField::new('id', 'ID')->setSortable(true),
  39. 'userLastname' => TextareaField::new('user.lastname')->setSortable(true)
  40. ->setCustomOption('filter_fqcn', OrderShopUserLastnameFilter::class),
  41. //->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'),
  42. 'userFirstname' => TextareaField::new('user.firstname')->setSortable(true)
  43. ->setCustomOption('filter_fqcn', OrderShopUserFirstnameFilter::class),
  44. //->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'),
  45. 'userEmail' => TextareaField::new('user.email')->setSortable(true)
  46. ->setCustomOption('filter_fqcn', OrderShopUserEmailFilter::class),
  47. //->setTemplatePath('@LcShop/backend/default/field/user.html.twig'),
  48. 'total' => NumberField::new('total')
  49. ->setTemplatePath('@LcCaracole/admin/order/field/total.html.twig'),
  50. 'orderStatus' => AssociationField::new('orderStatus')->setSortable(true)
  51. ->setTemplatePath('@LcCaracole/admin/order/field/order_status.html.twig'),
  52. 'createdAt' => DateTimeField::new('createdAt')->setSortable(true),
  53. 'updatedAt' => DateTimeField::new('updatedAt')->setSortable(true),
  54. 'orderShopCreatedAt' => DateTimeField::new('orderShopCreatedAt')->setSortable(true),
  55. 'distribution' => AssociationField::new('distribution')
  56. ->setSortable(true)
  57. ->setCustomOption('filter_type', TextType::class)
  58. ->setCustomOption('filter_on', 'cycleNumber')
  59. ,
  60. 'cycleDeliveryId' => IntegerField::new('cycleDeliveryId')->setSortable(true),
  61. 'cycleId' => IntegerField::new('cycleId')->setSortable(true),
  62. 'deliveryType' => Field::new('deliveryType')->setSortable(true),
  63. //->setTemplatePath('@LcShop/backend/default/field/options_translatable.html.twig'),
  64. 'reference' => TextField::new('reference')->setSortable(true),
  65. 'complementaryOrderShops' => AssociationField::new('complementaryOrderShops')
  66. ->setFormTypeOption('mapped', false)
  67. ->setTemplatePath('@LcCaracole/admin/order/field/complementary.html.twig')
  68. ->setCustomOption('filter', false)
  69. ,
  70. 'orderPayments' => AssociationField::new('orderPayments')
  71. ->setTemplatePath('@LcCaracole/admin/order/field/order_payment.html.twig')
  72. ->setCustomOption('filter', false),
  73. 'user'=> AssociationField::new('user')->setSortable(true)
  74. ];
  75. }
  76. }