|
|
@@ -265,39 +265,56 @@ function toggle(source) {
|
|
|
private function showPowiazania() {
|
|
|
// echo "Statystyki znalezionych powiązań [TODO]";
|
|
|
$dir = self::getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $this->powiazanie['ID']);
|
|
|
- $pdfFile = "{$dir}/relations.pdf";
|
|
|
- $htmlFile = "{$dir}/html/relations-{$this->powiazanie['ID']}.html";
|
|
|
- $htmlZipFile = "{$dir}/html.zip";
|
|
|
$url = self::getUrl('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $this->powiazanie['ID']);
|
|
|
- $pdfUrl = "{$url}/relations.pdf";
|
|
|
- $htmlUrl = "{$url}/html/relations-{$this->powiazanie['ID']}.html";
|
|
|
- $htmlZipUrl = "{$url}/html.zip";
|
|
|
+
|
|
|
+ $reports = [
|
|
|
+ 'pdf' => [
|
|
|
+ 'files' => glob("{$dir}/relations*.pdf"),
|
|
|
+ 'label' => 'Raporty PDF:<br/> ',
|
|
|
+ 'button' => 'Pokaż raport PDF',
|
|
|
+ 'regex' => '/^relations_([[:digit:]]+)\.pdf$/',
|
|
|
+ 'parentDir' => false,
|
|
|
+ ],
|
|
|
+ 'html' => [
|
|
|
+ 'files' => glob("{$dir}/html*/relations-{$this->powiazanie['ID']}*.html"),
|
|
|
+ 'label' => 'Raporty HTML<br/>do przeglądania:',
|
|
|
+ 'button' => 'Pokaż raport HTML',
|
|
|
+ 'regex' => "/^relations-{$this->powiazanie['ID']}_([[:digit:]]+)\.html$/",
|
|
|
+ 'parentDir' => true,
|
|
|
+ ],
|
|
|
+ 'htmlZip' => [
|
|
|
+ 'files' => glob("{$dir}/html*.zip"),
|
|
|
+ 'label' => 'Raporty HTML<br/>do pobrania:',
|
|
|
+ 'button' => 'Pobież raport HTML',
|
|
|
+ 'regex' => '/^html_([[:digit:]]+)\.zip$/',
|
|
|
+ 'parentDir' => false,
|
|
|
+ ],
|
|
|
+ ];
|
|
|
?>
|
|
|
<div class="container" style="margin-top:20px">
|
|
|
<legend>
|
|
|
Wygenerowany raport nr <?=$this->powiazanie['ID']?>
|
|
|
</legend>
|
|
|
- <div class="form-group">
|
|
|
- <div class="col-sm-12">
|
|
|
-<?php
|
|
|
- if (file_exists($pdfFile)) {
|
|
|
-?>
|
|
|
- <a href="<?=$pdfUrl?>" target="_blank" class="btn btn-primary">Pokaż raport PDF</a>
|
|
|
+ <div class="form-group" style="text-align: center;">
|
|
|
<?php
|
|
|
- }
|
|
|
-
|
|
|
- if (file_exists($htmlFile)) {
|
|
|
-?>
|
|
|
- <a href="<?=$htmlUrl?>" target="_blank" class="btn btn-primary">Pokaż raport HTML</a>
|
|
|
-<?php
|
|
|
- }
|
|
|
-
|
|
|
- if (file_exists($htmlZipFile)) {
|
|
|
-?>
|
|
|
- <a href="<?=$htmlZipUrl?>" target="_blank" download="Raport <?=$this->powiazanie['ID']?>.zip" class="btn btn-primary">Pobierz raport HTML</a>
|
|
|
-<?php
|
|
|
- }
|
|
|
+ array_walk($reports, function ($report) use ($url) {
|
|
|
+ echo "<div class=\"col-sm-2\"><h4>{$report['label']}</h4>";
|
|
|
+ $hrefs = array_diff(array_map(function ($path) use ($url, $report) {
|
|
|
+ if (!is_file($path)) return null;
|
|
|
+ $file = basename($path);
|
|
|
+ if (preg_match($report['regex'], $file, $matches)) $i = " (" . ltrim($matches[1], '0') . ")";
|
|
|
+ else $i = '';
|
|
|
+ if ($report['parentDir']) $file = basename(dirname($path)) . "/" . $file;
|
|
|
+ return "<a href=\"{$url}/{$file}\" target=\"_blank\" class=\"btn btn-primary\">{$report['button']}{$i}</a>";
|
|
|
+ }, $report['files']), [null]);
|
|
|
+ if ($hrefs) echo implode('<br/><br/>', $hrefs);
|
|
|
+ else echo "<h5>Nie znaleziono</h5>";
|
|
|
+ echo "</div>\n";
|
|
|
+ });
|
|
|
?>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-12">
|
|
|
<br/><br/><a href="<?=$this->REFERER?>" class="btn btn-default">Powrót</a>
|
|
|
</div>
|
|
|
</div>
|