Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

89 lines
2.9KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\Credit;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  8. use Lc\CaracoleBundle\Context\MerchantContextTrait;
  9. use Lc\CaracoleBundle\Solver\Credit\CreditHistorySolver;
  10. use Lc\CaracoleBundle\Solver\Order\OrderPaymentSolver;
  11. use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
  12. class CreditHistoryFieldDefinition extends AbstractFieldDefinition
  13. {
  14. use MerchantContextTrait;
  15. public function configureIndex(): array
  16. {
  17. return [
  18. 'id',
  19. 'type',
  20. 'amount',
  21. 'paidAt',
  22. 'meanPayment',
  23. 'reference',
  24. 'comment',
  25. ];
  26. }
  27. public function configureForm(): array
  28. {
  29. return [
  30. 'type',
  31. 'amount',
  32. 'paidAt',
  33. 'meanPayment',
  34. 'reference',
  35. 'comment',
  36. ];
  37. }
  38. public function configureFields(): array
  39. {
  40. return [
  41. 'id' => IdField::new('id')
  42. ->setSortable(true),
  43. 'type' => ChoiceField::new('type')
  44. ->setChoices(
  45. $this->translatorAdmin->transChoices(
  46. CreditHistorySolver::getTypeChoices(),
  47. 'CreditHistory',
  48. 'type'
  49. )
  50. )
  51. ->setSortable(true),
  52. 'amount' => NumberField::new('amount')
  53. ->setTemplatePath('@LcCaracole/admin/credit/field/amount.html.twig')
  54. ->setCustomOption('appendHtml', '&euro;')
  55. ->setSortable(false),
  56. 'paidAt' => DateField::new('paidAt')
  57. ->setFormTypeOption('required', true)
  58. ->setTemplatePath('@LcCaracole/admin/credit/field/paidAt.html.twig')
  59. ->setSortable(false),
  60. 'meanPayment' => ChoiceField::new('meanPayment')
  61. ->setChoices(
  62. $this->translatorAdmin->transChoices(
  63. OrderPaymentSolver::getMeanPaymentChoices(),
  64. 'OrderPayment',
  65. 'meanPayment'
  66. )
  67. )->setFormTypeOption('required', true)
  68. ->setTemplatePath('@LcCaracole/admin/credit/field/meanPayment.html.twig')
  69. ->setSortable(true),
  70. 'reference' => TextField::new('reference')
  71. ->setTemplatePath('@LcCaracole/admin/credit/field/reference.html.twig')
  72. ->setSortable(false),
  73. 'comment' => TextField::new('comment')
  74. ->setTemplatePath('@LcCaracole/admin/credit/field/comment.html.twig')
  75. ->setSortable(false),
  76. ];
  77. }
  78. }