Berichte create report from preview

This commit is contained in:
OpenXE 2024-01-19 10:02:27 +01:00
parent 567976ecda
commit 169a5c34c5
2 changed files with 50 additions and 9 deletions

View File

@ -53,9 +53,19 @@
<div class="row" id="report_list_main">
<div class="row-height">
<div class="col-xs-12 col-sm-10 col-sm-height">
<legend>
<legend style="float:left">
Tabelle&nbsp;[TABLENAME]
</legend>
<form method="post" action="#tabs-3">
<fieldset style="float: right;">
<input type="text" name="table" value="[TABLENAME]" hidden></input>
<table width="100%" border="0" class="mkTableFormular">
<tr>
<td><button name="submit" value="erzeugen" class="ui-button-icon" style="width:100%;float:right;">Bericht erzeugen</button></td>
</tr>
</table>
</fieldset>
</form>
<div>
[TAB3]
</div>

View File

@ -542,6 +542,7 @@ class Report
}
$heading = $columns;
$heading[] = '';
$findcols = $columns;
$searchsql = $columns;
@ -3232,6 +3233,7 @@ class Report
if (!empty($selectedtable)) {
$this->app->User->SetParameter('report_databaseview_selectedtable',$selectedtable);
$submit = $this->app->Secure->GetPost('submit');
$selectedcolumns = $this->app->Secure->GetPost('auswahl');
$sql = "SHOW COLUMNS FROM `".$selectedtable."`";
@ -3245,7 +3247,6 @@ class Report
$checked = 'checked';
}
}
$row = array();
$row[] = '<input type="checkbox" name="auswahl[]" '.$checked.' value="'.$column['Field'].'">';
$row = array_merge($row,$column);
@ -3254,12 +3255,42 @@ class Report
$column_easytable->DisplayNew('TAB2');
$this->app->Tpl->Set('TABLENAME',ucfirst($selectedtable));
switch($submit) {
case 'vorschau':
if (!empty($selectedcolumns)) {
$this->app->User->SetParameter('report_databaseview_selectedcolumns',implode(',',$selectedcolumns));
} else {
$this->app->YUI->Message('warning','Spalten w&auml;hlen');
}
$this->app->YUI->TableSearch('TAB3', 'databaseview', 'show', '', '', basename(__FILE__), __CLASS__);
break;
case 'erzeugen':
$selectedcolumns = $this->app->User->GetParameter('report_databaseview_selectedcolumns');
$columns = explode(',',$selectedcolumns);
$sql = "SELECT `".implode("`,`",$columns)."` from `".$selectedtable."`";
$name = $this->service->generateIncrementedReportName(ucfirst($selectedtable));
$userId = $this->app->User->GetID();
$report = ReportData::fromFormData(['name' => $name, 'sql_query' => $sql, 'description' => 'Erzeugt aus Datenbankansicht Tabelle '.ucfirst($selectedtable)]);
$newId = $this->service->saveReport($report);
if ($newId > 0) {
$this->service->saveReportUserArray([
'report_id' => $newId,
'user_id' => $userId,
'name' => $this->app->User->GetName(),
'chart_enabled' => 0,
'file_enabled' => 0,
'menu_enabled' => 0,
'tab_enabled' => 0,
]);
$report = $this->gateway->getReportById($newId);
$newReport = $this->service->autoCreateColumns($report);
$newId = $this->service->saveReport($newReport);
header('Location: index.php?module=report&action=edit&id='.$newId);
} else {
$this->app->YUI->Message('error','Bericht konnte nicht erzeugt werden');
}
break;
}
} else {
$this->app->YUI->Message('warning','Tabelle w&auml;hlen');
}