1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (C) 2020 Jan Böhmer |
4
|
|
|
* |
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU Affero General Public License as published |
7
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU Affero General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace App\Controller\Admin; |
20
|
|
|
|
21
|
|
|
use App\Admin\Field\VichyFileField; |
22
|
|
|
use App\Admin\Filter\ConfirmedFilter; |
23
|
|
|
use App\Admin\Filter\DepartmentTypeFilter; |
24
|
|
|
use App\Admin\Filter\MoneyAmountFilter; |
25
|
|
|
use App\Entity\PaymentOrder; |
26
|
|
|
use App\Helpers\ZIPBinaryFileResponseFacade; |
27
|
|
|
use App\Services\EmailConfirmation\ConfirmationEmailSender; |
28
|
|
|
use App\Services\PaymentOrderMailLinkGenerator; |
29
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
30
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; |
31
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; |
32
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; |
33
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; |
34
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; |
35
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; |
36
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; |
37
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto; |
38
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; |
39
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; |
40
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField; |
41
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; |
42
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; |
43
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; |
44
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; |
45
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField; |
46
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; |
47
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; |
48
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
49
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; |
50
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; |
51
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter; |
52
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; |
53
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry; |
54
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; |
55
|
|
|
use RuntimeException; |
56
|
|
|
use Symfony\Component\HttpFoundation\Response; |
57
|
|
|
|
58
|
|
|
class PaymentOrderCrudController extends AbstractCrudController |
59
|
|
|
{ |
60
|
|
|
private $mailToGenerator; |
61
|
|
|
private $dashboardControllerRegistry; |
62
|
|
|
private $confirmationEmailSender; |
63
|
|
|
private $adminURLGenerator; |
64
|
|
|
private $entityManager; |
65
|
|
|
|
66
|
|
|
public function __construct(PaymentOrderMailLinkGenerator $mailToGenerator, |
67
|
|
|
DashboardControllerRegistry $dashboardControllerRegistry, EntityManagerInterface $entityManager, |
68
|
|
|
ConfirmationEmailSender $confirmationEmailSender, AdminUrlGenerator $adminUrlGenerator) |
69
|
|
|
{ |
70
|
|
|
$this->mailToGenerator = $mailToGenerator; |
71
|
|
|
$this->dashboardControllerRegistry = $dashboardControllerRegistry; |
72
|
|
|
$this->confirmationEmailSender = $confirmationEmailSender; |
73
|
|
|
$this->adminURLGenerator = $adminUrlGenerator; |
74
|
|
|
$this->entityManager = $entityManager; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public static function getEntityFqcn(): string |
78
|
|
|
{ |
79
|
|
|
return PaymentOrder::class; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function sepaXMLExport(BatchActionDto $batchActionDto): Response |
83
|
|
|
{ |
84
|
|
|
return $this->redirect( |
85
|
|
|
$this->adminURLGenerator->setRoute('payment_order_export') |
86
|
|
|
->set('ids', implode(',', $batchActionDto->getEntityIds())) |
87
|
|
|
->generateUrl() |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function referencesExport(BatchActionDto $batchActionDto): Response |
92
|
|
|
{ |
93
|
|
|
$this->denyAccessUnlessGranted('ROLE_SHOW_PAYMENT_ORDERS'); |
94
|
|
|
|
95
|
|
|
$entityManager = $this->getDoctrine()->getManagerForClass($batchActionDto->getEntityFqcn()); |
96
|
|
|
|
97
|
|
|
$data = []; |
98
|
|
|
foreach ($batchActionDto->getEntityIds() as $id) { |
99
|
|
|
/** @var PaymentOrder $payment_order */ |
100
|
|
|
$payment_order = $entityManager->find($batchActionDto->getEntityFqcn(), $id); |
101
|
|
|
$path = $payment_order->getReferencesFile() |
102
|
|
|
->getPathname(); |
103
|
|
|
$extension = $payment_order->getReferencesFile() |
104
|
|
|
->getExtension(); |
105
|
|
|
|
106
|
|
|
if (empty($payment_order->getDepartment()->getReferencesExportPrefix())) { |
107
|
|
|
$prefix = ''; |
108
|
|
|
} else { |
109
|
|
|
$prefix = $payment_order->getDepartment() |
110
|
|
|
->getReferencesExportPrefix().'_'; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
$data[$prefix.$payment_order->getIDString().'.'.$extension] = $path; |
114
|
|
|
|
115
|
|
|
if ($this->isGranted('ROLE_EXPORT_PAYMENT_ORDERS_REFERENCES')) { |
116
|
|
|
//Set exported status |
117
|
|
|
$payment_order->setReferencesExported(true); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
if ($this->isGranted('ROLE_EXPORT_PAYMENT_ORDERS_REFERENCES')) { |
122
|
|
|
//Flush changes |
123
|
|
|
$this->entityManager->flush(); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
return ZIPBinaryFileResponseFacade::createZIPResponseFromFiles( |
127
|
|
|
$data, |
128
|
|
|
'Belege_'.date('Y-m-d_H-i-s').'.zip'); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function configureCrud(Crud $crud): Crud |
132
|
|
|
{ |
133
|
|
|
return $crud |
134
|
|
|
->setEntityLabelInSingular('payment_order.label') |
135
|
|
|
->setEntityLabelInPlural('payment_order.labelp') |
136
|
|
|
->setSearchFields(['id', 'first_name', 'last_name', 'project_name', 'funding_id', 'contact_email', 'amount', 'comment', 'bank_info.account_owner', 'bank_info.street', 'bank_info.zip_code', 'bank_info.city', 'bank_info.iban', 'bank_info.bic', 'bank_info.bank_name', 'bank_info.reference']); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function configureFilters(Filters $filters): Filters |
140
|
|
|
{ |
141
|
|
|
return $filters |
142
|
|
|
->add(EntityFilter::new('department', 'payment_order.department.label')) |
143
|
|
|
->add(DepartmentTypeFilter::new('department_type', 'payment_order.department_type.label')) |
144
|
|
|
->add(MoneyAmountFilter::new('amount', 'payment_order.amount.label')) |
145
|
|
|
->add(BooleanFilter::new('factually_correct', 'payment_order.factually_correct.label')) |
146
|
|
|
->add(BooleanFilter::new('exported', 'payment_order.exported.label')) |
147
|
|
|
->add(BooleanFilter::new('mathematically_correct', 'payment_order.mathematically_correct.label')) |
148
|
|
|
->add(ConfirmedFilter::new('confirmed', 'payment_order.confirmed.label')) |
149
|
|
|
->add(TextFilter::new('funding_id', 'payment_order.funding_id.label')) |
150
|
|
|
->add(DateTimeFilter::new('creation_date', 'creation_date')) |
151
|
|
|
->add(DateTimeFilter::new('last_modified', 'last_modified')) |
152
|
|
|
->add(DateTimeFilter::new('booking_date', 'payment_order.booking_date.label')) |
153
|
|
|
->add(BooleanFilter::new('references_exported', 'payment_order.references_exported.label')) |
154
|
|
|
; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Handler for action if user click "resend" button in admin page. |
159
|
|
|
*/ |
160
|
|
|
public function resendConfirmationEmail(AdminContext $context): Response |
161
|
|
|
{ |
162
|
|
|
$this->denyAccessUnlessGranted('ROLE_EDIT_PAYMENT_ORDERS'); |
163
|
|
|
$payment_order = $context->getEntity() |
164
|
|
|
->getInstance(); |
165
|
|
|
|
166
|
|
|
$this->confirmationEmailSender->resendConfirmations($payment_order); |
167
|
|
|
|
168
|
|
|
$this->addFlash('success', 'payment_order.action.resend_confirmation.success'); |
169
|
|
|
|
170
|
|
|
return $this->redirect($context->getReferrer() ?? '/admin'); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Handler for action if user click "check mathematically" button in admin page. |
175
|
|
|
*/ |
176
|
|
|
public function checkMathematicallyCorrect(AdminContext $context): Response |
177
|
|
|
{ |
178
|
|
|
$this->denyAccessUnlessGranted('ROLE_PO_MATHEMATICALLY'); |
179
|
|
|
|
180
|
|
|
/** @var PaymentOrder $payment_order */ |
181
|
|
|
$payment_order = $context->getEntity() |
182
|
|
|
->getInstance(); |
183
|
|
|
$payment_order->setMathematicallyCorrect(true); |
184
|
|
|
$this->entityManager->flush(); |
185
|
|
|
$this->addFlash('success', 'payment_order.action.mathematically_correct.success'); |
186
|
|
|
|
187
|
|
|
return $this->redirect($context->getReferrer() ?? '/admin'); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Handler for action if user click "check factually" button in admin page. |
192
|
|
|
*/ |
193
|
|
|
public function checkFactuallyCorrect(AdminContext $context): Response |
194
|
|
|
{ |
195
|
|
|
$this->denyAccessUnlessGranted('ROLE_PO_FACTUALLY'); |
196
|
|
|
|
197
|
|
|
/** @var PaymentOrder $payment_order */ |
198
|
|
|
$payment_order = $context->getEntity() |
199
|
|
|
->getInstance(); |
200
|
|
|
$payment_order->setFactuallyCorrect(true); |
201
|
|
|
$this->entityManager->flush(); |
202
|
|
|
$this->addFlash('success', 'payment_order.action.factually_correct.success'); |
203
|
|
|
|
204
|
|
|
return $this->redirect($context->getReferrer() ?? '/admin'); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
public function configureAssets(Assets $assets): Assets |
208
|
|
|
{ |
209
|
|
|
return $assets |
210
|
|
|
->addJsFile('js/admin/apply_row_color.js'); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
public function configureActions(Actions $actions): Actions |
214
|
|
|
{ |
215
|
|
|
if ($this->isGranted('ROLE_EXPORT_PAYMENT_ORDERS')) { |
216
|
|
|
// Button with text and icon |
217
|
|
|
$actions->addBatchAction(Action::new('sepaXMLExport', 'payment_order.action.export_xml') |
218
|
|
|
->linkToCrudAction('sepaXMLExport') |
219
|
|
|
->addCssClass('btn btn-primary') |
220
|
|
|
->setHtmlAttributes([ |
221
|
|
|
/*'onclick' => '$("#modal-batch-action").on("shown.bs.modal", function(e){ |
222
|
|
|
$("#modal-batch-action").addClass("d-none"); |
223
|
|
|
$("#modal-batch-action-button").trigger("click"); |
224
|
|
|
});'*/ |
225
|
|
|
//Very ugly hack to skip the confirmation dialog. |
226
|
|
|
'onclick' => ' |
227
|
|
|
let $actionElement = $(this); |
228
|
|
|
$("#modal-batch-action").addClass("d-none"); |
229
|
|
|
$actionElement.off("click"); |
230
|
|
|
|
231
|
|
|
const actionName = $actionElement.attr("data-action-name"); |
232
|
|
|
const selectedItems = $("input[type=\'checkbox\'].form-batch-checkbox:checked"); |
233
|
|
|
|
234
|
|
|
$form = document.createElement("form"); |
235
|
|
|
$form.setAttribute("action", $actionElement.attr("data-action-url")); |
236
|
|
|
$form.setAttribute("method", "POST"); |
237
|
|
|
|
238
|
|
|
$actionNameInput = document.createElement("input"); |
239
|
|
|
$actionNameInput.setAttribute("type", "hidden"); |
240
|
|
|
$actionNameInput.setAttribute("name", "batchActionName"); |
241
|
|
|
$actionNameInput.setAttribute("value", $actionElement.attr("data-action-name")); |
242
|
|
|
$form.appendChild($actionNameInput); |
243
|
|
|
|
244
|
|
|
$entityFqcnInput = document.createElement("input"); |
245
|
|
|
$entityFqcnInput.setAttribute("type", "hidden"); |
246
|
|
|
$entityFqcnInput.setAttribute("name", "entityFqcn"); |
247
|
|
|
$entityFqcnInput.setAttribute("value", $actionElement.attr("data-entity-fqcn")); |
248
|
|
|
$form.appendChild($entityFqcnInput); |
249
|
|
|
|
250
|
|
|
$actionUrlInput = document.createElement("input"); |
251
|
|
|
$actionUrlInput.setAttribute("type", "hidden"); |
252
|
|
|
$actionUrlInput.setAttribute("name", "batchActionUrl"); |
253
|
|
|
$actionUrlInput.setAttribute("value", $actionElement.attr("data-action-url")); |
254
|
|
|
$form.appendChild($actionUrlInput); |
255
|
|
|
|
256
|
|
|
$csrfTokenInput = document.createElement("input"); |
257
|
|
|
$csrfTokenInput.setAttribute("type", "hidden"); |
258
|
|
|
$csrfTokenInput.setAttribute("name", "batchActionCsrfToken"); |
259
|
|
|
$csrfTokenInput.setAttribute("value", $actionElement.attr("data-action-csrf-token")); |
260
|
|
|
$form.appendChild($csrfTokenInput); |
261
|
|
|
|
262
|
|
|
selectedItems.each((i, item) => { |
263
|
|
|
$entityIdInput = document.createElement("input"); |
264
|
|
|
$entityIdInput.setAttribute("type", "hidden"); |
265
|
|
|
$entityIdInput.setAttribute("name", `batchActionEntityIds[${i}]`); |
266
|
|
|
$entityIdInput.setAttribute("value", item.value); |
267
|
|
|
$form.appendChild($entityIdInput); |
268
|
|
|
}); |
269
|
|
|
|
270
|
|
|
document.body.appendChild($form); |
271
|
|
|
|
272
|
|
|
//modalTitle.text(titleContentWithPlaceholders); |
273
|
|
|
$form.submit(); |
274
|
|
|
' |
275
|
|
|
]) |
276
|
|
|
->setIcon('fas fa-file-export') |
277
|
|
|
); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
//if ($this->isGranted('ROLE_EXPORT_PAYMENT_ORDERS_REFERENCES')) { |
281
|
|
|
$actions->addBatchAction(Action::new('referencesExport', 'payment.order.action.export.export_references') |
282
|
|
|
->linkToCrudAction('referencesExport') |
283
|
|
|
->addCssClass('btn btn-primary') |
284
|
|
|
->setIcon('fas fa-file-invoice') |
285
|
|
|
); |
286
|
|
|
//} |
287
|
|
|
|
288
|
|
|
$actions->setPermissions([ |
289
|
|
|
Action::INDEX => 'ROLE_SHOW_PAYMENT_ORDERS', |
290
|
|
|
Action::DETAIL => 'ROLE_SHOW_PAYMENT_ORDERS', |
291
|
|
|
Action::EDIT => 'ROLE_EDIT_PAYMENT_ORDERS', |
292
|
|
|
Action::DELETE => 'ROLE_EDIT_PAYMENT_ORDERS', |
293
|
|
|
Action::NEW => 'ROLE_EDIT_PAYMENT_ORDERS', |
294
|
|
|
]); |
295
|
|
|
|
296
|
|
|
$emailAction = Action::new('sendEmail', 'payment_order.action.email', 'fas fa-envelope') |
297
|
|
|
->linkToUrl(function (PaymentOrder $paymentOrder) { |
298
|
|
|
return $this->mailToGenerator->generateContactMailLink($paymentOrder); |
299
|
|
|
}) |
300
|
|
|
->setCssClass('text-dark'); |
301
|
|
|
|
302
|
|
|
//Hide action if no contact emails are associated with department |
303
|
|
|
$emailAction->displayIf(function (PaymentOrder $paymentOrder) { |
304
|
|
|
return null !== $this->mailToGenerator->generateContactMailLink($paymentOrder); |
305
|
|
|
}); |
306
|
|
|
|
307
|
|
|
$hhv_action = Action::new('contactHHV', 'payment_order.action.contact_hhv', 'fas fa-comment-dots') |
308
|
|
|
->linkToUrl(function (PaymentOrder $paymentOrder) { |
309
|
|
|
return $this->mailToGenerator->getHHVMailLink($paymentOrder); |
310
|
|
|
}) |
311
|
|
|
->setCssClass('mr-2 text-dark'); |
312
|
|
|
|
313
|
|
|
$resend_confirmation_action = Action::new('resendConfirmation', 'payment_order.action.resend_confirmation', 'fas fa-redo') |
314
|
|
|
->linkToCrudAction('resendConfirmationEmail') |
315
|
|
|
->displayIf(function (PaymentOrder $paymentOrder) { |
316
|
|
|
return $this->isGranted('ROLE_EDIT_PAYMENT_ORDERS') && !$paymentOrder->isConfirmed(); |
317
|
|
|
}) |
318
|
|
|
->setCssClass('mr-2 text-dark'); |
319
|
|
|
|
320
|
|
|
$mathematically_correct_action = Action::new('mathematicallyCorrect', 'payment_order.action.mathematically_correct', 'fas fa-check') |
321
|
|
|
->linkToCrudAction('checkMathematicallyCorrect') |
322
|
|
|
->displayIf(function (PaymentOrder $paymentOrder) { |
323
|
|
|
return $this->isGranted('ROLE_PO_MATHEMATICALLY') |
324
|
|
|
&& $paymentOrder->isConfirmed() |
325
|
|
|
&& !$paymentOrder->isMathematicallyCorrect(); |
326
|
|
|
}) |
327
|
|
|
->setCssClass('mr-2 btn btn-success'); |
328
|
|
|
|
329
|
|
|
$factually_correct_action = Action::new('factuallyCorrect', 'payment_order.action.factually_correct', 'fas fa-check') |
330
|
|
|
->linkToCrudAction('checkFactuallyCorrect') |
331
|
|
|
->displayIf(function (PaymentOrder $paymentOrder) { |
332
|
|
|
return $this->isGranted('ROLE_PO_FACTUALLY') |
333
|
|
|
&& $paymentOrder->isConfirmed() |
334
|
|
|
&& !$paymentOrder->isFactuallyCorrect() |
335
|
|
|
&& $paymentOrder->isMathematicallyCorrect(); |
336
|
|
|
}) |
337
|
|
|
->setCssClass('mr-2 btn btn-success'); |
338
|
|
|
|
339
|
|
|
$manual_confirmation = Action::new('manual_confirmation', 'payment_order.action.manual_confirmation', 'fas fa-exclamation-triangle') |
340
|
|
|
->setCssClass('mr-1 text-dark') |
341
|
|
|
->linkToRoute('payment_order_manual_confirm', function (PaymentOrder $paymentOrder) { |
342
|
|
|
return [ |
343
|
|
|
'id' => $paymentOrder->getId(), |
344
|
|
|
]; |
345
|
|
|
}) |
346
|
|
|
->displayIf(function (PaymentOrder $paymentOrder) { |
347
|
|
|
return $this->isGranted('ROLE_MANUAL_CONFIRMATION') |
348
|
|
|
&& !$paymentOrder->isConfirmed(); |
349
|
|
|
}); |
350
|
|
|
|
351
|
|
|
$actions->add(Crud::PAGE_EDIT, $emailAction); |
352
|
|
|
$actions->add(Crud::PAGE_DETAIL, $emailAction); |
353
|
|
|
|
354
|
|
|
$actions->add(Crud::PAGE_EDIT, $hhv_action); |
355
|
|
|
$actions->add(Crud::PAGE_DETAIL, $hhv_action); |
356
|
|
|
|
357
|
|
|
$actions->disable(Crud::PAGE_NEW); |
358
|
|
|
|
359
|
|
|
$actions->add(Crud::PAGE_DETAIL, $resend_confirmation_action); |
360
|
|
|
$actions->add(Crud::PAGE_EDIT, $resend_confirmation_action); |
361
|
|
|
|
362
|
|
|
$actions->add(Crud::PAGE_DETAIL, $mathematically_correct_action); |
363
|
|
|
$actions->add(Crud::PAGE_DETAIL, $factually_correct_action); |
364
|
|
|
|
365
|
|
|
$actions->add(Crud::PAGE_DETAIL, $manual_confirmation); |
366
|
|
|
$actions->add(Crud::PAGE_EDIT, $manual_confirmation); |
367
|
|
|
|
368
|
|
|
return $actions->add(Crud::PAGE_INDEX, Action::DETAIL); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
public function configureFields(string $pageName): iterable |
372
|
|
|
{ |
373
|
|
|
//Documents |
374
|
|
|
$documentsPanel = FormField::addPanel('payment_order.group.documents'); |
375
|
|
|
$printed_form = VichyFileField::new('printed_form_file', 'payment_order.printed_form.label'); |
376
|
|
|
$references = VichyFileField::new('references_file', 'payment_order.references.label'); |
377
|
|
|
|
378
|
|
|
//Basic informations |
379
|
|
|
$infoPanel = FormField::addPanel('payment_order.group.info'); |
380
|
|
|
$id = IntegerField::new('id', 'payment_order.id.label'); |
381
|
|
|
$firstName = TextField::new('first_name', 'payment_order.first_name.label'); |
382
|
|
|
$lastName = TextField::new('last_name', 'payment_order.last_name.label'); |
383
|
|
|
$contact_email = EmailField::new('contact_email', 'payment_order.contact_email.label') |
384
|
|
|
->setFormTypeOption('empty_data', '') |
385
|
|
|
->setRequired(false); |
386
|
|
|
|
387
|
|
|
if (Crud::PAGE_INDEX === $pageName) { |
388
|
|
|
$tmp = 'payment_order.department.label_short'; |
389
|
|
|
} else { |
390
|
|
|
$tmp = 'payment_order.department.label'; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
$department = AssociationField::new('department', $tmp) |
394
|
|
|
->setFormTypeOption('attr', [ |
395
|
|
|
'data-widget' => 'select2', |
396
|
|
|
]); |
397
|
|
|
|
398
|
|
|
$amount = MoneyField::new('amount', 'payment_order.amount.label') |
399
|
|
|
->setCurrency('EUR') |
400
|
|
|
->setStoredAsCents(true); |
401
|
|
|
$projectName = TextField::new('project_name', 'payment_order.project_name.label'); |
402
|
|
|
$funding_id = TextField::new('funding_id', 'payment_order.funding_id.label') |
403
|
|
|
->setRequired(false) |
404
|
|
|
->setFormTypeOption('empty_data', ''); |
405
|
|
|
//Use short name for index |
406
|
|
|
$funding_id_index = TextField::new('funding_id', 'payment_order.funding_id.label_short') |
407
|
|
|
->setHelp('payment_order.funding_id.label'); |
408
|
|
|
$fsr_kom = BooleanField::new('fsr_kom_resolution', 'payment_order.fsr_kom.label') |
409
|
|
|
->setRequired(false); |
410
|
|
|
$resolution_date = DateField::new('resolution_date', 'payment_order.resolution_date.label') |
411
|
|
|
->setRequired(false); |
412
|
|
|
$comment = TextEditorField::new('comment', 'payment_order.comment.label') |
413
|
|
|
->setRequired(false) |
414
|
|
|
->setFormTypeOption('empty_data', ''); |
415
|
|
|
$lastModified = DateTimeField::new('last_modified', 'last_modified'); |
416
|
|
|
$creationDate = DateTimeField::new('creation_date', 'creation_date') |
417
|
|
|
->setTemplatePath('admin/field/datetime_overdue_hint.html.twig'); |
418
|
|
|
//$creationDate = TextField::new('creation_date', 'creation_date'); |
419
|
|
|
|
420
|
|
|
//Status informations |
421
|
|
|
$statusPanel = FormField::addPanel('payment_order.group.status'); |
422
|
|
|
$mathematicallyCorrect = BooleanField::new('mathematically_correct', 'payment_order.mathematically_correct.label') |
423
|
|
|
->setHelp('payment_order.mathematically_correct.help') |
424
|
|
|
//Disable fields (and show coloumns as read only tags) if user does not have proper permissions to change |
425
|
|
|
//factually and mathematically correct status |
426
|
|
|
->setFormTypeOption('disabled', !$this->isGranted('ROLE_PO_MATHEMATICALLY')) |
427
|
|
|
->renderAsSwitch($this->isGranted('ROLE_PO_MATHEMATICALLY')); |
428
|
|
|
$exported = BooleanField::new('exported', 'payment_order.exported.label') |
429
|
|
|
->setHelp('payment_order.exported.help'); |
430
|
|
|
$factuallyCorrect = BooleanField::new('factually_correct', 'payment_order.factually_correct.label') |
431
|
|
|
->setHelp('payment_order.factually_correct.help') |
432
|
|
|
->setFormTypeOption('disabled', !$this->isGranted('ROLE_PO_FACTUALLY')) |
433
|
|
|
->renderAsSwitch($this->isGranted('ROLE_PO_FACTUALLY')); |
434
|
|
|
$booking_date = DateTimeField::new('booking_date', 'payment_order.booking_date.label'); |
435
|
|
|
$confirmed_1 = DateTimeField::new('confirm1_timestamp', 'payment_order.confirmed_1.label'); |
436
|
|
|
$confirmed_2 = DateTimeField::new('confirm2_timestamp', 'payment_order.confirmed_2.label'); |
437
|
|
|
$references_exported = BooleanField::new('references_exported', 'payment_order.references_exported.label'); |
438
|
|
|
|
439
|
|
|
//Payee informations |
440
|
|
|
$payeePanel = FormField::addPanel('payment_order.group.receiver'); |
441
|
|
|
$bankInfoAccountOwner = TextField::new('bank_info.account_owner', 'bank_info.account_owner.label'); |
442
|
|
|
$bankInfoStreet = TextField::new('bank_info.street', 'bank_info.street.label'); |
443
|
|
|
$bankInfoZipCode = TextField::new('bank_info.zip_code', 'bank_info.zip_code.label'); |
444
|
|
|
$bankInfoCity = TextField::new('bank_info.city', 'bank_info.city.label'); |
445
|
|
|
|
446
|
|
|
//Payee bank account infos |
447
|
|
|
$bankInfoPanel = FormField::addPanel('payment_order.group.bank_info'); |
448
|
|
|
$bankInfoIban = TextField::new('bank_info.iban', 'bank_info.iban.label'); |
449
|
|
|
$bankInfoBic = TextField::new('bank_info.bic', 'bank_info.bic.label') |
450
|
|
|
->setRequired(false) |
451
|
|
|
->setFormTypeOption('empty_data', ''); |
452
|
|
|
$bankInfoBankName = TextField::new('bank_info.bank_name', 'bank_info.bank_name.label'); |
453
|
|
|
$bankInfoReference = TextField::new('bank_info.reference', 'bank_info.reference.label') |
454
|
|
|
->setRequired(false) |
455
|
|
|
->setFormTypeOption('empty_data', ''); |
456
|
|
|
|
457
|
|
|
if (Crud::PAGE_INDEX === $pageName) { |
458
|
|
|
return [$id, $projectName, $department, $amount, $mathematicallyCorrect, $factuallyCorrect, $funding_id_index, $creationDate]; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
if (Crud::PAGE_DETAIL === $pageName) { |
462
|
|
|
return [ |
463
|
|
|
//Documents section |
464
|
|
|
$documentsPanel, |
465
|
|
|
$printed_form, |
466
|
|
|
$references, |
467
|
|
|
//Basic informations |
468
|
|
|
$infoPanel, |
469
|
|
|
$id, |
470
|
|
|
$firstName, |
471
|
|
|
$lastName, |
472
|
|
|
$contact_email, |
473
|
|
|
$projectName, |
474
|
|
|
$department, |
475
|
|
|
$amount, |
476
|
|
|
$funding_id, |
477
|
|
|
$resolution_date, |
478
|
|
|
$fsr_kom, |
479
|
|
|
$comment, |
480
|
|
|
$lastModified, |
481
|
|
|
$creationDate, |
482
|
|
|
//Status infos |
483
|
|
|
$statusPanel, |
484
|
|
|
$mathematicallyCorrect, |
485
|
|
|
$exported, |
486
|
|
|
$factuallyCorrect, |
487
|
|
|
$booking_date, |
488
|
|
|
$confirmed_1, |
489
|
|
|
$confirmed_2, |
490
|
|
|
//Payee informations |
491
|
|
|
$payeePanel, |
492
|
|
|
$bankInfoAccountOwner, |
493
|
|
|
$bankInfoStreet, |
494
|
|
|
$bankInfoZipCode, |
495
|
|
|
$bankInfoCity, |
496
|
|
|
//Banking informations |
497
|
|
|
$bankInfoPanel, |
498
|
|
|
$bankInfoIban, |
499
|
|
|
$bankInfoBic, |
500
|
|
|
$bankInfoBankName, |
501
|
|
|
$bankInfoReference, |
502
|
|
|
]; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
if (Crud::PAGE_EDIT === $pageName) { |
506
|
|
|
return [ |
507
|
|
|
//Documents section |
508
|
|
|
$documentsPanel, |
509
|
|
|
$printed_form, |
510
|
|
|
$references, |
511
|
|
|
//Basic informations |
512
|
|
|
$infoPanel, |
513
|
|
|
$firstName, |
514
|
|
|
$lastName, |
515
|
|
|
$contact_email, |
516
|
|
|
$projectName, |
517
|
|
|
$department, |
518
|
|
|
$amount, |
519
|
|
|
$funding_id, |
520
|
|
|
$resolution_date, |
521
|
|
|
$fsr_kom, |
522
|
|
|
$comment, |
523
|
|
|
//Status infos |
524
|
|
|
$statusPanel, |
525
|
|
|
$mathematicallyCorrect, |
526
|
|
|
$exported, |
527
|
|
|
$factuallyCorrect, |
528
|
|
|
$references_exported, |
529
|
|
|
//Payee informations |
530
|
|
|
$payeePanel, |
531
|
|
|
$bankInfoAccountOwner, |
532
|
|
|
$bankInfoStreet, |
533
|
|
|
$bankInfoZipCode, |
534
|
|
|
$bankInfoCity, |
535
|
|
|
//Banking informations |
536
|
|
|
$bankInfoPanel, |
537
|
|
|
$bankInfoIban, |
538
|
|
|
$bankInfoBic, |
539
|
|
|
$bankInfoBankName, |
540
|
|
|
$bankInfoReference, |
541
|
|
|
]; |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
throw new RuntimeException('It should not be possible to reach this point...'); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
public function deleteEntity(EntityManagerInterface $entityManager, $entityInstance): void |
548
|
|
|
{ |
549
|
|
|
/** @var PaymentOrder $entityInstance */ |
550
|
|
|
//Forbit delete process if PaymentOrder was already exported or booked |
551
|
|
|
if ($entityInstance->isExported() |
552
|
|
|
|| null != $entityInstance->getBookingDate()) { |
553
|
|
|
$this->addFlash('warning', 'payment_order.flash.can_not_delete_checked_payment_order'); |
554
|
|
|
|
555
|
|
|
return; |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
parent::deleteEntity($entityManager, $entityInstance); |
559
|
|
|
} |
560
|
|
|
} |
561
|
|
|
|