diff --git a/application/ConstructionConsent/ConstructionConsent.php b/application/ConstructionConsent/ConstructionConsent.php index 609dbf2a7..f65b14df2 100644 --- a/application/ConstructionConsent/ConstructionConsent.php +++ b/application/ConstructionConsent/ConstructionConsent.php @@ -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']."%')) ) "; } diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php index f23ac2ec1..0e37962f2 100644 --- a/application/ConstructionConsent/ConstructionConsentController.php +++ b/application/ConstructionConsent/ConstructionConsentController.php @@ -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;