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
<?php
namespace App\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
use App\Enum\CurrencyEnum;
/**
* Administration des profils de cotisation.
*
* KOHINOS : Outil de gestion de Monnaie Locale Complémentaire
*/
class ProfilDeCotisationAdmin extends AbstractAdmin
{
protected $baseRouteName = 'profilcotisation';
protected $baseRoutePattern = 'profilcotisation';
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
/**
* {@inheritdoc}
*/
protected function configureFormFields(FormMapper $formMapper): void
{
$formMapper
->with('Profil', ['class' => 'col-md-12'])
->add('montant', NumberType::class, [
'label' => 'Montant'
])
->add('tauxCotisation', NumberType::class, [
'label' => 'Taux de cotisation'
])
->end()
;
parent::configureFormFields($formMapper);
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de création',
])
->add('updatedAt', 'doctrine_orm_datetime_range', [
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de mise à jour',
])
;
}
protected function configureListFields(ListMapper $listMapper): void
{
$listMapper
->addIdentifier('montant', FieldDescriptionInterface::TYPE_CURRENCY, [
'label' => 'Montant',
'currency' => CurrencyEnum::getCode(CurrencyEnum::CURRENCY_EURO),
'sortable' => true
])
->addIdentifier('tauxCotisation', null, [
'label' => 'Taux de cotisation',
'sortable' => true
])
->add('createdAt', 'date', [
'pattern' => 'dd/MM/YYYY HH:mm',
'label' => 'Crée le',
])
->add('updatedAt', 'date', [
'pattern' => 'dd/MM/YYYY HH:mm',
'label' => 'Mis à jour le',
])
->add('_action', null, [
'actions' => ['edit' => []],
])
;
}
}