fixed multiple stuff

This commit is contained in:
Luca Haid
2025-04-23 22:41:28 +02:00
parent 092e9c558a
commit 82a2889e92
13 changed files with 296 additions and 735 deletions

View File

@@ -322,12 +322,23 @@ class AddressModel {
}
}
if (array_key_exists("company", $filter)) {
$company = FronkDB::singleton()->escape($filter["company"]);
if ($company) {
$where .= " AND company like '%$company%'";
if (array_key_exists("company", $filter)) {
$companyInput = trim($filter["company"]);
if ($companyInput !== '') {
$companyParts = preg_split('/\s+/', $companyInput);
$companyConditions = [];
foreach ($companyParts as $companyPart) {
$escapedCompanyPart = FronkDB::singleton()->escape($companyPart);
if ($escapedCompanyPart) {
$companyConditions[] = "company LIKE '%{$escapedCompanyPart}%'";
}
}
if (!empty($companyConditions)) {
$where .= " AND (" . implode(" AND ", $companyConditions) . ")";
}
}
}
}
if (array_key_exists("firstname", $filter)) {
$firstname = FronkDB::singleton()->escape($filter["firstname"]);
@@ -343,12 +354,22 @@ class AddressModel {
}
}
if (array_key_exists("mergedName", $filter)) {
$name = FronkDB::singleton()->escape($filter["mergedName"]);
if ($name) {
$where .= " AND (CONCAT(firstname, ' ', lastname) like '%$name%' OR CONCAT(lastname, ' ', firstname) like '%$name%' )";
if (array_key_exists("mergedName", $filter)) {
$mergedName = trim($filter["mergedName"]);
if ($mergedName !== '') {
$names = preg_split('/\s+/', $mergedName);
$conditions = [];
foreach ($names as $namePart) {
$escapedNamePart = FronkDB::singleton()->escape($namePart);
if ($escapedNamePart) {
$conditions[] = "(firstname LIKE '%{$escapedNamePart}%' OR lastname LIKE '%{$escapedNamePart}%')";
}
}
if (!empty($conditions)) {
$where .= " AND (" . implode(" AND ", $conditions) . ")";
}
}
}
}
if (array_key_exists("street", $filter)) {
$street = FronkDB::singleton()->escape($filter["street"]);