Просмотр исходного кода

add display filter for device model to devcie index page

Roman Dmitriev 2 лет назад
Родитель
Сommit
3ed0200886

+ 4 - 1
html/admin/devices/index.php

@@ -2,6 +2,7 @@
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/devtypesfilter.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/devmodelsfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/buildingfilter.php");
 $default_sort='device_name';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
@@ -33,7 +34,8 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
 <form name="def" action="index.php" method="post">
 <table class="data">
 <tr class="info" align="right">
-<td class="info" colspan=6> <?php  print WEB_device_type_show; print_devtypes_select($db_link, "devtypes", $f_devtype_id, "id<3"); ?>
+<td class="info" colspan=3> <?php  print WEB_device_type_show; print_devtypes_select($db_link, "devtypes", $f_devtype_id, "id<3"); ?>
+<td class="info" colspan=3> <?php  print WEB_models; print_devmodels_select($db_link, "devmodels", $f_devmodel_id); ?>
 <?php print WEB_device_show_location; print_building_select($db_link, "building_id", $f_building_id); ?></td>
 <td class="info"><input type="submit" name="apply" value="<?php echo WEB_btn_show; ?>"></td>
 <td class="info" colspan=2><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove_device" value="<?php echo WEB_btn_delete; ?>"></td>
@@ -53,6 +55,7 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
 $filter = '';
 if ($f_building_id > 0) { $filter .= ' and building_id=' . $f_building_id; }
 if ($f_devtype_id >= 0) { $filter .= ' and device_type=' . $f_devtype_id; } else { $filter .= ' and device_type<=2'; }
+if ($f_devmodel_id > 0) { $filter .= ' and device_model_id=' . $f_devmodel_id; }
 
 $dSQL = 'SELECT * FROM devices WHERE deleted=0 '.$filter.' '.$sort_sql;
 $switches = get_records_sql($db_link,$dSQL);

+ 11 - 0
html/inc/common.php

@@ -741,6 +741,17 @@ function print_building_select($db, $building_name, $building_value)
     print "</select>\n";
 }
 
+function print_devmodels_select($db, $devmodel_name, $devmodel_value)
+{
+    print "<select name=\"$devmodel_name\">\n";
+    print_select_item(WEB_select_item_all, -1, $devmodel_value);
+    $t_devmodel = mysqli_query($db, "SELECT M.id,V.name,M.model_name FROM device_models M,vendors V WHERE M.vendor_id = V.id ORDER BY V.name,M.model_name");
+    while (list($f_devmodel_id, $f_devmodel_vendor, $f_devmodel_name) = mysqli_fetch_array($t_devmodel)) {
+        print_select_item($f_devmodel_vendor." ".$f_devmodel_name, $f_devmodel_id, $devmodel_value);
+    }
+    print "</select>\n";
+}
+
 function print_devtypes_select($db, $devtype_name, $devtype_value, $mode)
 {
     print "<select name=\"$devtype_name\">\n";

+ 10 - 0
html/inc/devmodelsfilter.php

@@ -0,0 +1,10 @@
+<?php
+if (! defined("CONFIG")) die("Not defined");
+if (isset($_POST['devmodels']) or isset($_GET['devmodels'])) {
+    if (isset($_GET['devmodels'])) { $f_devmodel_id = $_GET['devmodels']*1; }
+    if (isset($_POST['devmodels'])) { $f_devmodel_id = $_POST['devmodels']*1; }
+    } else {
+    if (isset($_SESSION[$page_url]['devmodels'])) { $f_devmodel_id=$_SESSION[$page_url]['devmodels']; } else { $f_devmodel_id = -1; }
+    }
+$_SESSION[$page_url]['devmodels']=$f_devmodel_id;
+?>

+ 1 - 0
html/inc/languages/english.php

@@ -321,6 +321,7 @@ define("WEB_public_month_traffic","per month, (In/Out)");
 
 /* device models */
 define("WEB_model_vendor","Vendor");
+define("WEB_models","Models");
 define("WEB_nagios_template","Nagios Template");
 
 /* edit_l3int */

+ 1 - 0
html/inc/languages/russian.php

@@ -349,6 +349,7 @@ define("WEB_device_port_allien","Не проверять");
 
 /* devices: index-passive */
 define("WEB_device_type_show","Тип оборудования");
+define("WEB_models","Модели");
 define("WEB_device_hide_unknown","Скрыть неизвестные");
 define("WEB_device_show_location","Расположение оборудования");