New Buildings are checked for existing adresses
This commit is contained in:
@@ -146,10 +146,21 @@ class BuildingController extends mfBaseController {
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = 1;
|
||||
$building = BuildingModel::create($data);
|
||||
|
||||
// check if building exists already
|
||||
$checkBuilding = BuildingModel::search(['street' => $data['street'], 'city' => $data['city'], 'zip' => $data['zip']]);
|
||||
if($checkBuilding) {
|
||||
$this->layout()->setFlash("Objekt ist <a target='_blank' href='".self::getUrl("Building")."#building=".$checkBuilding[0]->id."'>bereits vorhanden</a>!", "error");
|
||||
$this->layout()->set("building", $building);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
} else {
|
||||
$building->update($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//var_dump($address);exit;
|
||||
$new_id = $building->save();
|
||||
if(!$new_id) {
|
||||
|
||||
@@ -157,6 +157,27 @@ class BuildingModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("street", $filter)) {
|
||||
$street = FronkDB::singleton()->escape($filter["street"]);
|
||||
if($street) {
|
||||
$where .= " AND street='$street'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("zip", $filter)) {
|
||||
$zip = FronkDB::singleton()->escape($filter["zip"]);
|
||||
if($zip) {
|
||||
$where .= " AND zip='$zip'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("city", $filter)) {
|
||||
$city = FronkDB::singleton()->escape($filter["city"]);
|
||||
if($city) {
|
||||
$where .= " AND city='$city'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user