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