Index: trunk/ippMonitor/raw/czartool_labels.php
===================================================================
--- trunk/ippMonitor/raw/czartool_labels.php	(revision 40882)
+++ trunk/ippMonitor/raw/czartool_labels.php	(revision 40883)
@@ -399,4 +399,5 @@
         $qry2->fetchInto($summit);
 
+
         $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND rawExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
         $qry2 = $projectdb->query($sql);
@@ -407,12 +408,35 @@
         $qry2->fetchInto($dropped);
 
+
+        #Query with 30 minutes delay to check during the night if any exposures are missing.
+        $datehour = gmdate("Y-m-d H:i:s");
+        $sql = "SELECT COUNT(*) FROM summitExp left join pzDownloadExp using (summit_id) WHERE dateobs > '$date' AND dateobs <= date_sub('$datehour', interval 30 minute) AND exp_type = '$expType[0]' and (state != 'drop' or state is null) and fault != 1042";
+        $qry2 = $projectdb->query($sql);
+        $qry2->fetchInto($summitdelay);
+
+        $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.dateobs <= date_sub('$datehour', interval 30 minute) AND rawExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
+        $qry2 = $projectdb->query($sql);
+        $qry2->fetchInto($mhpccdelay);
+
         echo "<tr>";
 
-        if ($summit[0] == $mhpcc[0]) $error = 0;
+        $DLdiff = $summit[0] - $mhpcc[0];
+        if ($DLdiff == 0) $error = 0;
         else $error = 1;
+
+        $delayDLdiff = $summitdelay[0] - $mhpccdelay[0];
+        if ($delayDLdiff == 0) $errordelay = 0;
+        else $errordelay = 1;
 
         echo "<td>$expType[0]</td>";
         echo "<td>$summit[0]</td>";
-        createFormattedTableCell("", "", $mhpcc[0], $error, 0);
+        #createFormattedTableCell("", "", $mhpcc[0], $error, 0);
+        if ($delayDLdiff==0) {
+           createFormattedTableCell("", "", $mhpcc[0], $error, 0);
+        } else {
+           $DLStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">$mhpcc[0] ($delayDLdiff)</font>";
+           echo "<td>$DLStatus</td>";
+        }
+
         echo "<td>$dropped[0]</td>";
 
@@ -482,5 +506,5 @@
     createTableColumnHeader("Chunk");
     createTableColumnHeader("Nobs_1stvisit");
-    createTableColumnHeader("Nobs_4visits");
+    createTableColumnHeader("Nobs_4visits(bad cam)");
     createTableColumnHeader("Ndiffs_published");
     createTableColumnHeader("Completion");
@@ -492,4 +516,5 @@
         $Nfirstvisits = 0;
         $Nfourvisits = 0;
+        $badcam = 0;
 
         $chunkname = $row[0];
@@ -533,9 +558,30 @@
         }
 
+        #also query for bad quality camRun exposures
+        $query4 = "SELECT count(*) ";
+        $query4 .= " FROM rawExp";
+        $query4 .= " JOIN chipRun USING (exp_id)";
+        $query4 .= " JOIN camRun USING (chip_id)";
+        $query4 .= " JOIN camProcessedExp USING (cam_id)";
+        $query4 .= " WHERE dateobs LIKE '$date%'";
+        $query4 .= " AND exp_id > $refExpID[0]"; 
+        $query4 .= " AND exp_type = 'OBJECT'";
+        $query4 .= " AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%'";
+        $query4 .= " AND (camProcessedExp.quality > 0)";
+        $qry4 = $projectdb->query($query4);
+        $qry4->fetchInto($badcam);
+
+
+
         echo "<tr>";
 
         echo "<td>$chunkname</td>";
         echo "<td>$Nfirstvisits</td>";
-        echo "<td>$Nfourvisits</td>";
+        if ($badcam[0]==0) {
+           echo "<td>$Nfourvisits</td>";
+        } else {
+           $DLStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">$Nfourvisits ($badcam[0])</font>";
+           echo "<td>$DLStatus</td>";
+        }
         echo "<td>$Ndiffs</td>";
         echo "<td>$complete</td>";
