Переглянути джерело

added poe field to device models

Roman Dmitriev 1 рік тому
батько
коміт
e846394

+ 6 - 0
html/admin/customers/devmodels.php

@@ -34,6 +34,8 @@ if (isset($_POST['save'])) {
             if ($save_id>=10000) {
                 $new['vendor_id'] = $_POST['f_vendor'][$j];
 	            $new['model_name'] = $_POST['f_name'][$j];
+	            $new['poe_in'] = $_POST['f_poe_in'][$j];
+	            $new['poe_out'] = $_POST['f_poe_out'][$j];
 	        }
             $new['nagios_template'] = $_POST['f_nagios'][$j];
             update_record($db_link, "device_models", "id='{$save_id}'", $new);
@@ -132,6 +134,8 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td><b>Id</b></td>
 <td><b><?php echo WEB_model_vendor; ?></b></td>
 <td><b><?php echo WEB_cell_name; ?></b></td>
+<td><b><?php echo WEB_cell_poe_in; ?></b></td>
+<td><b><?php echo WEB_cell_poe_out; ?></b></td>
 <td><b><?php echo WEB_nagios_template; ?></b></td>
 <td><input type="submit" name='save' value="<?php echo WEB_btn_save; ?>"></td>
 <td><input type="submit" name='remove' value="<?php echo WEB_btn_delete; ?>"></td>
@@ -144,6 +148,8 @@ foreach ($t_ou as $row) {
     print "<td class=\"data\"><input type=\"hidden\" name='r_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
     print "<td class=\"data\" width=150>"; print_vendor_set($db_link,'f_vendor[]',$row['vendor_id']); print "</td>\n";
     print "<td class=\"data\"><input type=\"text\" name='f_name[]' value='{$row['model_name']}'></td>\n";
+    print "<td class=\"data\">";print_qa_select("f_poe_in", $row['poe_in']); print "</td>\n";
+    print "<td class=\"data\">";print_qa_select("f_poe_out", $row['poe_out']); print "</td>\n";
     print "<td class=\"data\"><input type=\"text\" name='f_nagios[]' value='{$row['nagios_template']}'></td>\n";
     print "<td class=\"data\"></td>\n";
     print "<td class=\"data\"></td>\n";

+ 19 - 14
html/admin/devices/switchstatus.php

@@ -4,6 +4,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php")
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/idfilter.php");
 
 $device = get_record($db_link, 'devices', "id=" . $id);
+$device_model = get_record($db_link, 'device_models', "id=" . $device['device_model_id']);
 
 if (isset($_POST["regensnmp"])) {
     $snmp_index = $_POST["f_snmp_start"] * 1;
@@ -94,7 +95,7 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
         $snmp_ok = 0;
         $vlan_list = [];
         $vlan_at_port_by_snmp = 1;
-        $port_poe_by_snmp = 1;
+        
         if (!empty($device['ip']) and $device['snmp_version'] > 0) {
             $snmp_ok = check_snmp_access($device['ip'], $device['community'], $device['snmp_version']);
             $modules_oids = NULL;
@@ -130,7 +131,9 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
         print "<td>" . WEB_device_port_errors . "</td>\n";
         print "<td>" . WEB_cell_mac_count . "</td>\n";
         print "<td>" . WEB_msg_additional . "</td>\n";
-        print "<td>" . WEB_device_poe_control . "</td>\n";
+        if ($device_model['poe_out']) {
+            print "<td>" . WEB_device_poe_control . "</td>\n";
+            }
         print "<td>" . WEB_device_port_control . "</td>\n";
         print "</tr>\n";
         $sSQL = "SELECT * FROM device_ports WHERE device_ports.device_id=$id ORDER BY port";
@@ -199,18 +202,20 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
                 $ifname = get_snmp_ifname($device['ip'], $device['community'], $device['snmp_version'], $row['snmp_index']);
 
                 //poe information
-                $poe_status = get_port_poe_state($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
-                if (isset($poe_status)) {
-                    if ($poe_status == 1) {
-                        $port_poe_detail = get_port_poe_detail($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
-                        if (empty($port_poe_detail)) {
-                            $poe_info = 'POE:on';
-                        } else {
-                            $poe_info = $port_poe_detail;
+                if ($device_model['poe_out']) {
+                    $poe_status = get_port_poe_state($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
+                    if (isset($poe_status)) {
+                        if ($poe_status == 1) {
+                            $port_poe_detail = get_port_poe_detail($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
+                            if (empty($port_poe_detail)) {
+                                $poe_info = 'POE:on';
+                            } else {
+                                $poe_info = $port_poe_detail;
+                            }
+                        }
+                        if ($poe_status == 2) {
+                            $poe_info = "POE:Off";
                         }
-                    }
-                    if ($poe_status == 2) {
-                        $poe_info = "POE:Off";
                     }
                 }
 
@@ -333,7 +338,7 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
             print "<td class='" . $cl . "' ><button onclick=\"". open_window_url('portmactable.php?id='.$row['id'])." return false;\">" . $row['last_mac_count'] . "</button></td>\n";
 
             print "<td class='" . $cl . "'>" . $sfp_status . " " . $poe_info . "</td>\n";
-            if (isset($poe_status) and !$row['skip']) {
+            if ($device_model['poe_out'] and isset($poe_status) and !$row['skip']) {
                 print "<td class=\"data\">";
                 if ($device['vendor_id'] != 9) {
                     if ($poe_status == 2) {

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

@@ -216,6 +216,8 @@ define("WEB_cell_rule", "Rules");
 define("WEB_cell_password","Password");
 define("WEB_cell_control_proto","Protocol");
 define("WEB_cell_control_port","Port");
+define("WEB_cell_poe_in","POE In");
+define("WEB_cell_poe_out","POE");
 
 /* lists name */
 define("WEB_list_ou","List of groups");

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

@@ -216,6 +216,8 @@ define("WEB_cell_rule","Правил");
 define("WEB_cell_password","Пароль");
 define("WEB_cell_control_proto","Протокол");
 define("WEB_cell_control_port","Порт");
+define("WEB_cell_poe_in","Питается по POE");
+define("WEB_cell_poe_out","POE");
 
 /* lists name */
 define("WEB_list_ou","Список групп");

+ 1 - 0
scripts/updates/2-6-3/device.sql

@@ -0,0 +1 @@
+ALTER TABLE `device_models` ADD `poe_in` BOOLEAN NOT NULL DEFAULT FALSE AFTER `vendor_id`, ADD `poe_out` BOOLEAN NOT NULL DEFAULT FALSE AFTER `poe_in`;

+ 1 - 0
scripts/updates/2-6-3/version.sql

@@ -0,0 +1 @@
+REPLACE INTO `version` (`version`) VALUES ('2.6.3');