From 0e0b6a666d48301797046259b0db6f227385199f Mon Sep 17 00:00:00 2001 From: Jonada Date: Tue, 2 Aug 2022 16:28:12 +0200 Subject: [PATCH] ScheduleForm: Add `Send Report Now` button --- library/Reporting/Web/Forms/ScheduleForm.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/library/Reporting/Web/Forms/ScheduleForm.php b/library/Reporting/Web/Forms/ScheduleForm.php index 47f3ee30..2266e7a9 100644 --- a/library/Reporting/Web/Forms/ScheduleForm.php +++ b/library/Reporting/Web/Forms/ScheduleForm.php @@ -6,11 +6,13 @@ use DateTime; use Icinga\Application\Version; use Icinga\Authentication\Auth; +use Icinga\Module\Reporting\Actions\SendMail; use Icinga\Module\Reporting\Database; use Icinga\Module\Reporting\ProvidedActions; use Icinga\Module\Reporting\Report; use Icinga\Module\Reporting\Web\Flatpickr; use Icinga\Module\Reporting\Web\Forms\Decorator\CompatDecorator; +use Icinga\Web\Notification; use ipl\Html\Contract\FormSubmitElement; use ipl\Html\Form; use ipl\Web\Compat\CompatForm; @@ -132,6 +134,20 @@ protected function assemble() return; } + + $sendButton = $this->createElement('submit', 'send', [ + 'label' => 'Send Report Now', + 'formnovalidate' => true + ]); + + $this->registerElement($sendButton); + $this->getElement('submit')->getWrapper()->prepend($sendButton); + + if ($sendButton->hasBeenPressed()) { + $sendMail = new SendMail(); + $sendMail->execute($this->report, $this->getValues()); + Notification::success('Report sent successfully'); + } } }