123 lines
4 KiB
PHP
123 lines
4 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Core\Form\Type\CollectionType;
|
|
use App\Entity\ExpenseReport;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
|
|
class ExpenseReportType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
$builder
|
|
->add('dateFrom', null, [
|
|
'html5' => true,
|
|
'widget' => 'single_text',
|
|
])
|
|
->add('dateTo', null, [
|
|
'html5' => true,
|
|
'widget' => 'single_text',
|
|
])
|
|
->add('moves', CollectionType::class, [
|
|
'entry_type' => ExpenseReportMoveType::class,
|
|
'collection_name' => 'moves',
|
|
'prototype' => true,
|
|
'allow_add' => true,
|
|
'allow_delete' => true,
|
|
'row_attr' => [
|
|
'class' => 'mb-3 pb-3 pl-3 pr-3 pt-1 bg-light',
|
|
],
|
|
'label_attr' => [
|
|
'class' => 'font-weight-bold',
|
|
],
|
|
'attr' => [
|
|
'class' => 'mb-3 row',
|
|
],
|
|
])
|
|
->add('variousPayments', CollectionType::class, [
|
|
'entry_type' => ExpenseReportVariousPaymentType::class,
|
|
'collection_name' => 'variousPayments',
|
|
'prototype' => true,
|
|
'allow_add' => true,
|
|
'allow_delete' => true,
|
|
'row_attr' => [
|
|
'class' => 'mb-3 pb-3 pl-3 pr-3 pt-1 bg-light',
|
|
],
|
|
'label_attr' => [
|
|
'class' => 'font-weight-bold',
|
|
],
|
|
'attr' => [
|
|
'class' => 'mb-3 row',
|
|
],
|
|
])
|
|
;
|
|
|
|
if ($builder->getData()->getId()) {
|
|
$builder
|
|
->add('newBills', CollectionType::class, [
|
|
'entry_type' => ExpenseReportNewBillType::class,
|
|
'mapped' => false,
|
|
'label' => 'Nouvelles factures',
|
|
'collection_name' => 'newBills',
|
|
'prototype' => true,
|
|
'allow_add' => true,
|
|
'allow_delete' => true,
|
|
'row_attr' => [
|
|
'class' => 'mb-3 pb-3 pl-3 pr-3 pt-1 bg-light',
|
|
],
|
|
'label_attr' => [
|
|
'class' => 'font-weight-bold',
|
|
],
|
|
'attr' => [
|
|
'class' => 'mb-3 row',
|
|
],
|
|
])
|
|
;
|
|
}
|
|
|
|
if (count($builder->getData()->getBills())) {
|
|
$builder
|
|
->add('deleteBills', ExpenseReportDeleteBillType::class, [
|
|
'mapped' => false,
|
|
'label' => 'Factures à supprimer',
|
|
'bills' => $builder->getData()->getBills(),
|
|
'row_attr' => [
|
|
'class' => 'mb-3 p-3 bg-light',
|
|
],
|
|
'label_attr' => [
|
|
'class' => 'font-weight-bold',
|
|
],
|
|
'attr' => [
|
|
'class' => 'row mb-3',
|
|
],
|
|
])
|
|
;
|
|
}
|
|
|
|
if ($options['is_treasurer']) {
|
|
$builder
|
|
->add('isPaid', CheckboxType::class, [
|
|
'required' => false,
|
|
])
|
|
->add('paidAt', null, [
|
|
'required' => false,
|
|
'html5' => true,
|
|
'widget' => 'single_text',
|
|
])
|
|
;
|
|
}
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver): void
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => ExpenseReport::class,
|
|
'is_treasurer' => false,
|
|
]);
|
|
}
|
|
}
|