session_start();
session_register("uid");
session_register("redirect");
session_register("sid");
session_register("uname");
//code updated 8-17-03 tsf
//code modified 7/13/06 tsf
//var_dump($_POST);
$connect=odbc_connect("ITLog", "anon","anon1");
require("common.inc");
mt_srand(getmicrotime);
//$sid=md5(uniqid(mt_rand(),1));
//echo $sid;
if(!isset($uid) or ($uid==""))
{//redirect to login page
$header="";
include("blank.inc");
}
elseif(!isset($nav) or ($nav==0))
{
$sid=md5(uniqid(mt_rand(),1));
$sql="select * from tbl_hd_transaction where (assignedto=$uid and status<>2 and status<>3) ORDER BY transdtrecd;";
$requests=odbc_exec($connect,$sql);
include("help_desk/hdlist.inc");
}
elseif($_GET['nav']==1 or $_POST['nav']==1)
{//chose client
if($function==0) {
include("help_desk/hdrequest.inc");
} elseif($function==13) {
require("help_desk/hdbkupreq.inc");
} else {
include("help_desk/hdrequest.inc");
}
}
elseif($_GET['nav']==2 or $_POST['nav']==2)
{
include("help_desk/hd.inc");
}
elseif($_GET['nav']==3 or $_POST['nav']==3)
{//process submitted data, allow user to add actions taken
if($function!=13) {
$date=check_errors($date);
$needed=check_errors($date);
$desc=check_errors($desc);
$needed=check_errors($needed);
$sql="insert into tbl_hd_transaction (transoperator, transcaller, transnatureofcall, transissuedesc, transdtrecd, transurgency, assignedto, sessionID, status, transdtNeeded, irritation_id, client_id) values ($uid,$call,$category,'$desc','$date',$urgent, $assign, '$sid', 1, '$needed', $irritation, $client);";
odbc_exec($connect,$sql);
$sql="select transkey from tbl_hd_transaction where sessionid='$sid';";
$request=odbc_exec($connect,$sql);
$r=odbc_result($request,1);
$header="";
//$complete="Add Actions to Request $r | Log Another Help Desk Request";
$links="Add Actions to Request $r | Log Another Request For This Client";
//$sql="select * from tbl_hd_transaction where (assignedto=$uid and status<>2 and status<>3) ORDER BY transdtrecd;";
$sql="select transkey from tbl_hd_transaction where sessionid='$sid'";
$requests=odbc_exec($connect,$sql);
$requestid=odbc_result($requests,1);
include("help_desk/hdview.inc");
} else {
$date=check_errors($date);
$desc=check_errors($desc);
$sql="insert into tbl_hd_transaction (transoperator, transnatureofcall,transissuedesc, transdtrecd, transurgency, assignedto, sessionid, status, client_id) values ($uid,$category,'$desc','$date',2, $uid, '$sid', 2, $client);";
odbc_exec($connect,$sql);
$header="";
include("help_desk/blank.inc");
}
}
elseif($_GET['nav']==4 or $_POST['nav']==4)//log actions for the request
{
include("help_desk/actions.inc");
}
elseif($_GET['nav']==5 or $_POST['nav']==5)//submitted new action on existing request
{
//$user
$adate=check_errors($adate);
$adesc=check_errors($adesc);
$adesc=shorten($adesc,500);
if($time=="") {
$time=0;
}
$sql="insert into tbl_action_transaction (actionuserfkey, actiondt, actiondesc, hd_transaction_Fkey, time_hours, is_billable, is_onsite) values ($user, '$adate', '$adesc', $requestid, $time, $is_billable, $is_onsite);";
odbc_exec($connect,$sql);
$complete="Add Actions to this Request
Log Another Help Desk Request";
$links="Update Request $requestid's Status | Add Actions to Request $requestid";
include("help_desk/hdviewonly.inc");
}
elseif($_GET['nav']==6 or $_POST['nav']==6)//list of requests
{
$user=$uid;
$sql="select * from tbl_hd_transaction where (assignedto=$uid and status<>2 and status<>3) ORDER BY transdtrecd;";
$requests=odbc_exec($connect,$sql);
include("help_desk/hdlist.inc");
}
elseif($_GET['nav']==7 or $_POST['nav']==7) //chose a specific request to look at
{ //now need to determine if you are going to update the status
//or add actions to the request.
$links="Update Request $requestid's Status | Add Actions to Request $requestid";
include("help_desk/hdviewonly.inc");
//include("hd/choose.inc");
}
elseif($_GET['nav']==8 or $_POST['nav']==8) //see status of request to change it
{
$links="Add Actions to Request $r | Log Another Request For This Client";
include("help_desk/hdview.inc");
}
elseif($_GET['nav']==9 or $_POST['nav']==9)//update status of hd request
{
$sql="update tbl_hd_transaction set status=$complete, assignedto=$assign where transkey=$requestid;";
odbc_exec($connect,$sql);
if($complete==2 or $complete==3) {
$sql="update tbl_hd_transaction set compl_dt=getdate() where transkey=$requestid;";
odbc_exec($connect,$sql);
}
$sql="select sum(time_hours) as total_hours from tbl_action_transaction where is_billable=1 and hd_transaction_fkey=$requestid";
$hourstobill=odbc_exec($connect,$sql);
$hours=odbc_result($hourstobill,1);
if($hours>0) {
/*Sample Code using the built-in mail function
$from = get_user_email($uid);
$recip = get_user_email($assign);
$subj="New Help Desk Request Assigned to You";
$today = date("F j, Y, g:i a");
$body="
A new help desk request was assigned to you on $today. ";
$body.="You can find the record just added with the key value of: $requestid.";
$body.="
Please login to the help desk log on the intranet here. ";
$body.="Navigate to Help Desk, then Review Help Desk Log to find this ticket. You will be asked to login with your Windows network credentials to access this information.";
$body.="
Please contact your system administrator if you do not have a password or your password does not allow you to see the log.";
$body.="
Sincerely,
Intranet Administrator";
$body.="";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.="From: $from";
$additional_parameters="-f ".$from;
mail("$recip","$subj","$body","$headers","$additional_parameters");
*/
$from="admin@2wgmultimedia.com";
$recip="billing@2wg.net";
$subj="New Billable Call Closed";
$today = date("F j, Y, g:i a");
$body="
| A new billable call was closed on $today. You can find the record just added with the key value $requestid; total hours to be billed totals $hours. |
| Sincerely, Net Admin - 2wg.net |