Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions library/Reporting/Web/Forms/ScheduleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand All @@ -39,7 +40,6 @@ class ScheduleForm extends CompatForm
public static function fromReport(Report $report): self
{
$form = new static();

$form->report = $report;

$schedule = $report->getSchedule();
Expand Down Expand Up @@ -73,7 +73,11 @@ public function setId(int $id): ScheduleForm

public function hasBeenSubmitted(): bool
{
return $this->hasBeenSent() && ($this->getPopulatedValue('submit') || $this->getPopulatedValue('remove'));
return $this->hasBeenSent() && (
$this->getPopulatedValue('submit')
|| $this->getPopulatedValue('remove')
|| $this->getPopulatedValue('send')
);
}

protected function assemble()
Expand Down Expand Up @@ -136,6 +140,13 @@ protected function assemble()
]);

if ($this->id !== null) {
$sendButton = $this->createElement('submit', 'send', [
'label' => $this->translate('Send Report Now'),
'formnovalidate' => true
]);
$this->registerElement($sendButton);
$this->getElement('submit')->getWrapper()->prepend($sendButton);

/** @var FormSubmitElement $removeButton */
$removeButton = $this->createElement('submit', 'remove', [
'label' => $this->translate('Remove Schedule'),
Expand All @@ -158,6 +169,14 @@ public function onSuccess()
}

$values = $this->getValues();
if ($this->getPopulatedValue('send')) {
$action = new $values['action']();
$action->execute($this->report, $values);

Notification::success($this->translate('Report sent successfully'));

return;
}

$now = time() * 1000;

Expand Down