Index: /trunk/ippMonitor/def/autocode.php
===================================================================
--- /trunk/ippMonitor/def/autocode.php	(revision 13565)
+++ /trunk/ippMonitor/def/autocode.php	(revision 13566)
@@ -27,9 +27,6 @@
 
 // get the result table count
-if ($WHERE) {
-  $sql = "SELECT count(*) FROM $TABLE WHERE $WHERE";
-} else {
-  $sql = "SELECT count(*) FROM $TABLE";
-}
+$sql = "SELECT count(*) FROM $TABLE $WHERE";
+
 $qry = $db->query($sql);
 if (DB::iserror($db)) {
@@ -53,9 +50,5 @@
 
 // query the database
-if ($WHERE) {
-  $sql = "SELECT $FIELDS FROM $TABLE WHERE $WHERE LIMIT $dTABLE OFFSET $rowStart";
-} else {
-  $sql = "SELECT $FIELDS FROM $TABLE LIMIT $dTABLE OFFSET $rowStart";
-}
+$sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
 
 $qry = $db->query($sql);
@@ -67,34 +60,6 @@
 // ** HEAD CODE **
 
-if ($rowStart > 0) {
-  $value = 0;
-  $link = "$FILE" . "?" . $ID['link'] . "&from=$value";
-  echo "<a width=10 class=\"button\" href=\"$link\">&#60&#60</a>\n";
-} else {
-  echo "&#60&#60\n";
-}
-if ($rowStart >= $dTABLE) {
-  $value = $rowStart - $dTABLE;
-  $link = "$FILE" . "?" . $ID['link'] . "&from=$value";
-  echo "<a class=\"button\" href=\"$link\">&#60</a>\n";
-} else {
-  echo "&#60\n";
-}
-
-if ($rowLast < $rowTotal) {
-  $value = $rowStart + $dTABLE;
-  $link = "$FILE" . "?" . $ID['link'] . "&from=$value";
-  echo "<a class=\"button\" href=\"$link\">&#62</a>\n";
-} else {
-  echo "&#62\n";
-}
-
-if ($rowLast < $rowTotal) {
-  $value = $rowTotal - $dTABLE;
-  $link = "$FILE" . "?" . $ID['link'] . "&from=$value";
-  echo "<a class=\"button\" href=\"$link\">&#62&#62</a>\n";
-} else {
-  echo "&#62&#62\n";
-}
+// ** BUTTON RESTRICTIONS **
+navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, '$FILE');
 
 echo "&nbsp; : &nbsp; or enter start row: <input type=\"text\" name=\"from\" size=\"5\" value=\"$rowStart\">\n";
@@ -104,5 +69,4 @@
 echo "<tr>\n";
 // ** TABLE HEADER **
-// echo "<th class=list> FIELD </th>\n";
 echo "</tr>\n";
 
@@ -117,8 +81,9 @@
   // $link = "$FILE" . "?expID=" . $row[0] . "&" . $ID['link'];
 
+  $class = "list";
+  // ** TD CLASS **
+
   echo "<tr>\n";
   // ** TABLE DATA **
-  // echo "<td class=list><a href=\"$link\"> $row[0] </a></td>\n";
-  // echo "<td class=list> $row[1] </td>\n";
   echo "</tr>\n";
 }
Index: /trunk/ippMonitor/def/detInputExp.d
===================================================================
--- /trunk/ippMonitor/def/detInputExp.d	(revision 13565)
+++ /trunk/ippMonitor/def/detInputExp.d	(revision 13566)
@@ -4,16 +4,20 @@
 MENU  ipp.detrend.dat
 
-ARGS  ARG1  exp_tag=$exp_tag
+ARGS  ARG1  rawImfile.exp_tag=$detInputExp.exp_tag
 
-ARGS  ARG2  exp_tag=$exp_tag
-ARGS  ARG2  det_id=$det_id
-ARGS  ARG2  iteration=$iteration
+ARGS  ARG2  detResidImfile.exp_tag=$detInputExp.exp_tag
+ARGS  ARG2  detResidImfile.det_id=$detInputExp.det_id
+ARGS  ARG2  detResidImfile.iteration=$detInputExp.iteration
 
-#     field      width 	name        show         link to                 extras
-FIELD det_id,    7,    	det_id
-FIELD exp_tag,   20,   	exposure,   value,       rawImfile.php,          ARG1
-FIELD iteration, 5,    	iteration
-FIELD include,   7,   	include
-FIELD *,         5,    	resid,      value=goto,  detResidImfile.php,     ARG2
-FIELD *,         5,    	proc,       value=goto,  detProcessedImfile.php, ARG2
+ARGS  ARG2  detProcessedImfile.exp_tag=$detInputExp.exp_tag
+ARGS  ARG2  detProcessedImfile.det_id=$detInputExp.det_id
+ARGS  ARG2  detProcessedImfile.iteration=$detInputExp.iteration
 
+#     field                  width 	name        show         link to                 extras
+FIELD detInputExp.det_id,    7,    	det_id
+FIELD detInputExp.exp_tag,   20,   	exposure,   value,       rawImfile.php,          ARG1
+FIELD detInputExp.iteration, 5,    	iteration
+FIELD detInputExp.include,   7,   	include
+FIELD *,                     5,    	choose,     value=resid, detResidImfile.php,     ARG2
+FIELD *,                     5,    	choose,     value=proc,  detProcessedImfile.php, ARG3
+
Index: /trunk/ippMonitor/def/detResidExp.d
===================================================================
--- /trunk/ippMonitor/def/detResidExp.d	(revision 13565)
+++ /trunk/ippMonitor/def/detResidExp.d	(revision 13566)
@@ -31,2 +31,4 @@
 FIELD detResidExp.path_base,    20,   path_base,  none
 FIELD rawExp.camera,            20,   camera,     none
+
+TD_CLASS list_off $detResidExp.accept == 0
Index: /trunk/ippMonitor/def/masterDetrendFrames.d
===================================================================
--- /trunk/ippMonitor/def/masterDetrendFrames.d	(revision 13565)
+++ /trunk/ippMonitor/def/masterDetrendFrames.d	(revision 13566)
@@ -12,8 +12,13 @@
 WHERE detRun.iteration = detRunSummary.iteration
 
-ARGS  ARG1 det_id=$detRunSummary.det_id
+ARGS  ARG1 detRunSummary.det_id=$detRunSummary.det_id
 
-ARGS  ARG2 det_id=$detRunSummary.det_id
-ARGS  ARG2 iteration=$detRunSummary.iteration
+ARGS  ARG2 detInputExp.det_id=$detRunSummary.det_id
+ARGS  ARG2 detInputExp.iteration=$detRunSummary.iteration
+
+ARGS  ARG3 detProcessedExp.det_id=$detRunSummary.det_id
+
+ARGS  ARG4 detResidExp.det_id=$detRunSummary.det_id
+ARGS  ARG4 detResidExp.iteration=$detRunSummary.iteration
 
 #     field                    width name          show         link to                   extras
@@ -21,7 +26,7 @@
 FIELD detRunSummary.iteration, 5,    iter
 FIELD detRun.det_type,         5,    type
-FIELD *,                       20,   choose,       value=files, detNormalizedImfiles.php, ARG2 
 FIELD *,                       20,   choose,       value=input, detInputExp.php,          ARG2
-FIELD *,                       20,   choose,       value=resid, detResidExp.php,          ARG2
+FIELD *,                       20,   choose,       value=proc,  detProcessedExp.php,      ARG3
+FIELD *,                       20,   choose,       value=resid, detResidExp.php,          ARG4
 FIELD detRunSummary.bg,        20,   bg
 FIELD detRunSummary.bg_stdev,  20,   bg_stdev
Index: /trunk/ippMonitor/generate
===================================================================
--- /trunk/ippMonitor/generate	(revision 13565)
+++ /trunk/ippMonitor/generate	(revision 13566)
@@ -59,4 +59,8 @@
 	}
 
+	if ($key eq "FILE") {
+	    $myFile = $value;
+	}
+
 	# list of the table fields
  	if ($key eq "HEAD") {
@@ -69,7 +73,13 @@
 	}
 
-	# the IMAGE commands sets up a reference name
+	# the ARGS commands defines arguments to FIELDS commands
 	if ($key eq "ARGS") {
 	    push @linkargs, $value;
+	}
+
+	# the TD_CLASS command sets up an alternate TD class
+	if ($key eq "TD_CLASS") {
+	    $tdClass = $value;
+	    # print STDERR "found TD_CLASS\n";
 	}
 
@@ -151,4 +161,9 @@
 	}
 
+	# fill in TD_CLASS test
+	if ($line =~ m|// \*\* TD CLASS \*\*|) {
+	    &write_td_class;
+	}
+
 	# fill in table data
 	if ($line =~ m|// \*\* TABLE DATA \*\*|) {
@@ -164,4 +179,9 @@
 	if ($line =~ m|// \*\* TABLE RESTRICTIONS \*\*|) {
 	    &write_table_restrict;
+	}
+
+	# fill in table restricts
+	if ($line =~ m|// \*\* BUTTON RESTRICTIONS \*\*|) {
+	    &write_button_restrict;
 	}
 
@@ -200,6 +220,23 @@
     for ($i = 0; $i < @field; $i++) {
 	if ($show[$i] eq "none")  { next; }
-	printf FILE "echo \"<th class=\\\"list\\\"> $name[$i] </th>\\n\";\n";
-    }
+	# printf FILE "echo \"<th class=\\\"list\\\"> $name[$i] </th>\\n\";\n";
+	printf FILE "write_table_header (\"list\", \"$name[$i]\", \"$field[$i]\", \$buttonLink, \$ID, '$myFile');\n";
+    }
+}
+
+sub write_td_class {
+    my ($field, $testline);
+
+    if ($tdClass eq "") { return; }
+    # print STDERR "write TD CLASS: $tdClass...\n";
+
+    # TD_CLASS class field expression
+    ($class, $field, $testline) = split (" ", $tdClass, 3);
+
+    $field = &parse_fieldname ($field);
+
+    printf FILE "  if ($field $testline) {\n";
+    printf FILE "    \$class = \"$class\";\n";
+    printf FILE "  }\n";
 }
 
@@ -208,5 +245,5 @@
 
     if ($WHERE) {
-	printf FILE "\$WHERE = \"$WHERE\";\n";
+	printf FILE "\$WHERE = \"WHERE $WHERE\";\n";
     }	
     for ($i = 0; $i < @field; $i++) {
@@ -215,4 +252,15 @@
 	printf FILE "\$WHERE = check_restrict ('$value', \$WHERE);\n";
     }
+    printf FILE "\$WHERE = check_ordering (\$WHERE);\n";
+}
+
+# generate a button link entry for each field (field != *)
+sub write_button_restrict {
+
+    for ($i = 0; $i < @field; $i++) {
+	$value = $field[$i];
+	if ($value eq "*") { next; }
+	printf FILE "\$buttonLink = button_restrict ('$value', \$buttonLink);\n";
+    }
 }
 
@@ -228,19 +276,17 @@
 	if ($label eq "none")  { next; }
 
-	if (($label eq "value") && !$link[$i]) { 
-	    # print value without link or image
-	    if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
-	    print FILE "  echo \"<td class=\\\"list\\\"> $value </td>\\n\";\n";
-	    next;
-	}
-
-	if (($label eq "value") && $link[$i]) {
+	if ($label eq "value") {
 	    # create the basic link variable
-	    printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
-	    # add extra GET data to target
-	    if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
+	    if ($link[$i]) {
+		printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
+		# add extra GET data to target
+		if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
+		$myLink = "\$link";
+	    } else {
+		$myLink = "\"\"";
+	    }
 	    # print the actual table cell line with the link...
 	    if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
-	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> $value </a></td>\\n\";\n";
+	    printf FILE "  write_table_cell (\$class, $myLink, $value);\n";
 	    next;
 	}
@@ -248,5 +294,5 @@
 	if (($label eq "image") && !$link[$i]) {
 	    # print the actual table cell line with the image...
-	    printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"$image{$value}\\\"></td>\\n\";\n";
+	    printf FILE "  echo \"<td class=\\\"\$class\\\"><img src=\\\"$image{$value}\\\"></td>\\n\";\n";
 	    next;
 	}
@@ -258,5 +304,5 @@
 	    if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 
 	    # print the actual table cell line with the link...
-	    printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
+	    printf FILE "  echo \"<td class=\\\"\$class\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
 	    next;
 	}
@@ -401,4 +447,6 @@
     my ($i);
     
+    # print STDERR "variable: $variable\n";
+
     unless ($variable =~ m|^\$|) {
 	return $variable;
@@ -407,8 +455,8 @@
     $fieldname = substr ($variable, 1);
 
-    print STDERR "fieldname: $fieldname\n";
-
-    for ($i = 0; $i < @field; $i++) {
-	print STDERR "$i: $field[$i] : $fieldname\n";
+    # print STDERR "fieldname: $fieldname\n";
+
+    for ($i = 0; $i < @field; $i++) {
+	# print STDERR "$i: $field[$i] : $fieldname\n";
 
 	if ($field[$i] eq "*") { next; }
@@ -420,5 +468,5 @@
 	$value = "\$row[$Nrow]";
 
-	print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
+	# print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
 	return $value;
     }
Index: /trunk/ippMonitor/raw/ipp.css
===================================================================
--- /trunk/ippMonitor/raw/ipp.css	(revision 13565)
+++ /trunk/ippMonitor/raw/ipp.css	(revision 13566)
@@ -101,4 +101,15 @@
 }
 
+td.list_off  { 
+           text-align: left; 
+           font-size: normal;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #a0a0a0; 
+	   background-color: #a0a0a0;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
 th.list  { 
            text-align: left; 
Index: /trunk/ippMonitor/raw/ipp.php
===================================================================
--- /trunk/ippMonitor/raw/ipp.php	(revision 13565)
+++ /trunk/ippMonitor/raw/ipp.php	(revision 13566)
@@ -1,5 +1,5 @@
 <?php
 
-$dTABLE = 10;
+$dTABLE = 80;
 
 function logintext () {
@@ -282,33 +282,128 @@
 }
 
+function navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, $file) {
+
+  if ($rowStart > 0) {
+    $value = 0;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    echo "<a width=10 class=\"button\" href=\"$link\">&#60&#60</a>\n";
+  } else {
+    echo "&#60&#60\n";
+  }
+  if ($rowStart >= $dTABLE) {
+    $value = $rowStart - $dTABLE;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    echo "<a class=\"button\" href=\"$link\">&#60</a>\n";
+  } else {
+    echo "&#60\n";
+  }
+
+  if ($rowLast < $rowTotal) {
+    $value = $rowStart + $dTABLE;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    echo "<a class=\"button\" href=\"$link\">&#62</a>\n";
+  } else {
+    echo "&#62\n";
+  }
+
+  if ($rowLast < $rowTotal) {
+    $value = $rowTotal - $dTABLE;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    echo "<a class=\"button\" href=\"$link\">&#62&#62</a>\n";
+  } else {
+    echo "&#62&#62\n";
+  }
+}
+
 function check_restrict ($key, $where) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
   if ($_SERVER[REQUEST_METHOD] == 'GET') { 
     $value = $_GET[$htmlkey]; 
-    // echo "using GET: $value<br>\n";
   } else {
     $value = $_POST[$htmlkey];
-    // echo "using POST: $value<br>\n";
-  }
-  // echo "value: $value<br>\n";
+  }
   if ($value != "") {
     if ($where) {
       $where = $where . " AND $key = '$value'";
-      // echo "where 1: $where<br>\n";
     } else {
-      $where = "$key = '$value'";
-      // echo "where 2: $where<br>\n";
+      $where = "WHERE $key = '$value'";
     }
   }
   return $where;
+}
+
+function check_ordering ($where) {
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET['sort']; 
+  } else {
+    $value = $_POST['sort'];
+  }
+  if ($value != "") {
+    $where = $where . " ORDER BY $value";
+  }
+  return $where;
+}
+
+function button_restrict ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$key=$value";
+    } else {
+      $line = "$key=$value";
+    }
+  }
+  return $line;
+}
+
+function write_table_header ($class, $name, $value, $buttonLink, $ID, $file) {
+
+  $link = "$file" . "?" . $ID['link'] . "&sort=$value";
+  if ($buttonLink != "") {
+    $link = $link . "&$buttonLink";
+  }
+  echo "<th class=\"$class\"><a href=\"$link\"> $name </a></th>\n";
 }
 
 function write_query_row ($key, $width) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
-  $value = $_POST[$htmlkey];
-  if (($_SERVER[REQUEST_METHOD] == 'POST') && $value) { 
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") { 
     echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" size=\"$width\" value=\"$value\"> </td>\n";
   } else {
     echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" size=\"$width\"> </td>\n";
+  }
+}
+
+function write_table_cell ($class, $link, $value) {
+  $myValue = $value;
+  if ($myValue == "") { $myValue = "&nbsp;"; }
+
+  if ($link) {
+    echo "<td class=\"$class\"><a href=\"$link\"> $myValue </a></td>\n";
+  } else {
+    echo "<td class=\"$class\"> $myValue </td>\n";
   }
 }
