Add helper user settings and html export

This commit is contained in:
Dennis Eichhorn 2020-02-10 22:32:50 +01:00
parent 4db59bf6dd
commit 64e90068e1
4 changed files with 37 additions and 11 deletions

View File

@ -132,8 +132,6 @@ final class ApiController extends Controller
. ((string) $request->getData('type'))
. '"'
, true);
$response->getHeader()->set('Content-Type', MimeType::M_XLSX, true);
$response->getHeader()->set('Content-Type', MimeType::M_XLSX, true);
break;
case 'json':
@ -168,8 +166,8 @@ final class ApiController extends Controller
if (StringUtils::endsWith($lowerPath, '.lang.php')) {
$tcoll['lang'] = $tMedia;
} elseif (StringUtils::endsWith($lowerPath, '.cfg.php')) {
$tcoll['cfg'][$tMedia->getName()] = $tMedia;
} elseif (StringUtils::endsWith($lowerPath, '.cfg.json')) {
$tcoll['cfg'] = $tMedia;
} elseif (StringUtils::endsWith($lowerPath, '.xlsx.php')
|| StringUtils::endsWith($lowerPath, '.xls.php')
) {

View File

@ -146,6 +146,8 @@ final class BackendController extends Controller
if (StringUtils::endsWith($lowerPath, '.lang.php')) {
$tcoll['lang'] = $tMedia;
} elseif (StringUtils::endsWith($lowerPath, '.cfg.json')) {
$tcoll['cfg'] = $tMedia;
} elseif (StringUtils::endsWith($lowerPath, 'worker.php')) {
$tcoll['worker'] = $tMedia;
} elseif (StringUtils::endsWith($lowerPath, '.xlsx.php') || StringUtils::endsWith($lowerPath, '.xls.php')) {
@ -197,6 +199,7 @@ final class BackendController extends Controller
$view->addData('rcoll', $rcoll);
}
$view->addData('unit', $this->app->orgId);
$view->addData('tcoll', $tcoll);
$view->addData('lang', $request->getData('lang') ?? $request->getHeader()->getL11n()->getLanguage());
$view->addData('template', $template);

View File

@ -34,6 +34,7 @@ return ['Helper' => [
'IndividualDB' => 'Individual DB',
'Info' => 'Info',
'Language' => 'Language',
'Load' => 'Load',
'Media' => 'Media',
'MediaDirectory' => 'Media Directory',
'Modified' => 'Modified',
@ -42,9 +43,11 @@ return ['Helper' => [
'Other' => 'Other',
'Overview' => 'Overview',
'Permission' => 'Permission',
'Print' => 'Print',
'Report' => 'Report',
'Reports' => 'Reports',
'Select' => 'Select',
'Settings' => 'Settings',
'Source' => 'Source',
'Sources' => 'Sources',
'Standalone' => 'Standalone',

View File

@ -12,6 +12,9 @@
*/
declare(strict_types=1);
use phpOMS\Model\Html\FormElementGenerator;
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
*/
@ -24,19 +27,19 @@ $report = $this->getData('report');
/** @noinspection PhpIncludeInspection */
$reportLanguage = isset($tcoll['lang']) ? include __DIR__ . '/../../../../' . \ltrim($tcoll['lang']->getPath(), '/') : [];
$lang = $reportLanguage[$cLang] ?? [];
$settings = isset($tcoll['cfg']) ? \json_decode(\file_get_contents(__DIR__ . '/../../../../' . \ltrim($tcoll['cfg']->getPath(), '/')), true) : [];
echo $this->getData('nav')->render(); ?>
<div class="row" style="height: calc(100% - 85px);">
<div class="col-xs-12 col-md-9">
<iframe src="<?= \phpOMS\Uri\UriFactory::build('{/api}helper/report/export/?id=' . $template->getId()); ?>" allowfullscreen></iframe>
<iframe src="<?= UriFactory::build('{/api}helper/report/export/?id=' . $template->getId()); ?>&u=<?= $this->getData('unit'); ?>" allowfullscreen></iframe>
</div>
<div class="col-xs-12 col-md-3">
<?php if (\count($reportLanguage) > 1) : ?>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Reports') ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('{/api}helper/template'); ?>" method="post">
<form action="<?= UriFactory::build('{/api}helper/template'); ?>" method="post">
<table class="layout wf-100">
<tbody>
<tr>
@ -57,14 +60,13 @@ echo $this->getData('nav')->render(); ?>
</form>
</div>
</section>
<?php endif; ?>
<?php if (isset($tcoll['excel']) || isset($tcoll['pdf']) || isset($tcoll['word']) || isset($tcoll['powerpoint']) || isset($tcoll['csv']) || isset($tcoll['json'])) : ?>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Export') ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('{/api}helper/template'); ?>" method="post">
<form>
<table class="layout wf-100">
<tbody>
<tr>
@ -72,6 +74,7 @@ echo $this->getData('nav')->render(); ?>
<tr>
<td><select id="iExport" name="export-type">
<option value="select" disabled><?= $this->getHtml('Select'); ?>
<option value="htm"><?= $this->getHtml('Print'); ?>
<option value="excel"<?= $this->printHtml((!isset($tcoll['excel'])) ? ' disabled' : ''); ?>>Excel
<option value="pdf"<?= $this->printHtml((!isset($tcoll['pdf'])) ? ' disabled' : ''); ?>>Pdf
<option value="doc"<?= $this->printHtml((!isset($tcoll['word'])) ? ' disabled' : ''); ?>>Word
@ -81,8 +84,27 @@ echo $this->getData('nav')->render(); ?>
</select>
<tr>
<td><input type="button" value="<?= $this->getHtml('Export'); ?>"
data-ropen="{#lang}/api/helper/export.php?{type=#iExport}{lang=#iLang}{QUERY}">
<td><a target="_blank" class="button" href="<?= UriFactory::build('{/api}helper/report/export?{?}'); ?>&type={#iExport}&lang={#iLang}{#iUiSettings}"><?= $this->getHtml('Export'); ?></a>
</table>
</form>
</div>
</section>
<?php endif; ?>
<?php if (!empty($settings)) : ?>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Settings') ?></h1></header>
<div class="inner">
<form id="iUiSettings">
<table class="layout wf-100">
<tbody>
<?php foreach ($settings as $element) : ?>
<tr>
<td><?= FormElementGenerator::generate($element, $this->request->getData($element['attributes']['name'] ?? '')); ?>
<?php endforeach; ?>
<tr>
<td><a class="button" href="<?= UriFactory::build('{%}') ;?>&type={#iExport}&lang={#iLang}{#iUiSettings}"><?= $this->getHtml('Load'); ?></a>
</table>
</form>
</div>