File: 1.09.6a/server/web/report.php (View as HTML)

  1: <?php
  2: /* -------------------------------------------------------------
  3: This file is part of FreeNATS
  4: 
  5: FreeNATS is (C) Copyright 2008 PurplePixie Systems
  6: 
  7: FreeNATS is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeNATS is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with FreeNATS.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freenats
 21: -------------------------------------------------------------- */
 22: 
 23: ob_start();
 24: require("include.php");
 25: $NATS->Start();
 26: if (!$NATS_Session->Check($NATS->DB))
 27: 	{
 28: 	header("Location: ./?login_msg=Invalid+Or+Expired+Session");
 29: 	exit();
 30: 	}
 31: if ($NATS_Session->userlevel<1) UL_Error("View Report");
 32: 
 33: if (isset($_REQUEST['mode'])) $mode=$_REQUEST['mode'];
 34: else $mode="";
 35: 
 36: if ($mode=="savereport")
 37: 	{
 38: 	if ($NATS_Session->userlevel<5) UL_Error("Save Report");
 39: 	$q="INSERT INTO fnreport(reportname,reporttests) VALUES(\"".ss($_REQUEST['reportname'])."\",\"".ss($_REQUEST['reporttests'])."\")";
 40: 	$NATS->DB->Query($q);
 41: 	header("Location: main.php?mode=views&message=Saved+Report");
 42: 	exit();
 43: 	}
 44: 	
 45: if ($mode=="delete")
 46: 	{
 47: 	if ($NATS_Session->userlevel<5) UL_Error("Delete Report");
 48: 	if (!isset($_REQUEST['confirmed']))
 49: 		{
 50: 		$back="report.php?mode=delete&reportid=".$_REQUEST['reportid']."&confirmed=1";
 51: 		$back=urlencode($back);
 52: 		$msg=urlencode("Delete availability report");
 53: 		header("Location: confirm.php?action=".$msg."&back=".$back);
 54: 		exit();
 55: 		}
 56: 	$q="DELETE FROM fnreport WHERE reportid=".ss($_REQUEST['reportid']);
 57: 	$NATS->DB->Query($q);
 58: 	$message=urlencode("Report Deleted");
 59: 	header("Location: main.php?mode=views&message=".$message);
 60: 	exit();
 61: 	}
 62: 	
 63: $testlist=array();
 64: if (isset($_REQUEST['reportid']))
 65: 	{
 66: 	$q="SELECT * FROM fnreport WHERE reportid=".ss($_REQUEST['reportid'])." LIMIT 0,1";
 67: 	$r=$NATS->DB->Query($q);
 68: 	if ($rep=$NATS->DB->Fetch_Array($r))
 69: 		{
 70: 		$testlist=explode(":",$rep['reporttests']);
 71: 		}
 72: 	}
 73: 		
 74: 		
 75: function slist($var,$min,$max,$val)
 76: 	{
 77: 	echo "\n<select name=\"".$var."\">\n";
 78: 	echo "<option value=\"".$val."\">".$val."</option>\n";
 79: 	for ($a=$min; $a<=$max; $a++)
 80: 		echo "<option value=\"".$a."\">".$a."</option>\n";
 81: 	echo "</select>\n";
 82: 	}
 83: 	
 84: function cbd($var,$name)
 85: 	{
 86: 	if (isset($_REQUEST[$var])) $s=" checked";
 87: 	else $s="";
 88: 	echo "<input type=checkbox name=\"".$var."\" value=1".$s."> ".$name;
 89: 	}
 90: 
 91: function np($big,$part)
 92: 	{
 93: 	if ($big==0) return "n/a";
 94: 	if ($part==0) return "0%";
 95: 	
 96: 	$p=($part/$big)*100;
 97: 	$p=round($p,2);
 98: 	return $p."%";
 99: 	}
100: 
101: $td_day=date("d");
102: $td_mon=date("m");
103: $td_yr=date("Y");
104: 	
105: $start=array();
106: $finish=array();
107: if (isset($_REQUEST['st_day'])) $start['day']=$_REQUEST['st_day'];
108: else $start['day']=$td_day;
109: if (isset($_REQUEST['st_mon'])) $start['mon']=$_REQUEST['st_mon'];
110: else $start['mon']=$td_mon;
111: if (isset($_REQUEST['st_yr'])) $start['yr']=$_REQUEST['st_yr'];
112: else $start['yr']=$td_yr;
113: if (isset($_REQUEST['st_hour'])) $start['hour']=$_REQUEST['st_hour'];
114: else $start['hour']=0;
115: if (isset($_REQUEST['st_min'])) $start['min']=$_REQUEST['st_min'];
116: else $start['min']=0;
117: if (isset($_REQUEST['st_sec'])) $start['sec']=$_REQUEST['st_sec'];
118: else $start['sec']=0;
119: 
120: if (isset($_REQUEST['fi_day'])) $finish['day']=$_REQUEST['fi_day'];
121: else $finish['day']=$td_day;
122: if (isset($_REQUEST['fi_mon'])) $finish['mon']=$_REQUEST['fi_mon'];
123: else $finish['mon']=$td_mon;
124: if (isset($_REQUEST['fi_yr'])) $finish['yr']=$_REQUEST['fi_yr'];
125: else $finish['yr']=$td_yr;
126: if (isset($_REQUEST['fi_hour'])) $finish['hour']=$_REQUEST['fi_hour'];
127: else $finish['hour']=23;
128: if (isset($_REQUEST['fi_min'])) $finish['min']=$_REQUEST['fi_min'];
129: else $finish['min']=59;
130: if (isset($_REQUEST['fi_sec'])) $finish['sec']=$_REQUEST['fi_sec'];
131: else $finish['sec']=59;
132: 
133: if (isset($_REQUEST['startx']))
134: 	{
135: 	$start['day']=date("d",$_REQUEST['startx']);
136: 	$start['mon']=date("m",$_REQUEST['startx']);
137: 	$start['yr']=date("Y",$_REQUEST['startx']);
138: 	$start['hour']=date("H",$_REQUEST['startx']);
139: 	$start['min']=date("i",$_REQUEST['startx']);
140: 	$start['sec']=date("s",$_REQUEST['startx']);
141: 	$startx=$_REQUEST['startx'];
142: 	}
143: else
144: 	$startx=mktime($start['hour'],$start['min'],$start['sec'],$start['mon'],$start['day'],$start['yr']);
145: 
146: if (isset($_REQUEST['finishx']))
147: 	{
148: 	$finish['day']=date("d",$_REQUEST['finishx']);
149: 	$finish['mon']=date("m",$_REQUEST['finishx']);
150: 	$finish['yr']=date("Y",$_REQUEST['finishx']);
151: 	$finish['hour']=date("H",$_REQUEST['finishx']);
152: 	$finish['min']=date("i",$_REQUEST['finishx']);
153: 	$finish['sec']=date("s",$_REQUEST['finishx']);
154: 	$finishx=$_REQUEST['finishx'];
155: 	}
156: else
157: 	$finishx=mktime($finish['hour'],$finish['min'],$finish['sec'],$finish['mon'],$finish['day'],$finish['yr']);
158: //echo $startx." ".nicedt($startx)."<br>";
159: //echo $finishx." ".nicedt($finishx)."<br>";
160: 
161: 
162: if ($mode=="")
163: 	{
164: 	Screen_Header("Service Availability Report",1);
165: 	ob_end_flush();
166: 	
167: 
168: 	
169: 	
170: 	
171: 	
172: 	
173: 	
174: 	
175: 	echo "<b class=\"subtitle\">Reporting Period</b><br><br>";
176: 	echo "<br><table border=0>";
177: 	echo "<form action=report.php method=get>";
178: 	echo "<tr><td align=left valign=center>";
179: 	echo "<input type=radio name=period value=custom checked > <b>Custom Period</b>";
180: 	echo "</td><td align=left valign=top>";
181: 	echo "<table class=\"nicetable\">";
182: 	echo "<tr><td>&nbsp;</td><td>Hour</td><td>Min</td><td>Sec</td><td>Day</td><td>Mon</td><td>Year</td></tr>";
183: 	
184: 	
185: 
186: 	
187: 	
188: 	echo "<tr><td><b>Start:</b></td>";
189: 	echo "<td>";
190: 	slist("st_hour",0,23,$start['hour']);
191: 	echo ":";
192: 	echo "</td>";
193: 	
194: 	echo "<td>";
195: 	slist("st_min",0,59,$start['min']);
196: 	echo ":";
197: 	echo "</td>";
198: 	
199: 	echo "<td>";
200: 	slist("st_sec",0,59,$start['sec']);
201: 	echo "&nbsp;&nbsp;";
202: 	echo "</td>";
203: 	
204: 	echo "<td>";
205: 	slist("st_day",1,31,$start['day']);
206: 	echo "/";
207: 	echo "</td>";
208: 	
209: 	echo "<td>";
210: 	slist("st_mon",1,12,$start['mon']);
211: 	echo "/";
212: 	echo "</td>";
213: 	
214: 	echo "<td>";
215: 	echo "<input type=text name=st_yr value=\"".$start['yr']."\" size=5 maxlength=4>";
216: 	
217: 	echo "&nbsp;";
218: 	
219: 	echo "</td>";
220: 	
221: 	echo "</tr>";
222: 	
223: 	// ----- finish
224: 	
225: 	echo "<tr><td><b>Finish:</b></td>";
226: 	echo "<td>";
227: 	slist("fi_hour",0,23,$finish['hour']);
228: 	echo ":";
229: 	echo "</td>";
230: 	
231: 	echo "<td>";
232: 	slist("fi_min",0,59,$finish['min']);
233: 	echo ":";
234: 	echo "</td>";
235: 	
236: 	echo "<td>";
237: 	slist("fi_sec",0,59,$finish['sec']);
238: 	echo "&nbsp;&nbsp;";
239: 	echo "</td>";
240: 	
241: 	echo "<td>";
242: 	slist("fi_day",1,31,$finish['day']);
243: 	echo "/";
244: 	echo "</td>";
245: 	
246: 	echo "<td>";
247: 	slist("fi_mon",1,12,$finish['mon']);
248: 	echo "/";
249: 	echo "</td>";
250: 	
251: 	echo "<td>";
252: 	echo "<input type=text name=fi_yr value=\"".$finish['yr']."\" size=5 maxlength=4>";
253: 	
254: 	echo "&nbsp;";
255: 	
256: 	echo "</td>";
257: 	
258: 	echo "</tr>";
259: 	
260: 	
261: 
262: 	echo "</table>";
263: 	
264: 	
265: 	echo "</td></tr><tr><td align=left valign=top>";
266: 	echo "<b>Pre-defined </b>";
267: 	echo "</td><td align=left valign=top>";
268: 	$now=time();
269: 	/*
270: 	// td_day mon yr
271: 	
272: 	// mktime h mi s mo d y
273: 	
274: 	// last 30 days
275: 	$fx=mktime(0,0,0,$td_mon,$td_day,$td_yr);
276: 	$sx=$fx-(60*60*24*30);
277: 	echo "<a href=report.php?startx=".$sx."&finishx=".$fx.">";
278: 	echo "Last 30 Days";
279: 	echo "</a>&nbsp;";
280: 	
281: 	// last 28 days
282: 	$fx=mktime(0,0,0,$td_mon,$td_day,$td_yr);
283: 	$sx=$fx-(60*60*24*28);
284: 	echo "<a href=report.php?startx=".$sx."&finishx=".$fx.">";
285: 	echo "Last 28 Days";
286: 	echo "</a>&nbsp;";
287: 	
288: 	// last calendar month
289: 	$prev_mon=$td_mon-1;
290: 	$prev_yr=$td_yr;
291: 	if ($prev_mon<1)
292: 		{
293: 		$prev_mon=12;
294: 		$prev_yr--;
295: 		}
296: 	$fx=mktime(0,0,0,$td_mon,1,$td_yr);
297: 	$sx=mktime(0,0,0,$prev_mon,1,$prev_yr);
298: 	echo "<a href=report.php?startx=".$sx."&finishx=".$fx.">";
299: 	echo "Previous Month";
300: 	echo "</a>&nbsp;";
301: 	
302: 	
303: 	// this month
304: 	$sx=mktime(0,0,0,$td_mon,1,$td_yr);
305: 	$sx=$now;
306: 	echo "<a href=report.php?startx=".$sx."&finishx=".$fx.">";
307: 	echo "This Month";
308: 	echo "</a>&nbsp;";
309: 	*/
310: 	
311: 	echo "<input type=radio name=period value=last30days> Last 30 Days<br>";
312: 	echo "<input type=radio name=period value=last28days> Last 28 Days<br>";
313: 	echo "<input type=radio name=period value=lastcalmonth> Last Calendar Month<br>";
314: 	echo "<input type=radio name=period value=thiscalmonth> This Month<br>";
315: 	
316: 	echo "</td></tr></table>";	
317: 	echo "<br><br>";
318: 
319: 	echo "<b class=\"subtitle\">Reported Tests</b><br>";
320: 	
321: 	$q="SELECT localtestid,nodeid,testname,testtype,testparam,testrecord FROM fnlocaltest WHERE testrecord>0 OR testtype=\"ICMP\" ORDER BY nodeid";
322: 	$r=$NATS->DB->Query($q);
323: 	$lastnode="";
324: 	while ($row=$NATS->DB->Fetch_Array($r))
325: 		{
326: 		if ($row['nodeid']!=$lastnode)
327: 			{
328: 			echo "<br><b>".$row['nodeid']."</b><br>";
329: 			$lastnode=$row['nodeid'];
330: 			
331: 			// Bodge in node-side tests here
332: 			$nq="SELECT nstestid,testname,testtype,testdesc FROM fnnstest WHERE testrecord>0 AND nodeid=\"".ss($row['nodeid'])."\"";
333: 			$nr=$NATS->DB->Query($nq);
334: 			while ($nrow=$NATS->DB->Fetch_Array($nr))
335: 				{
336: 				if (in_array("N".$nrow['nstestid'],$testlist)) $s=" checked";
337: 				else $s="";
338: 				echo "<input type=checkbox name=testlist[] value=N".$nrow['nstestid'].$s."> ";
339: 				if ($nrow['testname']!="") echo $nrow['testname'];
340: 				else if ($nrow['testdesc']!="") echo $nrow['testdesc'];
341: 				else echo $nrow['testtype'];
342: 				echo " on ".$row['nodeid']."<br>";
343: 				}
344: 			$NATS->DB->Free($nr);
345: 			
346: 			
347: 			}
348: 		if (in_array("L".$row['localtestid'],$testlist)) $s=" checked";
349: 		else $s="";
350: 		echo "<input type=checkbox name=testlist[] value=L".$row['localtestid'].$s."> ";
351: 		if ($row['testname']!="") echo $row['testname'];
352: 		else
353: 			{
354: 			echo lText($row['testtype']);
355: 			if ($row['testparam']!="") echo " (".$row['testparam'].")";
356: 			}
357: 		echo " on ".$row['nodeid'];
358: 		echo "<br>";
359: 		}
360: 	$NATS->DB->Free($r);
361: 	
362: 	echo "<br><br>";
363: 	echo "<input type=hidden name=mode value=report>";
364: 	echo "<input type=submit value=\"View Availability Report\"><br>";
365: 	echo "<input type=checkbox name=showdetail value=1> Show breakdown details<br>";
366: 	echo "</form>";
367: 	Screen_Footer();
368: 	exit();
369: 		
370: 		
371: 	}
372: 
373: if ($mode!="report")
374: 	{
375: 	Screen_Header("Error");
376: 	echo "Sorry - illegal mode specified<br><br>";
377: 	Screen_Footer();
378: 	exit();
379: 	}
380: 
381: 
382: 
383: 
384: 
385: // the actual run
386: 
387: Screen_Header("Availability Report");
388: ob_end_flush();
389: 
390: if (isset($_REQUEST['period'])) $period=$_REQUEST['period'];
391: else $period="";
392: $now=time();
393: $nowx=$now;
394: switch ($period)
395: 	{
396: 	// td_day mon yr
397: 	
398: 	// mktime h mi s mo d y
399: 	
400: 	case "last30days":
401: 	// last 30 days
402: 	$finishx=mktime(0,0,0,$td_mon,$td_day,$td_yr);
403: 	$startx=$finishx-(60*60*24*30);
404: 	break;
405: 	
406: 	case "last28days":
407: 	$fx=mktime(0,0,0,$td_mon,$td_day,$td_yr);
408: 	$sx=$finishx-(60*60*24*28);
409: 	break;
410: 	
411: 	case "lastcalmonth":
412: 	// last calendar month
413: 	$prev_mon=$td_mon-1;
414: 	$prev_yr=$td_yr;
415: 	if ($prev_mon<1)
416: 		{
417: 		$prev_mon=12;
418: 		$prev_yr--;
419: 		}
420: 	$finishx=mktime(0,0,0,$td_mon,1,$td_yr);
421: 	$startx=mktime(0,0,0,$prev_mon,1,$prev_yr);
422: 	break;
423: 	
424: 	case "thiscalmonth": case "thismonth":
425: 	// this month
426: 	$startx=mktime(0,0,0,$td_mon,1,$td_yr);
427: 	$finishx=$now;
428: 	break;
429: 	}
430: 	
431: echo "<b class=\"subtitle\">Reporting from ".nicedt($startx)." to ".nicedt($finishx)."</b><br><br>";
432: 
433: foreach($_REQUEST['testlist'] as $testid)
434: {
435: 
436: $tmode="";
437: switch($testid[0])
438: 	{
439: 	case "L": $tmode="local";
440: 	break;
441: 	case "N": $tmode="nodeside";
442: 	break;
443: 	default: $tmode="unknown";
444: 	}
445: $stid=substr($testid,1,128);
446: 
447: // get test info
448: $tnode="";
449: $tname="";
450: $ttype="";
451: $tparam="";
452: $tlastrunx="";
453: $trecord=1;
454: 
455: $q="";
456: if ($tmode=="local") $q="SELECT * FROM fnlocaltest WHERE localtestid=".ss($stid);
457: else if ($tmode=="nodeside") $q="SELECT * FROM fnnstest WHERE nstestid=".ss($stid);
458: 	
459: $r=$NATS->DB->Query($q);
460: 
461: if (!$row=$NATS->DB->Fetch_Array($r))
462: 	{
463: 	header("main.php?message=Error+opening+test+history");
464: 	exit();
465: 	}
466: 	
467: 	
468: 	
469: $tnode=$row['nodeid'];
470: $ttype=$row['testtype'];
471: if (isset($row['testparam'])) $tparam=$row['testparam'];
472: else $tparam="";
473: $tlastrunx=$row['lastrunx'];
474: $tunit="";
475: 
476: if ($tmode=="local")
477: 	{
478: 	$tname=lText($ttype);
479: 	$tunit=lUnit($ttype);
480: 	if ($tparam!="") $tname.=" (".$tparam.")";
481: 	if ($row['testname']!="")
482: 		{
483: 		$subtname=$tname;
484: 		$tname=$row['testname'];
485: 		$usesubname=true;
486: 		}
487: 	else $usesubname=false;
488: 	}
489: else if ($tmode=="nodeside")
490: 	{
491: 	if ($row['testname']!="") $tname=$row['testname'];
492: 	else $tname=$row['testtype'];
493: 	$subtname=$row['testdesc'];
494: 	$usesubname=true;
495: 	}
496: $NATS->DB->Free($r);
497: 
498: 
499: 
500: 
501: $diffx=$finishx-$startx;
502: $periods=8;
503: $periodx=$diffx/$periods;
504: $hperiodx=round($periodx/2,0);
505: $periodx=round($periodx,0);
506: $iwid=700;
507: $ihei=150;
508: $istart=50;
509: $iend=$iwid-5;
510: $idwid=$iend-$istart;
511: $iscale=$idwid/$periods;
512: 
513: 
514: 
515: 	
516: echo "<b>".$tname."</b>";
517: if ($usesubname) echo "<b> - ".$subtname."</b>";
518: echo "<b> on ".$tnode."</b>";
519: echo "<br>";
520: 
521: //echo "<i>node ";
522: //echo "<a href=node.php?nodeid=".$tnode.">".$tnode."</a>";
523: //echo " - ";
524: echo "<i>";
525: echo "Last Run : ";
526: 
527: if ($tlastrunx>0)
528: 	{
529: 	echo nicedt($tlastrunx)." - ";
530: 	echo dtago($tlastrunx);
531: 	}
532: else echo "Never";
533: echo "</i><br>";
534: 
535: 
536: //echo "<b>".$tname." from ".nicedt($startx)." to ".nicedt($finishx);
537: //if ($tunit!="") echo " (".$tunit.")";
538: // echo " (".nicediff($finishx-$startx).")";
539: //echo "</b><br><br>";
540: 
541: 
542: 
543: // table data
544: 
545: 
546: $q="SELECT alertlevel,testvalue,recordx FROM fnrecord WHERE ";
547: $q.="testid=\"".ss($testid)."\" AND recordx>=".ss($startx)." AND recordx<=".ss($finishx);
548: //if (!isset($_REQUEST['disp_pass'])) $q.=" AND alertlevel!=0";
549: $q.=" ORDER BY recordx ASC";
550: 
551: $firstx=0;
552: $lastx=0;
553: $records=0;
554: 
555: //echo $q;
556: $r=$NATS->DB->Query($q);
557: 
558: $testc=0;
559: $tested=0;
560: $untested=0;
561: $passc=0;
562: $warnc=0;
563: $failc=0;
564: $levelt=0;
565: 
566: while ($row=$NATS->DB->Fetch_Array($r))
567: 	{
568: 	$testc++;
569: 	$records++;
570: 	if ($firstx==0) $firstx=$row['recordx'];
571: 	$lastx=$row['recordx'];
572: 	switch ($row['alertlevel'])
573: 		{
574: 		case 0:
575: 			$passc++;
576: 			$tested++;
577: 			$levelt+=$row['testvalue'];
578: 			break;
579: 		case 1:
580: 			$warnc++;
581: 			$tested++;
582: 			//$levelt+=$row['testvalue'];
583: 			break;
584: 		case 2:
585: 			$failc++;
586: 			$tested++;
587: 			//$levelt+=$row['testvalue'];
588: 			break;
589: 		case -1:
590: 			$untested++;
591: 			break;
592: 		}
593: 	}
594: 	
595: 
596: echo "<table border=0>";
597: 
598: if (isset($_REQUEST['showdetail']))
599: 	{
600: 	echo "<tr><td>".$passc." passed out of ".$tested." valid tests";
601: 	echo "</td><td>&nbsp;</td><td>";
602: 	echo np($tested,$passc);
603: 	echo "</td></tr>";
604: 	
605: 	$notpass=$tested-$passc;
606: 	
607: 	echo "<tr><td>".$notpass." did not pass out of ".$tested." valid tests";
608: 	echo "</td><td>&nbsp;</td><td>";
609: 	echo np($tested,$notpass);
610: 	echo "</td></tr>";
611: 	
612: 	echo "<tr><td colspan=3>&nbsp;<br></td></tr>";
613: 	
614: 	echo "<tr><td>".$warnc." generated warnings out of ".$tested." valid tests";
615: 	echo "</td><td>&nbsp;</td><td>";
616: 	echo np($tested,$warnc);
617: 	echo "</td></tr>";
618: 	
619: 	echo "<tr><td>".$failc." generated failures out of ".$tested." valid tests";
620: 	echo "</td><td>&nbsp;</td><td>";
621: 	echo np($tested,$failc);
622: 	echo "</td></tr>";
623: 	
624: 	echo "<tr><td>".$warnc." generated warnings out of ".$notpass." unpassed tests";
625: 	echo "</td><td>&nbsp;</td><td>";
626: 	echo np($notpass,$warnc);
627: 	echo "</td></tr>";
628: 	
629: 	echo "<tr><td>".$failc." generated failures out of ".$notpass." unpassed tests";
630: 	echo "</td><td>&nbsp;</td><td>";
631: 	echo np($notpass,$failc);
632: 	echo "</td></tr>";
633: 	
634: 	echo "<tr><td colspan=3>&nbsp;<br></td></tr>";
635: 	
636: 	echo "<tr><td>the average test value returned by passed tests was</td>";
637: 	echo "<td>&nbsp;</td><td>";
638: 	if ($passc<=0) echo "n/a";
639: 	else if ($levelt==0) echo "0";
640: 	else echo round($levelt/$passc,4);
641: 	if ($tunit!="") echo " ".$tunit;
642: 	echo "</td></tr>";
643: 	
644: 	echo "<tr><td colspan=3>&nbsp;<br></td></tr>";
645: 	
646: 	$utt=$untested+$tested;
647: 	echo "<tr><td>".$untested." tests were untested (of ".$utt.")</td>";
648: 	echo "<td>&nbsp;</td><td>";
649: 	echo np($utt,$untested);
650: 	echo "</td></tr>";
651: 	
652: 	$npt=$untested+$notpass;
653: 	echo "<tr><td>of these (".$utt.") ".$npt." did not pass</td>";
654: 	echo "<td>&nbsp;</td><td>";
655: 	echo np($utt,$npt);
656: 	echo "</td></tr>";
657: 	
658: 	echo "<tr><td>of these (".$utt.") ".$passc." did pass</td>";
659: 	echo "<td>&nbsp;</td><td>";
660: 	echo np($utt,$passc);
661: 	echo "</td></tr>";
662: 	
663: 	echo "<tr><td colspan=3>&nbsp;<br></td></tr>";
664: 	
665: 	echo "<tr><td>".$testc." records of which ".$tested." returned a valid alert level";
666: 	echo "</td><td>&nbsp;</td><td>";
667: 	echo np($testc,$tested);
668: 	echo "</td></tr>";
669: 	
670: 	$nowx=time();
671: 	if ($finishx>$nowx) $fx=$nowx;
672: 	else $fx=$finishx;
673: 	$p=$fx-$startx;
674: 	$five_min=60*5;
675: 	$shouldhave=floor($p/$five_min);
676: 	
677: 	}
678: 
679: echo "<tr><td colspan=3>&nbsp;<br></td></tr>";
680: echo "<tr><td>First Test Record";
681: echo "</td><td>&nbsp;</td><td>";
682: echo nicedt($firstx);
683: echo "</td></tr>";
684: 
685: echo "<tr><td>Last Test Record";
686: echo "</td><td>&nbsp;</td><td>";
687: echo nicedt($lastx);
688: echo "</td></tr>";
689: 
690: echo "<tr><td colspan=3>&nbsp;<br></td></tr>";
691: echo "<tr><td><b>Service Availability</b>";
692: echo "</td><td>&nbsp;</td><td><b>";
693: // Service level is tested-failed
694: echo np($tested,$tested-$failc);
695: echo "</b></td></tr>";
696: 
697: echo "</table><br>";
698: 
699: /* - zoom period debugging
700: echo "Period: $p s (".($p/$five_min).")<br>";
701: echo "sx: ".$startx." fx: ".$finishx."<br>";
702: echo "diffx: ".($finishx-$startx)."<br>";
703: echo "fx2: ".$fx." p: ".$p."<br>";
704: */
705: 
706: 
707: echo "<br><hr style=\"width: 400px; border: 0 solid #a0a0a0; height: 1px; background-color: #a0a0a0; align: left;\" align=\"left\"><br>";
708: }
709: 
710: $savestring="";
711: $first=true;
712: foreach($_REQUEST['testlist'] as $testid)
713: 	{
714: 	if ($first) $first=false;
715: 	else $savestring.=":";
716: 	$savestring.=$testid;
717: 	}
718: echo "<form action=report.php method=post>";
719: echo "<input type=hidden name=reporttests value=\"".$savestring."\">";
720: echo "<input type=hidden name=mode value=savereport>";
721: echo "<b>Save Report As </b><input type=text size=30 name=reportname maxlength=128> <input type=submit value=Save>";
722: echo "</form><br><br>";
723: 
724: Screen_Footer();
725: ?>
726: