Browse Source

restore delete device from device list

rajven 3 years ago
parent
commit
48df349b71
1 changed files with 19 additions and 1 deletions
  1. 19 1
      html/admin/devices/index.php

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

@@ -7,6 +7,21 @@ $default_sort='device_name';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
+if (isset($_POST["remove_device"])) {
+    $dev_ids = $_POST["fid"];
+    foreach ($dev_ids as $key => $val) {
+        if ($val) {
+                unbind_ports($db_link, $val);
+                run_sql($db_link, "DELETE FROM connections WHERE device_id=".$val);
+                run_sql($db_link, "DELETE FROM device_l3_interfaces WHERE device_id=".$val);
+                run_sql($db_link, "DELETE FROM device_ports WHERE device_id=".$val);
+                delete_record($db_link, "devices", "id=".$val);
+                }
+            }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    exit;
+    }
+
 print_device_submenu($page_url);
 
 $sort_sql=" ORDER BY device_name";
@@ -20,9 +35,11 @@ if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field
 <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"); ?>
 <?php print WEB_device_show_location; print_building_select($db_link, "building_id", $f_building_id); ?></td>
-<td class="info" colspan=2> <input type="submit" name="apply" value="<?php echo WEB_btn_show; ?>"></td>
+<td class="info"><input type="submit" name="apply" value="<?php echo WEB_btn_show; ?>"></td>
+<td class="info"><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove_device" value="<?php echo WEB_btn_delete; ?>"></td>
 </tr>
 <tr align="center">
+<td align=Center><input type="checkbox" onClick="checkAll(this.checked);"></td>
 <td><b><a href=index.php?sort=device_type&order=<?php print $new_order; ?>><?php echo WEB_cell_type; ?></a></b></td>
 <td><b><a href=index.php?sort=device_name&order=<?php print $new_order; ?>><?php echo WEB_cell_name; ?></a></b></td>
 <td><b><a href=index.php?sort=ip&order=<?php print $new_order; ?>><?php echo WEB_cell_ip; ?></a></b></td>
@@ -46,6 +63,7 @@ foreach ($switches as $row) {
         $cl = 'shutdown';
         if ($row['nagios_status'] == 'UP') { $cl = 'up'; }
         }
+    print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
     print "<td class=\"$cl\">".get_devtype_name($db_link,$row['device_type'])."</td>\n";
     print "<td class=\"$cl\" align=left><a href=editdevice.php?id=".$row['id'].">" . $row['device_name'] . "</a></td>\n";
     if (isset($row['user_id']) and $row['user_id']>0) {