Location: PHPKode > projects > Insecticida > insecticida_wiki/usecase/viewusecase.php
<?
###################################################
# This file is part of Insecticida. (http://sourceforge.net/projects/insecticida/)
# Copyright (C) 2001-2007 Guillermo Schwarz
#
# viewusecase.php 10/07/2007   
#
# Based in Workbench v0.11 (http://workbench.sourceforge.net)
# Copyright (C)2001 Stuart Wigley (hide@address.com) 
#
# Insecticida is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Insecticida is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Insecticida; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
###############################################
session_start();
require_once("../config.php");
#if user has logged in get $login from session
if ( session_is_registered("login"))
{
	$login = $HTTP_SESSION_VARS["login"];
	require_once("$path/connect.php");
	require_once("$path/general.php"); 
	if ($HTTP_GET_VARS["usecaseID"])
	{
		$usecaseID = $HTTP_GET_VARS["usecaseID"];
	}
	else if ($HTTP_POST_VARS["usecaseID"])
	{
		$usecaseID = $HTTP_POST_VARS["usecaseID"];
	}
	if ($HTTP_GET_VARS["newissueID"])
	{
		$newissueID = $HTTP_GET_VARS["newissueID"];
	}
	else if ($HTTP_POST_VARS["newissueID"])
	{
		$newissueID = $HTTP_POST_VARS["newissueID"];
	}
	$issuenew = $HTTP_GET_VARS["issuenew"];
	$issueinsert = $HTTP_POST_VARS["issueinsert"];
	$issuedelete = $HTTP_GET_VARS["issuedelete"];
	$issueIDToDelete = $HTTP_GET_VARS["issueIDToDelete"];
	#echo "issuedelete = $issuedelete <hr>";
	
	$query = mysql_query("select * from params where params.paramID='use_case_url_base'") or die(mysql_error());
	if ($result = mysql_fetch_array($query))
	{
		$urlBase = $result[paramValue];
	}
	
	if ( $issueinsert )
	{
		# border cases:
		# 1. the bug must exist, otherwise do nothing
		# 2. the bug may already be linked to the use case, but be marked as isHidden (was deleted), in that case update to isHidden = false.
		$query = mysql_query("select * from bugs where bugs.bugID='$newissueID'") or die(mysql_error());
		if ( $result = mysql_fetch_array($query) )
		{
			$query = mysql_query("select * from usecaseissue where usecaseissue.usecaseID='$usecaseID' and usecaseissue.bugID = '$newissueID'") or die(mysql_error());
			if ( $result = mysql_fetch_array($query) )
			{
				$theQuery1 = "update usecaseissue set isHidden = 'N' where usecaseID = '$usecaseID' and bugID = '$newissueID'";
			}
			else {
				$theQuery1 = "insert into usecaseissue values ( '$usecaseID', '$newissueID', '$login', 'N', NULL )";
			}
			#echo("theQuery1 = $theQuery1 <hr>");
			mysql_query("$theQuery1") or die (mysql_error());
		}
	}
	else if ( $issuedelete ) 
	{
		$theQuery2 = "select * from usecaseissue where usecaseissue.usecaseID='$usecaseID' and usecaseissue.bugID = '$issueIDToDelete'";
		#echo("theQuery2 = $theQuery2 <hr>");
		$query = mysql_query( $theQuery2 ) or die(mysql_error());
		if ( $result = mysql_fetch_array($query) )
		{
			$theQuery1 = "update usecaseissue set isHidden = 'Y', loginHide = '$login' where usecaseID = '$usecaseID' and bugID = '$issueIDToDelete'";
			#echo("theQuery1 = $theQuery1 <hr>");
			mysql_query("$theQuery1") or die (mysql_error());
		}
	}
	
	include("$path/header.php");
?>
    <table cellspacing="0" class="table3">
		 <tr class="rowtitle">
		  <td><h5>View Use Case</h5></td>
		 </tr>
		 <tr><td colspan="2"><hr></td></tr>
		 <tr>
		  <td>
		   <form action="viewusecase.php" method="get">
			Use case: <select name="usecaseID" onchange="this.form.submit()">
				<option value="">Choose</option>
	<?
			$query = mysql_query("select * from mods, funpack, usecase where mods.isHidden='N' and mods.modID = funpack.modID and funpack.funpackID = usecase.funpackID order by mods.modID, funpack.funpackID, usecase.usecaseID") or die(mysql_error());
			while ($result = mysql_fetch_array($query))
			{
				echo("<option value=\"$result[usecaseID]\"" );
				if ( $usecaseID == $result[usecaseID] ) echo( " selected" );
				echo( ">$result[modName] - $result[funpackDesc] - $result[usecaseName] - $result[usecaseDesc] </option>");
			}
	?>
			</select>
			
			</form>
		  </td>
		 </tr>
		 <tr><td colspan="2"><hr></td></tr>
		 <tr>
		 <td>
		 <form method="post" name="viewusecase" action="viewusecase.php">
<?

if ( $usecaseID )
{
	#get all of the modules data
	$queryUseCase = mysql_query("select * from usecase, funpack, mods where usecase.usecaseID='$usecaseID' and usecase.funpackID = funpack.funpackID and funpack.modID = mods.modID") or die(mysql_error());
	$resultUseCase = mysql_fetch_array($queryUseCase);
	echo("<table class=\"table1\">");
	echo("<tr><td><strong>Name</strong></td><td>$resultUseCase[usecaseName]</td></tr>");
	echo("<tr><td><strong>Description</strong></td><td>$resultUseCase[usecaseDesc]</td></tr>");
	echo("<tr><td><strong>Module</strong></td><td>$resultUseCase[modName]</td></tr>");
	echo("<tr><td><strong>Fun Pack</strong></td><td>$resultUseCase[funpackDesc]</td></tr>");
	echo("<tr><td><strong>Java Class</strong></td><td>$resultUseCase[javaPackage].$resultUseCase[javaClass]</td></tr>");
	echo("<tr><td><strong>Document</strong></td><td><a href=\"$urlBase$resultUseCase[url]\">$resultUseCase[usecaseName]</a></td></tr>");
	echo("<tr><td><strong>Issues</strong></td></tr>");
	$totalCost = 0.0;
	$totalOpenCost = 0.0;
	echo( "<tr><td> &nbsp; </td><td><table>" );
	echo( "<tr bgcolor=\"#c0c0c0\"><td>#</td><td>Title</td><td>Opened by</td><td>Assigned to</td><td>Status</td><td>Cost</td><td>Still Open</td><td>Operation</td></tr>" );
	$query = mysql_query("select * from bugs, usecaseissue, status, severity where usecaseissue.usecaseID='$usecaseID' and bugs.bugID = usecaseissue.bugID and bugs.statusID=status.statusID and bugs.sevID=severity.sevID and usecaseissue.isHidden='N'") or die(mysql_error());
	while ( $result = mysql_fetch_array($query) )
	{
		$bugID = $result[bugID];
		echo( "<tr>");
		$colour = colorsFor( $result2[bgcolour], $result[sevColour], $result[statusID], $result[typeID] );
		$bgcolour1 = $colour->bgcolour1;
		$bgcolour2 = $colour->bgcolour2;
		echo "<td bgcolor=\"$bgcolour1\">";
		$showStar = isStar($result[bugID]);
		if ( $showStar )
		{
			echo "<img src=\"../images/happystar1.gif\" width=10 height=10>";
		}
		echo "$result[bugID]:</td>";
		echo("<td bgcolor=\"$bgcolour2\"><a class=\"nav\" href=\"../bugtracking/zoombug.php?theID=$result[bugID]\">$result[title]</a></td>");
		echo("<td bgcolor=\"$bgcolour2\">$result[openedBy]</td>");
		echo("<td bgcolor=\"$bgcolour2\">$result[assTo]</td>\n");
		echo("<td bgcolor=\"$bgcolour2\">$result[statusName]</td>");
		$cost = totalCost( $result[bugID] );
		$totalCost += $cost;
		$costStr = sprintf( "<td bgcolor=\"$bgcolour2\"> %3.1f </td>", 
						  $cost );
		$openCost = totalOpenCost( $result[bugID] );
		$totalOpenCost += $openCost;
		$openCostStr = sprintf( "<td bgcolor=\"$bgcolour2\"> %3.1f </td>", 
						   $openCost );
		echo( $costStr . $openCostStr );
		echo("<td><a href=\"viewusecase.php?usecaseID=$usecaseID&issueIDToDelete=$result[bugID]&issuedelete=1\">Del</a></td>");
		echo("</tr>\n");
	}
	if ( $issuenew )
	{
		echo("<input type=\"hidden\" name=\"usecaseID\" value=\"$usecaseID\">");
		echo("<tr><td><input type=\"text\" name=\"newissueID\"></td>");
		echo("<td><input type=\"hidden\" name=\"issueinsert\" value=\"1\"><a href=\"javascript:document.forms[2].submit()\" onClick=\"return validateForm('projectAdmin');\">Submit</a></td></tr>");
	}
	else {
		echo("<tr><td colspan=\"3\"><a href=\"viewusecase.php?usecaseID=$usecaseID&issuenew=1\">Add issue</a></td></tr>");
	}
	echo("</table></td></tr>");
	echo("</table>");
}
?>  
       </td>
	  </tr>
	 </table>
  </form>
<?include("$path/footer.php");
}
else{
	header("Location: $url/main.php");
	}
?>
Return current item: Insecticida