<?php
session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}

include("config.inc.php");
include("function.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");
if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

$query1="select grid_color1,grid_color2 from setup";
$result1=mysql_query($query1,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
	extract($rows);
}

$item   	= $_GET['item']; 		if ($item == ""){		$item 		= $_POST["item"];}
$frm	   	= $_GET['frm']; 		if ($frm == ""){		$frm 		= $_POST["frm"];}
$index		= $_GET['index']; 		if ($index == "") 		$index 		= $_POST['index'];
$PUser  	= $_POST["PUser"]; 		if ($PUser == ""){		$PUser 		= $_GET["PUser"];}
$PUserDesc  = $_POST["PUserDesc"]; 	if ($PUserDesc == ""){	$PUserDesc 	= $_GET["PUserDesc"];}


if($_GET['lcode']!=""){

	$query1=" select user_id, username, user_description from user_support ".
			" where user_id ='".$_GET['lcode']."'";
					  
	$result1=mysql_query($query1,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($result1)){
		extract($rows);

	}

	$_GET['post']="1";

} 



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>List of Problem Type</title>
<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>

<script type="text/javascript" language="javascript">

function clearform()
{
	document.form1.PUser.value='';
	document.form1.PUserDesc.value='';
	document.form1.action='List_SupportUsers.php';
	document.form1.submit();
}
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style1 {
	color: #333333;
	font-weight: bold;
}
.style2 {
	color: #999999;
	font-weight: bold;
}
.style3 {color: #999999; font-size: 13px;}
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="800" border="0" cellspacing="1" align="center">
	<col width='200'><col width='200'><col width='350'><col width='50px'>
    <tr>
      <th colspan="5" bgcolor="#DDDDDD"><span class="style1"> List of Support Users </span></th>
    </tr>
    <tr>
      <td bgcolor="#DDDDDD"> <span style="font-size: 11px; color: #999999; font-weight: bold;">Search for Users</span></td>
      <td bgcolor="#DDDDDD"><input type="text" name="PUser" value="<?php echo $PUser; ?>"  />
        <input name="code1" type="hidden" id="code1"  value="<?php echo $user_id; ?>">
        <input name="code2" type="hidden" id="code2"  value="<?php echo $username; ?>">
      <td bgcolor="#DDDDDD">
		<input type="text" name="PUserDesc" value="<?php echo $PUserDesc; ?>"  />
         <input type="submit" name="Submit" value="Find" style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
		<input type="button" name="cancelbtn" value="Cancel" onclick='clearform();'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/></td>
      <td bgcolor="#DDDDDD">
		<input name="item" type="hidden" id="item" value="<?php echo $item; ?>" />
		<input name="frm" type="hidden" id="frm" value="<?php echo $frm; ?>" />
		<input name="index" type="hidden" value="<?php echo $index; ?>">
	  </td>
    </tr>
<?php if($_GET['post']=="1") { ?>
<script type="text/javascript" language="javascript">
var FormOption = document.form1.frm.value;
var FormItem   = document.form1.item.value;
var vIndex	   = document.form1.index.value; 

if (FormOption == 1) {
	opener.document.getElementById('tsSupTeamId').value=document.form1.code1.value;
	opener.document.getElementById('tsSupTeam').value=document.form1.code2.value;
}	
else if (FormOption == 2) {
	opener.document.getElementById('tvSupTeamId').value=document.form1.code1.value;
	opener.document.getElementById('tvSupTeam').value=document.form1.code2.value;
}
self.close();

</script>
<?php } ?>
    <tr bgcolor="#E5E5E5">
      <td ><span class="style2">UserName </span></td>
      <td colspan='2'><span class="style2">Description</span></td>
      <td ><span class="style3"></span></td>
    </tr>
<?php
	$query = " select user_id, username, user_description from user_support where 1=1 ";
	if ($PUser != '') 
		$query .= " and username like '$PUser%' ";
	if ($PUserDesc != '') 
		$query .= " and user_description like '%$PUserDesc%' ";
	$query .= "order by username";
	
	$result = mysql_query($query, $connection);

while($rows=mysql_fetch_array($result)){
	extract($rows);

	$ct+=1;

	if($ct%2==0)
	{
		$Color="style='color:#0000FF;background-color:".$grid_color1."'";
	} else {
		$Color="style='color:#0000FF;background-color:".$grid_color2."'";	
	}

?>
    <tr <?php echo $Color; ?>>
      <td align="left"><span class="style3"><a href="List_SupportUsers.php?lcode=<?php echo $user_id; ?>&frm=<?php echo $frm; ?>&item=<?php echo $item; ?>&index=<?php echo $index; ?>"><?php echo $username; ?></a></span></td>
      <td colspan="2"><span class="style3"><a href="List_SupportUsers.php?lcode=<?php echo $user_id; ?>&frm=<?php echo $frm; ?>&item=<?php echo $item; ?>&index=<?php echo $index; ?>"><?php echo $user_description; ?></a></span></td>
      <td>&nbsp;</td>
    </tr>
<?php
	}
?>
  </table>
</form>
</body>
</html>
