Location: PHPKode > projects > QaTraq > qatraq/test_scripts_view_content.php
<?php
//  QaTraq - Test Management application
//  Copyright (C) 2006 Traq Software Ltd
//
//  The contents of this file are subject to the Mozilla Public License
//  Version 1.1 (the "License"); you may not use this file except in
//  compliance with the License. You may obtain a copy of the License at
//  http://www.mozilla.org/MPL/
//
//  Software distributed under the License is distributed on an "AS IS"
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
//  the License for the specific language governing rights and
//  limitations under the License.
//
//  The Original Code is QaTraq code, released 20th June 2004.
//
//  The Initial Developer of the Original Code is Traq Software Ltd.
//  Portions created by Traq Software are Copyright (C) 2004-2006
//  Traq Software Ltd. All Rights Reserved.
include('lib/session.inc');
include('lib/tmt.inc');
include('lib/uploads.inc');

requiresLogin ($_SERVER['REQUEST_URI']);

$id = $_GET['id'];
if (!$id) {
	redirect("test_scripts_view_search.php");
}
else {
	$id = (int)$id;
}

$PAGE_TITLE = "Test Scripts";
$PAGE_LOGO = "images/script_logo.gif";
$AREA_TYPE = AREA_TYPE_TEST_SCRIPTS;
$PAGE_TYPE = PAGE_TYPE_VIEW;

$tmt = new TMT($_SESSION['USER_ID']);
if (stg_check())
{
    include('lib/tmtpro.inc');
    $tmt = new TMTPRO($_SESSION['USER_ID']);
}

if (!$tmt->check_right($AREA_TYPE, $PAGE_TYPE)) {
	include('includes/no_rights.inc');
	exit();
}

$arr_priority_names = array("1"=>"P1", "2"=>"P2", "3"=>"P3", "4"=>"P4", "5"=>"P5");

// get Test Script details
$test_script = $tmt->test_scripts->get($id);

if (!$test_script) {
	include('includes/top.inc');

	echo table_start("Record deleted", 660);
?>
    <TABLE width="580" border="0" cellspacing="0" cellpadding="0" align="center">
        <TR>
          <TD height="100" width="163" align="right" valign="middle" class="normal">&nbsp;</TD>
          <TD width="435" align="left" valign="middle" class="normal">&nbsp;</TD>
        </TR>

        <TR>
          <TD colspan="2" align="center" valign="middle" class="normal">
			<font color="red"><b>Record does not exist. It might have been deleted recently !</b></font>
		  </TD>
        </TR>

        <TR>
          <TD height="100" width="163" align="right" valign="middle" class="normal">&nbsp;</TD>
          <TD width="435" align="left" valign="middle" class="normal">&nbsp;</TD>
        </TR>
    </TABLE>
<?php 
	echo table_end(660);
	include('includes/bottom.inc');

	exit();

}

$uploader = new Attachements($tmt->userid, $tmt->shared_db, UPLOAD_SCRIPT_ID, $test_script["TestScriptID"]);
$uploader->refresh();

$test_cases = $tmt->test_scripts->get_test_cases_test_scripts($id);
$design = $tmt->test_designs->get_latest_version($test_script["TestDesignID"]);

$product = $tmt->products->get($test_script["ProductID"]);
$product_version = $tmt->products->get_version($test_script["ProductID"], $test_script["ProductVersionID"]);

$platform = $tmt->platform->get($test_script["PlatformID"]);
$os = $tmt->os->get($test_script["OsID"]);

$latest_record = $tmt->test_scripts->get_latest_version($test_script["TestScriptID"]);
if (!$test_script["LatestVersion"] && $_GET["latest"]) {
  redirect("test_scripts_view_content.php?id=" . $latest_record["ID"]);
}

$newer_test_cases_text = "";
if ((count($test_cases) > 0) && ($test_script["LatestVersion"])) {
	for ($i = 0; $i < count($test_cases); $i++) {
		$row = $test_cases[(int)$i];
			if (!$row["LatestVersion"]) {
				$newer_test_cases_text = "There are newer versions of some test cases available in this test script.";
				$newer_test_cases_text = $newer_test_cases_text . "<br>To update test cases in this script please <a href=\"test_scripts_modify_content.php?id=$id&design_id=$test_script[TestDesignID]\">modify</a> this test script.";
				break;	
			}
	}
}

include('includes/top.inc');
?>

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
  <TR>
    <TD align="middle" valign="top" height="90">
	  <script language="javascript">
	  <!--
			function handleModify() {
				document.location.href = "test_scripts_modify_content.php?id=<?php echo $id;?>&design_id=<?php echo $test_script["TestDesignID"]?>";
			}

			function handleCopy() {
				document.location.href = "test_scripts_copy_content.php?id=<?php echo $id;?>&design_id=<?php echo $test_script["TestDesignID"]?>";
			}

			function handleDelete() {
				document.location.href = "test_scripts_delete_content.php?id=<?php echo $id;?>";
			}
	  //-->
	  </script>
      <FORM name="main" method="post" action="<?php echo $tmt->get_self()?>">
		  <input type="hidden" name="page_action" value="">
		  <input type="hidden" name="page_action2" value="">
		  <?php echo table_start("View Test Script", 660);?>
                <TABLE width="540" border="0" cellspacing="0" cellpadding="0" align="center">
                  <TR>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>
				  <?php if (!$test_script["LatestVersion"]) {?>
					  <TR>
						<TD colspan="3" class="normal"><B><font color="red">This is not the <a href="test_scripts_view_content.php?id=<?php echo $latest_record["ID"] ?>&latest=1">latest version</a> of this document.</font></B></TD>
					  </TR>
					  <TR>
						<TD class="normal" colspan="3">&nbsp;</TD>
					  </TR>
				  <?php }?>
                  <TR>
                    <TD colspan="3" class="normal"><B>Title</B></TD>
                  </TR>
                  <TR>
                    <TD colspan="3" class="normal">
                      <?php echo $test_script['Title'];?>
                    </TD>
                  </TR>
                  <TR>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>
                  <TR>
                    <TD class="normal" width="165"><B>Test Design Title</B></TD>
                    <TD class="normal" width="165"><B>ID</B></TD>
                    <TD class="normal" width="216"><B>Version</B></TD>
                  </TR>
                  <TR>
                    <TD class="normal" width="165"><?php echo $design["Title"]?></TD>
                    <TD class="normal" width="165"><?php echo $test_script['DocumentID']?></TD>
                    <TD class="normal" width="216"><?php echo $test_script['Version']?></TD>
                  </TR>
                  <TR>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>
                  <TR>
			<TD class="normal" width="165"><B>Author</B></TD>
                    <TD class="normal" width="165"><B>Creation Date</B></TD>
                    <TD class="normal" width="216"><B>Intended Tester</B></TD>
                  </TR>
		<TR>
			<TD class="normal" width="165" valign="top"><?php echo $test_script["Author"]?></TD>
			<TD class="normal" width="165" valign="top"><?php echo $test_script["CreationDate"]?></TD>
			<TD class="normal" width="216" valign="top"><?php echo $test_script["Tester"]?></TD>
		</TR>
                  <TR>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>


		<TR>
			<TD class="normal" width="165"><B>Product</B></TD>
			<TD class="normal" width="165"><B>Product version</B></TD>
			<TD class="normal" width="216"><B>Intended Platform</B></TD>
		</TR>
		<TR>
			<TD class="normal" width="165" valign="top"><?php echo $product["Name"]?></TD>
			<TD class="normal" width="165" valign="top"><?php echo $product_version["Version"]?></TD>
			<TD class="normal" width="216" valign="top"><?php echo $platform["PlatformName"]?></TD>
		</TR>
		<TR>
			<TD class="normal" width="165">&nbsp;</TD>
			<TD class="normal" width="165">&nbsp;</TD>
			<TD class="normal" width="216">&nbsp;</TD>
		</TR>
		<TR>
			<TD class="normal" width="165">
        <b>Over. Est. Time</b>
      </TD>
			<TD class="normal" width="165"><B>Calc. Est. Time</B></TD>
			<TD class="normal" width="216"><B>Intended Os</B></TD>
		</TR>
		<TR>
			<TD class="normal" width="165" valign="top">
        <?php echo $tmt->test_scripts->convert_time_to_string($test_script["OverEstTime"]);?></TD>
			<TD class="normal" width="165" valign="top"><?php echo $tmt->test_scripts->convert_time_to_string($tmt->test_scripts->sum_est_time($id));?></TD>
			<TD class="normal" width="216" valign="top"><?php echo $os["OsName"]?>
      </TD>
		<TR>
			<TD class="normal" width="165" valign="top">&nbsp;</TD>
			<TD class="normal" width="165" valign="top">&nbsp;</TD>
			<TD class="normal" width="216" valign="top">&nbsp;</TD>
		</TR>

                  <TR>
                    <TD class="normal" colspan="3"><?php 
                    $uploader->draw_attachements(0);
                    ?></TD>
                  </TR>

		<TR>
			<TD class="normal" width="165">&nbsp;</TD>
			<TD class="normal" width="165">&nbsp;</TD>
			<TD class="normal" width="216">&nbsp;</TD>
		</TR>


                  <TR>
                    <TD class="normal" width="165"><B>Content</B></TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>
                  <TR>
                    <TD class="normal" colspan="3">
                      <?php echo format_content($test_script["Content"])?>
                    </TD>
                  </TR>
                  <TR>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>
                <TR>
                  <TD colspan="3" align="middle" valign="middle" class="normal">
				    <?php if ($test_script["LatestVersion"]) {?>
					<INPUT type="button" class="button" name="modify" value="  MODIFY  " onclick="javascript:handleModify();">&nbsp;&nbsp;
					<?php }?>
					<INPUT type="button" class="button" name="copy" value="  COPY  " onclick="javascript:handleCopy();">&nbsp;&nbsp;
				    <?php if ($test_script["LatestVersion"]) {?>
					<INPUT type="button" class="button" name="delete" value="  DELETE  " onclick="javascript:handleDelete();">&nbsp;&nbsp;
					<?php }?>
				  </TD>
                </TR>
                <?php if ($test_script["LatestVersion"]) {?>
                <TR><TD colspan="3" align="middle" valign="middle" class="normal">&nbsp;</TD></TR>
                <TR><TD colspan="3" align="middle" valign="middle" class="normal">
                	<INPUT type="button" class="button" name="modify" value="  INCLUDE CASES  " onclick="document.location.href='test_scripts_include_cases_search.php?id=<?php echo $test_script["ID"]?>';">&nbsp;&nbsp;
                	<INPUT type="button" class="button" name="modify" value="  REMOVE CASES  " onclick="document.location.href='test_scripts_remove_cases_search.php?id=<?php echo $test_script["ID"]?>';">
                </TD></TR>
                <?php }?>
                  <TR>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="165">&nbsp;</TD>
                    <TD class="normal" width="216">&nbsp;</TD>
                  </TR>
				<?php if (!is_null($newer_test_cases_text)) { ?>			
					  <TR>
						<TD class="normal" colspan="3" width="495" align="middle">
							<?php echo $newer_test_cases_text; ?>
						</TD>
                  	  </TR>
				<?php } ?>
                </TABLE>
				<?php echo table_end(660);?>
				<?php 

				if (count($test_cases) > 0) {
					for ($i = 0; $i < count($test_cases); $i++) {
						echo("<br>");
						$row = $test_cases[(int)$i];

						$components_arr = $tmt->test_cases->get_components_for_test_case_version($row["ID"]);
						if (count($components_arr) > 0) {
							$components = implode("<br>", $components_arr);
						} else {
							$components = "";
						}

							// requirements
							$requirements_arr = $tmt->test_cases->get_requirements_for_test_case_version($row["ID"]);
							if (count($requirements_arr) > 0) {
								$requirements = format_list($requirements_arr);
							} else {
								$requirements = "";
							}

						$product = $tmt->test_cases->get_product_for_test_case($row["TestCaseID"]);

						$uploader = new Attachements($tmt->userid, $tmt->shared_db, UPLOAD_CASE_ID, $row["TestCaseID"]);
						$uploader->refresh();

						$title = $row["Title"];
						if (!$row["LatestVersion"]) {
							$title .= "&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>Newer version available!</font>&nbsp";
							$title .= "[<A href=\"test_scripts_modify_content.php?id=";
				   			$title .= $id . "&design_id=" . $test_script[TestDesignID] . "\"" ;
							$title .= " class=\"normal\">Modify</A>]";
						}
						echo table_start($title, 660);
						?><TABLE width="100%" border="0" cellspacing="0" cellpadding="0" ID="Table22">
						<TR><TD align="left" valign="bottom" class="normal" colspan="5" height="5"></TD></TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;<small><a href="test_cases_view_content.php?id=<?php echo $row["ID"] ?>"  target="_blank">View</a></small></TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Title :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $row["Title"]?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;<small><a href="test_cases_modify_content.php?id=<?php echo $row["ID"] ?>&filter_versions=2&filter_result=0"  target="_blank">Modify</a></small></TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>ID :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $row["DocumentID"]?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;<small><a href="test_cases_view_content.php?id=<?php echo $row["ID"] ?>&filter_versions=2&filter_result=0"  target="_blank">All results</a></small></TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Priority :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $arr_priority_names[$row["Priority"]]?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;<small><a href="results_view_single.php?id=<?php echo $id ?>&tca_id=<?php echo $row["ID"] ?>"  target="_blank">View result</a></small></TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Order :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $row["Ordering"]?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
              <TR>
                <TD width="1" bgcolor="#FFFFFF"></TD>
				<TD width="77"  align="left" valign="top" class="tdhead" height="19">&nbsp;<small><a href="results_view_multiple.php?id=<?php echo $id ?>"  target="_blank">View results</a></small></TD>
                <TD width="100" align="right" valign="top" class="tdhead" height="19">
                  <B>Est. Time :</B>
                </TD>
                <TD width="421" align="left" valign="top" class="normal" height="19">
                  &nbsp;<?php echo $tmt->test_scripts->convert_time_to_string($row["CalcEstTime"]);?>
                </TD>
                <TD width="1" bgcolor="#FFFFFF"></TD>
              </TR>
              <TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;</TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Product :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $product["Name"]?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;</TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Components :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $components?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;</TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Requirements :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo $requirements?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
						<TR>
							<TD width="1" bgcolor="#FFFFFF"></TD>
							<TD width="87"  align="left" valign="top" class="tdhead" height="19">&nbsp;</TD>
							<TD width="90" align="right" valign="top" class="tdhead" height="19"><B>Content :</B></TD>
							<TD width="421" align="left" valign="top" class="normal" height="19">&nbsp;<?php echo format_content($row["Content"])?></TD>
							<TD width="1" bgcolor="#FFFFFF"></TD>
						</TR>
                    	<TR>
                        	<TD width="1" bgcolor="#FFFFFF"></TD>
                        	<TD class="normal" colspan="3"><?php 
                        	$uploader->draw_attachements(0);
                        	?></TD>
                        	<TD width="1" bgcolor="#FFFFFF"></TD>
                    	</TR>

						</TABLE><?php 
						echo table_end(660);

//						}
					}
				}?>
		  </div>
      </FORM>
    </TD>
  </TR>
</TABLE>


<?php
include('includes/bottom.inc');
?>
Return current item: QaTraq