enabled creating interest preorders without any wohneinheit
This commit is contained in:
@@ -118,17 +118,34 @@ class PreorderIFrameModel extends mfBaseModel
|
||||
$results = $this->db->fetch_all_assoc($this->db->query($query));
|
||||
if (empty($results)) return [];
|
||||
|
||||
$orderType = $params['orderType'] ?? 'order';
|
||||
|
||||
// For 'interest' order type, return a single entry for the whole building.
|
||||
if ($orderType === 'interest') {
|
||||
$representativeAddress = $this->formatAddressRow($results[0]);
|
||||
$representativeAddress['wohneinheit_id'] = null; // Critical: No specific unit
|
||||
$representativeAddress['oaid'] = $results[0]['oaid']; // Use building OAID
|
||||
$representativeAddress['showText'] = "Gesamtes Gebäude";
|
||||
$representativeAddress['preorderTypes'] = ['interest'];
|
||||
return [$representativeAddress]; // Return one item, so frontend proceeds directly.
|
||||
}
|
||||
|
||||
// Original logic for 'order' type
|
||||
$addresses = [];
|
||||
$topCounter = 1;
|
||||
|
||||
if (count($results) > 1 && $results[0]['wohneinheit_id'] !== null) {
|
||||
foreach ($results as $row) {
|
||||
$addresses[] = array_merge($this->formatAddressRow($row), [
|
||||
'showText' => $this->buildShowText($row, $topCounter++)
|
||||
]);
|
||||
$address = $this->formatAddressRow($row);
|
||||
$address['showText'] = $this->buildShowText($row, $topCounter++);
|
||||
$address['preorderTypes'] = ['order'];
|
||||
$addresses[] = $address;
|
||||
}
|
||||
} else {
|
||||
$addresses[] = $this->formatAddressRow($results[0]);
|
||||
// Single unit or building without units
|
||||
$address = $this->formatAddressRow($results[0]);
|
||||
$address['preorderTypes'] = ['order'];
|
||||
$addresses[] = $address;
|
||||
}
|
||||
|
||||
return $addresses;
|
||||
@@ -139,7 +156,7 @@ class PreorderIFrameModel extends mfBaseModel
|
||||
return [
|
||||
'oaid' => $row['unit_oaid'] ?? $row['oaid'],
|
||||
'street' => $row['street'],
|
||||
'housenumber' => $row['hausnummer'],
|
||||
'housenumber' => $row['housenumber'],
|
||||
'hausnummer_id' => $row['hausnummer_id'],
|
||||
'wohneinheit_id' => $row['wohneinheit_id'],
|
||||
'building_type' => intval($row['building_type']),
|
||||
@@ -151,7 +168,6 @@ class PreorderIFrameModel extends mfBaseModel
|
||||
'zusatz' => $row['zusatz'],
|
||||
'building_unit_count' => $row['building_unit_count'],
|
||||
'showText' => $this->buildShowText($row, 1),
|
||||
'preorderTypes' => ['order', 'interest'] // Can be used for both
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user