get my_networks from parent address if exists
This commit is contained in:
@@ -16,7 +16,22 @@ class BuildingController extends mfBaseController {
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Building/Index");
|
||||
$this->layout()->set("buildings", BuildingModel::getAll());
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
$this->layout()->set("buildings", BuildingModel::getAll());
|
||||
} else {
|
||||
$buildings = [];
|
||||
foreach($this->me->my_networks as $network) {
|
||||
foreach(BuildingModel::search(["network_id" => $network->id]) as $b) {
|
||||
if(!array_key_exists($b->id, $buildings)) {
|
||||
$buildings[$b->id] = $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($buildings);exit;
|
||||
$this->layout()->set("buildings", $buildings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
|
||||
@@ -93,7 +93,7 @@ class BuildingModel {
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Address($data);
|
||||
$items[] = new Building($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -102,9 +102,14 @@ class BuildingModel {
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
/*
|
||||
* Address Type
|
||||
*/
|
||||
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
$network_id = $filter['network_id'];
|
||||
if(is_numeric($network_id)) {
|
||||
$where .= " AND Building.network_id=$network_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($filter['type']) && count($filter['type'])) {
|
||||
$ot = $filter['type'];
|
||||
$in = [];
|
||||
|
||||
Reference in New Issue
Block a user