END;
$header .= banner ();
$header .= <<Testcases for $versionFor
END;
return $header;
} // createHeader
function createPage ($version, $forEmail = false, $message = "") {
global $webdir, $direction, $sortBy, $script;
$data = getData ($version);
// Flip direction
$direction = ($direction == "ascending") ? "descending" : "ascending";
$urlParms = "$script?version=$version&action=$action&direction=$direction&sortBy";
if (!$forEmail) {
if ($sortBy == "Testcase") {
$testcaseDirection = ($direction == "ascending")
? ""
: "";
} elseif ($sortBy == "Unit") {
$unitDirection = ($direction == "ascending")
? ""
: "";
} elseif ($sortBy == "Type") {
$typeDirection = ($direction == "ascending")
? ""
: "";
} elseif ($sortBy == "Status") {
$statusDirection = ($direction == "ascending")
? ""
: "";
} elseif ($sortBy == "Duration") {
$durationDirection = ($direction == "ascending")
? ""
: "";
} else {
$startDirection = ($direction == "ascending")
? ""
: "";
} // if
if (isset ($message)) {
$page .= "$message
";
} // if
} // if
$page .= <<
END;
if (!$forEmail) {
$page .= <<
|
|
END;
} // if
$page .= <<
# |
Testcase $testcaseDirection |
Start Date/Time $startDirection |
Unit $unitDirection |
Type $typeDirection |
Status $statusDirection |
Duration $durationDirection |
END;
foreach ($data as $line) {
$row_nbr++;
$row_color = setRowColor ($line["Status"]);
$line["Status"] = colorResult ($line["Status"]);
$duration = FormatDuration ($line["Duration"]);
$page .= <<
$row_nbr |
$line[Testcase] |
$line[Start] |
$line[Unit] |
$line[Type] |
$line[Status] |
$duration |
END;
} // foreach
$page .= <<
END;
return $page;
} // createPage
function exportTestVersionsCSV ($version) {
if (isset ($version)) {
$title = "Testcases for $version";
$filename = "Testcases." . $version . ".csv";
} else {
$title = "Testcases for All Versions";
$filename = "Testcases for All Versionss.csv";
} // if
header ("Content-Type: application/octect-stream");
header ("Content-Disposition: attachment; filename=\"$filename\"");
print exportCSV (getData ($version), $title);
exit;
} // exportTestVersionsCSV
function setVersion () {
global $version;
return (isset ($version)) ? $version : "All Versions";
} // setVersion
function displayReport ($version, $message = "") {
print createHeader ();
print createPage ($version, false, $message);
copyright ();
} // displayReport
function mailTestVersionsReport ($version, $pnbr, $username) {
if (isset ($version)) {
$subject = "Testcases for $version";
$filename = "Testcases." . $version . ".csv";
} else {
$subject = "Test Versions for All Tests";
$filename = "Test Versions for All Tests.csv";
} // if
$body = createPage ($version, true);
$attachment = exportCSV (getData ($version, true), $subject);
return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
} // mailTestVersionsReport
openDB ();
$versionFor = setVersion ();
switch ($action) {
case "Export":
exportTestVersionsCSV ($version);
break;
case "Mail":
list ($pnbr, $username) = explode (":", $user);
displayReport ($version, mailTestVersionsReport ($version, $pnbr, $username));
break;
default:
displayReport ($version);
break;
} // switch
?>