Skip to content

Commit 1be357a

Browse files
author
Timm Ortloff
committed
ReportForm: Fix inserting data
1 parent 981469f commit 1be357a

1 file changed

Lines changed: 12 additions & 31 deletions

File tree

library/Reporting/Web/Forms/ReportForm.php

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use ipl\Html\Contract\FormSubmitElement;
1313
use ipl\Html\Form;
1414
use ipl\Html\FormElement\Collection;
15-
use ipl\Html\FormElement\FieldsetElement;
1615
use ipl\Web\Compat\CompatForm;
1716
use ipl\Web\FormDecorator\IcingaFormDecorator;
1817
use ipl\Web\Widget\Icon;
@@ -86,7 +85,7 @@ protected function assemble()
8685

8786
$collection = (new Collection('reportlet'))
8887
->setLabel('Reportlets')
89-
->setAddElement($this->createElement('select', 'add_reportlet', [
88+
->setAddElement($this->createElement('select', 'reportlet_class', [
9089
'required' => false,
9190
'label' => 'Reportlet',
9291
'options' => [null => 'Please choose'] + $this->listReports(),
@@ -111,7 +110,7 @@ protected function assemble()
111110

112111
$addElement->getWrapper()->ensureAssembled()->add($removeElement);
113112

114-
$reportletClass = $group->getPopulatedValue('add_reportlet');
113+
$reportletClass = $group->getPopulatedValue('reportlet_class');
115114
if (! empty($reportletClass)) {
116115
$config = new Form();
117116

@@ -198,49 +197,31 @@ public function onSuccess()
198197
}
199198
});
200199

201-
if (empty($reportlet['reportlet'])) {
200+
if (empty($reportlet['reportlet_class'])) {
202201
continue;
203202
}
204203

205204
$db->insert('reportlet', [
206205
'report_id' => $reportId,
207-
'class' => $reportlet['reportlet'],
206+
'class' => $reportlet['reportlet_class'],
208207
'ctime' => $now,
209208
'mtime' => $now
210209
]);
211210

212211
$reportletId = $db->lastInsertId();
213212

214213
foreach ($reportlet as $key => $value) {
215-
if ($key === 'reportlet') {
214+
if ($key === 'reportlet_class') {
216215
continue;
217216
}
218217

219-
foreach ($values as $name => $value) {
220-
$db->insert('config', [
221-
'reportlet_id' => $reportletId,
222-
'name' => $name,
223-
'value' => $value,
224-
'ctime' => $now,
225-
'mtime' => $now
226-
]);
227-
228-
$reportletId = $db->lastInsertId();
229-
230-
foreach ($reportlet as $key => $value) {
231-
if ($key === '__class') {
232-
continue;
233-
}
234-
235-
$db->insert('config', [
236-
'reportlet_id' => $reportletId,
237-
'name' => $key,
238-
'value' => $value,
239-
'ctime' => $now,
240-
'mtime' => $now
241-
]);
242-
}
243-
}
218+
$db->insert('config', [
219+
'reportlet_id' => $reportletId,
220+
'name' => $key,
221+
'value' => $value,
222+
'ctime' => $now,
223+
'mtime' => $now
224+
]);
244225
}
245226
}
246227

0 commit comments

Comments
 (0)