174 lines
6.2 KiB
PHP
174 lines
6.2 KiB
PHP
<?php
|
|
|
|
namespace HermannTelser\Gutachten\Downloads\Nutzflaeche;
|
|
|
|
use HermannTelser\Gutachten\DB\DbFunction;
|
|
use HermannTelser\Gutachten\Downloads\PdfNutzflaeche;
|
|
use HermannTelser\Gutachten\Utility\Helper;
|
|
|
|
class TabelleZuAbschlaege
|
|
{
|
|
/**
|
|
* @param mixed $_projekt
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function load($_projekt)
|
|
{
|
|
// DbFunction::$debug = 1;
|
|
|
|
$projektid = $_projekt[0]['id'];
|
|
|
|
$header_row = ['Top', 'Geschoß', 'Typ', 'Nutzfläche'];
|
|
$header_row[] = 0 != $_projekt[0]['loggia_title'] ? $_projekt[0]['loggia_title'] : 'Loggia / sonst. Zusatzflächen';
|
|
$header_row[] = 'Gesamtnutzfläche';
|
|
|
|
$_column_titel = DbFunction::select(
|
|
'tx_gutachten_help',
|
|
['colid', 'coltitel'],
|
|
['pid' => $projektid]
|
|
);
|
|
foreach ($_column_titel as $key => $value) {
|
|
$header_row[] = $value['coltitel'];
|
|
}
|
|
$header_row[] = 'Summe A-Z';
|
|
$header_row[] = 'Wohnungsbewertung';
|
|
$html = Helper::table_header_row_r($header_row);
|
|
|
|
$_fields = [
|
|
'tx_gutachten_raume_basis.id',
|
|
'tx_gutachten_raume_basis.topNr',
|
|
'tx_gutachten_raume_all.geschoss',
|
|
'tx_gutachten_raume_basis.typ',
|
|
'tx_gutachten_raume_basis.u(nutzflaeche)',
|
|
'tx_gutachten_raume_basis.u(loggia)',
|
|
'tx_gutachten_raume_basis.u(gesammtnutzflaeche)',
|
|
];
|
|
foreach ($_column_titel as $key => $value) {
|
|
$_fields[] = 'tx_gutachten_raume_basis.'.$value['colid'];
|
|
}
|
|
$_fields[] = 'tx_gutachten_raume_basis.summe_az';
|
|
$_fields[] = 'tx_gutachten_raume_basis.bewertung';
|
|
|
|
$_where = [];
|
|
$_where['AND']['tx_gutachten_raume_basis.pid'] = $projektid;
|
|
$_where['AND']['tx_gutachten_raume_basis.noDispInOrientierung'] = 0;
|
|
$_where['AND']['tx_gutachten_raume_all.tt_raumart_id'] = 1;
|
|
// $_where['AND']['tx_gutachten_raume_basis.typ[!]'] = '';
|
|
$_where['GROUP'] = 'tx_gutachten_raume_basis.id';
|
|
$_where['ORDER']['tx_gutachten_raume_basis.topNr'] = 'ASC';
|
|
|
|
$_raeume = DbFunction::selectJoin(
|
|
'tx_gutachten_raume_basis',
|
|
['[>]tx_gutachten_raume_all' => ['tx_gutachten_raume_basis.id' => 'tt_raume_basis_id']],
|
|
$_fields,
|
|
$_where
|
|
);
|
|
|
|
|
|
|
|
// $part1 = [];
|
|
// $part2 = [];
|
|
// foreach ($_raeume as $key => $value) {
|
|
// if($value['typ'] != '')
|
|
// {
|
|
// $part1[] = $value;
|
|
//
|
|
// }
|
|
// else {
|
|
// $part2[] = $value;
|
|
// }
|
|
// }
|
|
//
|
|
// $topNr = array_column($part1, 'topNr');
|
|
// array_multisort($topNr, SORT_ASC, $part1);
|
|
//
|
|
// $topNr = array_column($part2, 'topNr');
|
|
// array_multisort($topNr, SORT_ASC, $part2);
|
|
|
|
// $_raeume = array_merge($part1, $part2);
|
|
|
|
$summe_nutzfache = 0;
|
|
$summe_loggien = 0;
|
|
|
|
foreach ($_raeume as $key => $value) {
|
|
unset($_raeume[$key]['id']);
|
|
|
|
$tt_raume_basis_id = $value['id'];
|
|
|
|
$nutzflaeche = DbFunction::sum('tx_gutachten_raume_all', 'qm', ['AND' => ['tt_raumart_id' => 1, 'tt_raume_basis_id' => $tt_raume_basis_id]]);
|
|
|
|
$summe_nutzfache += $nutzflaeche;
|
|
|
|
$_raeume[$key]['nutzflaeche'] = Helper::number_format_de($nutzflaeche, 2);
|
|
|
|
$res = DbFunction::selectJoin(
|
|
'tx_gutachten_raume_all',
|
|
['[>]tx_gutachten_raume_generell' => 'tt_raumart_id'],
|
|
'tx_gutachten_raume_all.qm',
|
|
[
|
|
'AND' => [
|
|
'tx_gutachten_raume_all.pid' => $projektid,
|
|
'tx_gutachten_raume_all.tt_raume_basis_id' => $tt_raume_basis_id,
|
|
'tx_gutachten_raume_all.tt_raumart_id' => [2, 8],
|
|
'tx_gutachten_raume_generell.zunutzwert' => 1,
|
|
],
|
|
'GROUP' => 'tx_gutachten_raume_all.id',
|
|
]
|
|
);
|
|
$loggia = array_sum($res);
|
|
$summe_loggien += $loggia;
|
|
$_raeume[$key]['tt_raume_basis_id'] = $tt_raume_basis_id;
|
|
$_raeume[$key]['loggia'] = round($loggia, 2);
|
|
$sum = round($nutzflaeche + $loggia, 2);
|
|
$_raeume[$key]['gesammtnutzflaeche'] = Helper::number_format_de($sum, 2);
|
|
}
|
|
|
|
$_columns = range('a', 'u');
|
|
$_columns[] = 'loggia';
|
|
$_raeume = Helper::zero_to_null($_raeume, $_columns);
|
|
|
|
// print_r(PdfNutzflaeche::$_objekte_geschosse);
|
|
//
|
|
foreach ($_raeume as $key => $_row) {
|
|
$basisid = $_row['tt_raume_basis_id'];
|
|
|
|
if (isset(PdfNutzflaeche::$_objekte_geschosse[$basisid])) {
|
|
$_row['geschoss'] = PdfNutzflaeche::$_objekte_geschosse[$basisid];
|
|
}
|
|
unset($_row['tt_raume_basis_id']);
|
|
|
|
$html .= '<tr>';
|
|
$i = 1;
|
|
foreach ($_row as $key => $value) {
|
|
if (is_numeric($value)) {
|
|
$value = Helper::number_format_de($value, 2);
|
|
}
|
|
if ($i > 3) {
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb;" class="right">'.$value.'</td>';
|
|
} else {
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb;">'.$value.'</td>';
|
|
}
|
|
++$i;
|
|
}
|
|
$html .= '</tr>';
|
|
}
|
|
|
|
// SUMMEN
|
|
$html .= '<tr>';
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb;" colspan="3">Summen</td>';
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb;" class="right">'.Helper::number_format_de($summe_nutzfache, 2).'</td>';
|
|
if($summe_loggien){
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb;" class="right">'.Helper::number_format_de($summe_loggien, 2).'</td>';
|
|
}else {
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb;"> </td>';
|
|
}
|
|
$sum_total = $summe_nutzfache + $summe_loggien;
|
|
$html .= '<td style="border-bottom: 0.1mm solid #cbcbcb; border-right: 0.1mm solid #cbcbcb;" class="right">'.Helper::number_format_de($sum_total, 2).'</td>';
|
|
$html .= '</tr>';
|
|
|
|
|
|
return $html;
|
|
}
|
|
}
|