Add AP-Name filter to linework search and improve input handling in Index.php
This commit is contained in:
@@ -121,8 +121,33 @@ class LineworkController extends mfBaseController {
|
||||
}*/
|
||||
//var_dump($termination_search);exit;
|
||||
$networks = [];
|
||||
$pagination['maxItems'] = TerminationModel::count($termination_search);
|
||||
foreach(TerminationModel::search($termination_search, $pagination) as $term) {
|
||||
|
||||
// Store ap_name filter separately for post-processing
|
||||
$ap_name_filter = null;
|
||||
if(array_key_exists('ap_name', $termination_search) && $termination_search['ap_name']) {
|
||||
$ap_name_filter = $termination_search['ap_name'];
|
||||
unset($termination_search['ap_name']); // Remove from search as it's a workflow value
|
||||
}
|
||||
|
||||
if($ap_name_filter) {
|
||||
$all_terminations = TerminationModel::search($termination_search, false);
|
||||
$filtered_terminations = [];
|
||||
|
||||
foreach($all_terminations as $term) {
|
||||
$ap_name = $term->building->getWorkflowvalue('ist_anschlusspunkt_name') ?: $term->building->getWorkflowvalue('anschlusspunkt_name');
|
||||
if($ap_name && stripos($ap_name, $ap_name_filter) !== false) {
|
||||
$filtered_terminations[] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = count($filtered_terminations);
|
||||
$terminations = array_slice($filtered_terminations, $pagination['start'], $pagination['count']);
|
||||
} else {
|
||||
$pagination['maxItems'] = TerminationModel::count($termination_search);
|
||||
$terminations = TerminationModel::search($termination_search, $pagination);
|
||||
}
|
||||
|
||||
foreach($terminations as $term) {
|
||||
if(!array_key_exists($term->building->network->name, $networks)) {
|
||||
$networks[$term->building->network->name] = [];
|
||||
}
|
||||
@@ -188,10 +213,12 @@ class LineworkController extends mfBaseController {
|
||||
$new_filter['id'] = $value;
|
||||
continue;
|
||||
}*/
|
||||
|
||||
|
||||
// AP-Name filter is passed through to be handled by the model
|
||||
// It will filter by workflow values: ist_anschlusspunkt_name or anschlusspunkt_name
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user