session_start();
if (!session_is_registered("LLC"))
{
// if session check fails, invoke error handler
header("Location: /error.php?e=1");
exit();
}
$sn = $_POST['sn'];
$Type = isset($_POST['Type']) ? $_POST['Type'] : "1";
$Description = isset($_POST['Description']) ? $_POST['Description'] : "";
$Procedures = isset($_POST['Procedures']) ? $_POST['Procedures'] : "";
$Training = isset($_POST['Training']) ? $_POST['Training'] : "0";
$user = $_SESSION['UNAME'];
if (!session_is_registered("SUPER") && ($Type == '8'))
{
header("Location: /error.php?e=3");
exit();
}
include("../includes/dbconfig.php");
$connection = mysql_connect($db_host, $db_user, $db_pass) or die ("Unable to connect!");
$query = "SELECT FirstName, LastName, Extension from userlist WHERE username = '$user'";
mysql_select_db($db_name);
$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());
$row = mysql_fetch_row($result);
$fullname = $row[0].' '.$row[1];
$ext = $row[2];
$head = 'Comments from ';
if ($Type == '7') // change priority
{
$OldP = $_POST['OldPrio'];
$NPriority = $_POST['Priority'];
if ($OldP == '1')
{
$OPriority = "Medium";
}
else if ($OldP == '2')
{
$OPriority = "High";
}
else if ($OldP == '0')
{
$OPriority = "Low";
}
if ($NPriority == "Medium")
{
$NewP = '1';
}
else if ($NPriority == "High")
{
$NewP = '2';
}
else if ($NPriority == "Low")
{
$NewP = '0';
}
$Description = "Changed from $OPriority to $NPriority.\n".$Description;
}
if ($Type == '5')//change training
{
$OldT = $_POST['OldT'];
if ($OldT == $Training)
{ header("Location: detail.php?sn=$sn");
exit();
}
else if ($OldT == '0')
{ $Description = "Changed from No to Yes.";
}
else if ($OldT == '1')
{ $Description = "Changed from Yes to No.";
}
}
$query = "insert into followup set SerialNo='$sn', RecordTime=NOW(), Type='$Type', ";
$query = $query."Person='$fullname', UserName='$user', Extension='$ext', Description='$Description'";
$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());
if ($Type == '3')// resolve
{$query = "update request set UpdateTime=NOW(), Status='$Type', Procedures='$Procedures' ";
$head = 'Solved by ';}
else if ($Type == '5')// change training
{$query = "update request set UpdateTime=NOW(), Training='$Training' ";
$head = 'Further Training changed by ';}
else if ($Type == '8')// close
{$query = "update request set UpdateTime=NOW(), Status='$Type', Procedures='$Procedures', Training='$Training' ";
$head = 'Closed by ';}
else if ($Type == '9')// reopen
{$query = "update request set UpdateTime=NOW(), Status='0'";
$head = 'Reopened by ';}
else if ($Type == '7')// change priority
{$query = "update request set UpdateTime=NOW(), Priority='$NewP'";
$head = 'Priority changed by ';}
else
{$query = "update request set UpdateTime=NOW(), Procedures='$Procedures' ";}
$query = $query."where SerialNo='$sn'";
$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());
$now = date("F j, Y, g:i a");
include("SendMail.php");
$TEXT="Request #: $sn.\n\n";
$TEXT=$TEXT."The latest update on $now:\n$head$fullname.\n\n";
$TEXT=$TEXT.$Description."\n\n";
$TEXT=$TEXT."Please go to the following web address for detail information:\n";
$TEXT=$TEXT."detail.php?sn=$sn\n\n\n";
$TEXT=$TEXT."Language Learning Center\n";
$Description = str_replace("\n","
",$Description);
$HTML="\n";
$HTML=$HTML."Request #: $sn\n";
$HTML=$HTML."
\n";
$HTML=$HTML."The latest update on $now:\n";
$HTML=$HTML."
$head$fullname.";
$HTML=$HTML."
$Description";
$HTML=$HTML."
For detail information, please click here.\n";
$HTML=$HTML."
Language Learning Center\n";
// $ATTM=array("/home/myself/test/go.jpg", "/home/myself/test/SomeDoc.pdf");
$ATTM=array();
SendMail(
"pmarcy@mtsac.edu","Language Learning Center", //sender
"pmarcy@mtsac.edu","LLC staff", //recipient
"",
"LLC Computer service request update. #".$sn, //subject
$TEXT,$HTML,$ATTM); //body and attachment(s)
header("Location: detail.php?sn=$sn");
exit();
?>