<!--<?php print <<<EOT
-->
<div class="bdbA">
	<div id="breadcrumbs">
		<a class="crumbs-item gray3" href="$db_bfn" title="$db_bbsname"><strong>$db_bbsname</strong></a><span class="crumbs-item current"><i> </i><strong><a href="$basename">勛章中心</a></strong></span>
	</div>
</div>
<div class="t3" style="margin-top:8px">
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" valign="top">
<div class="t">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td class="h">
			操作
		</td>
	</tr>
	<tr class="tr3">
		<td>
			<a href="$basename">勛章介紹</a>
		</td>
	</tr>
<!--
EOT;
if($md_ifapply && strpos($md_appgroups,",$groupid,")!==false){print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=apply">申請勛章</a>
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=list">獲得勛章名單</a>
		</td>
	</tr>
	<tr class="tr3">
		<td>
			<a href="$basename&action=log">勛章頒發情況</a>
		</td>
	</tr>

<!--
EOT;
if(strpos($md_groups,",$groupid,")!==false){print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=award">頒發勛章</a>
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
<!--
EOT;
if($md_ifapply && strpos($md_groups,",$groupid,")!==false){print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=approve">審核申請</a>
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td class="h">您獲得的勛章</td>
	</tr>
	<tr class="tr1">
		<th style="text-align:center">
			$userface<br /><br />
<!--
EOT;
if($userdb['medals']){
foreach($userdb['medals'] as $key=>$value){
if($_MEDALDB[$value][picurl]){print <<<EOT
-->
			<img src="$hkimg/{$_MEDALDB[$value][picurl]}" title="{$_MEDALDB[$value][name]}"/> 
<!--
EOT;
}}}else{print <<<EOT
-->
			<br/>您還沒有勛章
<!--
EOT;
}print <<<EOT
-->
		</th>
	</tr>
</table>
</div>
</td>
<td valign="top">

<!--
EOT;
if(!$action){print <<<EOT
-->
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">勛章介紹</td></tr>
	<tr class="tr2 tac">
		<td width="5%">ID</td>
		<td width="15%">勛章名稱</td>
		<td width="*">勛章說明</td>
		<td width="15%">勛章圖片</td>
	</tr>
<!--
EOT;
$num=0;
foreach($_MEDALDB as $key => $value){
if($md_ifapply && strpos($md_appgroups,",$groupid,")!==false && !in_array($key,$userdb['medals'])){
	$value[name] = "<a href=\"$basename&action=apply&id=$value[id]\" title=\"申請此勛章\">".$value[name]."</a>";
}
$num++;
print <<<EOT
-->
	<tr class="tr3 tr tac">
		<td>$num</td>
		<td>$value[name]</td>
		<th>$value[intro]</th>
		<td><img src="$hkimg/$value[picurl]" /></td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table></div>
<!--
EOT;
}elseif($action=='list'){print <<<EOT
-->
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">獲得勛章名單</td></tr>
	<tr class="tr2 tac">
		<td width="5%">ID</td>
		<td>用戶名</td>
		<td>所獲勛章</td>
	</tr>
<!--
EOT;
$num=($page-1)*$db_perpage;
foreach($listdb as $key=>$value){
$num++;
print <<<EOT
-->
	<tr class="tr3 tr tac">
		<td>$num</td>
		<td><a href="u.php?action=show&uid=$value[uid]" target="_blank">$value[username]</a></td>
		<td>$value[medals]</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table></div>
<div class="t" style="width:98%;margin-right:0;border:none;">
	$pages
</div>
<!--
EOT;
}elseif($action=='award'){print <<<EOT
-->
<form method="post" action="$basename&action=award&">
<input type="hidden" name="step" value="2" />
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">頒發勛章</td></tr>
	<tr class="tr3 tr">
		<td style="text-align:right" width="30%">用戶名: </td>
		<th><input class="input" type="text" name="pwuser" size="40" value="$pwuser"/>(多個用戶可用","號隔開)</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">選擇操作: </td>
		<th>
			<input type="radio" name="type" value="1" $type_1 /> 頒發
			<input type="radio" name="type" value="2" $type_2/> 收回
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">選擇勛章: </td>
		<th>
			<select name="medal">
				<option>選擇勛章</option>
<!--
EOT;
foreach($_MEDALDB as $key=>$value){
if($medal){
	$selected = $medal==$key ? "selected=\"selected\"":"";
}else{
	$selected = "";
}
print <<<EOT
-->
				<option value="$key" $selected>$value[name]</option>
<!--
EOT;
}print <<<EOT
-->
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">有效期:</td>
		<th>
			<select name="timelimit">
				<option value="0">永久</option>
				<option value="1">一個月</option>
				<option value="3">三個月</option>
				<option value="6">六個月</option>
				<option value="12">一年</option>
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">操作理由: </td>
		<th><input class="input" type="text" name="reason" size="50" /></th>
	</tr>
</table></div>
<div style="text-align:center;margin-bottom:25px"><input class="btn" type="submit" value="提 交" /></div>
</form>
<!--
EOT;
}elseif($action=='log'){print <<<EOT
-->
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="9">勛章頒發情況</td></tr>
	<tr class="tr2 tac">
		<td width="5%">ID</td>
		<td width="12%">用戶名</td>
		<td width="12%">管理員</td>
		<td width="10%">勛章名稱</td>
		<td width="7%">操作</td>
		<td><div style="table-layout:fixed;word-wrap:break-word;">操作原因</div></td>
		<td width="15%">操作時間</td>
		<td width="7%">有效期</td>
<!--
EOT;
if($groupid==3){print <<<EOT
-->
		<td width="6%">刪除</td>
<!--
EOT;
}print <<<EOT
-->
	</tr>
<!--
EOT;
$num=($page-1)*$db_perpage;
foreach($logdb as $key=>$value){
$num++;
print <<<EOT
-->
	<tr class="tr3 tac">
		<td>$num</td>
		<td>$value[awardee]</td>
		<td>$value[awarder]</td>
		<td>{$_MEDALDB[$value[level]][name]}<br /></td>
<!--
EOT;
if($value[action]==1){print <<<EOT
-->
		<td>頒發</td>
<!--
EOT;
}elseif($value[action]==2){print <<<EOT
-->
		<td>收回</td>
<!--
EOT;
}print <<<EOT
-->
		<td>$value[why]<br /></td>
		<td>$value[awardtime]</td>
<!--
EOT;
if($value[action]==1){
if($value[timelimit]<1){print <<<EOT
-->
		<td>永久</td>
<!--
EOT;
}else{print <<<EOT
-->
		<td>$value[timelimit] 個月</td>
<!--
EOT;
}}else{ print <<<EOT
-->
		<td>--</td>
<!--
EOT;
}if($groupid==3){
if($value['action']==1 && $value['state']==0 && $value['timelimit']>0){print <<<EOT
-->
		<td>--</td>
<!--
EOT;
}else{ print <<<EOT
-->
		<td><a href="$basename&action=log&job=del&id=$value[id]">刪除</a></td>
<!--
EOT;
}}print <<<EOT
-->
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table></div>
<div class="t" style="width:98%;margin-right:0;border:none;">
	$pages
</div>
<!--
EOT;
}elseif($action=='apply'){
print <<<EOT
-->
<form method="post" action="$basename&action=apply&">
<input type="hidden" name="step" value="2" />
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">申請勛章</td></tr>
	<tr class="tr3 tr">
		<td style="text-align:right" width="30%">選擇勛章: </td>
		<th>
			<select name="medal">
				<option>選擇勛章</option>
<!--
EOT;
foreach($_MEDALDB as $key=>$value){
$selected = $key==$id ? "selected='selected'":'';
print <<<EOT
-->
				<option value="$key" $selected>$value[name]</option>
<!--
EOT;
}print <<<EOT
-->
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">有效期:</td>
		<th>
			<select name="timelimit">
				<option value="0">永久</option>
				<option value="1">一個月</option>
				<option value="3">三個月</option>
				<option value="6">六個月</option>
				<option value="12">一年</option>
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">申請理由: </td>
		<th><input class="input" type="text" name="reason" size="50" /></th>
	</tr>
</table></div>
<div style="text-align:center;margin-bottom:25px"><input class="btn" type="submit" value="提 交" /></div>
</form>
<!--
EOT;
}elseif($action=='approve'){
print <<<EOT
-->
<form action="$basename&action=approve&" method="post">
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="8">勛章申請列表</td></tr>
	<tr class="tr2 tac">
		<td width="5%">選擇</td>
		<td width="5%">ID</td>
		<td width="12%">用戶名</td>
		<td width="10%">勛章名稱</td>
		<td><div style="table-layout:fixed;word-wrap:break-word;">操作原因</div></td>
		<td width="15%">申請時間</td>
		<td width="7%">有效期</td>
		<td width="10%">操作</td>
	</tr>
<!--
EOT;
$num=($page-1)*$db_perpage;
foreach($appdb as $key=>$value){
$value[awardee1]=urlencode($value[awardee]);
$num++;
print <<<EOT
-->
	<tr class="tr3 tac">
		<td><input name="id[]" value="$value[id]" type="checkbox"></td>
		<td>$num</td>
		<td><a href="u.php?action=show&username=$value[awardee]" target="_blank" >$value[awardee]</a></td>
		<td>{$_MEDALDB[$value[level]][name]}<br /></td>
		<td>$value[why]<br /></td>
		<td>$value[awardtime]</td>
<!--
EOT;
if($value[timelimit]<1){print <<<EOT
-->
		<td>永久</td>
<!--
EOT;
}else{print <<<EOT
-->
		<td>$value[timelimit] 個月</td>
<!--
EOT;
}print <<<EOT
-->
		<td><a href="$basename&action=approve&job=del&id=$value[id]">刪除</a>|<a href="$basename&action=approve&job=pass&id=$value[id]">通過</a></td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<center>
	<input class="btn" name="chkall" value="全選" onclick="CheckAll(this.form)" type="button">
	<input class="btn" value="提交" type="submit">
	<input name="job" value="pass" type="radio">通過
	<input name="job" value="del" checked="checked" type="radio">刪除
</center>
</form>
<div class="t" style="width:98%;margin-right:0;border:none;">
	$pages
</div>
<script language="JavaScript">
ifcheck = true;
function CheckAll(form){
	for(var i=0;i<form.elements.length-2;i++){
		var e = form.elements[i];
		if(e.type=='checkbox' && e.name!='ifsave') e.checked = ifcheck;
	}
	ifcheck = ifcheck == true ? false : true;
}

</script>
<!--
EOT;
}print <<<EOT
-->
</td>
</tr>
</table></div>
<!--
EOT;
?>-->