592 lines
20 KiB
PHP
592 lines
20 KiB
PHP
<?php
|
|
|
|
class ADBHausnummerModel {
|
|
public $oaid;
|
|
public $adrcd;
|
|
public $subcd;
|
|
public $netzgebiet_id;
|
|
public $extref;
|
|
public $ortschaft_id;
|
|
public $plz_id;
|
|
public $strasse_id;
|
|
public $hausnummer;
|
|
public $stiege;
|
|
public $zusatz;
|
|
public $grund_nr;
|
|
public $gdaeigenschaft;
|
|
public $rw;
|
|
public $hw;
|
|
public $meridian;
|
|
public $unit_count;
|
|
public $gps_lat;
|
|
public $gps_long;
|
|
public $borderpoint_lat;
|
|
public $borderpoint_long;
|
|
public $trenches;
|
|
public $rollout;
|
|
public $rollout_info;
|
|
public $freigabe;
|
|
public $visibility;
|
|
public $manual_add;
|
|
public $manual_add_by;
|
|
public $manual_add_info;
|
|
public $manual_update;
|
|
public $manual_update_by;
|
|
public $manual_update_info;
|
|
public $rimo_id;
|
|
public $rimo_type;
|
|
public $rimo_ex_state;
|
|
public $rimo_op_state;
|
|
public $rimo_fcp_name;
|
|
|
|
public $create = null;
|
|
public $edit = null;
|
|
|
|
public static function create(Array $data) {
|
|
$model = new ADBHausnummer();
|
|
|
|
foreach($data as $field => $value) {
|
|
if(property_exists(get_called_class(), $field)) {
|
|
$model ->$field = $value;
|
|
}
|
|
}
|
|
|
|
$me = mfValuecache::singleton()->get("me");
|
|
if(!$me) {
|
|
$me = new User();
|
|
$me->loadMe();
|
|
mfValuecache::singleton()->set("me", $me);
|
|
}
|
|
/*
|
|
if($model->create_by === null) {
|
|
$model->create_by = $me->id;
|
|
}
|
|
if($model->edit_by === null) {
|
|
$model->edit_by = $me->id;
|
|
}*/
|
|
|
|
return $model;
|
|
}
|
|
|
|
public static function getFirst($filter) {
|
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
|
|
$sql = "SELECT Hausnummer.* FROM Hausnummer
|
|
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
|
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
|
LEFT JOIN Strasse ON (Hausnummer.strasse_id = Strasse.id)
|
|
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
|
LEFT JOIN HausnummerStatusflagValue ON (HausnummerStatusflagValue.hausnummer_id = Hausnummer.id)
|
|
WHERE $where
|
|
GROUP BY Hausnummer.id
|
|
ORDER BY netzgebiet_id,Gemeinde.id,ortschaft_id,strasse_id,LENGTH(hausnummer), hausnummer
|
|
LIMIT 1";
|
|
|
|
mfLoghandler::singleton()->debug($sql);
|
|
$res = $db->query($sql);
|
|
if($db->num_rows($res)) {
|
|
$data = $db->fetch_object($res);
|
|
|
|
// search in cache
|
|
$item = mfValuecache::singleton()->get("mfObjectmodel-adb_hausnummer-".$data->id);
|
|
if($item && $item->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-adb_hausnummer-".$data->id, $item);
|
|
return $item;
|
|
}
|
|
// if not in cache, load regularly
|
|
|
|
$item = new ADBHausnummer($data);
|
|
if($item->id) {
|
|
return $item;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static function getAll() {
|
|
$items = [];
|
|
|
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
|
|
$res = $db->select("Hausnummer", "*", "1=1 ORDER BY strasse_id,hausnummer");
|
|
if($db->num_rows($res)) {
|
|
while($data = $db->fetch_object($res)) {
|
|
$items[] = new ADBHausnummer($data);
|
|
}
|
|
}
|
|
return $items;
|
|
|
|
}
|
|
|
|
|
|
public static function count($filter, $join_tables = false) {
|
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
|
|
if ($join_tables) {
|
|
$sql = "SELECT COUNT(*) as cnt FROM (
|
|
SELECT Hausnummer.id FROM Hausnummer
|
|
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
|
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
|
LEFT JOIN Strasse ON (Hausnummer.strasse_id = Strasse.id)
|
|
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
|
LEFT JOIN HausnummerStatusflagValue ON (HausnummerStatusflagValue.hausnummer_id = Hausnummer.id)";
|
|
} else {
|
|
$sql = "SELECT COUNT(*) as cnt FROM Hausnummer";
|
|
}
|
|
|
|
// Only join Wohneinheit table if we're searching for Wohneinheit data
|
|
if (!empty($filter['home_oaid_rimo_id'])) {
|
|
$sql .= " LEFT JOIN Wohneinheit ON (Wohneinheit.hausnummer_id = Hausnummer.id)";
|
|
}
|
|
|
|
$sql .= " WHERE $where";
|
|
|
|
if (!empty($filter['home_oaid_rimo_id']) && !$join_tables) {
|
|
$sql .= " GROUP BY Hausnummer.id";
|
|
}
|
|
|
|
if($join_tables) {
|
|
$sql .= " GROUP BY Hausnummer.id ) count_table";
|
|
}
|
|
|
|
|
|
mfLoghandler::singleton()->debug($sql);
|
|
|
|
$res = $db->query($sql);
|
|
if ($db->num_rows($res)) {
|
|
$data = $db->fetch_object($res);
|
|
return $data->cnt;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
public static function countHomes($filter) {
|
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
|
|
$sql = "SELECT COUNT(Wohneinheit.id) as cnt
|
|
FROM Hausnummer
|
|
LEFT JOIN Wohneinheit ON (Wohneinheit.hausnummer_id = Hausnummer.id)
|
|
WHERE $where";
|
|
|
|
mfLoghandler::singleton()->debug($sql);
|
|
|
|
$res = $db->query($sql);
|
|
if ($db->num_rows($res)) {
|
|
$data = $db->fetch_object($res);
|
|
return $data->cnt;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param $filter
|
|
* @param $limit
|
|
* @param $returnDBRessource
|
|
* @return ADBHausnummer[] ADBHausnummer Objects
|
|
*/
|
|
public static function search($filter, $limit = false, $returnDBRessource = false) {
|
|
$items = [];
|
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
|
|
// Base SQL with standard joins
|
|
$sql = "SELECT Hausnummer.* FROM Hausnummer
|
|
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
|
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
|
LEFT JOIN Strasse ON (Hausnummer.strasse_id = Strasse.id)
|
|
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
|
LEFT JOIN HausnummerStatusflagValue ON (HausnummerStatusflagValue.hausnummer_id = Hausnummer.id)";
|
|
|
|
if (!empty($filter['home_oaid_rimo_id'])) {
|
|
$sql .= " LEFT JOIN Wohneinheit ON (Wohneinheit.hausnummer_id = Hausnummer.id)";
|
|
}
|
|
|
|
$sql .= " WHERE $where
|
|
GROUP BY Hausnummer.id
|
|
ORDER BY netzgebiet_id,Gemeinde.id,ortschaft_id,strasse_id,LENGTH(hausnummer), hausnummer";
|
|
|
|
if(is_array($limit) && count($limit)) {
|
|
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
|
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
|
} elseif(is_numeric($limit['count'])) {
|
|
$sql .= " LIMIT ".$limit['count'];
|
|
}
|
|
}
|
|
|
|
mfLoghandler::singleton()->debug($sql);
|
|
|
|
$res = $db->query($sql);
|
|
if($db->num_rows($res)) {
|
|
// hack for AddressDBController::exportAction
|
|
if($returnDBRessource) {
|
|
return $res;
|
|
}
|
|
|
|
while($data = $db->fetch_object($res)) {
|
|
$item = mfValuecache::singleton()->get("mfObjectmodel-adb_hausnummer-".$data->id);
|
|
if($item && $item->id) {
|
|
$items[] = $item;
|
|
} else {
|
|
$item = new ADBHausnummer($data);
|
|
mfValuecache::singleton()->set("mfObjectmodel-adb_hausnummer-".$data->id, $item);
|
|
$items[] = $item;
|
|
}
|
|
|
|
}
|
|
}
|
|
return $items;
|
|
}
|
|
|
|
|
|
private static function getSqlFilter($filter) {
|
|
$where = "1=1 ";
|
|
|
|
if(array_key_exists("adrcd", $filter)) {
|
|
$adrcd = FronkDB::singleton()->escape($filter['adrcd']);
|
|
if($adrcd) {
|
|
$where .= " AND Hausnummer.`adrcd` = '$adrcd'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("adrcd%", $filter)) {
|
|
$adrcd = FronkDB::singleton()->escape($filter['adrcd%']);
|
|
if($adrcd) {
|
|
$where .= " AND Hausnummer.`adrcd` like '$adrcd%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("subcd", $filter)) {
|
|
$subcd = FronkDB::singleton()->escape($filter['subcd']);
|
|
if($subcd === false || $subcd === null) {
|
|
$where .= " AND (Hausnummer.`subcd` IS NULL OR Hausnummer.`subcd` = 0)";
|
|
}
|
|
if($subcd) {
|
|
$where .= " AND Hausnummer.`subcd` = $subcd";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("oaid", $filter)) {
|
|
$oaid = FronkDB::singleton()->escape($filter['oaid']);
|
|
if($oaid) {
|
|
$where .= " AND Hausnummer.`oaid` = '$oaid'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("tool_building_type", $filter)) {
|
|
$tool_building_type = $filter['tool_building_type'];
|
|
if(is_numeric($tool_building_type)) {
|
|
$where .= " AND Hausnummer.tool_building_type=$tool_building_type";
|
|
} elseif(is_array($tool_building_type) && count($tool_building_type)) {
|
|
$where .= " AND Hausnummer.tool_building_type IN (". implode(",", $tool_building_type).")";
|
|
} elseif($tool_building_type === null) {
|
|
$where .= " AND Hausnummer.tool_building_type IS NULL";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("oaid%", $filter)) {
|
|
$oaid = FronkDB::singleton()->escape($filter['oaid%']);
|
|
if($oaid) {
|
|
$where .= " AND Hausnummer.`oaid` like '$oaid%'";
|
|
}
|
|
}
|
|
|
|
|
|
if(array_key_exists("extref", $filter)) {
|
|
$extref = FronkDB::singleton()->escape($filter['extref']);
|
|
if($extref) {
|
|
$where .= " AND Hausnummer.`extref` = '$extref'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("extref%", $filter)) {
|
|
$extref = FronkDB::singleton()->escape($filter['extref%']);
|
|
if($extref) {
|
|
$where .= " AND Hausnummer.`extref` like '$extref%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rimo_id", $filter)) {
|
|
$rimo_id = FronkDB::singleton()->escape($filter['rimo_id']);
|
|
if($rimo_id) {
|
|
$where .= " AND Hausnummer.rimo_id = '$rimo_id'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rimo_id%", $filter)) {
|
|
$rimo_id = FronkDB::singleton()->escape($filter['rimo_id%']);
|
|
if($rimo_id) {
|
|
$where .= " AND Hausnummer.rimo_id LIKE '%$rimo_id%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("plz", $filter)) {
|
|
$plz = FronkDB::singleton()->escape($filter['plz']);
|
|
if($plz) {
|
|
$where .= " AND Plz.plz = '$plz'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("plz%", $filter)) {
|
|
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
|
if($plz) {
|
|
$where .= " AND Plz.plz like '$plz%'";
|
|
}
|
|
}
|
|
|
|
|
|
if(array_key_exists("netzgebiet_id", $filter)) {
|
|
$netzgebiet_id = $filter['netzgebiet_id'];
|
|
if(is_numeric($netzgebiet_id)) {
|
|
$where .= " AND Hausnummer.netzgebiet_id=$netzgebiet_id";
|
|
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
|
$where .= " AND Hausnummer.netzgebiet_id IN (". implode(",", $netzgebiet_id).")";
|
|
} elseif($netzgebiet_id === null) {
|
|
$where .= " AND Hausnummer.netzgebiet_id IS NULL";
|
|
} elseif($netzgebiet_id === true) {
|
|
$where .= " AND Hausnummer.netzgebiet_id > 0";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("plz_id", $filter)) {
|
|
$plz_id = $filter['plz_id'];
|
|
if(is_numeric($plz_id)) {
|
|
$where .= " AND Hausnummer.plz_id=$plz_id";
|
|
} elseif(is_array($plz_id) && count($plz_id)) {
|
|
$where .= " AND Hausnummer.plz_id IN (". implode(",", $plz_id).")";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("strasse_id", $filter)) {
|
|
$strasse_id = $filter['strasse_id'];
|
|
if(is_numeric($strasse_id)) {
|
|
$where .= " AND Hausnummer.strasse_id=$strasse_id";
|
|
} elseif(is_array($strasse_id) && count($strasse_id)) {
|
|
$where .= " AND Hausnummer.strasse_id IN (". implode(",", $strasse_id).")";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("gemeinde_id", $filter)) {
|
|
$gemeinde_id = $filter['gemeinde_id'];
|
|
if(is_numeric($gemeinde_id)) {
|
|
$where .= " AND Ortschaft.gemeinde_id=$gemeinde_id";
|
|
} elseif(is_array($gemeinde_id) && count($gemeinde_id)) {
|
|
$where .= " AND Ortschaft.gemeinde_id IN (". implode(",", $gemeinde_id).")";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("gemeinde", $filter)) {
|
|
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde']);
|
|
if($gemeinde) {
|
|
$where .= " AND Gemeinde.name = '$gemeinde'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("gemeinde%", $filter)) {
|
|
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde%']);
|
|
if($gemeinde) {
|
|
$where .= " AND Gemeinde.name like '$gemeinde%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("ortschaft", $filter)) {
|
|
$ortschaft = FronkDB::singleton()->escape($filter['ortschaft']);
|
|
if($ortschaft) {
|
|
$where .= " AND Ortschaft.name = '$ortschaft'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("ortschaft%", $filter)) {
|
|
$ortschaft = FronkDB::singleton()->escape($filter['ortschaft%']);
|
|
if($ortschaft) {
|
|
$where .= " AND Ortschaft.name like '$ortschaft%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("ortschaft_id", $filter)) {
|
|
$ortschaft_id = $filter['ortschaft_id'];
|
|
if(is_numeric($ortschaft_id)) {
|
|
$where .= " AND Hausnummer.ortschaft_id=$ortschaft_id";
|
|
} elseif(is_array($ortschaft_id) && count($ortschaft_id)) {
|
|
$where .= " AND Hausnummer.ortschaft_id IN (". implode(",", $ortschaft_id).")";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("hausnummer", $filter)) {
|
|
if(is_array($filter['hausnummer'])) {
|
|
$hausnummer = $filter['hausnummer'];
|
|
$where .= " AND Hausnummer.`hausnummer` IN ('".implode("','", $hausnummer)."')";
|
|
} else {
|
|
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
|
|
if($hausnummer) {
|
|
$where .= " AND Hausnummer.`hausnummer` = '$hausnummer'";
|
|
}
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("hausnummer%", $filter)) {
|
|
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer%']);
|
|
if($hausnummer) {
|
|
$where .= " AND Hausnummer.`hausnummer` like '$hausnummer%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("stiege", $filter)) {
|
|
$stiege = FronkDB::singleton()->escape($filter['stiege']);
|
|
if($stiege) {
|
|
$where .= " AND stiege.name = '$stiege'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("strasse", $filter)) {
|
|
$strasse = FronkDB::singleton()->escape($filter['strasse']);
|
|
if($strasse) {
|
|
$where .= " AND Strasse.name = '$strasse'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("strasse%", $filter)) {
|
|
$strasse = FronkDB::singleton()->escape($filter['strasse%']);
|
|
if($strasse) {
|
|
$where .= " AND Strasse.name like '%$strasse%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("visibility", $filter)) {
|
|
$visibility = $filter['visibility'];
|
|
if(is_array($visibility)) {
|
|
$where .= " AND Hausnummer.visibility IN ('".implode("','", $visibility)."')";
|
|
} else {
|
|
$visibility = FronkDB::singleton()->escape($visibility);
|
|
$where .= " AND Hausnummer.visibility = '$visibility'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rollout", $filter)) {
|
|
$rollout = FronkDB::singleton()->escape($filter['rollout']);
|
|
if($rollout) {
|
|
$where .= " AND Hausnummer.rollout = '$rollout'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rollout%", $filter)) {
|
|
$rollout = FronkDB::singleton()->escape($filter['rollout%']);
|
|
if($rollout) {
|
|
$where .= " AND Hausnummer.rollout like '%$rollout%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rollout_info", $filter)) {
|
|
$rollout_info = FronkDB::singleton()->escape($filter['rollout_info']);
|
|
if($rollout_info) {
|
|
$where .= " AND Hausnummer.rollout_info = '$rollout_info'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rollout_info%", $filter)) {
|
|
$rollout_info = FronkDB::singleton()->escape($filter['rollout_info%']);
|
|
if($rollout_info) {
|
|
$where .= " AND Hausnummer.rollout_info like '%$rollout_info%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("status_id", $filter)) {
|
|
$status_id = $filter['status_id'];
|
|
if(is_array($status_id)) {
|
|
$where .= " AND Hausnummer.status_id IN (".implode(", ", $status_id).")";
|
|
} elseif(is_numeric($status_id)) {
|
|
$where .= " AND Hausnummer.status_id = $status_id";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("status_flag", $filter)) {
|
|
$status_flag = $filter['status_flag'];
|
|
if(is_array($status_flag)) {
|
|
$where .= " AND HausnummerStatusflagValue.flag_id IN (".implode(", ", $status_flag).") AND HausnummerStatusflagValue.value=1";
|
|
} elseif(is_numeric($status_flag)) {
|
|
$where .= " AND HausnummerStatusflagValue.flag_id = $status_flag AND HausnummerStatusflagValue.value=1";
|
|
}
|
|
}
|
|
|
|
if (array_key_exists("rimo_type", $filter)) {
|
|
$rimo_type = $filter['rimo_type'];
|
|
$where .= is_array($rimo_type)
|
|
? " AND Hausnummer.rimo_type IN ('" . implode("', '", $rimo_type) . "')"
|
|
: " AND Hausnummer.rimo_type = '$rimo_type'";
|
|
}
|
|
|
|
if (array_key_exists("rimo_ex_state", $filter)) {
|
|
$rimo_ex_state = $filter['rimo_ex_state'];
|
|
$where .= is_array($rimo_ex_state)
|
|
? " AND Hausnummer.rimo_ex_state IN ('" . implode("', '", $rimo_ex_state) . "')"
|
|
: " AND Hausnummer.rimo_ex_state = '$rimo_ex_state'";
|
|
}
|
|
|
|
if (array_key_exists("rimo_op_state", $filter)) {
|
|
$rimo_op_state = $filter['rimo_op_state'];
|
|
$where .= is_array($rimo_op_state)
|
|
? " AND Hausnummer.rimo_op_state IN ('" . implode("', '", $rimo_op_state) . "')"
|
|
: " AND Hausnummer.rimo_op_state = '$rimo_op_state'";
|
|
}
|
|
|
|
if (array_key_exists("home_oaid_rimo_id", $filter)) {
|
|
$searchTerm = $filter['home_oaid_rimo_id'];
|
|
|
|
$searchTerms = explode(',', $searchTerm);
|
|
$where .= " AND (";
|
|
$conditions = [];
|
|
foreach ($searchTerms as $term) {
|
|
$escapedTerm = FronkDB::singleton()->escape(trim($term));
|
|
if ($escapedTerm) {
|
|
$conditions[] = "(Wohneinheit.oaid LIKE '%{$escapedTerm}%' OR Wohneinheit.extref LIKE '%{$escapedTerm}%')";
|
|
}
|
|
}
|
|
$where .= implode(' OR ', $conditions);
|
|
$where .= ")";
|
|
}
|
|
|
|
if (array_key_exists("rimo_fcp_name", $filter)) {
|
|
if (is_array($filter['rimo_fcp_name'])) {
|
|
$escapedNames = array_map(function($name) {
|
|
return "'" . FronkDB::singleton()->escape($name) . "'";
|
|
}, $filter['rimo_fcp_name']);
|
|
$where .= " AND Hausnummer.rimo_fcp_name IN (" . implode(", ", $escapedNames) . ")";
|
|
} else {
|
|
$rimo_fcp_name = FronkDB::singleton()->escape($filter['rimo_fcp_name']);
|
|
if ($rimo_fcp_name) {
|
|
$where .= " AND Hausnummer.rimo_fcp_name = '$rimo_fcp_name'";
|
|
}
|
|
}
|
|
}
|
|
|
|
if (array_key_exists("fcp_id", $filter)) {
|
|
if (is_array($filter['fcp_id'])) {
|
|
$escapedIds = array_map(function($id) {
|
|
return "'" . FronkDB::singleton()->escape($id) . "'";
|
|
}, $filter['fcp_id']);
|
|
$where .= " AND Hausnummer.fcp_id IN (" . implode(", ", $escapedIds) . ")";
|
|
} else {
|
|
$fcp_id = FronkDB::singleton()->escape($filter['fcp_id']);
|
|
if ($fcp_id) {
|
|
$where .= " AND Hausnummer.fcp_id = '$fcp_id'";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return $where;
|
|
}
|
|
|
|
}
|