Files
gutachten_t3/packages/gutachten/Classes/Downloads/PdfParagraph6.php
T

155 lines
6.3 KiB
PHP

<?php
namespace HermannTelser\Gutachten\Downloads;
use HermannTelser\Gutachten\DB\DbFunction;
use HermannTelser\Gutachten\DB\Select\Paragraph62;
use HermannTelser\Gutachten\Utility\Helper;
use TYPO3\CMS\Core\Core\Environment;
use Mpdf;
// Mpdf installed by typo3 extension
use TYPO3\CMS\Core\Utility\GeneralUtility;
class PdfParagraph6
{
public static $Mpdf;
/**
* @return array
*/
public static function download()
{
// ob_clean(); // set to remove wrong headers which crashed some files (e.g. xls, dot, ...)
// DbFunction::$debug = 1;
DbFunction::$projektid = GeneralUtility::_GP('projekt_aktive');
if (0 == DbFunction::$projektid or !is_numeric(DbFunction::$projektid)) {
die('aktive projekt ID fehlt!');
}
$_platzhalter = DbFunction::select(
'tx_gutachten_projekteplatzhalter',
['code', 'txt'],
['pid' => DbFunction::$projektid]
);
$_projekt = DbFunction::select(
'tx_gutachten_projekte',
['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]
);
$_auftraggeber = DbFunction::select(
'tx_gutachten_auftraggeber',
'*',
['id' => $_projekt[0]['auftraggeber_id']]
);
$_gutachter = DbFunction::select(
'tx_gutachten_gutachter',
'*',
['id' => $_projekt[0]['gutachter_id']]
);
// print_r($_projekt);
// print_r($_auftraggeber);
// print_r($_gutachter);
// exit;
self::$Mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8',
'format' => 'A4-P',
'margin_left' => 10,
'margin_right' => 10,
'margin_top' => 10,
'margin_bottom' => 10,
'margin_header' => 0,
'margin_footer' => 0,
]);
$stylesheet = file_get_contents(__DIR__.'/style.css');
self::$Mpdf->WriteHTML($stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS);
// 1 tabelle
// 2 inhaltsverzeichnis
// 3 textblock
// 4 deckblatt
// 5 nur Überschrift
// 6 auftraggeber
// 7 tabelle § 6/2
// 8 allgemeinflächen
$_standards = DbFunction::select('tx_gutachten_projektestandards', '*', ['AND' => ['pid' => DbFunction::$projektid, 'kennung' => ['Deckblatt', '2.30 § 6 Teil 1', 'Tabelle § 6', '2.30 § 6 Teil 2']], 'ORDER' => 'pos']);
foreach ($_standards as $key => $value) {
$textartid = (int)$value['textart_id'];
switch ($textartid) {
case '4':
// DECKBLATT
$value['paragraph6'] = 1;
$html = Deckblatt::create($value, $_projekt, $_platzhalter, $_gutachter, $_auftraggeber);
self::$Mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
break;
case '3':
if (1 == $value['neueseite']) {
self::$Mpdf->AddPageByArray(['mgt' => 22, 'mgb' => 22, 'mgl' => 10, 'mgr' => 10]);
self::$Mpdf->SetHTMLFooter('<div class="size09 center">Seite {PAGENO}<br><br></div>');
}
// if ('' != $value['titel']) {
// $html = '<div class="header">'.$value['titel'].'</div>';
// } elseif ('' != $value['kennung']) {
// $html = '<div class="header">'.$value['kennung'].'</div>';
// }
$textblock = Helper::replacePlatzhalter($_platzhalter, $value['txt']);
$html = '<div class="textblock">' . $textblock . '</div>';
self::$Mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
break;
case '7':
// 7 tabelle § 6/2
if (1 == $value['neueseite']) {
self::$Mpdf->AddPage();
self::$Mpdf->SetHTMLFooter('<div class="size09 center">Seite {PAGENO}<br><br></div>');
}
$_paragraph_62 = Paragraph62::select(DbFunction::$projektid);
$html = '<table class="pure-table pure-table-striped nutzwert-neu center">';
$html .= '<thead><tr class="header-row">';
$html .= '<th style="border-bottom: 0.1mm solid #cbcbcb;">Top</th>';
$html .= '<th style="border-bottom: 0.1mm solid #cbcbcb;">Geschoß</th>';
$html .= '<th style="border-bottom: 0.1mm solid #cbcbcb;">Orientierung</th>';
$html .= '<th style="border-bottom: 0.1mm solid #cbcbcb;">Typ</th>';
$html .= '</tr></thead>';
// $html = '<table class="pure-table pure-table-striped nutzwert-neu">';
// $html .= Helper::table_header_row(['Top', 'Geschoß', 'Orientierung', 'Typ']);
foreach ($_paragraph_62 as $key => $value) {
$html .= Helper::table_row($value, 1);
}
$html .= '</table>';
self::$Mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
break;
}
}
// 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">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>';
self::$Mpdf->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
self::$Mpdf->Output('GutachtenParagraph6.pdf', Mpdf\Output\Destination::INLINE);
exit;
}
}