Added more Pagination
This commit is contained in:
@@ -23,6 +23,16 @@ class BuildingController extends mfBaseController {
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
}
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 5;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$my_networks = [];
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
@@ -54,43 +64,33 @@ class BuildingController extends mfBaseController {
|
||||
unset($filter['network_id']);
|
||||
|
||||
// get Buildings in networks
|
||||
$my_network_ids = [];
|
||||
$buildings = [];
|
||||
foreach($my_networks as $network) {
|
||||
$building_search = [
|
||||
"network_id" => $network->id,
|
||||
"workflow_finished" => 0
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$building_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(BuildingModel::search($building_search) as $b) {
|
||||
if(!array_key_exists($b->id, $buildings)) {
|
||||
$buildings[$b->id] = $b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$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);
|
||||
$my_network_ids[] = $network->id;
|
||||
}
|
||||
|
||||
|
||||
$building_search = [
|
||||
"network_id" => $my_network_ids,
|
||||
"workflow_finished" => 0
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$building_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = BuildingModel::count($building_search);
|
||||
foreach(BuildingModel::search($building_search, $pagination) as $b) {
|
||||
if(!array_key_exists($b->id, $buildings)) {
|
||||
$buildings[$b->id] = $b;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($buildings);exit;
|
||||
$this->layout()->set("buildings", $buildings);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
|
||||
Reference in New Issue
Block a user