<?php
require_once 'usercheck.php';
require_once 'database.php';
require_once 'transitions.php';
require_once 'errors.php';
?>
<html>
<link rel="stylesheet" href="style.css">
<?php
function getLookupFieldValue($connection, $query, $fieldName)
{
$result = ttdb_execQuery($connection, $query);
$fields = ttdb_getArray($result);
if (is_array($fields)) {
return $fields[$fieldName];
}
return "Field not found ($fieldname)";
}
?>
<title>View defect details</title>
<body>
<?php include 'header.php' ?> <?php
ttdb_connect($db);
if ($iddefect == "") {
tter_errorWithBackButton("No defect id given. You should specify one.");
exit;
}
$query = "select * from defect where iid = $iddefect";
$res = ttdb_execQuery($db, $query);
$defectFields = ttdb_getArray($res);
if (!is_array($defectFields)) {
$i = 0;
?>
<h1>Defect not found.</h1>
<p>The defect you have asked for (<?php print($iddefect); ?>) can not be found in the database. Please check the number and try again.</p>
<?php } else { ?>
<h1>Viewing <?php print($tr_states[$defectFields['iiddefectstatus']]); ?>
defect
<?php print($defectFields['iid']); ?></h1>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableFieldName">
<tr>
<td class="tableFieldName" width="180">Defect Id</td>
<td class="tableFieldContent"><?php print($defectFields['iid']); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Project</td>
<td class="tableFieldContent"><?php print(getLookupFieldValue($db,
"select sname from project where iid = ".$defectFields['iidproject'],
"sname")); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Software</td>
<td class="tableFieldContent"><?php print(getLookupFieldValue($db,
"select sname from software where iid = ".$defectFields['iidsoftware'],
"sname")); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Headline</td>
<td class="tableFieldContent"><b><?php print(htmlspecialchars($defectFields['sheadline'])); ?></b></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Repeatability</td>
<td class="tableFieldContent"><?php print(getLookupFieldValue($db,
"select sname from repeat where iid = ".$defectFields['iidrepeat'],
"sname")); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Defect type</td>
<td class="tableFieldContent"><?php print(getLookupFieldValue($db,
"select sname from defecttype where iid = ".$defectFields['iiddefecttype'],
"sname")); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Detection method</td>
<td class="tableFieldContent"><?php print(getLookupFieldValue($db,
"select sname from detectionmethod where iid = ".$defectFields['iiddetectionmethod'],
"sname")); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Detection date</td>
<td class="tableFieldContent"><?php print($defectFields['ddetectdate']); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Detected on release</td>
<td class="tableFieldContent"><?php $detectedOnRelease = $defectFields['iiddetectedinrelease'];
if ($detectedOnRelease != "") {
print(getLookupFieldValue($db,
"select sname from releases where iid = ".$detectedOnRelease,
"sname"));
}
?></td>
<tr>
<td class="tableFieldName" width="180">Priority</td>
<td class="tableFieldContent"><?php print(getLookupFieldValue($db,
"select sname from priority where iid = ".$defectFields['iidpriority'],
"sname")); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Submitter</td>
<td class="tableFieldContent"><?php
$user = getLookupFieldValue($db,
"select sname from users where iid = ".$defectFields['iidsubmitter'],
"sname");
echo "<a href='userlookup.php?userqname=$user'>$user</a>";
?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Assigned engineer</td>
<td class="tableFieldContent"><?php
$idAssigned = $defectFields['iidassigned'];
if ($idAssigned != "") {
$user = getLookupFieldValue($db,
"select sname from users where iid = $idAssigned",
"sname");
echo "<a href='userlookup.php?userqname=$user'>$user</a>";
}
?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Resolution date</td>
<td class="tableFieldContent"><?php print($defectFields['dresolutiondate']); ?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Integrated on release</td>
<td class="tableFieldContent"><?php $integratedOnRelease = $defectFields['iidintegratedinrelease'];
if ($integratedOnRelease != "") {
print(getLookupFieldValue($db,
"select sname from releases where iid = ".$integratedOnRelease,
"sname"));
}
?></td>
</tr>
<tr>
<td class="tableFieldName" width="180">Resolution type</td>
<td class="tableFieldContent"><?php
$resolType = $defectFields['iidresolutiontype'];
if ($resolType != "")
print(getLookupFieldValue($db,
"select sname from resolution where iid = ".$resolType,
"sname")); ?></td>
</tr>
</table>
<form method="post" action="editfields.php">
<input type="hidden" name = "iddefect" value="<?php echo $iddefect; ?>">
<input type="submit" value="Edit fields">
</form>
<br>
<img src="images/titleback.jpg" valign="middle" width="100%" height="5">
<h2>Log</h2>
<br>
<table width="100%" border="0" cellspacing="2" cellpadding="0" class="tableStyle">
<?php
$hist = ttdb_execQuery($db, "select * from history where iiddefect = $iddefect");
while(($fields = ttdb_getArray($hist)) != false) {
?>
<tr>
<td class="tableFieldContent" width="180"><?php print($fields['ddate']);?></td>
<td class="tableFieldContent"><?php print($fields['stext']);?></td>
</tr>
<?php } //while ?>
</table>
<h2>Change state</h2>
<p>
<table>
<tr>
<?php
$states = tr_getStatesFor($defectFields['iiddefectstatus']);
foreach ($states as $state) { ?>
<td>
<form method="post" action="<?php echo ($tr_state_actions[$state]);
?>?iddefect=<?php print($defectFields['iid']) ?>">
<input type="submit" value="<?php echo ($tr_state_captions[$state]); ?>">
</form>
</td>
<?php } //for ?>
</tr>
</table>
<h2>Add new enclosure / attachment</h2>
<p>
<table>
<tr>
<td>
<form method="post" action="enclosure.php">
<input type="hidden" name="iddefect" value="<?php print($defectFields['iid']); ?>" >
<input type="submit" value="Add new enclosure">
</form>
</td>
<td>
<form method="post" action="uploadattach.php">
<input type="hidden" name="iddefect" value="<?php print($defectFields['iid']); ?>">
<input type="submit" value="Add new attachment">
</form>
</td>
</tr>
</table>
<h2>Attachments</h2>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
$query = "select * from attachments where iiddefect = $iddefect";
$res = ttdb_execQuery($db, $query);
while(($fields = ttdb_getArray($res)) != false) {
?>
<tr>
<td width="20%" class="tableFieldName"><a href="<?php echo "getattachment.php?iidatt={$fields['iid']}"; ?>"><?php echo $fields['sfile']; ?></a></td>
<td class="tableFieldContent"><?php echo $fields['sdescription']; ?></td>
</tr>
<?php } //while ?>
</table>
<span class="tableFieldContent"><img src="images/titleback.jpg" valign="middle" width="100%" height="3"></span>
<h2>Enclosures</h2>
<?php
$query = "select * from enclosure where iiddefect = $iddefect";
$res = ttdb_execQuery($db, $query);
while (($enclosureFields = ttdb_getArray($res)) != false) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableFieldName">
<tr>
<td><h4><?php $title = $enclosureFields['stitle']; print ($title); ?></h4></td>
</tr>
<tr>
<td class="tableFieldContent"><?php
$text = $enclosureFields['stext'];
if ($text != "") {
?>
<pre><font size="2"><?php print(htmlspecialchars(stripslashes(wordwrap($text,80)))) ?></font></pre>
<?php } else { ?> <No description text given> <?php } // if ?> </td>
</tr>
</table>
<form action="enclosure.php" method="POST">
<input type="hidden" name="iddefect" value="<?php print($iddefect); ?>">
<input type="hidden" name="idenclosure" value="<?php print($enclosureFields['iid']); ?>">
<input type="hidden" name="fTitle" value="<?php print($title); ?>">
<input type="hidden" name="fText" value="<?php print(htmlspecialchars($text)); ?>">
<input type="submit" name="Submit" value="Edit enclosure">
</form>
<table width="100%" border="0" cellpadding="0" align="center">
<tr bgcolor="#CCCCCC"><td height="1"></td></tr>
</table>
<br>
<?php } // for ?>
<?php ttdb_close($db); ?>
<?php } ?>
<p> </p>
<?php include 'footer.php' ?>
</html>