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

View File

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

View File

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

View File

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