Merge branch 'develop'
This commit is contained in:
commit
b507bfca79
4 changed files with 120 additions and 1 deletions
|
|
@ -118,6 +118,19 @@ class ExpenseReportAdminController extends CrudController
|
|||
|
||||
$route = 'admin_expense_report_paid';
|
||||
$tokenName = 'paid';
|
||||
|
||||
$form2 = $this->createFormBuilder()
|
||||
->add('message', TextareaType::class, [
|
||||
'required' => false,
|
||||
'label' => 'Message',
|
||||
'help' => 'Message à ajouter dans le mail de notification (optionnel)',
|
||||
])
|
||||
->getForm()
|
||||
->createView()
|
||||
;
|
||||
|
||||
$route2 = 'admin_expense_report_missing_proofs';
|
||||
$tokenName2 = 'missingProofs';
|
||||
}
|
||||
|
||||
if (isset($form)) {
|
||||
|
|
@ -128,6 +141,14 @@ class ExpenseReportAdminController extends CrudController
|
|||
;
|
||||
}
|
||||
|
||||
if (isset($form2)) {
|
||||
$this->getConfiguration()
|
||||
->addViewData('edit', 'mail2FormRoute', $route2)
|
||||
->addViewData('edit', 'mail2FormTokenName', $tokenName2)
|
||||
->addViewData('edit', 'mail2Form', $form2)
|
||||
;
|
||||
}
|
||||
|
||||
return $this->doEdit($entity, $entityManager, $request, [$this, 'beforeUpdate']);
|
||||
}
|
||||
|
||||
|
|
@ -222,6 +243,41 @@ class ExpenseReportAdminController extends CrudController
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/admin/expense_report/missing_proofs/{entity}/{token}", name="admin_expense_report_missing_proofs", methods={"POST"})
|
||||
*/
|
||||
public function missingProofs(
|
||||
Entity $entity,
|
||||
string $token,
|
||||
EntityManager $entityManager,
|
||||
Request $request,
|
||||
EventDispatcherInterface $eventDispatcher
|
||||
): Response {
|
||||
if (!$this->isGranted('ROLE_TREASURER')) {
|
||||
throw $this->createAccessDeniedException();
|
||||
}
|
||||
|
||||
if (!$this->isCsrfTokenValid('missingProofs', $token)) {
|
||||
throw $this->createAccessDeniedException();
|
||||
}
|
||||
|
||||
$message = $request->request->get('form')['message'] ?? null;
|
||||
$entity->setIsRequestedPayment(false);
|
||||
|
||||
$entityManager->update($entity);
|
||||
|
||||
$eventDispatcher->dispatch(new EntityManagerEvent($entity, [
|
||||
'message' => $message,
|
||||
'user' => $this->getUser(),
|
||||
]), 'expense_report.missing_proofs');
|
||||
|
||||
$this->addFlash('success', 'The data has been saved.');
|
||||
|
||||
return $this->redirectToRoute('admin_expense_report_edit', [
|
||||
'entity' => $entity->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function beforeUpdate(EntityInterface $entity, FormInterface $form, Request $request)
|
||||
{
|
||||
$deleteBills = $request->request->get($form->getName())['deleteBills']['bills'] ?? [];
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class ExpenseReportEventSubscriber extends EntityManagerEventSubscriber
|
|||
return array_merge(parent::getSubscribedEvents(), [
|
||||
'expense_report.requested_payment' => ['onRequestedPayment', self::$priority],
|
||||
'expense_report.paid' => ['onPaid', self::$priority],
|
||||
'expense_report.missing_proofs' => ['onMissingProofs', self::$priority],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -92,6 +93,31 @@ class ExpenseReportEventSubscriber extends EntityManagerEventSubscriber
|
|||
;
|
||||
}
|
||||
|
||||
public function onMissingProofs(EntityManagerEvent $event)
|
||||
{
|
||||
if (!$this->supports($event->getEntity())) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->notifier
|
||||
->setSubject('[Tinternet][NDF] Justificatif(s) manquant(s)')
|
||||
->addRecipient($event->getEntity()->getUser()->getEmail())
|
||||
->addRecipientsByUsers($this->userQuery->where('.isTreasurer = true')->find(), true)
|
||||
->notify('mail/expense_report/missing_proofs.html.twig', [
|
||||
'entity' => $event->getEntity(),
|
||||
'message' => $event->getParams()['message'],
|
||||
'user' => $event->getParams()['user'],
|
||||
'show_url' => $this->urlGenerator->generate(
|
||||
'admin_expense_report_edit',
|
||||
[
|
||||
'entity' => $event->getEntity()->getId(),
|
||||
],
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function onPreCreate(EntityManagerEvent $event)
|
||||
{
|
||||
if (!$this->supports($event->getEntity())) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
<span class="btn btn-success" data-toggle="modal" data-target="#notification">
|
||||
Définir comme payée
|
||||
</span>
|
||||
|
||||
<span class="btn btn-warning" data-toggle="modal" data-target="#notification2">
|
||||
Justificatif(s) manquant(s)
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
@ -53,4 +57,37 @@
|
|||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% set mail2FormRoute = configuration.viewData(context, 'mail2FormRoute') %}
|
||||
{% set mail2FormTokenName = configuration.viewData(context, 'mail2FormTokenName') %}
|
||||
{% set mail2Form = configuration.viewData(context, 'mail2Form') %}
|
||||
|
||||
{% if mail2FormRoute %}
|
||||
<form action="{{ path(mail2FormRoute, {entity: entity.id, token: csrf_token(mail2FormTokenName)}) }}" method="POST">
|
||||
<div class="modal modal-static" tabindex="-1" id="notification2">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Notification</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-warning">
|
||||
Attention, si vous avez modifié la note de frais sans avoir enregistré,
|
||||
les données ne seront pas conservées.
|
||||
</div>
|
||||
|
||||
{{ form(mail2Form) }}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Close'|trans }}</button>
|
||||
<button type="submit" class="btn btn-primary">{{ 'Submit'|trans }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<img src="{{ absolute_url(asset('build/images/tinternet.png')) }}" alt="Tinternet & Cie" width="50">
|
||||
</p>
|
||||
|
||||
<p style="text-align: center; font-size: 20px">Le paiement pour la <a href="{{ show_url }}">note de frais #{{ entity.id }}</a> a été réalisé ☺️</p>
|
||||
<p style="text-align: center; font-size: 20px">{{ user.displayName }} indique qu'un ou plusieurs justificatifs sont manquants pour payer la <a href="{{ show_url }}">note de frais #{{ entity.id }}</a> 🔔.</p>
|
||||
|
||||
{% if message %}
|
||||
<p style="text-align: center"><strong>Message de {{ user.displayName }}</strong> :</p>
|
||||
Loading…
Add table
Add a link
Reference in a new issue