145 lines
6.2 KiB
PHP
145 lines
6.2 KiB
PHP
<?php
|
|
|
|
namespace HermannTelser\Gutachten\Downloads;
|
|
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
use HermannTelser\Gutachten\Berechnungen\Berechnung;
|
|
use HermannTelser\Gutachten\DB\DbFunction;
|
|
use HermannTelser\Gutachten\Downloads\Nutzflaeche\NutzflaecheZusammenstellung;
|
|
use HermannTelser\Gutachten\Downloads\Nutzflaeche\NutzwertBerechnungM1M4;
|
|
use HermannTelser\Gutachten\Downloads\Nutzflaeche\NutzwertBerechnungM5;
|
|
use HermannTelser\Gutachten\Downloads\Nutzflaeche\TabelleZuAbschlaege;
|
|
use HermannTelser\Gutachten\Downloads\Nutzflaeche\ObjectAufGeschossen;
|
|
use HermannTelser\Gutachten\Utility\Helper;
|
|
use TYPO3\CMS\Core\Core\Environment;
|
|
// Mpdf installed by typo3 extension
|
|
use Mpdf;
|
|
|
|
class PdfNutzflaeche
|
|
{
|
|
public static $projektname = '';
|
|
public static $_platzhalter = [];
|
|
public static $_projekt = [];
|
|
public static $_objekte_geschosse = [];
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function download()
|
|
{
|
|
// DbFunction::$debug = 1;
|
|
|
|
Berechnung::berechnen();
|
|
|
|
self::$_objekte_geschosse = ObjectAufGeschossen::load();
|
|
|
|
ob_clean(); // set to remove wrong headers which crashed some files (e.g. xls, dot, ...)
|
|
|
|
if (!isset(DbFunction::$projektid) or 0 == DbFunction::$projektid) {
|
|
die('aktive projekt ID fehlt!');
|
|
}
|
|
|
|
$_projekt = DbFunction::select(
|
|
'tx_gutachten_projekte',
|
|
['id', 'auftraggeber_id', 'gutachter_id', 'intname', 'name', 'beschreibung', 'erstellung', 'onoff', 'upload', 'allgemeinupload', 'recalculate', 'zuabTitel', 'nwbTitel', 'zustTitel', 'allgemTitel', 'loggia_title', 'nwbStartSeite', 'm1pP', 'm5pP', 'timestamp', 'status', 'erstelldatum'],
|
|
['id' => DbFunction::$projektid]
|
|
);
|
|
|
|
|
|
$zuabTitel = ('' == $_projekt[0]['zuabTitel'] or 'fehlt!' == $_projekt[0]['zuabTitel']) ? '3.21 ZU UND ABSCHLAEGE' : $_projekt[0]['zuabTitel'];
|
|
$nwbTitel = ('' == $_projekt[0]['nwbTitel'] or 'fehlt!' == $_projekt[0]['nwbTitel']) ? '3.30 NUTZWERTBERECHNUNG' : $_projekt[0]['nwbTitel'];
|
|
$zustTitel = ('' == $_projekt[0]['zustTitel'] or 'fehlt!' == $_projekt[0]['zustTitel']) ? '3.40 ZUSAMMENSTELLUNG' : $_projekt[0]['zustTitel'];
|
|
$allgemTitel = ('' == $_projekt[0]['allgemTitel'] or 'fehlt!' == $_projekt[0]['allgemTitel']) ? '3.40 ZUSAMMENSTELLUNG' : $_projekt[0]['allgemTitel'];
|
|
|
|
$_platzhalter = DbFunction::select(
|
|
'tx_gutachten_projekteplatzhalter',
|
|
['code', 'txt'],
|
|
['pid' => DbFunction::$projektid]
|
|
);
|
|
|
|
$_projektestandards = DbFunction::select(
|
|
'tx_gutachten_projektestandards',
|
|
['pos', 'neueseite', 'kennung', 'titel', 'txt', 'platzhalter', 'textart_id'],
|
|
['pid' => DbFunction::$projektid, 'ORDER' => 'pos']
|
|
);
|
|
|
|
foreach ($_projektestandards as $key => $value) {
|
|
if (4 == $value['textart_id']) {
|
|
$title = Helper::replacePlatzhalter($_platzhalter, $value['txt']);
|
|
$title = explode('<br />', $title);
|
|
$projektname = $title[0];
|
|
}
|
|
}
|
|
// $title = DbFunction::get('tx_gutachten_projektestandards', 'txt', ['AND' => ['textart_id' => 4, 'pid' => $projektid]]);
|
|
// $title = Helper::replacePlatzhalter($_platzhalter, $title);
|
|
|
|
$mpdf = new \Mpdf\Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 22,
|
|
'margin_bottom' => 20,
|
|
'margin_header' => 0,
|
|
'margin_footer' => 0,
|
|
]);
|
|
$mpdf->shrink_tables_to_fit = 1;
|
|
|
|
$stylesheet = file_get_contents(__DIR__.'/style.css');
|
|
$mpdf->WriteHTML($stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS);
|
|
|
|
// 1 Tabelle Zu und Abschläge
|
|
$mpdf->AddPage('', '', $_projekt[0]['nwbStartSeite']);
|
|
// $footer = Helper::footer($projektname);
|
|
$mpdf->SetHTMLFooter('<div class="size07 center">Seite {PAGENO}<br><br></div>');
|
|
$html = '<div class="header">'.$zuabTitel.'</div>';
|
|
$html .= '<table class="pure-table pure-table-striped nutzwert-neu">';
|
|
$html .= TabelleZuAbschlaege::load($_projekt);
|
|
$html .= '</table>';
|
|
$mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
|
|
|
|
// // 2 NUTZWERTBERECHNUNG M1 - M4
|
|
$mpdf->AddPage();
|
|
$mpdf->SetHTMLFooter('<div class="size07 center">Seite {PAGENO}<br><br></div>');
|
|
$html = '<div class="header">'.$nwbTitel.'</div>';
|
|
$html .= NutzwertBerechnungM1M4::berechnen();
|
|
$mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
|
|
|
|
// 3 NUTZWERTBERECHNUNG M5
|
|
$html = NutzwertBerechnungM5::berechnen();
|
|
$mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
|
|
|
|
// 4 ZUSAMMENSTELLUNG
|
|
$mpdf->AddPage();
|
|
$mpdf->SetHTMLFooter('<div class="size07 center">Seite {PAGENO}<br><br></div>');
|
|
$html = '<div class="header">'.$zustTitel.'</div>';
|
|
$html .= NutzflaecheZusammenstellung::load($_projekt);
|
|
|
|
// 5 DIGITALE SIGNATUR
|
|
$image = Environment::getProjectPath()."/public/typo3conf/ext/gutachten/Resources/Public/Images/avf_stempel.png";
|
|
$html .= '<div style="height: 150mm; padding: 0; page-break-inside: avoid;">';
|
|
$html .= '<div class="header">3.41 Digitale Signatur</div>';
|
|
$html .= '<table style="width:194mm; margin-top:80mm;"><tr>';
|
|
$html .= '<td style="vertical-align:middle; text-align:right;">'.$_projekt[0]['erstellung'].'</td>';
|
|
$html .= '<td style="text-align:right;"><img src="'.$image.'" style="width:36mm; height:36mm"></td>';
|
|
$html .= '</tr></table>';
|
|
$html .= '</div>';
|
|
$mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
|
|
|
|
// 6 ALLGEMEINTABELLE
|
|
$mpdf->AddPage();
|
|
$mpdf->SetHTMLFooter('<div class="size07 center">Seite {PAGENO}<br><br></div>');
|
|
$html = '<div class="header">'.$allgemTitel.'</div>';
|
|
$html .= AllgemeinTabelle::load();
|
|
$mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
|
|
|
|
// finale
|
|
$mpdf->Output('Nutzflächen.pdf', Mpdf\Output\Destination::INLINE);
|
|
|
|
exit;
|
|
}
|
|
}
|