Location: PHPKode > projects > Tech Tickets > technician/tt_view_tech.php
<?php include("../include/secure.php"); ?>
<?php require_once('../include/connections.php'); ?>
<?php
mysql_select_db($database, $conn);
if($_POST){
	$farchived = $_POST["f-archived"];
	$fid = $_POST["f-id"];
	$fstatus = $_POST["f-status"];
	$furgency = $_POST["f-urgency"];
	$fsubject = $_POST["f-subject"];
	$ffdate = $_POST["f-fdate"];
	$ftdate = $_POST["f-tdate"];
	
}else{
	$farchived = 0;
	$fid = "";
	$fstatus = "";
	$furgency = "";
	$fsubject = "";
	$ffdate = "";
	$ftdate = "";
}

if($farchived == ""){$farchived = 0;}

if($_GET){
	$user_id = $_GET['user_id'];
}else{
	$user_id = $_SESSION['pid'];
}

$sql = "SELECT tt_id, parent_tt_id, cl_id, p_id, date_format(datetimestamp,'%m-%d-%Y %r') as datetimestamp, status, subject, urgency ";
$sql .= "FROM tt_tickets ";
$sql .= "WHERE parent_tt_id = 0 AND tech_id = ". $user_id ." ";
if($farchived != 1){$sql .= " AND archived = $farchived ";}
if($fid != "")	   {$sql .= " AND tt_id LIKE '$fid' ";}
if($fstatus != "") {$sql .= " AND status LIKE '$fstatus' ";}
if($furgency != ""){$sql .= " AND urgency LIKE '$furgency' ";}
if($fsubject != ""){$sql .= " AND subject LIKE '%$fsubject%' ";}
if($ffdate != "")  {$sql .= " AND datetimestamp BETWEEN '".date("Y-m-d",strtotime($ffdate))."' AND '".date("Y-m-d",strtotime($ftdate))."' ";}
$sql .= "ORDER BY tt_id DESC";
//echo $sql;

$open_tickets = mysql_query($sql, $conn) or die(mysql_error());
$row_open_tickets = mysql_fetch_assoc($open_tickets);
$totalRows_open_tickets = mysql_num_rows($open_tickets);

$query_client_name = "SELECT UserID as id, FirstName, LastName FROM tt_users WHERE UserID = " . $user_id;
$client_name = mysql_query($query_client_name, $conn) or die(mysql_error());
$row_client_name = mysql_fetch_assoc($client_name);
$totalRows_client_name = mysql_num_rows($client_name);
$company_name = $row_client_name['FirstName']." ".$row_client_name['LastName'];
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>Open 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"); ?>
<?php include("r_header.php"); ?>
	  
      <!--<h1 align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Tickets</font></h1>-->
      <h2 align="center"><?php echo $company_name; ?>&nbsp;</h3>
	
	<table border="0" cellpadding="2" cellspacing="2" align="center" width="100%">
	<form id="filter" method="post">
	<tr>
		<td colspan="2" align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Show Archived:<input type="checkbox" name="f-archived" value="1" <?php if($farchived == 1){ echo "checked";} ?>></font></td>
		<td colspan="3" align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Date Filter: <span id="datespan"><?php if($ffdate!=""){echo $ffdate." > ".$ftdate; } else{echo "none";} ?></span></font></td>
	</tr>
	<tr bgcolor="#666666"> 
		<td> <div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">TT ID</font></div></td>
        <td> <div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Status</font></div></td>
        <td> <div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Subject</font></div></td>
        <td> <div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Urgency</font></div></td>
		<td> <div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Submitted</font></div></td>
	</tr>
	<tr bgcolor="#666666"> 
		<td><input type="text" name="f-id" style="width:100%" value="<?php echo $fid; ?>" ></td>
		<td>
			<select name="f-status" style="width:100%">
			<option value=""></option>
			<option Value="P" <?php if($fstatus == "P"){echo "selected";} ?>>Pending</option>
			<option Value="O" <?php if($fstatus == "O"){echo "selected";} ?>>Open</option>
			<option Value="C" <?php if($fstatus == "C"){echo "selected";} ?>>Closed</option>
			<option Value="E" <?php if($fstatus == "E"){echo "selected";} ?>>Escalated</option>
			</select>
		</td>
		<td><input type="text" name="f-subject" style="width:100%" value="<?php echo $fsubject; ?>"></td>
		<td>
			<select name="f-urgency" style="width:100%">
			<option value=""></option>
			<option Value="E" <?php if($furgency == "E"){echo "selected";} ?>>Emergency </option>
			<option Value="A" <?php if($furgency == "A"){echo "selected";} ?>>ASAP</option>
			<option Value="N" <?php if($furgency == "N"){echo "selected";} ?>>Next Visit</option>
			</select>
		</td>
		<td align="right">
			<input type="hidden" name="f-fdate" id="f-fdate" value="<?php echo $ffdate; ?>">
			<input type="hidden" name="f-tdate" id="f-tdate" value="<?php echo $ftdate; ?>">
			<input type="submit" value="Filter">
			<input type="image" src="../images/ibtn.gbldatefilter.gif" width="18" height="18" value="date" onClick="window.open('dateselect.php?ffdate=<?php echo $ffdate; ?>&ftdate=<?php echo $ftdate; ?>','ds','width=540,height=200,alwaysRaised=yes,resizable=yes,scrollbars=yes,location=no,status=1');">
			<!--<input type="button" name="f-date" style="width:30%" value="date" onClick="window.open('dateselect.php','ds','width=530,height=200,alwaysRaised=yes,resizable=yes,scrollbars=yes,location=no,status=1');">-->
		</td>
	</tr>
	</form>
    <?php do { ?>
	<tr bgcolor="#CCCCCC"> 
        <?php $ttid = $row_open_tickets['tt_id'];?>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="tt_view_one.php?tt_id=<?php echo $ttid;?>"><?php echo $ttid; ?></a></font></td>
		<td>
		  	<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			<?php 
			if($row_open_tickets['status'] == "O"){ 
				echo "Open";
			} elseif($row_open_tickets['status'] == "C"){ 
				echo "Closed";
			} elseif($row_open_tickets['status'] == "E"){
				echo "Escalated";
			} 
			?>
			</font>
		</td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_open_tickets['subject']; ?></font></td>
        <td>
		  	<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			<?php 
		  	if ($row_open_tickets['urgency'] == "N"){
				echo "Next Visit";
			}elseif ($row_open_tickets['urgency'] == "A"){
				echo "ASAP";
			}elseif ($row_open_tickets['urgency'] == "E"){
				echo "Emergency";
			}else{
				echo "";
			}
		    ?>
		</td>
		<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_open_tickets['datetimestamp']; ?></font></td>
	</tr>
	<?php } while ($row_open_tickets = mysql_fetch_assoc($open_tickets)); ?>
	</table>
	<form action="LaunchDataExport.php" name="exported" method="post">
	<input type="hidden" name="sql" value="<?php echo urlencode($sql); ?>">
	<input type="hidden" name="e-archived" value="<?php echo $farchived; ?>" >
	<input type="hidden" name="e-id" value="<?php echo $fid; ?>" >
	<input type="hidden" name="e-user" value="<?php echo $fuser; ?>" >
	<input type="hidden" name="e-status" value="<?php echo $fstatus; ?>" >	
	<input type="hidden" name="e-subject" value="<?php echo $fsubject; ?>">
	<input type="hidden" name="e-urgency" value="<?php echo $furgency; ?>">
	<input type="hidden" name="e-fdate" value="<?php echo $ffdate; ?>">
	<input type="hidden" name="e-tdate" value="<?php echo $ftdate; ?>">
	<input type="hidden" name="e-tech" value="<?php echo $user_id; ?>">
	<input type="hidden" name="e-archived" value="<?php echo $farchived; ?>">
	<input type="submit" value="Export to Excel">
	</form>
     <p>&nbsp;</p>

<?php include("footer.php"); ?>
</body>
</html>
<?php
mysql_free_result($open_tickets);

mysql_free_result($client_name);
?>


Return current item: Tech Tickets