<?php
include("CheckSession.php");
?>
<!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=utf-8" />
<meta name="description" content="馬戲團" />
<title>馬戲團</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<?php
require_once("class/DBConfig.php");
require_once("class/DBOperation.php");

$db = new DBOperation();
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$ARights = "";
$querySql = "";
if($_SESSION['rightLevel'] == "0")
{
	$querySql = "select * from AdminUser,GroupRights where AGroupId = GId and AFlag = '1' order by ACreateTime,GRightLevel";
}
elseif($_SESSION['rightLevel'] == "1")
{
	$querySql = "select AId,AName,AAccount,AFlag,GName from AdminUser,GroupRights where AFlag = '1' and AGroupId = GId And AGroupId = ".$_SESSION['groupId']." order by AId";
}
elseif($_SESSION['rightLevel'] == "2")
{
	$querySql = "select ARights from AdminUser where AId = ".$_SESSION['userId']." and AFlag = '1'";
	$db->query($querySql);
	$myrow = $db->fetch_array();
	$ARights = $myrow['ARights'];
	$querySql = "";
}
if($querySql != "")
{
	$db->query($querySql);
}

$AddTel = $_GET["AddTel"];

?>
<body>
<form name="form1" method="post" action="CustomerQueryInput1.php">
<table border="0" cellspacing="1" cellspadding="1" width="95%">
<input type="hidden" id="AddTel" name="AddTel" value="<?php echo $AddTel; ?>">
<tr>
<td align="center" colspan="2">
<span class="title"><b>新增客戶資料</b></span>
</td>
</tr>
<tr>
<td align="center" colspan="2" width="70%">
&nbsp;
</td>
</tr>
<tr>
<td align="center" colspan="2" width="70%">
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td align="center" width="20%">
<span class="t12">誰的客戶</span>
</td>
<td align="left">
<?php
if($_SESSION['rightLevel'] != "2")
{
	$i = 0;
	while($myrow = $db->fetch_array())
	{
		$i = $i + 1;
	?>
	<input type="radio" value="<?php echo $myrow['AId'];?>" <?php if($i == 1) echo "checked"; ?> name="AId">
	<span class="t12"><?php echo $myrow['AName'];?></span>
	<?php
		if($i%6 == 0)
		{
			echo "<br>";
		} 
	?>
	<?php
	}
	$db->close_db();
}
else
{
?>
<input type="hidden" value="<?php echo $_SESSION['userId'];?>" name="AId" id="AId">
<span class="t12"><?php echo $_SESSION['username1'];?></span>
<?php
}
?>
</td>
</tr>
<tr>
<td align="center" width="20%">
<span class="t12">電話</span>
</td>
<td align="left">
<input type="text" value="<?php echo $AddTel;?>" name="QueryTel" id="QueryTel" size="70" maxlength="255" style="font-size: 12.0pt;font-family: 微軟正黑體;"/>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" name="btnSub" id="btnSub" value="新增客戶資料" class="t12" style="WIDTH:550px;Height:40px;"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
