Index: trunk/ippMonitor/raw/czartool_labels.php
===================================================================
--- trunk/ippMonitor/raw/czartool_labels.php	(revision 30943)
+++ trunk/ippMonitor/raw/czartool_labels.php	(revision 30948)
@@ -13,4 +13,5 @@
 
 $gpc1db = dbconnect($ID['proj']);
+
 
 $PATH = getenv("PATH");
@@ -211,5 +212,38 @@
      echo "</td>\n";
      echo "<td>\n";
-      createDatesTable($czardb);
+
+      echo "<table>\n";
+       echo "<tr>\n";
+         echo "<td>\n";
+          createDatesTable($czardb);
+         echo "</td>\n";
+       echo "</tr>\n";
+       echo "<tr>\n";
+         echo "<td>\n";
+          createPStampDataTable();
+         echo "</td>\n";
+       echo "</tr>\n";
+       echo "<tr>\n";
+         echo "<td>\n";
+               if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
+         echo "</td>\n";
+       echo "</tr>\n";
+       echo "<tr>\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";
@@ -218,34 +252,50 @@
  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();
 
+
+###########################################################################
+#
+# Creates a postage stamp status table
+#
+###########################################################################
+function createPStampDataTable() {
+
+    $sql = "SELECT label, COUNT(job_id) AS 'Unfinished Jobs', IFNULL(priority,10000) AS priority FROM pstampRequest JOIN pstampJob USING(req_id) LEFT JOIN Label USING(label) WHERE pstampJob.state ='run' and pstampRequest.state ='run' GROUP by label";
+
+    $pstampdb = DB::connect("mysql://ippuser:ippuser@ippc17/ippRequestServer");
+    $qry = $pstampdb->query($sql);
+    if (dberror($qry)) {
+        echo "<b>error reading pstamp table</b><br>\n";
+        echo "<br><small><b> table query : $sql </b></small><br>\n";
+        menu_end();
+    }
+
+    // set up the table
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>";
+    echo "<th colspan=\"3\">Postage stamp requests</th>";
+    echo "<tr>";
+    echo "<th>Label</th>";
+    echo "<th>Unfinished jobs</th>";
+    echo "<th>Priority</th>";
+
+    // list the results
+    while ($qry->fetchInto($row)) {
+
+        echo "<tr>";
+
+        echo "<td>$row[0]</td>";
+        echo "<td>$row[1]</td>";
+        echo "<td>$row[2]</td>";
+        
+        echo "</tr>";
+    }
+
+    echo "</table>\n";
+
+}
 
 ###########################################################################
@@ -886,5 +936,5 @@
         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("");
+        die("");
         return;
 
