Index: trunk/ippMonitor/raw/czartool_labels.php
===================================================================
--- trunk/ippMonitor/raw/czartool_labels.php	(revision 30760)
+++ trunk/ippMonitor/raw/czartool_labels.php	(revision 30908)
@@ -58,11 +58,26 @@
 if ($plotType == "") { $plotType = "linear"; }
 
+
+// header block
+echo "<head>";
+echo "<h1 align=\"middle\">Czartool</h1>";
+echo "</head>";
+
+// status table at top
 $nsStatus = getNightlyScienceStatus($czardb);
 $plotTypeLink = ($plotType == "linear") ? "log" : "linear";
 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
-echo "<p>Current ippMonitor SVN version: ";
-include 'version.php';
-echo "</p>";
-echo "<p  align=\"center\"> Current status of the IPP as of $lastUpdateTime (faults are shown in parentheses). <br>Documentation can be found <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\">here</a> and cluster load monitored <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&c=IPP%2520Production\">here</a><br>Current nightly science status: $nsStatus<br>Use <a href=\"$link\"> $plotTypeLink</a> plots <br/><a href=\"http://ipp004.ifa.hawaii.edu/clusterMonitor/top.html\">Who uses the cluster?</a><br><a href=\"http://ipp004.ifa.hawaii.edu/ippMetrics\">IPP Metrics</a><br/><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PS1_IPP_CzarLogs\">Czar log pages</a><br><a href=\"czartool_exposures.php?pass=$pass&proj=$proj\">Exposure summary</a></p>";
+echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+echo "<tr>\n";
+echo "<tr><td>Time of last update</td><td>$lastUpdateTime</td></tr>";
+echo "<tr><td>ippMonitor SVN version</td><td>"; include 'version.php'; echo "</td></tr>"; 
+echo "<tr><td>Current nightly science status</td><td>$nsStatus</td></tr>"; 
+echo "<tr><td>Documentation</td><td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\">here</a></td></tr>";
+echo "<tr><td>Cluster load</td><td><a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&c=IPP%2520Production\">here</a></td></tr>";
+echo "<tr><td>Who's using the cluster?</td><td><a href=\"http://ipp004.ifa.hawaii.edu/clusterMonitor/top.html\">here</a></td></tr>";
+echo "<tr><td>IPP metrics</td><td><a href=\"http://ipp004.ifa.hawaii.edu/ippMetrics\">here</a></td></tr>";
+echo "<tr><td>Czar log pages</td><td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PS1_IPP_CzarLogs\">here</a></td></tr>";
+echo "<tr><td>Exposure summary</td><td><a href=\"czartool_exposures.php?pass=$pass&proj=$proj\">here</a></td></tr>";
+echo "</table>\n";
 
 // deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later
@@ -102,131 +117,131 @@
 echo "</form>\n";
 
-  echo "<table>\n";
-
-
-  # 1st row
-    echo "<tr>\n";
+echo "<table>\n";
+
+ # 1st row
+  echo "<tr>\n";
+   echo "<td> \n";
+    echo "<table>\n";
+     echo "<tr valign=center>\n";
       echo "<td> \n";
-        echo "<table>\n";
-          echo "<tr valign=center>\n";
-            echo "<td> \n";
-              # timeseries plot
-              echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage&plottype=$plotType\"><br>";
-            echo "</td>\n";
-            echo "<td>\n";
-              createLabelsTable($pass, 
-                      $proj, 
-                      $czardb, 
-                      "stdscience", 
-                      $stdsLabels, 
-                      $distLabels, 
-                      $pubLabels, 
-                      $stages, 
-                      $states, 
-                      "new", 
-                      $selectedLabel, 
-                      $selectedStage, 
-                      $plotType);
-            echo "</td>\n";
-          echo "</tr>\n";
-        echo "</table>\n";
-      echo "</td> \n";
-    echo "</tr>\n";
-
-
-
-    # 2nd row
-    echo "<tr>\n";
-      echo "<td> \n";
-        echo "<table>\n";
-          echo "<tr valign=center>\n";
-            echo "<td> \n";
-              # rate plot
-              echo "<img src=\"czartool_getplot.php?type=r&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
-            echo "</td>\n";
-            echo "<td>\n";
-            createLabelsTable($pass, 
-                    $proj, 
-                    $czardb, 
-                    "update", 
-                    $updateLabels, 
-                    $distLabels, 
-                    $pubLabels, 
-                    $stages, 
-                    $states, 
-                    "new", 
-                    $selectedLabel, 
-                    $selectedStage, 
-                    $plotType);
-            echo "</td>\n";
-          echo "</tr>\n";
-        echo "</table>\n";
-      echo "</td> \n";
-    echo "</tr>\n";
-
-
-    # 3rd row
-    echo "<tr>\n";
-      echo "<td> \n";
-        echo "<table>\n";
-          echo "<tr valign=top>\n";
-            echo "<td> \n";
-              # histogram plot
-              echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
-            echo "</td>\n";
-            echo "<td>\n";
-              createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
-            echo "</td>\n";
-
-            echo "<td> \n";
-              $today = date("Y-m-d");
-              createSummitDataTable($gpc1db, $today);
-            echo "</td>\n";
-          echo "</tr>\n";
-        echo "</table>\n";
-      echo "</td> \n";
-    echo "</tr>\n";
-
-    # 4th row
-    echo "<tr>\n";
-      echo "<td> \n";
-        echo "<table>\n";
-          echo "<tr valign=top>\n";
-            echo "<td> \n";
-              # storage plot
-              echo "<img src=\"czartool_getplot.php?type=s\"><br>";
-            echo "</td>\n";
-            echo "<td>\n";
-              createDatesTable($czardb);
-            echo "</td>\n";
-          echo "</tr>\n";
-        echo "</table>\n";
-      echo "</td> \n";
-    echo "</tr>\n";
-
-    # 5th row
-    echo "<tr>\n";
+       # timeseries plot
+       echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage&plottype=$plotType\"><br>";
+      echo "</td>\n";
       echo "<td>\n";
-        echo "<table>\n";
-          echo "<tr valign=top>\n";
-            echo "<td> \n";
-              if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
-            echo "</td>\n";
-            echo "<td>\n";
-            # This is awful
-              echo "<table border=\"1\"><tr><td colspan=\"2\"><b>Databases Replication Status</b></td></tr>";
-                echo "<tr><td colspan=\"2\">Update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\">here</a></td></tr>";
-                echo "<tr><td>Database</td><td>Replication Status</td></tr>";
-                showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_DBNAME_GPC1);
-                showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_DBNAME_NEBULOUS);
-		showReplicationsStatus($REPL_HOST_PSTAMP, $REPL_USER_PSTAMP, $REPL_PASSWORD_PSTAMP, $REPL_DBNAME_PSTAMP);
-              echo "</table>";
-            echo "</td>\n";
-          echo "</tr>\n";
-        echo "</table>\n";
-      echo "</td> \n";
-    echo "</tr>\n";
-
-  echo "</table>\n";
+       createLabelsTable($pass, 
+         $proj, 
+         $czardb, 
+         "stdscience", 
+         $stdsLabels, 
+         $distLabels, 
+         $pubLabels, 
+         $stages, 
+         $states, 
+         "new", 
+         $selectedLabel, 
+         $selectedStage, 
+         $plotType);
+      echo "</td>\n";
+    echo "</tr>\n";
+   echo "</table>\n";
+  echo "</td> \n";
+ echo "</tr>\n";
+
+ # 2nd row
+ echo "<tr>\n";
+  echo "<td> \n";
+   echo "<table>\n";
+    echo "<tr valign=center>\n";
+     echo "<td> \n";
+      # rate plot
+      echo "<img src=\"czartool_getplot.php?type=r&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+     echo "</td>\n";
+     echo "<td>\n";
+      createLabelsTable($pass, 
+         $proj, 
+         $czardb, 
+         "update", 
+         $updateLabels, 
+         $distLabels, 
+         $pubLabels, 
+         $stages, 
+         $states, 
+         "new", 
+         $selectedLabel, 
+         $selectedStage, 
+         $plotType);
+     echo "</td>\n";
+    echo "</tr>\n";
+   echo "</table>\n";
+  echo "</td> \n";
+ echo "</tr>\n";
+ 
+
+ # 3rd row
+ echo "<tr>\n";
+  echo "<td> \n";
+   echo "<table>\n";
+    echo "<tr valign=top>\n";
+     echo "<td> \n";
+      # histogram plot
+      echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+     echo "</td>\n";
+     echo "<td>\n";
+      createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
+     echo "</td>\n";
+ 
+     echo "<td> \n";
+      $today = date("Y-m-d");
+      createSummitDataTable($gpc1db, $today);
+     echo "</td>\n";
+    echo "</tr>\n";
+   echo "</table>\n";
+  echo "</td> \n";
+ echo "</tr>\n";
+
+ # 4th row
+ echo "<tr>\n";
+  echo "<td> \n";
+   echo "<table>\n";
+    echo "<tr valign=top>\n";
+     echo "<td> \n";
+      # storage plot
+      echo "<img src=\"czartool_getplot.php?type=s\"><br>";
+     echo "</td>\n";
+     echo "<td>\n";
+      createDatesTable($czardb);
+     echo "</td>\n";
+    echo "</tr>\n";
+   echo "</table>\n";
+  echo "</td> \n";
+ echo "</tr>\n";
+
+ # 5th row
+ echo "<tr>\n";
+  echo "<td>\n";
+   echo "<table>\n";
+    echo "<tr valign=top>\n";
+     echo "<td> \n";
+      if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
+     echo "</td>\n";
+     echo "<td>\n";
+      # This is awful
+      echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+      echo "<tr>";
+      echo "<th colspan=\"2\">Database replication status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\">here</a>)</th>";
+      echo "<tr>";
+      echo "<th>Database</th>";
+      echo "<th>Status</th>";
+      showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_DBNAME_GPC1);
+      showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_DBNAME_NEBULOUS);
+      showReplicationsStatus($REPL_HOST_PSTAMP, $REPL_USER_PSTAMP, $REPL_PASSWORD_PSTAMP, $REPL_DBNAME_PSTAMP);
+      echo "</table>";
+     echo "</td>\n";
+    echo "</tr>\n";
+   echo "</table>\n";
+  echo "</td> \n";
+ echo "</tr>\n";
+
+echo "</table>\n";
 
 menu_end();
@@ -250,9 +265,11 @@
 
     // set up the table
-    echo "<table class=list>\n";
-    echo "<tr><td></td>\n";
-    write_header_cell ("list", "Exposure type");
-    write_header_cell ("list", "At summit");
-    write_header_cell ("list", "Registered at MHPCC");
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>";
+    echo "<th colspan=\"3\">Status of last night's data</th>";
+    echo "<tr>";
+    echo "<th>Exposure type</th>";
+    echo "<th>At summit</th>";
+    echo "<th>Registered at MHPCC</th>";
 
     $msg = "No science images taken since $date";
@@ -268,25 +285,26 @@
         $qry2->fetchInto($mhpcc);
 
-        $class = "list";
-        echo "<tr><td></td>\n";
-
-        if ($expType[0] == "OBJECT") {
-	  if ($summit[0] == $mhpcc[0]) {
-	    $msg = "All science exposures taken since $date<br>have been registered at MHPCC";
-	  }
-	  else {
-	    $msg = "<font color=\"orange\">Warning: Not all science exposures taken since $date<br>have been registered at MHPCC</a>";
-	  }
+        echo "<tr>";
+
+        if ($summit[0] == $mhpcc[0]) {
+
+            if ($expType[0] == "OBJECT") $msg = "All science exposures taken since $date<br>have been registered at MHPCC";
+            $color = "";
         }
-
-        write_table_cell ($class, '%s', "", $expType[0]);
-        write_table_cell ($class, '%d', "", $summit[0]);
-        write_table_cell ($class, '%d', $link, $mhpcc[0]);
-        echo "</tr>\n";
-    }
-
+        else {
+            if ($expType[0] == "OBJECT") $msg = "<font color=\"red\">Warning: Not all science exposures taken since $date<br>have been registered at MHPCC</a>";
+            $color = "red";
+        }
+
+        echo "<td>$expType[0]</td>";
+        echo "<td>$summit[0]</td>";
+        
+        echo "<td bgcolor=\"$color\">$mhpcc[0]</td>";
+
+        echo "</tr>";
+    }
+
+    echo "<td colspan=\"3\">$msg</td>";
     echo "</table>\n";
-
-    echo "<p> $msg </p>";
 
 }
@@ -331,14 +349,36 @@
         $selectedLabel, $selectedStage, $plotType) {
 
-    // set up table columns
-    $class = "list";
-    echo "<table class=$class >\n";
-    echo "<tr><td></td>\n";
-
-    echo "<p  align=\"center\"> Current labels for $server server (D=distributing, P=publishing)</p>";
-
-    write_header_cell($class, "");
-    write_header_cell($class, "");
-    write_header_cell($class, "Reverts:");
+    // setup table
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>\n";
+    echo "<th colspan=\"12\">";
+    
+    $link = "czartool_labels.php?pass=".$pass
+        ."&proj=".$proj
+        ."&label=".$selectedLabel
+        ."&stage=all_stages"
+        ."&plottype=".$plotType;
+    if ($selectedStage != "all_stages") echo "<a href=\"$link\">";
+    else echo "<a>";
+    echo "Plot all stages</a> | ";
+    $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage."&plottype=".$plotType;
+    echo "<a ";
+    if ($selectedLabel != "all_".$server."_labels") echo "<a href=\"$link\">";
+    else echo "<a>";
+    echo "Plot all ".$server."_labels</a> | ";
+    $plotTypeLink = ($plotType == "linear") ? "log" : "linear";
+    $plotTypeText = ($plotType == "linear") ? "Use log plots" : "Use linear plots";
+    $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
+    echo "<a href=\"$link\">$plotTypeText</a>";
+
+
+    echo "</th>";
+    echo "</tr>\n";
+
+    echo "<tr>\n";
+    //echo "<th></th>";
+    echo "<th colspan=\"2\">$server server</th>";
+    echo "<th>Reverts:</th>";
+
     foreach ($stages as &$stage) {
 
@@ -357,38 +397,28 @@
         if($reverting) {$label = "Stop";$link = $link . "off";}
         unset($reverting);
-        write_table_cell($class, '%s', $link, $label);
-    }
-    write_header_cell($class, "");
-
-    echo "</tr>\n";
-    echo "<tr><td></td>\n";
-    write_header_cell($class, " ");
-    write_header_cell($class, "Label (in order of priority)");
+        echo "<td><a href=\"$link\"> $label</td>";
+
+    }
+
+    echo "</tr>\n";
+    echo "<tr>\n";
+    //echo "<th> </th>";
+    echo "<th colspan=\"2\">Label (in order of priority)</th>";
     foreach ($stages as &$stage) {
 
-        if ($stage == $selectedStage) $link = "";
-        else $link = 
+        if ($stage == $selectedStage) $showLink = 0;
+        else $showLink = 1;
+        $link = 
             "czartool_labels.php?pass=".$pass
-                ."&proj=".$proj 
-                ."&label=".$selectedLabel
-                ."&stage=".$stage
-                ."&plottype=".$plotType;
-
-        write_table_cell($class, '%s', $link, $stage);
-    }
-
-    if ($selectedStage=="all_stages") $link = "";
-    else $link = 
-        "czartool_labels.php?pass=".$pass
-            ."&proj=".$proj
+            ."&proj=".$proj 
             ."&label=".$selectedLabel
-            ."&stage=all_stages"
+            ."&stage=".$stage
             ."&plottype=".$plotType;
 
-    write_table_cell($class, '%s', $link, "All stages");
-
-    echo "</tr>\n";
-    echo "<tr><td></td>\n";
-
+        createLabelTableCell($showLink, $link, $stage);
+    }
+
+
+    // setup default link
     $defaultlink = 
         "czartool_labels.php?pass=".$pass
@@ -415,20 +445,21 @@
         }
 
-        // create link to label summary page for each label
-        if ($thisLabel == $selectedLabel) $link = "";
-        else $link = 
-            "czartool_labels.php?pass=".$pass
-                ."&proj=".$proj
-                ."&label=".$thisLabel
-                ."&stage=".$selectedStage
-                ."&plottype=".$plotType;
-
-        echo "<tr><td></td>\n";
-        $distPub = " ";
+        // show distribution/publishing status
+        echo "<tr>\n";
+        $distPub = "&nbsp;";
         if ($distributing) $distPub = "D";
         if ($publishing) $distPub = $distPub . "P";
-        write_table_cell($class, '%s', "", $distPub);
-
-        write_table_cell($class, '%s', $link, $thisLabel);
+        echo "<td>$distPub</td>";
+
+        // create link to label summary page for each label
+        if ($thisLabel == $selectedLabel) $showLink = 0;
+        else $showLink = 1;
+        $link = 
+            "czartool_labels.php?pass=".$pass
+            ."&proj=".$proj
+            ."&label=".$thisLabel
+            ."&stage=".$selectedStage
+            ."&plottype=".$plotType;
+        createLabelTableCell($showLink, $link, $thisLabel);
 
         $str = "";
@@ -437,54 +468,64 @@
         $link = $defaultlink;
         getStateAndFaults($db, $thisLabel, $selectedState, "burntool", $str, $anyFaults);
-        write_table_cell($class, '%s', $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = "failedChipProcessedImfile.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $thisLabel . "&chipRun.state=".$searchState;
         getStateAndFaults($db, $thisLabel, $selectedState, "chip", $str, $anyFaults);
-        write_table_cell($class, '%s', $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = "failedCamProcessedExp.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $thisLabel . "&camRun.state=".$searchState;
         getStateAndFaults($db, $thisLabel, $selectedState, "cam", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link =  "failedFakeProcessedImfile.php?pass=" . $pass . "&proj=" . $proj . "&fakeRun.label=" . $thisLabel . "&fakeRun.state=".$searchState;
         getStateAndFaults($db, $thisLabel, $selectedState, "fake", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = "failedWarpSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $thisLabel . "&warpRun.state=".$searchState;
         getStateAndFaults($db, $thisLabel, $selectedState, "warp", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "",  $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = "failedStackSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $thisLabel . "&stackRun.state=".$searchState;
         getStateAndFaults($db, $thisLabel, $selectedState, "stack", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = "failedDiffSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $thisLabel . "&diffRun.state=".$searchState;
         getStateAndFaults($db, $thisLabel, $selectedState, "diff", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "",  $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = $defaultlink;
         getStateAndFaults($db, $thisLabel, $selectedState, "magic", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = $defaultlink;
         getStateAndFaults($db, $thisLabel, $selectedState, "magicDS", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         $link = $defaultlink;
         getStateAndFaults($db, $thisLabel, $selectedState, "dist", $str, $anyFaults);
-        write_table_cell($class, '%s',  $anyFaults ? $link : "", $str);
+        createLabelTableCell($anyFaults, $link, $str);
 
         echo "</tr>\n";
     }
 
-    if ($selectedLabel == "all_".$server."_labels") $link = "";
-    else  $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage."&plottype=".$plotType;
-
-    echo "<tr><td></td>\n";
-    write_table_cell($class, '%s', "", " ");
-    write_table_cell($class, '%s', $link, "All $server labels");
+    if ($selectedLabel == "all_".$server."_labels") $showLink = 0;
+    else  $showLink = 1;
+    $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage."&plottype=".$plotType;
 
     echo "</tr>\n";
     echo "</table>\n";
+}
+
+
+###########################################################################
+#
+# Creates table cell for lable table
+#
+###########################################################################
+function createLabelTableCell($showLink, $link, $str) {
+
+    if ($showLink) echo "<td><a href=\"$link\">$str</td>";
+    else if ($str) echo "<td>$str</td>";
+    else echo "<td>&nbsp;</td>";
 }
 
@@ -594,9 +635,10 @@
 function createDatesTable($db) {
 
-    $class = "list";
-    echo "<table class=$class>\n";
-    echo "<tr><td></td>\n";
-    write_header_cell($class, "Server");
-    write_header_cell($class, "Dates");
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>\n";
+    echo "<th colspan=\"3\">Current dates for selected pantasks servers</th>";
+    echo "<tr>\n";
+    echo "<th>Server</th>";
+    echo "<th>Dates</th>";
     echo "</tr>\n";
 
@@ -632,9 +674,8 @@
     }
 
-    $class = "list";
-    echo "<tr><td></td>\n";
-    write_table_cell($class, '%s', "", $server);
-    write_table_cell($class, '%s', "", $dates);
-    echo "</tr>\n";
+    echo "<tr>";
+    echo "<td>$server</td>";
+    echo "<td>$dates</td>";
+    echo "</tr>";
 
 }
@@ -648,27 +689,32 @@
 
     // set up table columns
-    $class = "list";
-    echo "<table class=$class>\n";
-    echo "<tr><td></td>\n";
-    write_header_cell($class, "Server");
-    write_header_cell($class, "Alive?");
-    $link = "czartool_labels.php?pass=".$pass
-        ."&proj=".$proj
-        ."&label=".$selectedLabel
-        ."&stage=".$selectedStage
-        ."&plottype=".$plotType
-        ."&allservercmd=stop";
-
-    $link = ""; # TODO removed links temporarily
-        write_table_cell($class, '%s', $link, "Stop all");
-    $link = "czartool_labels.php?pass=".$pass
-        ."&proj=".$proj
-        ."&label=".$selectedLabel
-        ."&stage=".$selectedStage
-        ."&plottype=".$plotType
-        ."&allservercmd=run";
-
-    $link = ""; # TODO removed links temporarily
-        write_table_cell($class, '%s', $link, "Run all");
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>";
+    echo "<th colspan=\"3\">Pantasks server status</th>";
+    echo "<tr>";
+    echo "<th>Server</th>";
+    echo "<th>Alive?</th>";
+    echo "<th>Running?</th>";
+
+    //write_header_cell($class, "Server");
+    //write_header_cell($class, "Alive?");
+    //$link = "czartool_labels.php?pass=".$pass
+    //    ."&proj=".$proj
+    //    ."&label=".$selectedLabel
+    //    ."&stage=".$selectedStage
+    //    ."&plottype=".$plotType
+    //    ."&allservercmd=stop";
+
+    //$link = ""; # TODO removed links temporarily
+    //    write_table_cell($class, '%s', $link, "Stop all");
+    //$link = "czartool_labels.php?pass=".$pass
+    //    ."&proj=".$proj
+    //    ."&label=".$selectedLabel
+    //    ."&stage=".$selectedStage
+    //    ."&plottype=".$plotType
+    //    ."&allservercmd=run";
+
+    //$link = ""; # TODO removed links temporarily
+    //    write_table_cell($class, '%s', $link, "Run all");
     echo "</tr>\n";
 
@@ -677,5 +723,5 @@
         getServerStatus($db, $server, $alive, $running);
 
-        echo "<tr><td></td>\n";
+        echo "<tr>\n";
         $link = "czartool_labels.php?pass=".$pass
             ."&proj=".$proj
@@ -686,37 +732,44 @@
 
         #$link = ""; # TODO removed links temporarily
-        write_table_cell($class, '%s', $link, $server);
-        write_table_cell($class, '%s', "", $alive ? "yes" : "NO");
-
-        if ($alive) {
-
-            $link = "czartool_labels.php?pass=".$pass
-                ."&proj=".$proj
-                ."&label=".$selectedLabel
-                ."&stage=".$selectedStage
-                ."&plottype=".$plotType
-                ."&server=".$server
-                ."&servercmd=";
-
-            if ($running)  {
-
-                $link = $link . "stop";
-                $link = ""; # TODO removed links temporarily
-                    write_table_cell($class, '%s', $link, "stop");
-                write_table_cell($class, '%s', "", "");
-            }
-            else {
-
-                $link = $link . "run";
-                write_table_cell($class, '%s', "", "");
-                $link = ""; # TODO removed links temporarily
-                    write_table_cell($class, '%s', $link, "run");
-            }
-        }
-        else {
-
-            write_table_cell($class, '%s', "", "");
-            write_table_cell($class, '%s', "", "");
-        }
+        //write_table_cell($class, '%s', $link, $server);
+        //write_table_cell($class, '%s', "", $alive ? "yes" : "NO");
+        echo "<td>$server</td>";
+        $yesNo = $alive ? "yes" : "NO";
+        $color = $alive ? "" : "red";
+        echo  "<td bgcolor=\"$color\">$yesNo</td>";
+        $yesNo = $running ? "yes" : "NO";
+        $color = $running ? "" : "red";
+        echo  "<td bgcolor=\"$color\">$yesNo</td>";
+
+        //if ($alive) {
+
+          //  $link = "czartool_labels.php?pass=".$pass
+            //    ."&proj=".$proj
+              //  ."&label=".$selectedLabel
+              //  ."&stage=".$selectedStage
+              //  ."&plottype=".$plotType
+              //  ."&server=".$server
+              //  ."&servercmd=";
+
+            //if ($running)  {
+
+              //  $link = $link . "stop";
+              //  $link = ""; # TODO removed links temporarily
+              //      write_table_cell($class, '%s', $link, "stop");
+              //  write_table_cell($class, '%s', "", "");
+           // }
+           // else {
+
+             //   $link = $link . "run";
+              //  write_table_cell($class, '%s', "", "");
+              //  $link = ""; # TODO removed links temporarily
+               //     write_table_cell($class, '%s', $link, "run");
+           // }
+       // }
+       // else {
+
+         //   write_table_cell($class, '%s', "", "");
+         //   write_table_cell($class, '%s', "", "");
+       // }
         echo "</tr>\n";
     }
@@ -822,5 +875,9 @@
     $dbRepl = DB::connect("mysql://$replUser:$replPassword@$replHost");
     if (PEAR::isError($dbRepl)) {
-        die("MySQL DB connection error: Check the configuration for $replDatabaseName");
+        echo "<tr><td>$replDatabaseName</td><td bgcolor=\"red\">MySQL DB connection error - check configuration</td></tr>";
+        //die("MySQL DB connection error: Check the configuration for $replDatabaseName");
+        die("");
+        return;
+
     }
     $res = $dbRepl->query('SHOW SLAVE STATUS');
