<?php include("secure.php");?>
<?php
$p_id = $_SESSION['pid'];
$firstname = $_SESSION['firstname'];
?>
<?php require_once('include/connections.php'); ?>
<?php
mysql_select_db($database, $conn);
$query_client_email = "SELECT Email FROM tt_users WHERE UserID = $p_id";
$client_email = mysql_query($query_client_email, $conn) or die(mysql_error());
$row_client_email = mysql_fetch_assoc($client_email);
$totalRows_client_email = mysql_num_rows($client_email);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if(isset($HTTP_POST_VARS['comment'])){$comment_and_signature = $HTTP_POST_VARS['comment'] . "<br><br>By: " . $firstname;}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tt_tickets (p_id, status, subject, comment, urgency, bywho) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['p_id'], "int"),
GetSQLValueString($HTTP_POST_VARS['status'], "text"),
GetSQLValueString($HTTP_POST_VARS['subject'], "text"),
GetSQLValueString($comment_and_signature, "text"),
GetSQLValueString($HTTP_POST_VARS['urgency'], "text"),
GetSQLValueString($HTTP_POST_VARS['bywho'], "text"));
mysql_select_db($database, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
if ($HTTP_POST_VARS['urgency']=="E" or $HTTP_POST_VARS['urgency'] == "A") {
$Esubject = "Tech Ticket from ".$firstname.". Subject: ".$HTTP_POST_VARS['subject'];
$Ebody = $HTTP_POST_VARS['comment'];
mail($EmailTo,$Esubject,$Ebody,'From:'.$EmailFrom);
}
//mail client confirmation
$Esubject = "Tech Ticket Received";
$Ebody = "
We have received your tech ticket at $CompanyName.
We will process your ticket according to the urgency you selected.
Please do not hesitate to contact us by phone if your issue is an emergency. $CompanyPhone.
Thanks,
$CompanyName
--------
Your ticket text follows:
" . $HTTP_POST_VARS['comment'];
mail($row_client_email['Email'],$Esubject,$Ebody,'From:'.$EmailFrom);
$insertGoTo = "my_tickets_viewall.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php include("welcome.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Tickets</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="include/style.css" type="text/css" rel="stylesheet" />
</head>
<body topmargin="0">
<?php include("header.php"); ?>
<h1 align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Add
New Ticket</font></h1>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center" border="0">
<tr valign="baseline">
<td valign="top" bgcolor="#999999"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Subject</font></strong></td>
<td bgcolor="#CCCCCC"> <input type="text" name="subject" value="" size="50"></td>
</tr>
<tr valign="baseline">
<td valign="top" bgcolor="#999999"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Comment</font></strong></td>
<td bgcolor="#CCCCCC"> <textarea name="comment" rows="10" cols="50"></textarea></td>
</tr>
<tr valign="baseline">
<td valign="top" bgcolor="#999999"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Urgency</font></strong></td>
<td bgcolor="#CCCCCC"> <p>
<select name="urgency">
<option value="N">Next Visit</option>
<option value="A">ASAP</option>
<option value="E">Emergency</option>
</select>
</p>
<p> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Emergency=we
will be emailed immediately<br>
ASAP=we will be emailed<br>
Next Visit=the technician will address this issue on the next
visit</font></p></td>
</tr>
<tr valign="baseline" bgcolor="#CCCCCC">
<td colspan="2" align="right" nowrap> <div align="center">
<input type="submit" value="Submit Ticket">
</div></td>
</tr>
</table>
<input type="hidden" name="p_id" value="<?php echo $p_id ?>">
<input type="hidden" name="status" value="P">
<input type="hidden" name="bywho" value="Y">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<p> </p>
<?php include("footer.php"); ?>
</body>
</html>
<?php
mysql_free_result($client_email);
?>