Index: trunk/MagicSoft/Mars/datacenter/db/resetseq.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/resetseq.php	(revision 8742)
+++ trunk/MagicSoft/Mars/datacenter/db/resetseq.php	(revision 8743)
@@ -11,8 +11,9 @@
         mysql_select_db($db);
 
-        $query1="SELECT MAX(fStartDate) FROM MarsVersion";
-        $dateresult=mysql_query($query1);
-        $row = mysql_fetch_row($dateresult);
-        $date=$row[0];
+        $query1="SELECT fMarsVersionName, fStartDate FROM MarsVersion ORDER BY fMarsVersion DESC LIMIT 0,1";
+        $marsresult=mysql_query($query1);
+        $row = mysql_fetch_row($marsresult);
+        $mars=$row[0];
+        $date=$row[1];
         if (mysql_errno()>0)
             printf("&nbsp; Error-Number: %s <br>", mysql_errno());
@@ -21,8 +22,8 @@
         if (mysql_info()!="")
             printf("&nbsp; Mysql-Info: %s <br>", mysql_info());
-        mysql_free_result($dateresult);
-        if (empty($date))
-        {
-            printf("Could not get date of latest Mars version from database.");
+        mysql_free_result($marsresult);
+        if (empty($mars))
+        {
+            printf("Could not get information for latest Mars version from the database.");
             return;
         }
@@ -30,16 +31,20 @@
         if (empty($_GET["insert"]))
         {
-            $query0  = "SELECT fSequenceFirst, ";
-            $query0 .= "if (fCallisto " . " < '" . $date . "', 'callisto to be resetted', ";
-            $query0 .= "if (not isnull(fCallisto), 'callisto already processed with new release', ";
-            $query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime), 'callisto running',";
-            $query0 .= "if (isnull(fFailedTime), 'callisto already resetted for new release', ";
-            $query0 .= " 'callisto crashed or failed')))) as 'calstat', ";
-            $query0 .= "if (fStar " . " < '" . $date . "', 'star to be resetted', ";
-            $query0 .= "if (not isnull(fStar), 'star already processed with new release', ";
-            $query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime), 'star running',";
-            $query0 .= "if (isnull(fFailedTime), 'star already resetted for new release', ";
-            $query0 .= " 'star crashed or failed')))) as 'starstat' ";
+            $query0  = "SELECT SequenceProcessStatus.fSequenceFirst, ";
+//            $query0 .= "if (fCallisto " . " < '" . $date . "', 'to be resetted', ";
+            $query0 .= "if (fCallisto " . " < '" . $date . "', CONCAT('outdated (', (SELECT fMarsVersionName FROM MarsVersion WHERE fCallisto > fStartDate ORDER BY fMarsVersion DESC LIMIT 0,1), ')'), ";
+            $query0 .= "if (not isnull(fCallisto), 'up to date (" . $mars . ")', ";
+            $query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime), 'running (" . $mars . ")',";
+            $query0 .= "if (isnull(fFailedTime), 'already resetted', ";
+            $query0 .= " 'crashed or failed')))) as 'calstat', ";
+//            $query0 .= "if (fStar " . " < '" . $date . "', 'to be resetted', ";
+            $query0 .= "if (fStar " . " < '" . $date . "', CONCAT('outdated (', (SELECT fMarsVersionName FROM MarsVersion WHERE fStar > fStartDate ORDER BY fMarsVersion DESC LIMIT 0,1), ')'), ";
+            $query0 .= "if (not isnull(fStar), 'up to date (" . $mars . ")', ";
+            $query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime) AND not isnull(fCallisto), 'running (" . $mars . ")',";
+            $query0 .= "if (isnull(fFailedTime), 'already resetted', ";
+            $query0 .= " 'crashed or failed')))) as 'starstat', fProjectName, fRunStart ";
             $query0 .= "FROM SequenceProcessStatus ";
+            $query0 .= "LEFT JOIN Sequences       ON Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
+            $query0 .= "LEFT JOIN Project         ON Project.fProjectKEY=Sequences.fProjectKEY ";
         }
         else
@@ -63,9 +68,9 @@
         if (ereg("^([ ]*[0-9]{5,8}[ ]*[,])*[ ]*[0-9]{5,8}[ ]*$",$_GET["Seqs"]))
         {
-            if (strpos($query0, " WHERE ")==FALSE)
+            if (strpos($query0, " WHERE ")==FALSE || (strpos($query0, " CONCAT(")==TRUE && strpos($query0, " WHERE ")==TRUE))
                 $query0 .= " WHERE ";
             else
                 $query0 .= " AND ";
-            $query0 .=" fSequenceFirst IN (" . $_GET["Seqs"] . ")";
+            $query0 .=" SequenceProcessStatus.fSequenceFirst IN (" . $_GET["Seqs"] . ")";
         }
         else
@@ -101,5 +106,5 @@
                 return;
             }
-            echo "The status of the sequences you entered: <br>\n";
+//            echo "The status of the sequences you entered: <br>\n";
             $star="";
             $callisto="";
@@ -110,24 +115,32 @@
             $col   = FALSE;
             $bgcolor='#C0C0C0';
-            printf("<table border='0'>\n");
-            printf("<tr bgcolor='%s'>\n<th style='padding-left:1ex;padding-right:1ex'>\n<u>Sequence</u>\n</th>\n<th>\n<u>Status Callisto</u>\n</th>\n<th>\n<u>Status Star</u>\n</th>\n</tr>\n", $bgcolor);
+            $checked=0;
+            printf("<table border='0' align='center'>\n");
+            printf("<tr bgcolor='%s'>\n<th style='padding-left:1ex;padding-right:1ex'>\n<u>Sequence</u>\n</th>\n", $bgcolor);
+            printf("\n<th>\n<u>ProjectName</u>\n</th>\n");
+            printf("<th>\n<u>Status Callisto</u>\n</th>");
+            printf("\n<th>\n<u>Status Star</u>\n</th>\n");
+            printf("\n<th>\n<u>Starttime</u>\n</th>\n");
+            printf("</tr>\n");
             while ($row = mysql_fetch_row($result0))
             {
-                if ($row[2]=='star to be resetted' && $_GET["step"]=='star')
+                if (ereg('outdated', $row[2]) && $_GET["step"]=='star')
                 {
                     $star[]=$row[0];
                     $starcolor='green';
-                        $style='bold';
+                    $style='bold';
+                    $row[2]=str_replace('outdated', 'marked for reset', $row[2]);
                 }
-                if ($row[1]=='callisto to be resetted' && $_GET["step"]=='callisto')
+                if (ereg('outdated', $row[1]) && $_GET["step"]=='callisto')
                 {
                     $callisto[]=$row[0];
                     $calcolor='green';
+                    $starcolor='green';
                     $style='bold';
                 }
-                if (($row[1]=='callisto crashed or failed' || $row[2]=='star crashed or failed') && $_GET["step"]=='crashed')
+                if (($row[1]=='crashed or failed' || $row[2]=='crashed or failed') && $_GET["step"]=='crashed')
                 {
                     $crashed[]=$row[0];
-                    if ($row[1]=='callisto crashed or failed')
+                    if ($row[1]=='crashed or failed')
                     {
                         $calcolor='green';
@@ -146,9 +159,13 @@
                 $col = !$col;
                 printf("<tr bgcolor='%s'>\n<td align='center' style='font-weight:%s'>\n%s \n</td>\n", $bgcolor, $style, $row[0]);
+                printf("<td style='padding-left:1ex;padding-right:1ex'>\n %s \n</td>\n", $row[3]);
                 printf("<td style='padding-left:1ex;padding-right:1ex'>\n <font color='%s'>%s </font>\n</td>\n", $calcolor, $row[1]);
-                printf("<td style='padding-left:1ex;padding-right:1ex'>\n <font color='%s'>%s </font>\n</td>\n</tr>\n", $starcolor, $row[2]);
+                printf("<td style='padding-left:1ex;padding-right:1ex'>\n <font color='%s'>%s </font>\n</td>\n", $starcolor, $row[2]);
+                printf("<td style='padding-left:1ex;padding-right:1ex'>\n %s \n</td>\n", $row[4]);
+                printf("</tr>\n");
                 $calcolor='black';
                 $starcolor='black';
                 $style='normal';
+                $checked+=1;
             }
             printf("</table>\n");
@@ -157,22 +174,34 @@
                 printf("<br>\n You chose to reset only the sequences which are crashed or failed.<br>\n");
             else
-                printf("<br>\n Only the sequences which have not yet been processed or resetted, will be resetted.<br>\n");
-            printf("To <b>reset</b> them, please check the insert checkbox and submit again.<br><br>\n");
-
+                printf("<br>\n Only the sequences which are not 'up to date', 'running' or 'resetted', can be resetted.<br>\n");
             if (empty($star) && empty($callisto) && empty($crashed))
                 echo "With your choice no sequences would be resetted.";
             else
-                echo "With your choice the following sequences would be resetted: ";
+                echo "With your choice the following sequences would be resetted:\n ";
+            $marked=0;
             if (!empty($star))
+            {
                 foreach($star as $num => $seq)
                     echo $seq . " ";
+                $marked+=count($star);
+            }
             if (!empty($callisto))
+            {
                 foreach($callisto as $num => $seq)
                     echo $seq . " ";
+                $marked+=count($callisto);
+            }
             if (!empty($crashed))
+            {
                 foreach($crashed as $num => $seq)
                     echo $seq . " ";
+                $marked+=count($crashed);
+            }
+            printf("<br>\n Listed: %d <br> Marked: %d", $checked, $marked);
+            printf("<br>\n<br>\nTo <b>reset</b> the <font color='green'>green marked entries</font>, please press the button 'Reset Sequences'.<br><br>\n");
+
             mysql_free_result($result0);
-            printf("<br>\n<br>\n<input type='button' value='Reset Sequences' onClick='self.location.href=\"%s&amp;insert=On\"'>&nbsp;&nbsp;&nbsp;\n", htmlspecialchars($_SERVER["REQUEST_URI"]));
+            printf("<input type='button' value='Reset Sequences' onClick='self.location.href=\"%s&amp;insert=On\"'>&nbsp;&nbsp;&nbsp;\n", htmlspecialchars($_SERVER["REQUEST_URI"]));
+
         }
         mysql_close($db_id);
@@ -192,5 +221,5 @@
     echo (file_get_contents("index-header.html"));
 
-    $ips=array("91.64.78.187", "132.187.47.10", "132.187.47.67");
+    $ips=array("91.64.78.187", "132.187.47.10", "132.187.47.67", "132.187.47.63", "129.217.160.151");
     if (!in_array($_SERVER['REMOTE_ADDR'], $ips))
     {
@@ -217,12 +246,12 @@
     printf("<input type='radio' name='step' value='star' %s> star<br>", $_GET["step"]=="star" ? "checked" : "");
 
-    printf("<table>\n<tr>\n<td align='left'>\nSequences: \n</td>\n</td>\n</tr>\n<tr>\n<td valign='left'>\n");
-    printf("<input name='Seqs' type='text' size='75' maxlength='300' value='%s'>\n</td>\n</tr>\n</table>\n<br>\n", $_GET["Seqs"]);
+    printf("<table>\n<tr>\n<td align='left'>\nSequences: \n</td>\n</tr>\n<tr>\n<td>\n");
+    printf("<input name='Seqs' type='text' size='80' maxlength='300' value='%s'>\n</td>\n</tr>\n</table>\n<br>\n", $_GET["Seqs"]);
 
     ini_set("mysql.trace_mode", "Off");
 //    ini_set("display_errors", "Off");
 
-    printf("<input type='submit' value='Reset Sequences in DB'>&nbsp;&nbsp;&nbsp;\n");
-    printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"resetseq.php\"'>&nbsp;&nbsp;&nbsp;\n");
+    printf("<input type='submit' value='Check Sequence Status'>&nbsp;&nbsp;&nbsp;\n");
+    printf("<input class='Width' type='button' value='Clear Form' onClick='self.location.href=\"resetseq.php\"'>&nbsp;&nbsp;&nbsp;\n");
 //    if (!empty($_GET["step"]) && ereg("^([ ]*[0-9]{5,8}[ ]*[,])*[ ]*[0-9]{5,8}[ ]*$",$_GET["Seqs"]))
 //        printf("<input type='checkbox' name='insert' value='On'>insert\n");
