<?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");

$action = $_GET["action"];

$strNowDate = Date('Y-m-d');
$strNextDate = Date('Y-m-d', strtotime("+1 days"));
$NewsDate = $strNowDate;
$StartDate = $strNowDate;
$EndDate = $strNextDate;

$Rights = "";
$FieldRights = "";
$ViewData = "";
$id = "";
$GroupName = "";
$UpdateViewData = "";
$RightLevel = "";

$db = new DBOperation();

if($action == "Update")
{
  $id = $_GET["id"];
  $db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
  $db->query("SELECT * FROM GroupRights where GId = '".$db->mysql_real_escape_string($id)."'");
  $row = $db->fetch_row();
   
  $GroupName =  $row[1];
  $Rights = $row[2];
  $FieldRights = $row[3];
  $ViewData = $row[4];
  $UpdateViewData = $row[9];
  $ViewFileData = $row[10];
  $RightLevel = $row[11];
  $Uplevel = $row[12];
  $db->close_db();
}

$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$querySql = "select * from GroupRights where GRightLevel = '2' order by GCreateTime";
$db->query($querySql);

?>
<SCRIPT language="JavaScript">
function validateForm(objThisUi) 
{
	if(objThisUi.GroupName.value.length == 0)
	{
		alert("請輸入群組名稱!!");
		objThisUi.GroupName.focus();		
		return false;                              
	}
	return true;  
}
</SCRIPT>
<body>
<form name="GroupRightsForm" method="post" action="GroupRightsUpdateDeal.php" id="GroupRightsForm"
 onSubmit="return validateForm(this);">
<input type="hidden" name="action" id="action" value="<?php echo $action ?>"/>
<input type="hidden" name="id" id="id" value="<?php echo $id ?>"/>
<table border="0" cellspacing="0" cellspadding="0" width="90%">
<!--
<tr>
<td align="center" colspan="2">
<span class="title"><b>群組權限管理</b></span>
</td>
</tr>
-->
<tr>
<td align="left" colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td align="left" colspan="2">
<span class="t14b"><b>新增/修改群組權限</b></span>
</td>
</tr>
<tr>
<td align="left" colspan="2">

<table border="3" cellspacing="2" cellspadding="2" width="100%">
<tr>
<td align="left" width="25%">
<span class="t12">群組名稱</span>
</td>
<td align="left" width="75%">
<input type="text" value="<?php echo $GroupName ?>" name="GroupName" id="GroupName" size="70" maxlength="100" style="font-size: 12.0pt;font-family: 微軟正黑體;"/>
</td>
</tr>
<!--
<tr>
<td align="left">
<span class="t12">群組層級</span>
</td>
<td align="left">
<input type="radio" value="1" <?php if($RightLevel == "1") echo "checked"; ?> name="RightLevel">
<span class="t12">最高管理者</span>
<br>
<input type="radio" value="2" <?php if($RightLevel == "2") echo "checked"; ?> name="RightLevel">
<span class="t12">群主</span>
<br>
<input type="radio" value="3" <?php if($RightLevel == "3") echo "checked"; elseif($RightLevel == null) echo "checked"; ?> name="RightLevel">
<span class="t12">人員</span>
</td>
</tr>
<tr>
<td align="left">
<span class="t12">人員層級的群主層級<br>
<font color="red"><b>(只有群組層級為人員，此欄位才有效。)</b></font></span>
</td>
<td align="left">
<?php
$i = 0;
while($myrow = $db->fetch_array())
{
	$i = $i + 1;
?>
<input type="radio" value="<?php echo $myrow['GId'];?>" name="Uplevel" <?php if($myrow['GId'] == $Uplevel) echo "checked"; ?>>
<span class="t12"><?php echo $myrow['GName'];?></span>
<?php
	if($i%6 == 0)
	{
		echo "<br>";
	} 
?>
<?php
}
$db->close_db();
?>
</td>
</tr>
-->
<tr>
<td align="left" width="25%">
<span class="t12">功能權限</span>
</td>
<td align="left" width="75%">
<span class="t12">
<input type="checkbox" name="chkA1" id="chkA1" value="A1" <?php if(str_indexof($Rights,"A1") >= 0) echo "checked"; ?>>群組權限控管管理
<br>
<input type="checkbox" name="chkA2" id="chkA2" value="A2" <?php if(str_indexof($Rights,"A2") >= 0) echo "checked"; ?>>使用者管理
<br>
<!--
<input type="checkbox" name="chkA3" id="chkA3" value="A3" <?php if(str_indexof($Rights,"A3") >= 0) echo "checked"; ?>>操作紀錄查詢
<br>
<input type="checkbox" name="chkA4" id="chkA4" value="A4" <?php if(str_indexof($Rights,"A4") >= 0) echo "checked"; ?>>系統參數管理
<br>
-->
<input type="checkbox" name="chkB1I" id="chkB1I" value="B1I" <?php if(str_indexof($Rights,"B1I") >= 0) echo "checked"; ?>>客戶資料新增
<br>
<input type="checkbox" name="chkB1U" id="chkB1U" value="B1U" <?php if(str_indexof($Rights,"B1U") >= 0) echo "checked"; ?>>客戶資料更新
<br>
<input type="checkbox" name="chkB1D" id="chkB1D" value="B1D" <?php if(str_indexof($Rights,"B1D") >= 0) echo "checked"; ?>>客戶資料刪除
<br>
<input type="checkbox" name="chkB2" id="chkB2" value="B2" <?php if(str_indexof($Rights,"B2") >= 0) echo "checked"; ?>>客戶資料查詢
<br>
<input type="checkbox" name="chkB3" id="chkB3" value="B3" <?php if(str_indexof($Rights,"B3") >= 0) echo "checked"; ?>>客戶消費次數查詢
<br>
<input type="checkbox" name="chkC1I" id="chkC1I" value="C1I" <?php if(str_indexof($Rights,"C1I") >= 0) echo "checked"; ?>>檔案資料新增
<br>
<input type="checkbox" name="chkC1U" id="chkC1U" value="C1U" <?php if(str_indexof($Rights,"C1U") >= 0) echo "checked"; ?>>檔案資料更新
<br>
<input type="checkbox" name="chkC1D" id="chkC1D" value="C1D" <?php if(str_indexof($Rights,"C1D") >= 0) echo "checked"; ?>>檔案資料刪除
<br>
<input type="checkbox" name="chkC1Q" id="chkC1Q" value="C1Q" <?php if(str_indexof($Rights,"C1Q") >= 0) echo "checked"; ?>>檔案資料下載
<br>
</span>
</td>
</tr>
<tr>
<td align="left">
<span class="t12">查詢客戶資料<br>欄位顯示</span>
</td>
<td align="left">
<span class="t12">
<!--
<input type="checkbox" name="chkCNickname" id="chkCNickname" value="CNickname" <?php if(str_indexof($FieldRights,"CNickname") >= 0) echo "checked"; ?>>暱稱
<br>
<input type="checkbox" name="chkCArea" id="chkCArea" value="CArea" <?php if(str_indexof($FieldRights,"CArea") >= 0) echo "checked"; ?>>地區
<br>
-->
<input type="checkbox" name="chkCSource" id="chkCSource" value="CSource" <?php if(str_indexof($FieldRights,"CSource") >= 0) echo "checked"; ?>>客戶來源
<br>
<input type="checkbox" name="chkCClass" id="chkCClass" value="CClass" <?php if(str_indexof($FieldRights,"CClass") >= 0) echo "checked"; ?>>類別
<br>
<input type="checkbox" name="chkCGreenTel" id="chkCGreenTel" value="CGreenTel" <?php if(str_indexof($FieldRights,"CGreenTel") >= 0) echo "checked"; ?>><font color="green"><b>電話(綠)</b></font>
<br>
<input type="checkbox" name="chkCBlackTel" id="chkCBlackTel" value="CBlackTel" <?php if(str_indexof($FieldRights,"CBlackTel") >= 0) echo "checked"; ?>><b>電話(黑)</b>
<br>
<input type="checkbox" name="chkCRedTel" id="chkCRedTel" value="CRedTel" <?php if(str_indexof($FieldRights,"CRedTel") >= 0) echo "checked"; ?>><font color="red"><b>電話(紅)</b></font>
<br>
<input type="checkbox" name="chkCMemo" id="chkCMemo" value="CMemo" <?php if(str_indexof($FieldRights,"CMemo") >= 0) echo "checked"; ?>>喜好/其他
<br>
<input type="checkbox" name="chkCMiss" id="chkCMiss" value="CMiss" <?php if(str_indexof($FieldRights,"CMiss") >= 0) echo "checked"; ?>>消費內容
</td>
</tr>
</span>
<!--
<tr>
<td align="left">
<span class="t12">查詢客戶資料權限</span>
</td>
<td align="left">
<input type="radio" value="1" <?php if($ViewData == "1") echo "checked"; elseif($ViewData == null) echo "checked"; ?> name="ViewData">
<span class="t12">查詢所有客戶資料</span>
<br>
<input type="radio" value="2" <?php if($ViewData == "2") echo "checked"; ?> name="ViewData">
<span class="t12">查詢群組以下所有客戶資料</span>
<br>
<input type="radio" value="0" <?php if($ViewData == "0") echo "checked"; ?> name="ViewData">
<span class="t12">只能查詢自己新增的資料</span>
</td>
</tr>
<tr>
<td align="left">
<span class="t12">修改/刪除客戶資料權限</span>
</td>
<td align="left">
<input type="radio" value="1" <?php if($UpdateViewData == "1") echo "checked"; elseif($UpdateViewData == null) echo "checked"; ?> name="UpdateViewData">
<span class="t12">修改/刪除所有客戶資料</span>
<br>
<input type="radio" value="2" <?php if($UpdateViewData == "2") echo "checked"; ?> name="UpdateViewData">
<span class="t12">修改/刪除群組以下客戶資料</span>
<br>
<input type="radio" value="0" <?php if($UpdateViewData == "0") echo "checked"; ?> name="UpdateViewData">
<span class="t12">只能修改/刪除自己新增的資料</span>
</td>
</tr>
<tr>
<td align="left">
<span class="t12">修改/刪除/下載檔案資料權限</span>
</td>
<td align="left">
<input type="radio" value="1" <?php if($ViewFileData == "1") echo "checked"; elseif($ViewFileData == null) echo "checked"; ?> name="ViewFileData">
<span class="t12">修改/刪除/下載所有檔案資料</span>
<br>
<input type="radio" value="2" <?php if($ViewFileData == "2") echo "checked"; ?> name="ViewFileData">
<span class="t12">修改/刪除/下載群組以下檔案資料</span>
<br>
<input type="radio" value="0" <?php if($ViewFileData == "0") echo "checked"; ?> name="ViewFileData">
<span class="t12">只能修改/刪除/下載自己新增的檔案資料</span>
</td>
</tr>
-->
<tr>
<td  align="center" colspan="2">
<input type="submit" name="btnSub" id="btnSub" value="<?php if($action == "Insert") echo "確認新增"; else echo "確認修改" ?>" class="t12" />
</td>
</tr>
</table>

</td>
</tr>
</table>
</form>
</body>
</html>
