1 | <?php
|
---|
2 |
|
---|
3 | function EnumQuery($name)
|
---|
4 | {
|
---|
5 | $var = $name . "Enum";
|
---|
6 | $txt = "";
|
---|
7 | switch ($_GET[$var])
|
---|
8 | {
|
---|
9 | case 0: $txt .= ""; break;
|
---|
10 | case 1: $txt .= $name . "='yes' AND "; break;
|
---|
11 | case 2: $txt .= $name . "='no' AND "; break;
|
---|
12 | case 3: $txt .= ""; break;
|
---|
13 | }
|
---|
14 | return $txt;
|
---|
15 | }
|
---|
16 |
|
---|
17 | function PrintEnumMenu($name, $text)
|
---|
18 | {
|
---|
19 | $var = $name . "Enum";
|
---|
20 |
|
---|
21 | if ($_GET[$name]=="On")
|
---|
22 | $checked = "checked";
|
---|
23 | else
|
---|
24 | $checked = "";
|
---|
25 |
|
---|
26 | printf(" <input type='checkbox' name='%s' value='On' %s>%s\n", $name, $checked, $text);
|
---|
27 | printf("<BR>");
|
---|
28 |
|
---|
29 | printf(" <select name='%s'>\n", $var);
|
---|
30 |
|
---|
31 | $status = array
|
---|
32 | ( 0 => "all",
|
---|
33 | 1 => "yes",
|
---|
34 | 2 => "no",
|
---|
35 | 3 => "group by"
|
---|
36 | );
|
---|
37 |
|
---|
38 | $stat=$_GET[$var];
|
---|
39 | for ($i=0; $i<4; $i++)
|
---|
40 | {
|
---|
41 | if ($stat==$i)
|
---|
42 | printf("<option value='%d' selected>%s</option>\n", $i, $status[$i]);
|
---|
43 | else
|
---|
44 | printf("<option value='%d'>%s</option>\n", $i, $status[$i]);
|
---|
45 | }
|
---|
46 |
|
---|
47 | printf(" </select>\n");
|
---|
48 | printf(" \n");
|
---|
49 |
|
---|
50 | }
|
---|
51 |
|
---|
52 | function StatusQuery($name, $needs, $timelimits)
|
---|
53 | {
|
---|
54 | if (empty($timelimits[$name]))
|
---|
55 | $timelimit="12";
|
---|
56 | else
|
---|
57 | $timelimit=$timelimits[$name];
|
---|
58 | $var = $name . "Status";
|
---|
59 | $txt = "";
|
---|
60 | switch ($_GET[$var])
|
---|
61 | {
|
---|
62 | case 0: $txt .= ""; break;
|
---|
63 | case 1: $txt .= "NOT (IsNull(" . $name . ") OR " . $name . "='1970-01-01 00:00:00') AND "; break;
|
---|
64 | // case 2: $txt .= "IsNull(" . $name . ") AND IsNull(fStartTime) AND IsNull(fFailedTime) AND NOT IsNull(" . $needs[$name] . ") AND "; break; //not done but step before is done
|
---|
65 | case 2: $txt .= "IsNull(" . $name . ") AND "; break; //not done no matter what status of previous step is
|
---|
66 | case 3: $txt .= $name ."='1970-01-01 00:00:00' AND "; break;
|
---|
67 | case 4: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval " . $timelimit . " hour) < fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
|
---|
68 | case 5: $txt .= " (IsNull(" . $name . ") AND NOT IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
|
---|
69 | case 6: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval " . $timelimit . " hour) > fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
|
---|
70 | // case 6: $txt .= "crashed"; break;
|
---|
71 | case 7: $txt .= ""; break;
|
---|
72 | }
|
---|
73 | return $txt;
|
---|
74 | }
|
---|
75 |
|
---|
76 | function PrintStatusMenu($name, $text)
|
---|
77 | {
|
---|
78 | $var = $name . "Status";
|
---|
79 |
|
---|
80 | if ($_GET[$name]=="On")
|
---|
81 | $checked = "checked";
|
---|
82 | else
|
---|
83 | $checked = "";
|
---|
84 |
|
---|
85 | printf(" <input type='checkbox' name='%s' value='On' %s>%s\n", $name, $checked, $text);
|
---|
86 | printf("<BR>");
|
---|
87 |
|
---|
88 | printf(" <select name='%s'>\n", $var);
|
---|
89 |
|
---|
90 | $status = array
|
---|
91 | ( 0 => "ALL",
|
---|
92 | 1 => "done",
|
---|
93 | 2 => "not done",
|
---|
94 | 3 => "not to be done",
|
---|
95 | 4 => "running",
|
---|
96 | 5 => "failed",
|
---|
97 | 6 => "crashed",
|
---|
98 | 7 => "GROUP BY",
|
---|
99 | );
|
---|
100 |
|
---|
101 | $stat=$_GET[$var];
|
---|
102 | for ($i=0; $i<8; $i++)
|
---|
103 | {
|
---|
104 | if ($stat==$i)
|
---|
105 | printf("<option value='%d' selected>%s</option>\n", $i, $status[$i]);
|
---|
106 | else
|
---|
107 | printf("<option value='%d'>%s</option>\n", $i, $status[$i]);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*
|
---|
111 | $status = array("all", "done", "not done", "not to be done");
|
---|
112 | $counter = 0;
|
---|
113 | foreach ($status as $element)
|
---|
114 | {
|
---|
115 | if ($counter==$_GET[$var])
|
---|
116 | printf("<option value=\"%d\" selected>%3s</option>\n", $counter++, $element);
|
---|
117 | else
|
---|
118 | printf("<option value=\"%d\">%3s</option>\n", $counter++, $element);
|
---|
119 | }*/
|
---|
120 | printf(" </select>\n");
|
---|
121 | printf(" \n");
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 | function PrintPullDown($host, $user, $pw, $db, $table, $name, $index, $descr)
|
---|
126 | {
|
---|
127 | $db_id = mysql_connect($host, $user, $pw);
|
---|
128 | if ($db_id==FALSE)
|
---|
129 | {
|
---|
130 | printf("mysql_connect returned the following error:<br>");
|
---|
131 | printf("%s<br>", mysql_error());
|
---|
132 | die("");
|
---|
133 | }
|
---|
134 |
|
---|
135 | $query = "SELECT " . $index . ", " . $name . " FROM " . $db . "." . $table . " ORDER BY " . $name;
|
---|
136 | $result = mysql_query($query);
|
---|
137 |
|
---|
138 | if (!$result)
|
---|
139 | {
|
---|
140 | printf("-N/A-");
|
---|
141 | return;
|
---|
142 | }
|
---|
143 |
|
---|
144 | $numrows = mysql_num_rows($result);
|
---|
145 |
|
---|
146 | if ($_GET[$name]=="On")
|
---|
147 | $checked = "checked";
|
---|
148 | else
|
---|
149 | $checked = "";
|
---|
150 |
|
---|
151 | printf(" <input type='checkbox' name='%s' value='On' %s><A HREF='printtable.php?fTable=%s'>%s</A>\n", $name, $checked, $table, $descr);
|
---|
152 |
|
---|
153 | printf(" <BR>\n");
|
---|
154 |
|
---|
155 | printf(" <select name='%s' size='1' class='Width'>\n", $index);
|
---|
156 |
|
---|
157 | if (empty($_GET[$index]) || $_GET[$index]==0)
|
---|
158 | printf(" <option value='0' selected>--- ALL ---</option>\n");
|
---|
159 | else
|
---|
160 | printf(" <option value='0'>--- ALL ---</option>\n");
|
---|
161 |
|
---|
162 | if (!empty($_GET[$index]) && $_GET[$index]==-1)
|
---|
163 | printf(" <option value='-1' selected>--- GROUP BY ---</option>\n");
|
---|
164 | else
|
---|
165 | printf(" <option value='-1'>--- GROUP BY ---</option>\n");
|
---|
166 |
|
---|
167 | while ($row = mysql_fetch_row($result))
|
---|
168 | {
|
---|
169 | if (!empty($_GET[$index]) && $_GET[$index]==$row[0])
|
---|
170 | printf(" <option value='%s' selected>%s</option>\n", $row[0], $row[1]);
|
---|
171 | else
|
---|
172 | printf(" <option value='%s'>%s</option>\n", $row[0], $row[1]);
|
---|
173 | }
|
---|
174 | printf(" </select>\n");
|
---|
175 | printf(" \n", $index);
|
---|
176 |
|
---|
177 | mysql_free_result($result);
|
---|
178 |
|
---|
179 | mysql_close($db_id);
|
---|
180 | }
|
---|
181 |
|
---|
182 | function GetMin($field, $table, $host, $user, $pw, $db)
|
---|
183 | {
|
---|
184 | $db_id = mysql_connect($host, $user, $pw);
|
---|
185 | if ($db_id==FALSE)
|
---|
186 | {
|
---|
187 | printf("mysql_connect returned the following error:<br>");
|
---|
188 | printf("%s<br>", mysql_error());
|
---|
189 | die("");
|
---|
190 | }
|
---|
191 |
|
---|
192 | $query = "SELECT MIN(" . $field . ") FROM " . $db . "." . $table;
|
---|
193 | $result = mysql_query($query);
|
---|
194 | if (!$result)
|
---|
195 | return "0";
|
---|
196 |
|
---|
197 | $row = mysql_fetch_row($result);
|
---|
198 |
|
---|
199 | $min = $row[0];
|
---|
200 |
|
---|
201 | mysql_free_result($result);
|
---|
202 | mysql_close($db_id);
|
---|
203 |
|
---|
204 | return $min;
|
---|
205 | }
|
---|
206 |
|
---|
207 | function GetMax($field, $table, $host, $user, $pw, $db)
|
---|
208 | {
|
---|
209 | $db_id = mysql_connect($host, $user, $pw);
|
---|
210 | if ($db_id==FALSE)
|
---|
211 | {
|
---|
212 | printf("mysql_connect returned the following error:<br>");
|
---|
213 | printf("%s<br>", mysql_error());
|
---|
214 | die("");
|
---|
215 | }
|
---|
216 |
|
---|
217 | $query = "SELECT MAX(" . $field . ") FROM " . $db . "." . $table;
|
---|
218 | $result = mysql_query($query);
|
---|
219 | if (!$result)
|
---|
220 | return "0";
|
---|
221 |
|
---|
222 | $row = mysql_fetch_row($result);
|
---|
223 |
|
---|
224 | $max = $row[0];
|
---|
225 |
|
---|
226 | mysql_free_result($result);
|
---|
227 | mysql_close($db_id);
|
---|
228 |
|
---|
229 | return $max;
|
---|
230 | }
|
---|
231 |
|
---|
232 | function GetMaxDate($field, $table, $host, $user, $pw, $db)
|
---|
233 | {
|
---|
234 | $db_id = mysql_connect($host, $user, $pw);
|
---|
235 | if ($db_id==FALSE)
|
---|
236 | {
|
---|
237 | printf("mysql_connect returned the following error:<br>");
|
---|
238 | printf("%s<br>", mysql_error());
|
---|
239 | die("");
|
---|
240 | }
|
---|
241 |
|
---|
242 | $query = "SELECT DATE_FORMAT(if(MAX(" . $field . ")<'13:00:00', MAX(" . $field . "), ADDDATE(MAX(" . $field . "), INTERVAL +1 DAY)), '%Y-%m-%d') FROM " . $db . "." . $table;
|
---|
243 | $result = mysql_query($query);
|
---|
244 | if (!$result)
|
---|
245 | return "0";
|
---|
246 |
|
---|
247 | $row = mysql_fetch_row($result);
|
---|
248 |
|
---|
249 | $maxdate = $row[0];
|
---|
250 |
|
---|
251 | mysql_free_result($result);
|
---|
252 | mysql_close($db_id);
|
---|
253 |
|
---|
254 | return $maxdate;
|
---|
255 | }
|
---|
256 |
|
---|
257 | //for download of output
|
---|
258 | function PrintText($result0)
|
---|
259 | {
|
---|
260 | while ($row0 = mysql_fetch_assoc($result0))
|
---|
261 | {
|
---|
262 | foreach ($row0 as $key => $element)
|
---|
263 | printf("%s\t", $element);
|
---|
264 | printf("\n");
|
---|
265 | }
|
---|
266 | }
|
---|
267 |
|
---|
268 | function PrintSubmittedQuery($query0, $html, $db, $old)
|
---|
269 | {
|
---|
270 | //diplay query on old websites
|
---|
271 | if (empty($old))
|
---|
272 | printf("<tr class='Block' id='showquery' style='display:none'><td>");
|
---|
273 | else
|
---|
274 | printf("<tr class='Block' id='showquery' style='display:block'><td>");
|
---|
275 | if ($html=="1")
|
---|
276 | {
|
---|
277 | printf("<b>DB:</b> %s <br>", $db);
|
---|
278 | printf("<U><B>submitted query:</B></U><BR>%s<BR>", htmlspecialchars($query0));
|
---|
279 | }
|
---|
280 | printf("</td></tr>");
|
---|
281 | }
|
---|
282 |
|
---|
283 | function Checkbox($value, $text)
|
---|
284 | {
|
---|
285 | if ($_GET[$value]=="On")
|
---|
286 | $checked = "checked";
|
---|
287 | else
|
---|
288 | $checked = "";
|
---|
289 |
|
---|
290 | printf("<td><input type='checkbox' name='%s' value='On' %s>%s</td>\n", $value, $checked, $text);
|
---|
291 | }
|
---|
292 |
|
---|
293 | function RadioButton($name, $value, $text)
|
---|
294 | {
|
---|
295 | if ($_SESSION[$name]==$value)
|
---|
296 | $checked = "checked";
|
---|
297 | else
|
---|
298 | $checked = "";
|
---|
299 |
|
---|
300 | printf("<td><input type='radio' name='%s' value='%s' %s>%s</td>\n", $name, $value, $checked, $text);
|
---|
301 | }
|
---|
302 |
|
---|
303 | function CheckWhere($column)
|
---|
304 | {
|
---|
305 | foreach ($_GET as $key => $element)
|
---|
306 | {
|
---|
307 | if ($key==$column)
|
---|
308 | {
|
---|
309 | // if ($element>0)
|
---|
310 | // printf ("FIXED: %s<BR>", $column);
|
---|
311 | return $element;
|
---|
312 | }
|
---|
313 | }
|
---|
314 | return 0;
|
---|
315 | }
|
---|
316 |
|
---|
317 | function CheckGroup($column)
|
---|
318 | {
|
---|
319 | foreach ($_GET as $key => $element)
|
---|
320 | {
|
---|
321 | if ($key==$column)
|
---|
322 | {
|
---|
323 | //if ($element==-1)
|
---|
324 | // printf ("GROUP: %s<BR>", $column);
|
---|
325 | return $element;
|
---|
326 | }
|
---|
327 | }
|
---|
328 | return 0;
|
---|
329 | }
|
---|
330 |
|
---|
331 | function CheckStatusGroup($column)
|
---|
332 | {
|
---|
333 | foreach ($_GET as $key => $element)
|
---|
334 | if ($key==$column)
|
---|
335 | if ($element==7)
|
---|
336 | return -1;
|
---|
337 | return 0;
|
---|
338 | }
|
---|
339 |
|
---|
340 | function CheckEnumGroup($column)
|
---|
341 | {
|
---|
342 | foreach ($_GET as $key => $element)
|
---|
343 | if ($key==$column)
|
---|
344 | if ($element==3)
|
---|
345 | return -1;
|
---|
346 | return 0;
|
---|
347 | }
|
---|
348 |
|
---|
349 | function RemoveSortBy()
|
---|
350 | {
|
---|
351 | $menu = "";
|
---|
352 |
|
---|
353 | $uri = $_SERVER["REQUEST_URI"];
|
---|
354 | $pos = strpos($uri, "fSortBy");
|
---|
355 | $amp3=FALSE;
|
---|
356 | if ($pos!=FALSE)
|
---|
357 | {
|
---|
358 | $amp1 = substr($uri, 0, $pos-1);
|
---|
359 | $amp2 = substr($uri, $pos);
|
---|
360 | $amp3 = strchr($amp2, "&");
|
---|
361 |
|
---|
362 | $uri = $amp1;
|
---|
363 | }
|
---|
364 |
|
---|
365 | return $uri;
|
---|
366 | }
|
---|
367 |
|
---|
368 | function FindAlias($alias, $search)
|
---|
369 | {
|
---|
370 | foreach ($alias as $key => $element)
|
---|
371 | if ($element==$search)
|
---|
372 | return $key;
|
---|
373 |
|
---|
374 | if ($search=="# Runs")
|
---|
375 | return "NumRuns";
|
---|
376 | if ($search=="# Sequ")
|
---|
377 | return "NumSequ";
|
---|
378 | if ($search=="# Datasets")
|
---|
379 | return "NumDS";
|
---|
380 | if ($search=="# days")
|
---|
381 | return "NumDays";
|
---|
382 | return $search;
|
---|
383 | return "";
|
---|
384 | }
|
---|
385 |
|
---|
386 | //function for button in builddatasets.php
|
---|
387 | function GetClearedURL($all)
|
---|
388 | {
|
---|
389 | $url=$_SERVER["REQUEST_URI"];
|
---|
390 | if ($all=="yes")
|
---|
391 | {
|
---|
392 | $url=str_replace("&DisplaySelected=yes", "", $url);
|
---|
393 | $url=str_replace("&DisplaySelected=no", "", $url);
|
---|
394 | $url=str_replace("&DisplaySelected=inverse", "", $url);
|
---|
395 | //reset fNumStart
|
---|
396 | $url=preg_replace("/&fNumStart[=][0-9]*/", "", $url);
|
---|
397 | }
|
---|
398 | $url=str_replace("&insert=yes", "", $url);
|
---|
399 | $url=str_replace("&fSendTxt=2", "", $url);
|
---|
400 | $url=str_replace("&fSendTxt=1", "", $url);
|
---|
401 | $url=htmlspecialchars($url);
|
---|
402 | return $url;
|
---|
403 | }
|
---|
404 |
|
---|
405 | function PrintUpdateDataSetButton()
|
---|
406 | {
|
---|
407 | if (empty($_SESSION["insert"]))
|
---|
408 | printf("<input type='submit' value='Update Selection'> \n");
|
---|
409 | else
|
---|
410 | printf("<input type='button' value='Continue' onClick='self.location.href=\"%s\"'> \n", GetClearedURL());
|
---|
411 |
|
---|
412 | }
|
---|
413 |
|
---|
414 | //function for button in builddatasets.php
|
---|
415 | function PrintDisplaySequencesButtons()
|
---|
416 | {
|
---|
417 | if (!empty($_SESSION["DataSetSelection"]) && empty($_SESSION["DataSetAcknowledged"]))
|
---|
418 | return;
|
---|
419 |
|
---|
420 | if ((empty($_SESSION["DisplaySelected"]) || $_SESSION["DisplaySelected"]=="no")
|
---|
421 | && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
|
---|
422 | {
|
---|
423 | PrintUpdateDataSetButton();
|
---|
424 | printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
|
---|
425 | printf(" <input type='button' value='Display Not-Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=inverse\"'>\n", GetClearedURL("yes"));
|
---|
426 | printf("<br><br>\n");
|
---|
427 | }
|
---|
428 |
|
---|
429 | if ($_SESSION["DisplaySelected"]=="yes"
|
---|
430 | && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
|
---|
431 | {
|
---|
432 | PrintUpdateDataSetButton();
|
---|
433 | printf("<input type='button' value='Display Not-Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=inverse\"'>\n", GetClearedURL("yes"));
|
---|
434 | printf(" <input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
|
---|
435 | printf(" <i>Currently only selected sequences are displayed.</i><br><br>\n");
|
---|
436 | }
|
---|
437 |
|
---|
438 | if ($_SESSION["DisplaySelected"]=="inverse"
|
---|
439 | && !(empty($_SESSION["sequon"]) && empty($_SESSION["sequoff"])))
|
---|
440 | {
|
---|
441 | PrintUpdateDataSetButton();
|
---|
442 | printf("<input type='button' value='Display Selected Sequences' onClick='self.location.href=\"%s&DisplaySelected=yes\"'>\n", GetClearedURL("yes"));
|
---|
443 | printf(" <input type='button' value='Display All Sequences' onClick='self.location.href=\"%s&DisplaySelected=no\"'>\n", GetClearedURL("yes"));
|
---|
444 | printf(" <i>Currently only NOT selected sequences are displayed.</i><br><br>\n");
|
---|
445 | }
|
---|
446 | }
|
---|
447 |
|
---|
448 |
|
---|
449 | function ReplaceInUri($name, $rows, $direction, $totalnumrows=0)
|
---|
450 | {
|
---|
451 | //direction:
|
---|
452 | // 0: Prev Link
|
---|
453 | // 1: Next Link
|
---|
454 | // 2: First Link
|
---|
455 | // 3: Last Link
|
---|
456 |
|
---|
457 | $uri = htmlspecialchars($_SERVER["REQUEST_URI"]);
|
---|
458 | //append string in case it is not in url
|
---|
459 | if (!preg_match("/&fNumStart[=][0-9]*/", $uri))
|
---|
460 | $uri.="&fNumStart=";
|
---|
461 |
|
---|
462 | switch($direction)
|
---|
463 | {
|
---|
464 | case 0:
|
---|
465 | $pos = $_GET["fNumStart"]-$rows;
|
---|
466 | if ($pos<0)
|
---|
467 | $pos=0;
|
---|
468 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'>< Prev</A> \n";
|
---|
469 | break;
|
---|
470 | case 1:
|
---|
471 | //display link only if more results available
|
---|
472 | if ($_GET["fNumStart"]+$rows==$totalnumrows)
|
---|
473 | break;
|
---|
474 | $pos = $_GET["fNumStart"]+$rows;
|
---|
475 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'>Next ></A> \n";
|
---|
476 | break;
|
---|
477 | case 2:
|
---|
478 | $pos = 0;
|
---|
479 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'><< First</A> \n";
|
---|
480 | break;
|
---|
481 | case 3:
|
---|
482 | //display link only if more results available
|
---|
483 | if ($_GET["fNumStart"]+$rows==$totalnumrows)
|
---|
484 | break;
|
---|
485 | $pos = $totalnumrows-$rows+1;
|
---|
486 | $link .= " <A HREF='" . preg_replace("/&fNumStart[=][0-9]*/", "&fNumStart=".$pos, $uri) . "'>Last >></A> \n";
|
---|
487 | break;
|
---|
488 | }
|
---|
489 |
|
---|
490 | return $link;
|
---|
491 | }
|
---|
492 |
|
---|
493 | function CreateMenu($rows, $totalnumrows)
|
---|
494 | {
|
---|
495 | $menu = "";
|
---|
496 |
|
---|
497 | if (empty($_GET["fNumResults"]))
|
---|
498 | return;
|
---|
499 |
|
---|
500 | if ($_GET["fNumStart"]!=0)
|
---|
501 | {
|
---|
502 | $menu .= ReplaceInUri("fNumStart", $rows, 2, $totalnumrows);
|
---|
503 | $menu .= ReplaceInUri("fNumStart", $rows, 0, $totalnumrows);
|
---|
504 | }
|
---|
505 |
|
---|
506 | $menu .= " --- <B>";
|
---|
507 | if (empty($_GET["fNumStart"]))
|
---|
508 | $menu .= "0";
|
---|
509 | else
|
---|
510 | $menu .= $_GET["fNumStart"];
|
---|
511 | $menu .= "</B> --- \n";
|
---|
512 |
|
---|
513 | if ($rows==$_GET["fNumResults"])
|
---|
514 | {
|
---|
515 | $menu .= ReplaceInUri("fNumStart", $rows, 1, $totalnumrows);
|
---|
516 | $menu .= ReplaceInUri("fNumStart", $rows, 3, $totalnumrows);
|
---|
517 | }
|
---|
518 | return $menu;
|
---|
519 | }
|
---|
520 |
|
---|
521 | function PrintMagicTable($result0, $alias, $rightalign, $limitsmean, $limitsmin, $limitsmax, $result1, $form="")
|
---|
522 | {
|
---|
523 | $row1 = mysql_fetch_assoc($result1);
|
---|
524 | $totalnumrows=$row1["FOUND_ROWS()"];
|
---|
525 |
|
---|
526 | $col = FALSE;
|
---|
527 | $first = TRUE;
|
---|
528 |
|
---|
529 | $sigma = array
|
---|
530 | (
|
---|
531 | 1 => "#33CC00",
|
---|
532 | 2 => "#FFFF66",
|
---|
533 | 3 => "#FF9900",
|
---|
534 | 5 => "#FF0000",
|
---|
535 | );
|
---|
536 | $okcolour="#006600";
|
---|
537 |
|
---|
538 |
|
---|
539 | $menu = CreateMenu(mysql_num_rows($result0), $totalnumrows);
|
---|
540 |
|
---|
541 | if ($form)
|
---|
542 | {
|
---|
543 | printf("<form method='POST'>");
|
---|
544 | PrintDisplaySequencesButtons();
|
---|
545 | }
|
---|
546 | printf("\n<center>\n");
|
---|
547 | if (empty($_GET["fPrintTable"]))
|
---|
548 | printf("%s\n", $menu);
|
---|
549 |
|
---|
550 | printf("<table BORDER='0' style='margin-top:1ex'>\n");
|
---|
551 | $counter=0;
|
---|
552 | while ($row0 = mysql_fetch_assoc($result0))
|
---|
553 | {
|
---|
554 | if ($first)
|
---|
555 | {
|
---|
556 | printf(" <tr BGCOLOR='#C0C0C0'>\n<td BGCOLOR='#F0F0F0'><img src='plus.png' alt='+' onClick='showalllines(%d)'></td>\n", mysql_num_rows($result0));
|
---|
557 | $first = FALSE;
|
---|
558 | if ($form)
|
---|
559 | {
|
---|
560 | printf("<td>ON<br><input type='radio' name='SelectAllSequForDS' value='ON' onclick='selectallsequences(\"ON\");' %s></td>\n",
|
---|
561 | $_SESSION["SelectAllSequForDS"]=="ON"?"checked":"");
|
---|
562 | printf("<td>Off<br><input type='radio' name='SelectAllSequForDS' value='Off' onclick='selectallsequences(\"Off\");' %s></td>\n",
|
---|
563 | $_SESSION["SelectAllSequForDS"]=="Off"?"checked":"");
|
---|
564 | printf("<td>Not<br><input type='radio' name='SelectAllSequForDS' value='Not' onclick='selectallsequences(\"Not\");' %s></td>\n",
|
---|
565 | $_SESSION["SelectAllSequForDS"]=="Not"?"checked":"");
|
---|
566 | }
|
---|
567 | foreach ($row0 as $key => $element)
|
---|
568 | {
|
---|
569 | $col = FindAlias($alias, $key);
|
---|
570 |
|
---|
571 | $ord="-";
|
---|
572 | $issort = "";
|
---|
573 | if (!empty($_GET["fSortBy"]) && substr($_GET["fSortBy"], 0, -1)==$col)
|
---|
574 | {
|
---|
575 | if (substr($_GET["fSortBy"], -1)=="-")
|
---|
576 | {
|
---|
577 | $ord="+";
|
---|
578 | $issort=" <IMG SRC='down.gif'>";
|
---|
579 | }
|
---|
580 | else
|
---|
581 | $issort=" <IMG SRC='up.gif'>";
|
---|
582 | }
|
---|
583 | printf(" <th> <A HREF='%s&fSortBy=%s%s'>%s</A>%s </th>\n",
|
---|
584 | htmlspecialchars(RemoveSortBy()), $col, $ord, $key, $issort);
|
---|
585 | }
|
---|
586 | printf(" </tr>\n\n");
|
---|
587 | }
|
---|
588 |
|
---|
589 | $counter++;
|
---|
590 | if (!$col)
|
---|
591 | printf(" <tr id='line%s' BGCOLOR='#E0E0E0'>\n<td BGCOLOR='#F0F0F0'>\n<img id='line%sbutton' src='minus.png' alt='-' onClick='showhide(\"line%s\")'>\n</td>\n", $counter, $counter, $counter);
|
---|
592 | else
|
---|
593 | printf(" <tr id='line%s' BGCOLOR='#D0D0D0'>\n<td BGCOLOR='#F0F0F0'>\n<img id='line%sbutton' src='minus.png' alt='-' onClick='showhide(\"line%s\")'>\n</td>\n", $counter, $counter, $counter);
|
---|
594 | $col = !$col;
|
---|
595 |
|
---|
596 | if ($form)
|
---|
597 | {
|
---|
598 | RadioButton("DSSeq".$row0["Sequ"], "ON", "");
|
---|
599 | RadioButton("DSSeq".$row0["Sequ"], "Off", "");
|
---|
600 | RadioButton("DSSeq".$row0["Sequ"], "Not", "");
|
---|
601 | }
|
---|
602 | foreach ($row0 as $key => $element)
|
---|
603 | {
|
---|
604 | if (empty($rightalign[$key]))
|
---|
605 | printf(" <td align='left' valign='top'>");
|
---|
606 | else
|
---|
607 | printf(" <td align='right' valign='top'>");
|
---|
608 |
|
---|
609 | $colour='#000000';
|
---|
610 | //determine color of text in cell
|
---|
611 | if (!empty($limitsmean))
|
---|
612 | {
|
---|
613 | foreach($limitsmean as $key2 => $element2)
|
---|
614 | {
|
---|
615 | $mean=$key2 . "Mean";
|
---|
616 | $rms2=$key2 . "Rms";
|
---|
617 | if ($key==$alias[$element2] && !empty($_GET[$mean]) && !empty($_GET[$rms2]))
|
---|
618 | {
|
---|
619 | $colour=$okcolour;
|
---|
620 | foreach ($sigma as $margin => $newcolour)
|
---|
621 | {
|
---|
622 | $min=$_GET[$mean] - ($margin * $_GET[$rms2]);
|
---|
623 | $max=$_GET[$mean] + ($margin * $_GET[$rms2]);
|
---|
624 | if (!($min < $element && $element < $max))
|
---|
625 | $colour=$newcolour;
|
---|
626 | }
|
---|
627 | }
|
---|
628 | }
|
---|
629 | }
|
---|
630 | if (!empty($limitsmin))
|
---|
631 | {
|
---|
632 | foreach($limitsmin as $key2 => $element2)
|
---|
633 | {
|
---|
634 | $limit1=$key2 . "1";
|
---|
635 | $limit2=$key2 . "2";
|
---|
636 | if ($key==$alias[$element2] && !empty($_GET[$limit1]))
|
---|
637 | {
|
---|
638 | if ($colour=='#000000')
|
---|
639 | $colour=$okcolour;
|
---|
640 |
|
---|
641 | if (!empty($_GET[$limit2]) && $_GET[$limit2] > $element)
|
---|
642 | $colour=$sigma[5];
|
---|
643 |
|
---|
644 | if ($_GET[$limit1] > $element && $_GET[$limit2] <= $element)
|
---|
645 | $colour=$sigma[3];
|
---|
646 | }
|
---|
647 | }
|
---|
648 | }
|
---|
649 |
|
---|
650 | if (!empty($limitsmax))
|
---|
651 | {
|
---|
652 | foreach($limitsmax as $key2 => $element2)
|
---|
653 | {
|
---|
654 | $limit1=$key2 . "1";
|
---|
655 | $limit2=$key2 . "2";
|
---|
656 | if ($key==$alias[$element2] && !empty($_GET[$limit1]))
|
---|
657 | {
|
---|
658 | if ($colour=='#000000')
|
---|
659 | $colour=$okcolour;
|
---|
660 |
|
---|
661 | if (!empty($_GET[$limit2]) && $_GET[$limit2] < $element)
|
---|
662 | $colour=$sigma[5];
|
---|
663 |
|
---|
664 | if ($_GET[$limit1] < $element && $_GET[$limit2] >= $element)
|
---|
665 | $colour=$sigma[3];
|
---|
666 | }
|
---|
667 | }
|
---|
668 | }
|
---|
669 | if ($colour!='#000000' && (!empty($limitsmean) || !empty($limitsmin) || !empty($limitsmax)))
|
---|
670 | printf("<font color='%s' style='font-weight:bold'>", $colour);
|
---|
671 |
|
---|
672 | //fill text in cell
|
---|
673 | printf(" %s </td>\n", str_replace("&ws;", " ", str_replace(" ", " ", $element)));
|
---|
674 |
|
---|
675 | if ($colour!='#000000' && (!empty($limitsmean) || !empty($limitsmin) || !empty($limitsmax)))
|
---|
676 | printf("</font>");
|
---|
677 | }
|
---|
678 | printf(" </tr>\n");
|
---|
679 | }
|
---|
680 | printf("</table>\n");
|
---|
681 |
|
---|
682 | /*
|
---|
683 | $info = mysql_info();
|
---|
684 | if (!empty($info))
|
---|
685 | printf("%s<BR>\n", $info);
|
---|
686 | */
|
---|
687 |
|
---|
688 | printf("<P><B>Number of displayed results: %d of %s in total</B><P><P>\n", mysql_num_rows($result0), $totalnumrows);
|
---|
689 | if (empty($_GET["fPrintTable"]))
|
---|
690 | printf("%s\n", $menu);
|
---|
691 | printf("<P>\n");
|
---|
692 | printf("</center>\n");
|
---|
693 |
|
---|
694 | if (!$form)
|
---|
695 | {
|
---|
696 | printf("</td>\n");
|
---|
697 | printf("</tr>\n");
|
---|
698 | }
|
---|
699 | else
|
---|
700 | PrintDisplaySequencesButtons();
|
---|
701 | }
|
---|
702 |
|
---|
703 | ?>
|
---|