Added pagination to Pipework and Linework
This commit is contained in:
@@ -80,7 +80,26 @@ class BuildingModel {
|
||||
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Building
|
||||
LEFT JOIN Buildingtype ON (Buildingtype.id = Building.type_id)
|
||||
LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id)
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -89,7 +108,16 @@ class BuildingModel {
|
||||
LEFT JOIN Buildingtype ON (Buildingtype.id = Building.type_id)
|
||||
LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id)
|
||||
WHERE $where
|
||||
ORDER BY network_id,pop_id,street,zip,city";
|
||||
ORDER BY network_id, pop_id, street, zip, city";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
@@ -107,6 +135,8 @@ class BuildingModel {
|
||||
$network_id = $filter['network_id'];
|
||||
if(is_numeric($network_id)) {
|
||||
$where .= " AND Building.network_id=$network_id";
|
||||
} elseif(is_array($network_id) && count($network_id)) {
|
||||
$where .= " AND Building.network_id IN (". implode(",", $network_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user