added new AP Name filter in Pipework
This commit is contained in:
@@ -113,9 +113,33 @@ class PipeworkController extends mfBaseController {
|
||||
$this->log->debug("is pipeworker");
|
||||
$building_search["pipeworker_id"] = ($this->me->address->parent_id) ? $this->me->address->parent_id : $this->me->address_id;
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = BuildingModel::count($building_search);
|
||||
foreach(BuildingModel::search($building_search, $pagination) as $b) {
|
||||
|
||||
// Store ap_name filter separately for post-processing
|
||||
$ap_name_filter = null;
|
||||
if(array_key_exists('ap_name', $building_search) && $building_search['ap_name']) {
|
||||
$ap_name_filter = $building_search['ap_name'];
|
||||
unset($building_search['ap_name']); // Remove from search as it's a workflow value
|
||||
}
|
||||
|
||||
if($ap_name_filter) {
|
||||
$all_buildings = BuildingModel::search($building_search, false);
|
||||
$filtered_buildings = [];
|
||||
|
||||
foreach($all_buildings as $b) {
|
||||
$ap_name = $b->getWorkflowvalue('ist_anschlusspunkt_name') ?: $b->getWorkflowvalue('anschlusspunkt_name');
|
||||
if($ap_name && stripos($ap_name, $ap_name_filter) !== false) {
|
||||
$filtered_buildings[] = $b;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = count($filtered_buildings);
|
||||
$buildings = array_slice($filtered_buildings, $pagination['start'], $pagination['count']);
|
||||
} else {
|
||||
$pagination['maxItems'] = BuildingModel::count($building_search);
|
||||
$buildings = BuildingModel::search($building_search, $pagination);
|
||||
}
|
||||
|
||||
foreach($buildings as $b) {
|
||||
if(!array_key_exists($b->network->name, $networks)) {
|
||||
$networks[$b->network->name] = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user