1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
namespace App\Admin;
use App\Enum\HelloassoStateEnum;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
* Gestion des paiements / cotisations HelloAsso.
*
* @author Julien Jorry <julien.jorry@gmail.com>
*/
class HelloAssoAdmin extends AbstractAdmin
{
protected $baseRoutePattern = 'helloasso';
protected $baseRouteName = 'helloasso';
protected $datagridValues = [
// reverse order (default = 'ASC')
'_sort_order' => 'DESC',
// name of the ordered field (default = the model's id field, if any)
'_sort_by' => 'createdAt',
// '_page' => 1,
// '_per_page' => 32
];
/**
* {@inheritdoc}
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(['list', 'show']);
$collection->add('synchro');
$collection->add('synchrotest');
}
public function configureActionButtons($action, $object = null)
{
$buttonList = parent::configureActionButtons($action, $object);
$buttonList['synchro'] = ['template' => '@kohinos/admin/helloasso_synchro_button.html.twig'];
$buttonList['synchrotest'] = ['template' => '@kohinos/admin/helloasso_synchro_test_button.html.twig'];
return $buttonList;
}
protected function configureListFields(ListMapper $listMapper): void
{
parent::configureListFields($listMapper);
unset($this->listModes['mosaic']);
$listMapper
->add('createdAt', 'datetime', [
'label' => 'Date',
])
->add('helloassoid')
->add('type')
->add('amount', null, [
'label' => 'Montant',
])
// ->add('data')
->add('fulluser', null, [
'label' => 'Utilisateur',
])
->add('fullpayer', null, [
'label' => 'Payeur',
])
->add(
'prestaoradh',
null,
[
'label' => 'Presta ou Adhérent',
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list_presta_or_adherent.html.twig',
]
)
->add('state', null, [
'label' => 'Etat',
])
->add('statePayment', null, [
'label' => 'Etat du paiement',
])
->add('operationState', null, [
'label' => 'Etat de l\'opération',
])
->add('errors', null, [
'label' => 'Erreurs',
])
->add('flux')
->add('historical', null, [
'label' => 'Historique ?',
])
;
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de création',
])
->add('state', 'doctrine_orm_string', [
'advanced_filter' => false,
'show_filter' => true,
'label' => 'Etat',
], ChoiceType::class, [
'choices' => [
'Waiting' => 'Waiting',
'Processed' => 'Processed',
'Registered' => 'Registered',
'Deleted' => 'Deleted',
'Refunded' => 'Refunded',
'Unknown' => 'Unknown',
'Canceled' => 'Canceled',
'Contested' => 'Contested',
],
])
->add('statePayment', 'doctrine_orm_string', [
'advanced_filter' => false,
'show_filter' => true,
'label' => 'Etat du paiement',
], ChoiceType::class, [
'choices' => [
'Pending' => 'Pending',
'Authorized' => 'Authorized',
'Refused' => 'Refused',
'Unknown' => 'Unknown',
'Registered' => 'Registered',
'Error' => 'Error',
'Refunded' => 'Refunded',
'Refunding' => 'Refunding',
'Waiting' => 'Waiting',
'Canceled' => 'Canceled',
'Contested' => 'Contested',
'WaitingBankValidation' => 'WaitingBankValidation',
'WaitingBankWithdraw' => 'WaitingBankWithdraw',
],
])
->add('operationState', null, [
'advanced_filter' => false,
'show_filter' => true,
'label' => 'Etat de l\'opération',
], ChoiceType::class, [
'choices' => HelloassoStateEnum::getAvailableTypes(),
'choice_label' => function ($choice) {
return HelloassoStateEnum::getTypeName($choice);
},
])
->add('prestataire', null, [
'label' => 'Prestataire',
'advanced_filter' => false,
])
->add('adherent', null, [
'label' => 'Adhérent',
'advanced_filter' => false,
])
->add('historical', null, [
'label' => 'Historique',
'advanced_filter' => false,
])
;
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
}