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.

81 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')->hideOnForm(),
  42. 'type' => ChoiceField::new('type')
  43. ->setChoices(
  44. $this->translatorAdmin->transChoices(
  45. CreditHistorySolver::getTypeChoices(),
  46. 'CreditHistory',
  47. 'type'
  48. )
  49. ),
  50. 'amount' => NumberField::new('amount')
  51. ->setTemplatePath('@LcCaracole/admin/credit/field/amount.html.twig')
  52. ->setCustomOption('appendHtml', '&euro;'),
  53. 'paidAt' => DateField::new('paidAt')->setFormTypeOption('required', true)
  54. ->setTemplatePath('@LcCaracole/admin/credit/field/paidAt.html.twig'),
  55. 'meanPayment' => ChoiceField::new('meanPayment')
  56. ->setChoices(
  57. $this->translatorAdmin->transChoices(
  58. OrderPaymentSolver::getMeanPaymentChoices(),
  59. 'OrderPayment',
  60. 'meanPayment'
  61. )
  62. )->setFormTypeOption('required', true)
  63. ->setTemplatePath('@LcCaracole/admin/credit/field/meanPayment.html.twig'),
  64. 'reference' => TextField::new('reference')
  65. ->setTemplatePath('@LcCaracole/admin/credit/field/reference.html.twig'),
  66. 'comment' => TextField::new('comment')
  67. ->setTemplatePath('@LcCaracole/admin/credit/field/comment.html.twig'),
  68. ];
  69. }
  70. }