<!--<?php
include_once PrintEot('profile_header');
print <<<EOT
-->
<div id="user-main">
	<div class="u-m-bg"></div>
	<div class="u-m-bg-c cc">
		<div class="p10">
			<div class="u-nav-2 cc">
				<ul id="infolist">
					<li id="pay_begin"><a href="userpay.php" hidefocus="true">我的賬戶</a></li>
					<li id="pay_buy"><a href="userpay.php?action=buy" hidefocus="true">積分充值</a></li>
					<li id="pay_virement"><a href="userpay.php?action=virement" hidefocus="true">轉 賬</a></li>
					<li id="pay_list"><a href="userpay.php?action=list" hidefocus="true">訂單記錄</a></li>
					<li id="pay_log"><a href="userpay.php?action=log" hidefocus="true">積分日志</a></li>
					<li id="pay_change"><a href="userpay.php?action=change" hidefocus="true">積分轉換</a></li>
				</ul>
 			</div>
<script>
var action = "$action";
if (action == 'pay') {
	action = 'buy';
}
setCurrent('pay_'+action,'pay_begin','current');
</script>
			<div class="u-cont-bg-c">
			<table width="100%" height="450">
				<tr><td class="vt">		
<!--
EOT;
if (!$action) {print<<<EOT
-->
					<div class="p30" style="padding-top:15px;">
<!--
EOT;
if ($paycredit) {print <<<EOT
-->
						<dl class="user-account cc">
							<dt>$pay_link</dt>
							<dd>
							<p><span class="f14 org">{$credit->cType[$paycredit]}</span>&nbsp;&nbsp;<span class="f24 b org" style="line-height:1.1;font-family:Georgia;">$creditdb[$paycredit]</span></p>
							<p class="gray f12 lh24 mt5">當前匯率:{$db_creditpay[$paycredit][rmbrate]} {$credit->cType[$paycredit]} = ¥1 </p>
							</dd>
						</dl>
<!--
EOT;
}print <<<EOT
-->
						<ul class="user-integral cc" style="padding-bottom:35px;">
<!--
EOT;
foreach ($credit->cType as $key => $value) {
if ($key != $paycredit) {
!isset($creditdb[$key]) && $creditdb[$key] = 0;
print <<<EOT
-->
							<li>{$value}︰$creditdb[$key]</li>
<!--
EOT;
}}print <<<EOT
-->
						</ul>
<!--
EOT;
if ($orderdb) {print <<<EOT
-->
						<div class="u-box-a">
							<span class="f14 b lh24">近期訂單狀態</span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="userpay.php?action=list" class="green">進入訂單記錄 &nbsp;&gt;&gt;</a>
							<table width="530" class="mt5">
								<tr class="tr-bg-a">
									<td>訂單</td><td width="120">狀態</td><td width="125">操作日期</td>
								</tr>
<!--
EOT;
foreach ($orderdb as $key => $value) {print <<<EOT
-->
								<tr>
									<td>$value[order_no]</td>
									<td>
<!--
EOT;
if ($value['state'] == 2) {print <<<EOT
-->
										已完成訂單
<!--
EOT;
} else {print <<<EOT
-->
										<span class="org">未完成訂單</span>
<!--
EOT;
}print <<<EOT
-->
									</td>
									<td>$value[date]</td>
								</tr>
<!--
EOT;
}print <<<EOT
-->
							</table>
						</div>
<!--
EOT;
}print <<<EOT
-->
					</div>
<!--
EOT;
} elseif ($action == 'buy') {print<<<EOT
-->
					<div class="p15">
						<form method="post" action="userpay.php?" target="_blank">
						<input type="hidden" name="action" value="pay" />
						<input type="hidden" name="verify" value="$verifyhash" />
						<div class="p15">
						<div class="b s5">積分充值過程:</div><ol>
	<li>填寫信息:進入積分充值頁面，填寫充值金額，並選擇支付方式，提交進入下一步</li>
	<li>生成訂單:系統自動生成一條充值訂單記錄，等待用戶付款，此時訂單狀態為“未支付訂單”</li>
	<li>用戶付款:進入付款頁面，當您付款成功後，訂單信息會變為“已完成訂單”狀態，同時系統會給您的積分帳戶充入相應的金額</li></ol>
						</div>
						<div class="bor-t-c mb10"></div>
						<div style="padding:10px 5px;">
						<table width="100%">
							<tr class="user-tr2">
								<td width="110">請選擇充值積分:</td>
								<td width="400">
									<select name="paycredit" id="paycredit" onchange="payinfo(this.value);">
<!--
EOT;
foreach ($db_creditpay as $key => $value) {
$select = $key == $paycredit ? 'selected' : '';
print <<<EOT
-->
										<option value="$key" {$select}>{$credit->cType[$key]}</option>
<!--
EOT;
}print <<<EOT
-->
									</select>&nbsp;&nbsp;<span class="org"><span id="payinfo"></span></span>
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr class="user-tr2">
								<td>請輸入充值金額:</td>
								<td>
									<input class="input" type="text" name="number" value="10" size="8" />&nbsp;元
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr class="user-tr2">
								<td>支付方式: </td>
								<td>
									<input type="radio" name="method" value="2" checked /> 支付寶
<!--
EOT;
if($ol_tenpay && $ol_tenpaycode){print <<<EOT
-->
									<input type="radio" name="method" value="4" /> 財付通
<!--
EOT;
}if($ol_paypal && $ol_paypalcode){print <<<EOT
-->
									<input type="radio" name="method" value="1" /> 貝寶
<!--
EOT;
}if($ol_99bill && $ol_99billcode){print <<<EOT
-->
									<input type="radio" name="method" value="3" /> 快錢
<!--
EOT;
}print <<<EOT
-->
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr class="user-tr2">
								<td>&nbsp;</td>
								<td>
								<input class="user-charge" style="border:none; cursor:pointer;width:120px;padding:0 10px 5px 25px;" type="submit" value="提交訂單" /></td>
								<td></td>
							</tr>
						</table>
						</div>
						</form>
					</div>
<script>
var creditinfo = $creditinfo;
function payinfo(c) {
	getObj('payinfo').innerHTML = '當前匯率:' + creditinfo[c][0] + ' ' + creditinfo[c][2] + ' = ¥1（最低充值 ' + creditinfo[c][1] + ' 元人民幣 ）';
}
payinfo(getObj('paycredit').value);
</script>
<!--
EOT;
} elseif ($action == 'list') {
${'statestyle'.$state} = 'current';
print<<<EOT
-->
					<div class="p15">
						<table width="100%" class="mt10 bor-t-c">
							<tr class="user-tr"><td><b>訂單狀態說明:</b><ol>
	<li>未完成訂單:未充值成功的訂單，用戶尚未付款成功</li>
	<li>已完成訂單:已充值成功的訂單，用戶已經完成付款，{$db_currencyname}充值成功.</li></ol></td></tr>
						</table>
						<table width="100%">
							<tr class="user-tr">
								<td colspan="6">
								<div class="u-nav-3">
									<ul class="cc">
										<li class="$statestyle"><a href="userpay.php?action=list"><span>所有訂單</span></a></li>
										<li class="$statestyle2"><a href="userpay.php?action=list&state=2"><span>已完成訂單</span></a></li>
										<li class="$statestyle1"><a href="userpay.php?action=list&state=1"><span>未完成訂單</span></a></li>
									</ul>
								</div>
								</td>
							</tr>
							<tr class="user-tr tac">
								<td>ID</td>
								<td>訂單號</td>
								<td>支付金額</td>
								<td>充值積分</td>
								<td>交易狀態</td>
								<td>交易時間</td>
							</tr>
<!--
EOT;
$id=($page-1)*$db_perpage;
foreach($orderdb as $key => $value){
if($value[state]==0){
$state='未完成訂單';
}elseif($value[state]==1){
$state='已支付訂單，等待用戶確認';
}elseif($value[state]==2){
$state='已完成訂單';
}
$id++;
print <<<EOT
-->
							<tr class="user-tr tac">
								<td>$id</td>
								<td>$value[order_no]</td>
								<td>$value[price]</td>
								<td>{$credit->cType[$value[paycredit]]}</td>
								<td>$state</td>
								<td>$value[date]</td>
							</tr>
<!--
EOT;
}print <<<EOT
-->
							<tr class="user-tr"><td colspan="5">$pages</td></tr>
						</table>
					</div>
<!--
EOT;
} elseif ($action == 'log') {print<<<EOT
-->
					<div class="p15">
						<script src="js/date.js"></script>
						<form action="userpay.php?action=log" method="post">
						<table width="100%" class="mt10 bor-t-c">
							<tr class="user-tr">
								<td>
									積分 <select name="ctype">
									<option></option>
<!--
EOT;
foreach ($credit->cType as $key => $value) {print <<<EOT
-->
									<option value="$key">$value</option>
<!--
EOT;
}print <<<EOT
-->
									</select>
								</td>
								<td>日期 <input class="input" type="text" name="stime" size="10" id="stime" onclick="ShowCalendar(this.id)" />&nbsp;-&nbsp;<input class="input" type="text" name="etime" size="10" id="etime" onclick="ShowCalendar(this.id)" />
								</td>
								<td>操作 <select name="logtype">
									<option></option>
<!--
EOT;
foreach($lang['logtype']['creditlog'] as $key => $value){
if(strpos($key,'_') === false){print <<<EOT
-->
									<option value="$key">&#62;&#62; $value</option>
<!--
EOT;
}else{print <<<EOT
-->
									<option value="$key"> &nbsp;|- $value</option>
<!--
EOT;
}}print <<<EOT
-->
									</select>
								</td>
								<td>
								<span class="button"><span><button type="submit">提 交</button></span></span>
								</td>
							</tr>
						</table>
						</form>
						<table width="100%">
							<tr class="user-tr tac">
								<td width="20">ID</td>
								<td width="10%">操作</td>
								<td width="60">積分</td>
								<td width="60">流通值</td>
								<td>描述</td>
								<td width="150">時間</td>
							</tr>
<!--
EOT;
$id=($page-1)*$db_perpage;
foreach($logdb as $key => $value){
$id++;
print <<<EOT
-->
							<tr class="user-tr tac">
								<td class="f10">$id</td>
								<td>{$lang[logtype][creditlog][$value[logtype]]}</td>
								<td>{$credit->cType[$value[ctype]]}</td>
								<td>$value[affect]</td>
								<td align="left">$value[descrip]</td>
								<td class="gray">$value[adddate]</td>
							</tr>
<!--
EOT;
}print <<<EOT
-->
							<tr  class="user-tr"><td colspan="6">$pages</td></tr>
						</table>
					</div>

<!--
EOT;
} elseif ($action == 'virement') {print<<<EOT
-->
					<div class="p15">
						<form method="post" action="userpay.php?">
						<input type="hidden" name="action" value="virement" />
						<input type="hidden" name="verify" value="$verifyhash" />
						<input type="hidden" name="step" value="2" />
						<div class="p15">
						<div class="b f14">
							我的積分
						</div>
						<ul class="user-integral cc mt10">
<!--
EOT;
foreach ($credit->cType as $key => $value) {
!isset($creditdb[$key]) && $creditdb[$key] = 0;
print <<<EOT
-->
							<li>{$value}︰$creditdb[$key]</li>
<!--
EOT;
}print <<<EOT
-->
						</ul></div>
						<div class="bor-t-c"></div>
						<div style="padding:10px 5px;">
						<table width="100%">
							<tr class="user-tr2">
								<td width="110">轉帳手續費</td>
								<td>$db_virerate%</td>
							</tr>
							<tr class="user-tr2">
								<td>轉入用戶名</td>
								<td><input class="input" type="text" name="pwuser" size="20" /></td>
							</tr>
							<tr class="user-tr2">
								<td>轉帳積分名</td>
								<td>
									<select name="vmcredit">
<!--
EOT;
foreach ($vm_credit as $key => $value) {print <<<EOT
-->
										<option value="$value">{$credit->cType[$value]}</option>
<!--
EOT;
}print <<<EOT
-->
									</select>
								</td>
							</tr>
							<tr class="user-tr2">
								<td>轉帳金額數</td>
								<td><input class="input" type="text" name="paynum" size="20" />&nbsp;&nbsp;<span class="org">最低轉帳金額:{$db_virelimit}</span></td>
							</tr>
							<tr class="user-tr2">
								<td>請輸入密碼</td>
								<td><input class="input" type="password" name="pwpwd" size="20" /></td>
							</tr>
							<tr class="user-tr2">
								<td>&nbsp;</td>
								<td><input class="user-charge" style="border:none; cursor:pointer;width:120px;padding:0 10px 5px 25px;" type="submit" value="確認提交" /></td>
							</tr>
						</table>
						</div>
						</form>
					</div>
<!--
EOT;
} elseif ($action == 'pay' && $method == 3) {print<<<EOT
-->
					<div class="p15">
						<form action="https://www.99bill.com/gateway/recvMerchantInfoAction.htm" method="POST">
						$inputMsg
						<input type="hidden" name="signMsg" value="$signMsg" />
						<table width="100%" class="mt10 bor-t-c">
							<tr class="user-tr">
								<td>支付方式</td><td>快錢支付</td>
							</tr>
							<tr class="user-tr">
								<td>訂單號:</td>
								<td>$order_no</td>
							</tr>
							<tr class="user-tr">
								<td>購買商品:</td>
								<td> 購買站點交易幣</td>
							</tr>
							<tr class="user-tr">
								<td>總價格:</td>
								<td><font color="#FF0000"> ¥$number</font></td>
							</tr>
						</table>
						<div class="tac" style="padding:1em">
							<span class="button"><span><button type="submit">提 交</button></span></span>
						</div>
						</form>
					</div>
<!--
EOT;
} elseif ($action == 'change') {print <<<EOT
-->
					<div class="p15">
					
					<div class="p15">
						<div class="b f14">
							我的積分
						</div>
						<ul class="user-integral cc mt10">
							<li>$db_rvrcname : $userrvrc $db_rvrcunit</li>
							<li>$db_creditname : $winddb[credit] $db_creditunit</li>
							<li>$db_moneyname : $winddb[money] $db_moneyunit</li>
							<li>$db_currencyname : $winddb[currency] $db_currencyunit</li>
<!--
EOT;
foreach($_CREDITDB as $key => $value){print <<<EOT
-->
							<li>$value[0] : {$creditdb[$key]} $value[1]</li>
<!--
EOT;
}print <<<EOT
-->
						</ul></div>
						<div class="bor-t-c"></div>

						<div style="padding-right:200px">
							<div style="width:100%;float:left">
								<table width="100%">
<!--
EOT;
foreach($jf as $key=>$value){print <<<EOT
-->
								<form method="post" action="userpay.php?action=change&">
								<input type="hidden" name="step" value="3" />
								<input type="hidden" name="type" value="$key" />
								<input type="hidden" name="verify" value="$verifyhash" />
									<tr class="user-tr">
										<td class="b f14" width="25%">{$value[0]} <span class="gray">-&gt;</span> {$value[1]}</td>
										<td class="lh24" width="250">
											<input name="change" type="text" class="input" /> <span class="button"><span><button type="submit">兌換成{$value[1]}</button></span></span>
										</td>
										<td><span class="org">必須為{$value[2]}的整數倍</span><br />
										<span class="gray">行情:</span> {$value[2]}{$value[0]}={$value[3]}{$value[1]}</td>
									</tr>
								</form>
<!--
EOT;
}print <<<EOT
-->
								</table>
							</div>
						</div>
					</div>
<!--
EOT;
}print<<<EOT
-->
				</td></tr>
			</table>
			</div>
			</form>
		</div>
	</div>
	<div class="u-m-bg"></div>
</div>
<!--
EOT;
?>-->