Merge branch 'ConstructionConsent/fix-bugs' into 'master'

fixed import bugs and filter

See merge request fronk/thetool!1547
This commit is contained in:
Luca Haid
2025-07-16 14:53:52 +00:00
2 changed files with 9 additions and 3 deletions

View File

@@ -688,7 +688,8 @@ FROM ConstructionConsent
SELECT 1
FROM ConstructionConsentOwner co
WHERE co.constructionconsent_id = ConstructionConsent.id
AND LOWER(CONCAT(co.firstname, ' ', co.lastname)) LIKE LOWER('%".$filter['cwo']."%')
AND (LOWER(CONCAT(co.firstname, ' ', co.lastname)) LIKE LOWER('%".$filter['cwo']."%') OR
LOWER(co.company) LIKE LOWER('%".$filter['cwo']."%'))
)
";
}

View File

@@ -1127,7 +1127,11 @@ class ConstructionConsentController extends mfBaseController {
foreach ($consentRecords as $consentRecord) {
$birthdate = (isset($ownerData["GEB"]) && preg_match("/^\d{4}-\d{2}-\d{2}$/", $ownerData["GEB"])) ? $ownerData["GEB"] : null;
$ownerFilter = ["constructionconsent_id" => $consentRecord->id, "firstname" => $ownerData["VN"] ?? null, "lastname" => $ownerData["NN"] ?? null];
$ownerFilter = ["constructionconsent_id" => $consentRecord->id];
if (isset($ownerData["VN"])) { $ownerFilter["firstname"] = $ownerData["VN"]; }
if (isset($ownerData["NN"])) { $ownerFilter["lastname"] = $ownerData["NN"]; }
if (isset($ownerData["BEZ"])) { $ownerFilter["company"] = $ownerData["BEZ"]; }
if ($birthdate) { $ownerFilter["birthdate"] = $birthdate; }
$isNew = !($ownerRecord = ConstructionConsentOwner::getFirst(array_filter($ownerFilter)));
@@ -1152,7 +1156,8 @@ class ConstructionConsentController extends mfBaseController {
$ownerRecord->firstname = $ownerData["VN"] ?? null;
$ownerRecord->lastname = (($ownerData["JUR"] ?? 'nein') === "ja") ? ($ownerData['BEZ'] ?? $ownerData["NN"]) : ($ownerData["NN"] ?? null);
$ownerRecord->lastname = $ownerData["NN"] ?? null;
$ownerRecord->company = $ownerData["BEZ"] ?? null;
$ownerRecord->birthdate = $birthdate;
$ownerRecord->street = $street;
$ownerRecord->city = $city;