<?php
//This is a self posting page to add actions to the issue passed in the querystring
session_register("lname");
session_register("pass");
include ("pagefunctions.php");
include ("checkuser.php");
$userstatus = checkuser($lname, $pass);
if ($userstatus == "isvalid") {
gentop("The Title");
//Checks to see if it is posting to its self to add action
if ($stage == 1)
{
$date = date("Y-m-d, h:m:s");
/* insert the values into the action table*/
$sql_iinsert1 = "INSERT INTO action (IUID,Pname,Date,Description,Effort)
VALUES ($IUID,'$Pname','$date','$Description',$effort)";
$insert1_result = mysql_query($sql_iinsert1,$connection) or die (mysql_error());
if ($resolved)
{
/*update the issue table if the problem has been resolved*/
$sql_iinsert1 = "update issue set Resolution=1 where IUID=$IUID";
$insert1_result = mysql_query($sql_iinsert1,$connection) or die (mysql_error());
}
/*Get the issue description for the email notifications*/
$sql_command = "SELECT * FROM issue Where IUID=$IUID";
$sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$descrip=$row["Description"];
$contact=$row["Contact"];
$cat=$row["Category"];
$iuid=$row["IUID"];
$res=$row["Resolution"];
/*Generate email output*/
if ($res==1)
{$output="Good news, the problem has been resolved!\n";}
else
{$output="An action has been taken on your issue, it is still not resolved.\n\n";}
$output.="Problem:$descrip\n\nAction Taken By:$Pname\n\nAction Taken:$Description\n\n\n";
$output.="Please do not reply to this email. This is an automatic service.\n";
global $serverhome;
$output.="If you have any questions please go to the web site at $serverhome/radtracker\n";
$output.="\n\n-Radiology Support";
/*Mail a copy to the contact*/
mail("$contact","An action has been taken on one of your issues",$output);
/*Mail a copy to the support team for that category*/
$sql_iinsert1="Select Email from personnel,expertise,category where personnel.name=expertise.name and expertise.CUID=category.CUID and category.category='$cat'";
$sql_result = mysql_query($sql_iinsert1,$connection) or die (mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$recip=$row["Email"];
mail(" $recip","Action log on $cat ","$output");
print("$mailsend");
}
}
}
?>
<form method="post" action="<?php print($serverhome . "$PHP_SELF?IUID=$IUID");?>">
<?php
//generate table with issue information
echo "<table width='99%' align='center' border='1' cellpadding='2' cellspacing='2'>";
echo "<TR><td colspan=2 align=middle><b> Problem Description</b></td><td align=middle><b>Date</td>";
echo "<td align=middle><b>Severity</b></td><td align=middle><b>Category</b></td>";
echo "<td align=middle><b>Contact</b></td><td><b>Phone</b></td></tr>";
$sql_command = "SELECT * FROM issue Where IUID=$IUID";
$sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$descrip=$row["Description"];
$mdate=$row["Date"];
$serv=$row["Severity"];
$contact=$row["Contact"];
$contactphone=$row["Contactphone"];
$cat=$row["Category"];
$iuid=$row["IUID"];
$res=$row["Resolution"];
$resoutput="Yes";
if ($res==0) $resoutput="No";
echo "<TR>";
if ($userstatus == "isvalid") {
echo "<td><font size='2'><a href='editissue.php?IUID=$IUID'><img src='images/edit.gif' border='0'></a></font></td>";
}
else { echo "<td><font size='2'> </font></td>"; }
echo " <TD><font size='2'>$descrip</font></td>
<Td><font size='2'>$mdate</font></td>
<td><font size='2'>$serv</font></td>
<td><font size='2'>$cat</font></td>
<td><font size='2'>$contact</font></td>
<td><font size='2'>$contactphone</font></td>
</tr><br>";
}
echo "</table><hr><!-----Get Actions------>";
echo "<table width='99%' align='center' border='1' cellpadding='2' cellspacing='2'>";
echo "<TR><td align=middle><b> Action Description</b></td><td align=middle><b>Date</b></td>";
echo "<td><b>Tech Name</b></td></tr>";
//Generate table to display all the actions taken so far
$sql_command = "SELECT * FROM action Where IUID=$IUID";
$sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$descrip=$row["Description"];
$pname=$row["Pname"];
$mdate=$row["Date"];
$iuid=$row["IUID"];
echo "<TR>
<TD><font size='2'>$descrip</font></td>
<Td><font size='2'>$mdate</font></td>
<td><font size='2'>$pname</font></td>
</tr><br>";
}
echo "</table>";
if ($userstatus == "isvalid") {
//Generate form to add a new action
echo "<hr><table width='99%' align='center' border='1' cellpadding='2' cellspacing='2'>";
echo "<TR><TD colspan=2 align=middle ><b>Add an action</b></td></tr>";
echo "<TR><td>Tech Name</td><td><select name='Pname' size='1'>";
$sql_command = "SELECT Name FROM personnel ORDER BY Name";
$sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$name = $row["Name"];
echo "<option value=\"$name\">$name</option>";
}
echo "</select></td></tr><tr><TD>Action Description</td>";
echo "<Td><textarea name='Description' rows='5' cols='50' wrap='auto' name='Description'></textarea></td></tr>";
echo "<tr><TD>Effort (hours)</td><td><input type='text' value=0 name='effort'>";
echo "<input name='stage' value='1' type=hidden></td></tr>";
echo "<Tr><td>Issue Resolved?</td><td align=left><input name='resolved' type='checkbox'></td></tr>";
echo "<tr><td align=middle colspan=2><input type='submit'></td></tr></table></form>";
}
genbottom();
}
else {
global $serverhome;
header("Location: " . $serverhome . "/radtracker/login.php?from=$PHP_SELF");
}
?>