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.

104 line
5.2KB

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