diff --git a/Layout/default/Pipework/Index.php b/Layout/default/Pipework/Index.php index 7beed1813..e43f10fdb 100644 --- a/Layout/default/Pipework/Index.php +++ b/Layout/default/Pipework/Index.php @@ -25,7 +25,49 @@

Filter

- +
"> +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + +
+
+
+ + ">Filter zurücksetzen +
+
+
diff --git a/application/Building/BuildingModel.php b/application/Building/BuildingModel.php index 63add4620..354b0075a 100644 --- a/application/Building/BuildingModel.php +++ b/application/Building/BuildingModel.php @@ -110,6 +110,13 @@ class BuildingModel { } } + if(array_key_exists("status_id", $filter)) { + $status_id = $filter['status_id']; + if(is_numeric($status_id)) { + $where .= " AND Building.status_id=$status_id"; + } + } + if(is_array($filter['type']) && count($filter['type'])) { $ot = $filter['type']; $in = []; @@ -153,28 +160,28 @@ class BuildingModel { if(array_key_exists("code", $filter)) { $code = FronkDB::singleton()->escape($filter['code']); if($code) { - $where .= " AND Building.`code`='$code'"; + $where .= " AND Building.`code` like '%$code%'"; } } if(array_key_exists("street", $filter)) { $street = FronkDB::singleton()->escape($filter["street"]); if($street) { - $where .= " AND street='$street'"; + $where .= " AND street like '%$street%'"; } } if(array_key_exists("zip", $filter)) { $zip = FronkDB::singleton()->escape($filter["zip"]); if($zip) { - $where .= " AND zip='$zip'"; + $where .= " AND zip like '%$zip%'"; } } if(array_key_exists("city", $filter)) { $city = FronkDB::singleton()->escape($filter["city"]); if($city) { - $where .= " AND city='$city'"; + $where .= " AND city like '%$city%'"; } } diff --git a/application/Network/NetworkModel.php b/application/Network/NetworkModel.php index ecf5e721c..3cce3dab7 100644 --- a/application/Network/NetworkModel.php +++ b/application/Network/NetworkModel.php @@ -105,6 +105,8 @@ class NetworkModel { } } + + //var_dump($filter, $where);exit; return $where; } diff --git a/application/Pipework/PipeworkController.php b/application/Pipework/PipeworkController.php index 8eb844b2d..b9e877e3a 100644 --- a/application/Pipework/PipeworkController.php +++ b/application/Pipework/PipeworkController.php @@ -17,16 +17,42 @@ class PipeworkController extends mfBaseController { protected function indexAction() { $this->layout()->setTemplate("Pipework/Index"); + $this->layout->set("filter", $this->request->filter); + if($this->request->filter) { $filter = $this->getPreparedFilter($this->request->filter); } + $my_networks = []; + // get allowed networks if($this->me->is("Admin")) { - $my_networks = NetworkModel::getAll(); + if($filter['network_id']) { + $my_networks[] = new Network($filter['network_id']); + } else { + $my_networks = NetworkModel::getAll(); + } + $this->layout()->set("mynetworks", NetworkModel::getAll()); } else { + $use_filter_network = false; $my_networks = $this->me->my_networks; + + foreach($my_networks as $mn) { + if($mn->id == $filter['network_id']) { + $use_filter_network = true; + continue; + } + } + + if($use_filter_network) { + $my_networks = []; + $my_networks[] = new Network($filter['network_id']); + } + + $this->layout()->set("mynetworks", $this->me->my_networks); + } + unset($filter['network_id']); // get Buildings in networks $networks = []; @@ -39,13 +65,15 @@ class PipeworkController extends mfBaseController { "network_id" => $network->id, "workflow_finished" => 0 ]; + if(is_array($filter) && count($filter)) { - $building_search = array_merge($building_search, $filter); + foreach($filter as $name => $value) { + $building_search[$name] = $value; + } + //$building_search = array_merge($building_search, $filter); } - $this->log->debug(print_r($building_search, true)); - - + foreach(BuildingModel::search($building_search) as $b) { if(!array_key_exists($b->id, $networks[$network->name])) { $networks[$network->name][$b->id] = $b; @@ -77,8 +105,17 @@ class PipeworkController extends mfBaseController { } private function getPreparedFilter($filter) { + $new_filter = []; - return $filter; + foreach($filter as $name => $value) { + /*if($name == 'network_id') { + $new_filter['id'] = $value; + continue; + }*/ + $new_filter[$name] = $value; + } + + return $new_filter; } protected function saveAction() {