Index: /branches/ccl_branches/ipp-20190806/ippMonitor/raw/czartool_labels.php
===================================================================
--- /branches/ccl_branches/ipp-20190806/ippMonitor/raw/czartool_labels.php	(revision 41002)
+++ /branches/ccl_branches/ipp-20190806/ippMonitor/raw/czartool_labels.php	(revision 41003)
@@ -8,6 +8,6 @@
 if (! $ID['proj']) { projectform ($ID); }
 
-// connect to czarDb 
-$czardb = dbconnect($CZARDBNAME); 
+// connect to czarDb
+$czardb = dbconnect($CZARDBNAME);
 $lastUpdateTime = getLastUpdateTime($czardb);
 
@@ -35,5 +35,5 @@
         "fullforce",
         "diff",
-        "dist", 
+        "dist",
         "pub",
 	);
@@ -49,7 +49,7 @@
         "fullforce" => "failedFullForceSkyfiles.php",
         "diff"      => "failedDiffSkyfile.php",
-        "dist"      => "NONE", 
+        "dist"      => "NONE",
         "pub"       => "publishDone.php",
-);	     
+);
 
 $mainTable = array(
@@ -62,7 +62,7 @@
         "fullforce" => "fullForceRun",
         "diff"      => "diffRun",
-        "dist"      => "distRun", 
+        "dist"      => "distRun",
         "pub"       => "publishRun",
-);	     
+);
 
 $addSearchState = array(
@@ -77,5 +77,5 @@
         "dist"      => 0,
         "pub"       => 0,
-);	     
+);
 
 $servers=array(
@@ -100,5 +100,5 @@
 
 // The Update mode of czartool is obsolete since we don't use the update
-// pantasks. 
+// pantasks.
 // $selectedMode = $_GET[mode];
 $selectedMode = "stdscience";
@@ -226,6 +226,6 @@
 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>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>Postage stamp server status</td><td><a href=\"http://pstamp.ipp.ifa.hawaii.edu/status.php\"><font color=\"blue\">here</font></a></td></tr>";
 echo "<tr><td>Documentation</td><td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\"><font color=\"blue\">here</font></a></td></tr>";
@@ -244,15 +244,15 @@
 echo "<br>";
 
-       createLabelsTable($pass, 
-         $proj, 
-         $czardb, 
-         $selectedMode, 
-         $labels, 
-         $distLabelsExist, 
-         $pubLabelsExist, 
-         $stages, 
-         "new", 
-         $selectedLabel, 
-         $selectedStage, 
+       createLabelsTable($pass,
+         $proj,
+         $czardb,
+         $selectedMode,
+         $labels,
+         $distLabelsExist,
+         $pubLabelsExist,
+         $stages,
+         "new",
+         $selectedLabel,
+         $selectedStage,
          $plotType);
 
@@ -263,5 +263,5 @@
       createServersTable($pass, $proj,$selectedMode,$czardb, $servers, $selectedLabel, $selectedStage, $plotType); echo "<br>";
       createSummitDataTable($projectdb); echo "<br>"; // this is slow because of the join between summitExp and rawExp
-      createChunkDataTable($projectdb); echo "<br>"; 
+      createChunkDataTable($projectdb); echo "<br>";
       createDatesTable($czardb, $proj); echo "<br>";
 
@@ -353,5 +353,5 @@
         echo "<td>$row[1]</td>";
         echo "<td>$row[2]</td>";
-        
+
         echo "</tr>";
     }
@@ -399,5 +399,4 @@
         $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);
@@ -408,35 +407,12 @@
         $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>";
 
-        $DLdiff = $summit[0] - $mhpcc[0];
-        if ($DLdiff == 0) $error = 0;
+        if ($summit[0] == $mhpcc[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);
-        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>";
-        }
-
+        createFormattedTableCell("", "", $mhpcc[0], $error, 0);
         echo "<td>$dropped[0]</td>";
 
@@ -461,5 +437,5 @@
     if (dberror($qry)) {
         print "*** WARNING: no data in period 10-20 days before requested date (query will be slower) **\n";
-        $refExpID = 0; 
+        $refExpID = 0;
     }
     $qry->fetchInto($refExpID);
@@ -467,4 +443,5 @@
         $refExpID[0] = 0;
     }
+
 
     #Find the number of chunks
@@ -509,5 +486,5 @@
     createTableColumnHeader("Chunk");
     createTableColumnHeader("Nobs_1stvisit");
-    createTableColumnHeader("Nobs_4visits(bad cam)");
+    createTableColumnHeader("Nobs_4visits");
     createTableColumnHeader("Ndiffs_published");
     createTableColumnHeader("Completion");
@@ -519,5 +496,4 @@
         $Nfirstvisits = 0;
         $Nfourvisits = 0;
-        $badcam = 0;
 
         $chunkname = $row[0];
@@ -550,6 +526,6 @@
         }
 
-        if ($Ndiffs != ($Nfirstvisits*4)) $complete = "chunk not done";  
-        if ($Ndiffs == ($Nfirstvisits*4)) $complete = "chunk done";        
+        if ($Ndiffs != ($Nfirstvisits*4)) $complete = "chunk not done";
+        if ($Ndiffs == ($Nfirstvisits*4)) $complete = "chunk done";
 
         if ($Nfirstvisits != $Nfourvisits) {
@@ -561,30 +537,9 @@
         }
 
-        #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>";
-        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>$Nfourvisits</td>";
         echo "<td>$Ndiffs</td>";
         echo "<td>$complete</td>";
@@ -623,13 +578,13 @@
 ###########################################################################
 function createLabelsTable(
-        $pass, 
-        $proj, 
-        $db, 
-        $selectedMode, 
-        $labels, 
-        $distLabelsExist, 
-        $pubLabelsExist, 
-        $stages, 
-        $selectedState, 
+        $pass,
+        $proj,
+        $db,
+        $selectedMode,
+        $labels,
+        $distLabelsExist,
+        $pubLabelsExist,
+        $stages,
+        $selectedState,
         $selectedLabel, $selectedStage, $plotType) {
 
@@ -660,7 +615,7 @@
         if ($stage == $selectedStage) $showLink = 0;
         else $showLink = 1;
-        $link = 
+        $link =
             "czartool_labels.php?pass=".$pass
-            ."&proj=".$proj 
+            ."&proj=".$proj
             ."&mode=" .$selectedMode
             ."&label=".$selectedLabel
@@ -673,5 +628,5 @@
 
     // setup default link
-    $defaultlink = 
+    $defaultlink =
         "czartool_labels.php?pass=".$pass
         ."&proj=".$proj
@@ -696,5 +651,5 @@
         if ($thisLabel == $selectedLabel) $showLink = 0;
         else $showLink = 1;
-        $link = 
+        $link =
             "czartool_labels.php?pass=".$pass
             ."&proj=".$proj
@@ -706,5 +661,5 @@
 
         $str = "";
-        $anyFaults = false; 
+        $anyFaults = false;
 
         foreach ($stages as &$stage) {
@@ -727,5 +682,5 @@
 
 	  $cellcolor = 0;
-	  if ("$stage" == "dist") { 
+	  if ("$stage" == "dist") {
 	    $cellcolor = (!$isUpdate && !$distributing) ? "gray" : 0;
           }
@@ -802,5 +757,5 @@
 ###########################################################################
 #
-# Sets reverts status 
+# Sets reverts status
 #
 ###########################################################################
@@ -816,5 +771,5 @@
 ###########################################################################
 #
-# Returns current nightly science status 
+# Returns current nightly science status
 #
 ###########################################################################
@@ -900,5 +855,5 @@
 ###########################################################################
 #
-# Populates a tables with the current dates listed in the server_dates table 
+# Populates a tables with the current dates listed in the server_dates table
 #
 ###########################################################################
@@ -923,5 +878,5 @@
 ###########################################################################
 #
-# Checks the status of all the pantasks servers 
+# Checks the status of all the pantasks servers
 #
 ###########################################################################
@@ -933,5 +888,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $dates = ""; 
+    $dates = "";
     $firstIn = true;
     while ($qry->fetchInto($row)) {
@@ -954,5 +909,5 @@
 ###########################################################################
 #
-# Checks the status of all the pantasks servers 
+# Checks the status of all the pantasks servers
 #
 ###########################################################################
@@ -1050,5 +1005,5 @@
 ###########################################################################
 #
-#  Commands a server to stop or run 
+#  Commands a server to stop or run
 #
 ###########################################################################
@@ -1059,5 +1014,5 @@
     $running = 0;
     if ($response[0] == "running") {$alive = 1; $running = 1;}
-    else if ($response[0] == "stopped") {$alive = 1; $running = 0;} 
+    else if ($response[0] == "stopped") {$alive = 1; $running = 0;}
     else if ($response[0] == "dead") {$alive = 0; $running = 0;}
     setServerStatus($db, $server, $alive, $running);
@@ -1066,5 +1021,5 @@
 ###########################################################################
 #
-# Sets server status 
+# Sets server status
 #
 ###########################################################################
@@ -1100,5 +1055,5 @@
 ###########################################################################
 #
-# Returns time of last czarDb update 
+# Returns time of last czarDb update
 #
 ###########################################################################
@@ -1118,5 +1073,5 @@
 ###########################################################################
 #
-# Shows the status of the provided pantasks server 
+# Shows the status of the provided pantasks server
 #
 ###########################################################################
@@ -1152,5 +1107,5 @@
     }
 
-    # note: mysql user must have either SUPER or REPLICATION CLIENT privileges on the database 
+    # note: mysql user must have either SUPER or REPLICATION CLIENT privileges on the database
     $res = $dbRepl->query('SHOW SLAVE STATUS');
     if (dberror($res)) {
@@ -1168,5 +1123,5 @@
 	    $sec_behind = 99999999;
 	    $errorStatusInMySql = 999999999;
-	}   
+	}
         $replStatus = ($errorStatusInMySql==0?"OK ($sec_behind)":"<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">PROBLEM</font>");
         echo "<tr><td>$replDatabaseName</td><td>$replStatus</td></tr>";
