Index: branches/eam_branches/ipp-20101205/ippMonitor/Makefile.in
===================================================================
--- branches/eam_branches/ipp-20101205/ippMonitor/Makefile.in	(revision 30103)
+++ branches/eam_branches/ipp-20101205/ippMonitor/Makefile.in	(revision 30446)
@@ -55,4 +55,5 @@
 $(DESTWWW)/czartool_labels.php \
 $(DESTWWW)/czartool_getplot.php \
+$(DESTWWW)/czartool_exposures.php \
 $(DESTWWW)/histogram.php \
 $(DESTWWW)/show_and_delete_image.php \
Index: branches/eam_branches/ipp-20101205/ippMonitor/def/mopsStatus.d
===================================================================
--- branches/eam_branches/ipp-20101205/ippMonitor/def/mopsStatus.d	(revision 30103)
+++ branches/eam_branches/ipp-20101205/ippMonitor/def/mopsStatus.d	(revision 30446)
@@ -1,3 +1,3 @@
-TABLE rawExp LEFT JOIN chipRun using(exp_id) LEFT JOIN camRun using(chip_id) LEFT JOIN fakeRun using(cam_id) LEFT JOIN warpRun using(fake_id) LEFT JOIN diffInputSkyfile AS diffInput ON diffInput.warp1 = warp_id LEFT JOIN diffRun AS diffInputRun ON diffInput.diff_id = diffInputRun.diff_id LEFT JOIN diffInputSkyfile AS diffTemplate ON diffTemplate.warp2 = warp_id LEFT JOIN diffRun AS diffTemplateRun ON diffTemplate.diff_id = diffTemplateRun.diff_id LEFT JOIN publishRun ON stage_id=diffInput.diff_id
+TABLE rawExp LEFT JOIN chipRun using(exp_id) LEFT JOIN camRun using(chip_id) LEFT JOIN fakeRun using(cam_id) LEFT JOIN warpRun using(fake_id) LEFT JOIN diffInputSkyfile AS diffInput ON diffInput.warp1 = warp_id LEFT JOIN diffRun AS diffInputRun ON diffInput.diff_id = diffInputRun.diff_id LEFT JOIN diffInputSkyfile AS diffTemplate ON diffTemplate.warp2 = warp_id LEFT JOIN diffRun AS diffTemplateRun ON diffTemplate.diff_id = diffTemplateRun.diff_id LEFT JOIN publishRun ON stage_id=diffInput.diff_id AND (client_id=1 OR client_id=5) LEFT JOIN publishRun AS pubRun2 ON pubRun2.stage_id=diffTemplate.diff_id AND (pubRun2.client_id=1 OR pubRun2.client_id=5) LEFT JOIN magicDSRun ON magicDSRun.magic_ds_id=camRun.magicked
 TITLE MOPS Status
 FILE mopsStatus.php
@@ -10,14 +10,15 @@
 OP OP1 ($row[8]>$row[9]?$row[8]. "(1)":($row[9]!=0?$row[9]. "(2)":"0"))
 # $diffInput.diff_id+$diffTemplate.diff_id
-OP OP2 $row[8]+$row[9]
-#  "[".$diffInput.diff_id."]:[".$tdiff_id."]"
+# PUB ID
+OP OP2 ($row[12]>$row[13]?$row[12]. "(I)":($row[13]!=0?$row[13]. "(T)":"0"))
+#($row[13]>$row[14])
 
 #     field                    width format  name          show         link to                   extras
-FIELD dateobs, 		       15,   %T,     Date Obs
+FIELD dateobs, 		       13,   %T,     Date Obs
 FIELD exp_name, 	       5,    %s,     Exp Name
 FIELD rawExp.exp_id, 	       5,    %d,     Exp ID
 FIELD chipRun.data_group,      5,    %s,     Data grp
 FIELD chip_id, 		       5,    %d,     Chip ID (Stage 1)
-FIELD cam_id, 		       5,    %d,     Cam ID (Stage 2)
+FIELD camRun.cam_id AS camID, 		       5,    %d,     Cam ID (Stage 2)
 FIELD fake_id, 		       5,    %d,     Fake ID (Stage 3)
 FIELD warp_id, 		       5,    %d,     Warp ID (Stage 4)
@@ -25,13 +26,16 @@
 FIELD diffTemplate.diff_id AS tdiff_id,    5,    %d,     tdiff_id, none
 FIELD *,		       5,    %s,     Diff ID (Stage 5),		op=OP1
-#FIELD *,		       5,    %d,     Diff ID (Stage 5),		op=OP2
-FIELD camRun.magicked, 	       5,    %d,     Cam Magicked (Stage 6)
-FIELD publishRun.pub_id,       5,    %d,     Pub ID (Stage 7)
+FIELD camRun.magicked, 	       5,    %d,     Magick ID (Stage 6)
+FIELD magicDSRun.magic_ds_id,       5,    %d, DestreakID (Stage 7)
+FIELD publishRun.pub_id AS pubId1,       5,    %d,     pubId1, none
+FIELD pubRun2.pub_id AS pubId2,       5,    %d,     pubId2, none
+FIELD *,	     		10, %s, Pub ID, op=OP2
 FIELD filter, 		       5,    %s,     Filter
 FIELD object, 		       15,    %s,     Object
+FIELD obs_mode, 	       5,    %s,     Obs Mode
 FIELD comment, 		       40,    %s,     Comment
 
-FIELD diffInput.diff_id AS ddiffId,       5,    %s,     ddiffId,	none
-FIELD diffTemplate.diff_id AS tdiffId,    5,    %s,     tdiffId, 	none
+#FIELD diffInput.diff_id AS ddiffId,       5,    %s,     ddiffId,	none
+#FIELD diffTemplate.diff_id AS tdiffId,    5,    %s,     tdiffId, 	none
 
 MODE summary
Index: branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_exposures.php
===================================================================
--- branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_exposures.php	(revision 30446)
+++ branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_exposures.php	(revision 30446)
@@ -0,0 +1,541 @@
+<?php
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID();
+
+if (! $ID['proj']) { projectform ($ID); }
+$gpc1db = dbconnect($ID['proj']);
+
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+if ($ID['menu']) {$myMenu = $ID['menu'];}
+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");
+
+echo "</p>";
+echo "<p  align=\"center\"> Current status of all exposures taken $today UTC </p>"; 
+
+createTableForThisSurvey($gpc1db, $today, "");
+
+menu_end();
+
+###########################################################################
+#
+# Generates a table for the provided survey 
+#
+###########################################################################
+function createTableForThisSurvey($db, $date, $surveyStr) {
+
+    $conditions = "FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN warpImfile USING (warp_id) 
+        WHERE dateobs LIKE '$date%'
+        AND comment NOT LIKE '%calcite%'
+        AND comment NOT LIKE '%focus%'
+        AND comment NOT LIKE '%pointing%'
+        AND comment NOT LIKE '%stare%'
+        AND comment LIKE '%$surveyStr%'
+        AND exp_type = 'OBJECT'";
+
+    $sql = "SELECT COUNT(DISTINCT exp_id) " . $conditions;
+
+    $qry = $db->query($sql);
+    $qry->fetchInto($count);
+
+    if ($surveyStr == "") $surveyText = "all surveys"; 
+    else $surveyText = "$surveyStr survey";
+
+    echo "<p  align=\"center\"> Found " . $count[0] . " exposures for $surveyText </p>";
+
+    $chipDist = array(); getChipDist($db, $date, $surveyStr, &$chipDist);
+    $camDist = array(); getCamDist($db, $date, $surveyStr, &$camDist);
+    $warpDist = array(); getWarpDist($db, $date, $surveyStr, &$warpDist);
+    $stackDist = array(); getStackDist($db, $date, $surveyStr, &$stackDist);
+    $stack_hash = array(); getStackProduced($db, $date, $surveyStr, &$stack_hash);
+
+    $wsDiffProduced = array();
+    $ww1DiffProduced = array();
+    getWSDiffDist($db, $date, $surveyStr, &$wsDiffProduced, &$ww1DiffProduced);
+
+    $wsDiffDist = array();
+    $ww1DiffDist = array();
+    getWSAndWW1DiffDist($db, $date, $surveyStr, &$wsDiffDist, &$ww1DiffDist, $wsDiffProduced);
+
+    $ww2DiffDist = array(); getWW2DiffDist($db, $date, $surveyStr, &$ww2DiffDist);
+    $ssDiffDist = array(); getSSDiffDist($db, $date, $surveyStr, &$ssDiffDist);
+
+    $ww2DiffProduced = array(); getWW2DiffProduced($db, $date, $surveyStr, &$ww2DiffProduced);
+    $ssDiffProduced = array(); getSSDiffProduced($db, $date, $surveyStr, &$ssDiffProduced); 
+
+    $class = "list";
+    echo "<table class=$class >\n";
+    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 "<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");
+
+    $sql = 
+        "SELECT
+        exp_id,
+        exp_name, 
+        filter, 
+        comment, 
+        rawExp.state, 
+        chipRun.state, 
+        camRun.state, 
+        warpRun.state, 
+        COUNT(skycell_id) 
+            $conditions 
+            GROUP BY exp_name;"; 
+            //echo "$sql<br>";
+
+            if ($debug) {echo "$sql<br>";}
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n"; return;}
+
+    // loop through results in order to make html table
+    while ($qry->fetchInto($row)) {
+
+        $exp_id = $row[0];
+        $exp_name = $row[1];
+        $filter = preg_replace("/([a-z]{1})\.[0-9]+/", "$1", $row[2]);
+        $comment = $row[3];
+        $rawExp = $row[4];
+        $chipState = $row[5];
+        $camState = $row[6];
+        $warpState = $row[7];
+
+        echo "<tr><td></td>\n";
+
+        // chip
+        if (!$chipDist[$exp_id]) $chipDistStr = "N";
+        else $chipDistStr = $chipDist[$exp_id];
+
+        // cam
+        if (!$camDist[$exp_id]) $camDistStr = "N";
+        else $camDistStr = $camDist[$exp_id];
+
+        // warp
+        if (!$warpDist[$exp_id]) $warpDistStr = "N";
+        else $warpDistStr = $warpDist[$exp_id];
+
+        // stack
+        if (!$stack_hash[$exp_id] && !$stackDist[$exp_id]) $stackDistStr = "";
+        else $stackDistStr = $stack_hash[$exp_id] . "/" . $stackDist[$exp_id];
+
+        // WS diff
+        if (!$wsDiffProduced[$exp_id] && !$wsDiffDist[$exp_id]) $wsDistStr = "";
+        else $wsDistStr = $wsDiffProduced[$exp_id] . "/" . $wsDiffDist[$exp_id];
+
+        // WW1 diff
+        if (!$ww1DiffProduced[$exp_id] && !$ww1DiffDist[$exp_id]) $ww1DistStr = "";
+        else $ww1DistStr = $ww1DiffProduced[$exp_id] . "/" . $ww1DiffDist[$exp_id];
+
+        // WW2 dist
+        if (!$ww2DiffProduced[$exp_id] && !$ww2DiffDist[$exp_id]) $ww2DistStr = "";
+        else $ww2DistStr =  $ww2DiffProduced[$exp_id] . "/" . $ww2DiffDist[$exp_id];
+
+        // SS dist
+        if (!$ssDiffProduced[$exp_id] && !$ssDiffDist[$exp_id]) $ssDistStr = "";
+        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);
+
+        echo "</tr>\n";
+    }
+
+    echo "</table>\n";
+}
+
+
+###########################################################################
+#
+# Gets count of chips distributed 
+#
+###########################################################################
+function getChipDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN distRun ON chip_id = stage_id 
+        AND stage = 'chip' 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = "Y";
+        else $hash[$row[0]] = "N";
+    }
+}
+
+###########################################################################
+#
+# Gets count of cams distributed
+#
+###########################################################################
+function getCamDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN distRun ON cam_id = stage_id 
+        WHERE dateobs like '$date%' 
+        AND stage = 'camera' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = "Y";
+        else $hash[$row[0]] = "N";
+    }
+}
+
+###########################################################################
+#
+# Gets count of warps distributed
+#
+###########################################################################
+function getWarpDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id)
+        LEFT JOIN distRun ON warp_id = stage_id 
+        WHERE dateobs like '$date%' 
+        AND stage = 'warp' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = "Y";
+        else $hash[$row[0]] = "N";
+    }
+}
+
+###########################################################################
+#
+# Gets count of stacks distributed
+#
+###########################################################################
+function getStackDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN distRun ON stack_id = stage_id 
+        WHERE dateobs like '$date%' 
+        AND stage = 'stack' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of stacks produced
+#
+###########################################################################
+function getStackProduced($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stack_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN stackRun USING (stack_id) 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of WS and WW1 diffs distributed
+#
+###########################################################################
+function getWSAndWW1DiffDist($db, $date, $surveyStr, $hash1, $hash2, $wsDiffProduced) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(diff_id), stack1 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN diffInputSkyfile ON warp_id = warp1 
+        LEFT JOIN distRun ON stage_id = diff_id AND stage = 'diff' 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) {
+
+            if ($wsDiffProduced[$row[0]] != null)
+                $hash1[$row[0]] = $row[2];
+            else 
+                $hash2[$row[0]] = $row[2];
+        }
+    }
+}
+
+###########################################################################
+#
+# Gets count of WW2 diffs distributed
+#
+###########################################################################
+function getWW2DiffDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(diff_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN diffInputSkyfile ON warp_id = warp2 
+        LEFT JOIN distRun ON stage_id = diff_id AND stage = 'diff' 
+        WHERE dateobs like '$date%' 
+        AND comment LIKE '%$surveyStr%'
+        AND exp_type = 'OBJECT' 
+        GROUP BY exp_id
+        ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of SS diffs distributed
+#
+###########################################################################
+function getSSDiffDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(diff_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN diffInputSkyfile ON stack_id = stack1 
+        LEFT JOIN distRun ON stage_id = diff_id AND stage = 'diff' 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT'
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of WW2 diffs produced
+#
+###########################################################################
+function getWW2DiffProduced($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT rawExp.exp_id, COUNT(warp2), diff_mode 
+        FROM rawExp, chipRun, camRun, fakeRun, warpRun, diffInputSkyfile, diffRun  
+        WHERE rawExp.exp_id = chipRun.exp_id 
+        AND chipRun.chip_id = camRun.chip_id 
+        AND camRun.cam_id = fakeRun.cam_id 
+        AND fakeRun.fake_id = warpRun.fake_id 
+        AND diffInputSkyfile.warp2 = warpRun.warp_id 
+        AND diffInputSkyfile.diff_id = diffRun.diff_id 
+        AND dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id, diff_mode
+        ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        $hash[$row[0]] = $row[1];
+    }
+}
+
+###########################################################################
+#
+# Gets count of SS diffs produced
+#
+###########################################################################
+function getSSDiffProduced($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stack1), diff_mode 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN diffInputSkyfile ON stack_id = stack1 
+        LEFT JOIN diffRun USING (diff_id) 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id, diff_mode;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of WS diffs distributed
+#
+###########################################################################
+function getWSDiffDist($db, $date, $surveyStr, $hash1, $hash2) {
+
+    $sql = "
+        SELECT rawExp.exp_id, COUNT(warp1), diff_mode 
+        FROM rawExp, chipRun, camRun, fakeRun, warpRun, diffInputSkyfile, diffRun  
+        WHERE rawExp.exp_id = chipRun.exp_id 
+        AND chipRun.chip_id = camRun.chip_id 
+        AND camRun.cam_id = fakeRun.cam_id 
+        AND fakeRun.fake_id = warpRun.fake_id 
+        AND diffInputSkyfile.warp1 = warpRun.warp_id 
+        AND diffInputSkyfile.diff_id = diffRun.diff_id 
+        AND dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id, diff_mode
+        ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $hash = array();
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] == 2) $hash1[$row[0]] = $row[1];
+        else  $hash2[$row[0]] = $row[1];
+    }
+}
+
+
+
Index: branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_labels.php
===================================================================
--- branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_labels.php	(revision 30103)
+++ branches/eam_branches/ipp-20101205/ippMonitor/raw/czartool_labels.php	(revision 30446)
@@ -64,6 +64,5 @@
 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></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>";
 
 // deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later
@@ -182,5 +181,5 @@
             echo "<td> \n";
               $today = date("Y-m-d");
-              showSummitData($gpc1db, $today);
+              createSummitDataTable($gpc1db, $today);
             echo "</td>\n";
           echo "</tr>\n";
@@ -189,6 +188,22 @@
     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";
@@ -196,6 +211,5 @@
           echo "<tr valign=top>\n";
             echo "<td> \n";
-              # storage plot
-              echo "<img src=\"czartool_getplot.php?type=s\"><br>";
+              if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
             echo "</td>\n";
             echo "<td>\n";
@@ -206,4 +220,5 @@
                 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);
+
               echo "</table>";
             echo "</td>\n";
@@ -213,20 +228,4 @@
     echo "</tr>\n";
 
-    # 5th row
-    echo "<tr>\n";
-      echo "<td> \n";
-        echo "<table>\n";
-          echo "<tr valign=top>\n";
-            echo "<td> \n";
-              # server output
-              if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
-            echo "</td>\n";
-            echo "<td>\n";
-            echo "</td>\n";
-          echo "</tr>\n";
-        echo "</table>\n";
-      echo "</td> \n";
-    echo "</tr>\n";
-
   echo "</table>\n";
 
@@ -236,8 +235,8 @@
 ###########################################################################
 #
-# Checks summitExp table agains rawExp table 
-#
-###########################################################################
-function showSummitData($gpc1db, $date) {
+# Creates a table of summitExp against rawExp
+#
+###########################################################################
+function createSummitDataTable($gpc1db, $date) {
 
     $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'";
@@ -590,4 +589,57 @@
 ###########################################################################
 #
+# Populates a tables with the current dates listed in the server_dates table 
+#
+###########################################################################
+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 "</tr>\n";
+
+    createServerDateRow($db, "stdscience");
+    createServerDateRow($db, "registration");
+
+    echo "</table>\n";
+}
+
+
+###########################################################################
+#
+# Checks the status of all the pantasks servers 
+#
+###########################################################################
+function createServerDateRow($db, $server) {
+
+    $sql = "SELECT date FROM server_dates WHERE server LIKE '$server' ORDER BY date";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $dates = ""; 
+    $firstIn = true;
+    while ($qry->fetchInto($row)) {
+
+        if ($firstIn) {
+
+            $dates = $row[0];
+            $firstIn = false;
+        }
+        else $dates = $dates . ", " . $row[0];
+    }
+
+    $class = "list";
+    echo "<tr><td></td>\n";
+    write_table_cell($class, '%s', "", $server);
+    write_table_cell($class, '%s', "", $dates);
+    echo "</tr>\n";
+
+}
+
+###########################################################################
+#
 # Checks the status of all the pantasks servers 
 #
@@ -633,6 +685,6 @@
             ."&plottype=".$plotType;
 
-        $link = ""; # TODO removed links temporarily
-            write_table_cell($class, '%s', $link, $server);
+        #$link = ""; # TODO removed links temporarily
+        write_table_cell($class, '%s', $link, $server);
         write_table_cell($class, '%s', "", $alive ? "yes" : "NO");
 
