Added search and sorting support

This commit is contained in:
laf
2015-07-20 14:03:09 +01:00
parent c579805292
commit 57540aacbc
2 changed files with 8 additions and 4 deletions

View File

@@ -7,6 +7,10 @@ $device_id = $_POST['device_id'];
$sql = 'FROM `ports` WHERE `device_id` = ?';
$param = array($device_id);
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`ifName` LIKE '%$searchPhrase%' OR `ifAlias` LIKE '%$searchPhrase%' OR `ifDescr` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(`port_id`) $sql";
$total = dbFetchCell($count_sql, $param);
if (empty($total)) {
@@ -53,7 +57,7 @@ foreach (dbFetchRows($sql, $param) as $port) {
$response[] = array(
'ifIndex' => $port['ifIndex'],
'label' => $port['label'],
'ifName' => $port['label'],
'ifAdminStatus' => $port['ifAdminStatus'],
'ifOperStatus' => '<span name="operstatus_'.$port['port_id'].'"'.$outofsync.'>'.$port['ifOperStatus'].'</span>',
'disabled' => '<input type="checkbox" class="disable-check" name="disabled_'.$port['port_id'].'"'.($port['disabled'] ? 'checked' : '').'>