Index: branches/czw_branch/20101203/ippMonitor/raw/czartool_exposures.php
===================================================================
--- branches/czw_branch/20101203/ippMonitor/raw/czartool_exposures.php	(revision 30586)
+++ branches/czw_branch/20101203/ippMonitor/raw/czartool_exposures.php	(revision 30587)
@@ -17,16 +17,34 @@
 else {$myMenu = "ipp.imfiles.dat";}
 
-menu($myMenu, 'Czartool on '.$lastUpdateTime, 'ipp.css', $ID['link'], $ID['proj']);
-
 $pass = $ID['pass'];
 $proj = $ID['proj'];
 $menu = $ID['menu'];
 
-$today = date("Y-m-d");
-
+$date = $_POST['date'];
+$survey = $_POST['survey'];
+
+// if no date chosen, use today
+if ($date == "") $date = date("Y-m-d");
+if ($survey == "") $survey = "";
+
+menu($myMenu, 'Exposure summary for '.$date , 'ipp.css', $ID['link'], $ID['proj']);
+
+// set up the form
+echo "<form action=\"czartool_exposures.php\" method=\"POST\">\n";
+
+echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+echo "<input type=\"hidden\" name=\"proj\" value=\"$proj\">\n";
+echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n";
+
+
+echo "<form method=post action=czartool_exposures.php?pass=$pass&proj=$proj&date=$date&survey=$survey>";
+echo "<p  align=\"center\"> Current status of all exposures taken on (UTC) <input type=text name=date value='$date'>";
+echo " for survey <input type=text name=survey value='$survey'> (leave blank for all surveys)";
+echo "<input type=submit value=Submit>";
 echo "</p>";
-echo "<p  align=\"center\"> Current status of all exposures taken $today UTC </p>"; 
-
-createTableForThisSurvey($gpc1db, $today, "");
+
+echo "</form>\n";
+
+createTableForThisSurvey($gpc1db, $date, $survey);
 
 menu_end();
@@ -58,5 +76,5 @@
     $qry->fetchInto($count);
 
-    if ($surveyStr == "") $surveyText = "all surveys"; 
+    if ($surveyStr == "") $surveyText = "all surveys";
     else $surveyText = "$surveyStr survey";
 
@@ -83,34 +101,36 @@
     $ssDiffProduced = array(); getSSDiffProduced($db, $date, $surveyStr, &$ssDiffProduced); 
 
-    $class = "list";
-    echo "<table class=$class >\n";
+    // create table
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+
+    // table headers
     echo "<tr><td></td>\n";
-    write_header_cell($class, "");
-    write_header_cell($class, "");
-    write_header_cell($class, "");
-    write_header_cell($class, "");
-    write_header_cell($class, "Raw");
-    write_header_cell($class, "Chip");
-    write_header_cell($class, "Camera");
-    write_header_cell($class, "Warp");
-    write_header_cell($class, "Stack");
-    write_header_cell($class, "Warp-Stack Diff");
-    write_header_cell($class, "Warp-Warp1 Diff");
-    write_header_cell($class, "Warp-Warp2 Diff");
-    write_header_cell($class, "Stack-Stack Diff");
+    echo "<th></th>";
+    echo "<th></th>";
+    echo "<th></th>";
+    echo "<th></th>";
+    echo "<th>Raw</th>";
+    echo "<th>Chip</th>";
+    echo "<th>Camera</th>";
+    echo "<th>Warp</th>";
+    echo "<th>Stack</th>";
+    echo "<th>Warp-Stack Diff</th>";
+    echo "<th>Warp-Warp1 Diff</th>";
+    echo "<th>Warp-Warp2 Diff</th>";
+    echo "<th>Stack-Stack Diff</th>";
     echo "<tr><td></td>\n";
-    write_header_cell($class, "Exp ID");
-    write_header_cell($class, "Exp Name");
-    write_header_cell($class, "Filter");
-    write_header_cell($class, "Comment");
-    write_header_cell($class, "state");
-    write_header_cell($class, "state/dist?");
-    write_header_cell($class, "state/dist?");
-    write_header_cell($class, "state/dist?");
-    write_header_cell($class, "total/dist");
-    write_header_cell($class, "total/dist");
-    write_header_cell($class, "total/dist");
-    write_header_cell($class, "total/dist");
-    write_header_cell($class, "total/dist");
+    echo "<th>Exp ID</th>";
+    echo "<th>Exp Name</th>";
+    echo "<th>Filter</th>";
+    echo "<th>Comment</th>";
+    echo "<th>state</th>";
+    echo "<th>state/dist?</th>";
+    echo "<th>state/dist?</th>";
+    echo "<th>state/dist?</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
 
     $sql = 
@@ -147,49 +167,54 @@
         echo "<tr><td></td>\n";
 
+        echo "<TD>$exp_id</td>";
+        echo "<TD>$exp_name</td>";
+        echo "<TD>$filter</td>";
+        echo "<TD>$comment</td>";
+        echo "<TD>$rawExp</td>";
+
         // chip
         if (!$chipDist[$exp_id]) $chipDistStr = "N";
         else $chipDistStr = $chipDist[$exp_id];
+        echo "<TD>$chipState/$chipDistStr</td>";
 
         // cam
         if (!$camDist[$exp_id]) $camDistStr = "N";
         else $camDistStr = $camDist[$exp_id];
+        echo "<TD>$camState/$camDistStr</td>";
 
         // warp
         if (!$warpDist[$exp_id]) $warpDistStr = "N";
         else $warpDistStr = $warpDist[$exp_id];
+        echo "<TD>$warpState/$warpDistStr</td>";
 
         // stack
-        if (!$stack_hash[$exp_id] && !$stackDist[$exp_id]) $stackDistStr = "";
+        if (!$stack_hash[$exp_id] && !$stackDist[$exp_id]) $stackDistStr = "&nbsp;";
         else $stackDistStr = $stack_hash[$exp_id] . "/" . $stackDist[$exp_id];
+        $color = getColour($stack_hash[$exp_id], $stackDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$stackDistStr</td>";
 
         // WS diff
-        if (!$wsDiffProduced[$exp_id] && !$wsDiffDist[$exp_id]) $wsDistStr = "";
+        if (!$wsDiffProduced[$exp_id] && !$wsDiffDist[$exp_id]) $wsDistStr = "&nbsp;";
         else $wsDistStr = $wsDiffProduced[$exp_id] . "/" . $wsDiffDist[$exp_id];
+        $color = getColour($wsDiffProduced[$exp_id], $wsDiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$wsDistStr</td>";
 
         // WW1 diff
-        if (!$ww1DiffProduced[$exp_id] && !$ww1DiffDist[$exp_id]) $ww1DistStr = "";
+        if (!$ww1DiffProduced[$exp_id] && !$ww1DiffDist[$exp_id]) $ww1DistStr = "&nbsp;";
         else $ww1DistStr = $ww1DiffProduced[$exp_id] . "/" . $ww1DiffDist[$exp_id];
+        $color = getColour($ww1DiffProduced[$exp_id], $ww1DiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$ww1DistStr</td>";
 
         // WW2 dist
-        if (!$ww2DiffProduced[$exp_id] && !$ww2DiffDist[$exp_id]) $ww2DistStr = "";
+        if (!$ww2DiffProduced[$exp_id] && !$ww2DiffDist[$exp_id]) $ww2DistStr = "&nbsp;";
         else $ww2DistStr =  $ww2DiffProduced[$exp_id] . "/" . $ww2DiffDist[$exp_id];
+        $color = getColour($ww2DiffProduced[$exp_id], $ww2DiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$ww2DistStr</td>";
 
         // SS dist
-        if (!$ssDiffProduced[$exp_id] && !$ssDiffDist[$exp_id]) $ssDistStr = "";
+        if (!$ssDiffProduced[$exp_id] && !$ssDiffDist[$exp_id]) $ssDistStr = "&nbsp;";
         else $ssDistStr = $ssDiffProduced[$exp_id] . "/" . $ssDiffDist[$exp_id];
-
-        write_table_cell($class, '%s', "", $exp_id);
-        write_table_cell($class, '%s', "", $exp_name);
-        write_table_cell($class, '%s', "", $filter);
-        write_table_cell($class, '%s', "", $comment);
-        write_table_cell($class, '%s', "", $rawExp);
-        write_table_cell($class, '%s', "", "$chipState/$chipDistStr");
-        write_table_cell($class, '%s', "", "$camState/$camDistStr");
-        write_table_cell($class, '%s', "", "$warpState/$warpDistStr");
-        write_table_cell($class, '%s', "", $stackDistStr);
-        write_table_cell($class, '%s', "", $wsDistStr);
-        write_table_cell($class, '%s', "", $ww1DistStr);
-        write_table_cell($class, '%s', "", $ww2DistStr);
-        write_table_cell($class, '%s', "", $ssDistStr);
+        $color = getColour($ssDiffProduced[$exp_id], $ssDiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$ssDistStr</td>";
 
         echo "</tr>\n";
@@ -199,4 +224,14 @@
 }
 
+###########################################################################
+#
+# Gets the right cell colour provided number created and distributed 
+#
+###########################################################################
+function getColour($created, $distributed) {
+
+    if ($distributed > 0 && $created > 0 && $distributed % $created != 0) return "red";
+    return "";
+}
 
 ###########################################################################
