Browse Source

Fix some HTML issues and a problem when there are no available logical
switches for a physical switch.

Joe Clarke 9 years ago
parent
commit
0a2b5fbb3c
1 changed files with 17 additions and 10 deletions
  1. 17 10
      index.php

+ 17 - 10
index.php

@@ -179,10 +179,10 @@ if (!isset($_REQUEST['filter'])) {
 
 print_header("Switch Registration Tool: Physical Switches");
 ?>
-  <script language="javascript">
-var deletes = 0;
-  </script>
   <body class="flex">
+    <script language="javascript">
+var deletes = 0;
+    </script>
     <div id="headswreg">
       <div class="apage">
         <div id="header">
@@ -195,6 +195,7 @@ var deletes = 0;
       </div>
     </div>
     <div class="apage">
+       <form method="POST" name="search_form" action="<?=$_SERVER['PHP_SELF']?>">
        <table class="noborder" summary="Filter Table">
          <tr>
 	   <td class="left_act">Show Only:
@@ -211,14 +212,13 @@ foreach ($pids as $lsp => $value) {
 }
 ?>
            </select></td>
-           <form method="POST" name="search_form" action="<?=$_SERVER['PHP_SELF']?>">
              <td class="right">Switch Search:
 	       <input type="text" size="16" name="switch_name" value="<?=$_REQUEST['switch_name']?>">
                <input type="image" value="Submit" name="search" src="/images/submit_button.png">
              </td>
-           </form>
         </tr>
       </table>
+      </form>
       <br/>
       <table class="noborder" summary="Control Table">
         <tr>
@@ -228,7 +228,7 @@ foreach ($pids as $lsp => $value) {
         </tr>
       </table>
       <form name="mod_phys_switch_form" method="POST" action="<?=$_SERVER['PHP_SELF']?>" onSubmit='if (deletes > 0) { return confirm("Are you sure you want to delete these physical switches?"); }'>
-        <table class="swreg" summary="Button Table" class="full">
+        <table class="swreg" summary="Button Table">
           <tr>
             <td><input type="reset" value="Reset" name="reset">
             <input type="submit" value="Submit" name="submit"></td>
@@ -244,10 +244,10 @@ foreach ($errors as $error) {
 }
 ?>
         </div>
-        <table class="swreg" summary="Physical Switch Table" class="full">
+        <table class="swreg" summary="Physical Switch Table">
           <tr>
             <th class="delete">Row No.</th>
-            <th class="delete">Delete?</td>
+            <th class="delete">Delete?</th>
             <th class="delete">Provisioned?</th>
 	    <th class="headlink">Serial Number</th>
             <th class="headlink">Product ID</th>
@@ -283,6 +283,7 @@ foreach ($switches as $row) {
             <td><?=$row['max_ports']?></td>
 	    <td><select id="asw<?=$i?>" name="assigned_switch[<?=$sn?>]" onChange='var elem = document.getElementById("checked_<?=$i?>"); if (this.value == "__BOGUS__") { elem.checked = false; } else { elem.checked = true; }'>
 <?php
+	$has_avail = FALSE;
 	foreach ($lswitches[$row['pid']] as $lsw) {
 		$selected = ($row['assigned_switch'] == $lsw) ? "selected" : "";
 		if ($selected == '' && isset($used[$lsw]) && $used[$lsw] === TRUE) {
@@ -293,14 +294,20 @@ foreach ($switches as $row) {
               <option value="__BOGUS__" <?=$selected?>>--Please Select--</option>
 <?php
 		} else {
+			$has_avail = TRUE;
 ?>
 	      <option value="<?=$lsw?>" <?=$selected?>><?=$lsw?></option>
 <?php
 		}
 	}
+	if (!$has_avail) {
+?>
+                <option value="__BOGUS__" <?=$selected?>>--Please Select--</option>
+<?php
+	}
 ?>
 	      </select>
-	      &nbsp;<a href="#" onClick='var lsw = document.getElementById("asw<?=$i?>"); if (lsw.value == "__BOGUS__") { alert("There is no logical switch associated to this device."); return false; } else { window.open("<?=$base?>/logicsw.php?switch_name=" + lsw.value, "Logical switch " + lsw.value, "height=480,width=980"); return false; }'><img src="/images/switch.gif" border="0" title="View logical switch"></a>&nbsp;<a href="#" onClick='var pros = document.getElementById("pros<?=$i?>"); var lsw = document.getElementById("asw<?=$i?>"); if (lsw.value == "0") { alert("This switch is not yet provisioned."); return false; } else { window.open("<?=$base?>/show_config.php?cfg=" + lsw.value + "-config.txt&dname=" + lsw.value, "Config for switch " + lsw.value, "height=650,width=980"); return false; }'><img src="/images/mag.gif" border="0" title="View switch config"></a>
+	      &nbsp;<a href="#" onClick='var lsw = document.getElementById("asw<?=$i?>"); if (lsw.value == "__BOGUS__") { alert("There is no logical switch associated to this device."); return false; } else { window.open("<?=$base?>/logicsw.php?switch_name=" + lsw.value, "Logical switch " + lsw.value, "height=480,width=980"); return false; }'><img src="/images/switch.gif" border="0" title="View logical switch"></a>&nbsp;<a href="#" onClick='var pros = document.getElementById("pros<?=$i?>"); var lsw = document.getElementById("asw<?=$i?>"); if (pros.value == "0") { alert("This switch config has not yet been generated."); return false; } else { window.open("<?=$base?>/show_config.php?cfg=" + lsw.value + "-config.txt&dname=" + lsw.value, "Config for switch " + lsw.value, "height=650,width=980"); return false; }'><img src="/images/mag.gif" border="0" title="View switch config"></a>
             </td>
 <?php
 	$color = '#FFFFFF';
@@ -344,7 +351,7 @@ foreach ($switches as $row) {
 ?>
         </table>
         <br/>
-        <table class="swreg" summary="Button Table" class="full">
+        <table class="swreg" summary="Button Table">
           <tr>
             <td><input type="reset" value="Reset" name="reset">
             <input type="submit" value="Submit" name="submit"></td>