<!--<?php
require_once uTemplate::PrintEot('header');
require_once uTemplate::PrintEot('profile_left');
print <<<EOT
-->
	<div class="contUser">
        	<div class="p15">
            	<h4 class="site"><span>積分</span></h4>
                <div class="navC">
                    <ul>
                        <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>
<script>
var action = "$action";
if (action == 'pay') {
	action = 'buy';
}
setCurrent('pay_'+action,'pay_begin','current');
</script>
                    </ul>
                </div>
					<table width="100%" height="450">
						<tr><td class="vt"><div class="p15">
<!--
EOT;
if (!$action) {
if ($paycredit) {print <<<EOT
-->
								<dl class="user-account cc">
									<dt>{$pay_link}</dt>
									<dd>
										<p><span class="f14 s2">{$credit->cType[$paycredit]}</span>&nbsp;&nbsp;<span class="f24 b s2 mb5" style="line-height:1.1;font-family:Georgia;">$creditdb[$paycredit]</span></p>
										<p class="gray f12 lh_24">當前匯率:{$db_creditpay[$paycredit][rmbrate]} {$credit->cType[$paycredit]} = ¥1 </p>
									</dd>
								</dl>
<!--
EOT;
}print <<<EOT
-->
								<ul class="user-integral s5 cc mb20">
<!--
EOT;
foreach ($credit->cType as $key => $value) {
if ($key != $paycredit) {
!isset($creditdb[$key]) && $creditdb[$key] = 0;
print <<<EOT
-->
									<li class="w mb5">{$value}︰$creditdb[$key]</li>
<!--
EOT;
}}print <<<EOT
-->
								</ul>
<!--
EOT;
if ($orderdb) {print <<<EOT
-->
							   <h5 class="h5"><a class="fr" href="userpay.php?action=list">進入訂單記錄 &gt;&gt;</a><strong>近期訂單狀態</strong></h5>
							   <div class="u-box-a mb20">
									<table width="100%" class="tA">
										<tr class="tr">
											<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="s2">未完成訂單</span>
<!--
EOT;
}print <<<EOT
-->
											</td>
											<td>$value[date]</td>
										</tr>
<!--
EOT;
}print <<<EOT
-->
									</table>
								</div>
<!--
EOT;
}print <<<EOT
-->
<!--
EOT;
if ($logdb) {print <<<EOT
-->
							   <h5 class="h5"><a class="fr" href="userpay.php?action=log">進入積分日志 &gt;&gt;</a><strong>積分日志</strong></h5>
							   <div class="u-box-a mb20">
									<table width="100%" class="tA">
										<tr class="tr">
											<td width="30">ID</td>
											<td width="60">操作</td>
											<td width="70">獎懲</td>
											<td>描述</td>
											<td width="100">時間</td>
										</tr>
<!--
EOT;
foreach ($logdb as $key => $value) {
$value[affect] > 0 && $value[affect] = '+'.$value[affect];
print <<<EOT
-->
									<tr>
										<td class="f10">$value[id]</td>
										<td>{$lang[logtype][creditlog][$value[logtype]]}</td>
										<td>{$credit->cType[$value[ctype]]}{$value[affect]}</td>
										<td>$value[descrip]</td>
										<td class="gray">$value[adddate]</td>
									</tr>
<!--
EOT;
}print <<<EOT
-->
									</table>
								</div>
<!--
EOT;
}} elseif ($action == 'buy') {print<<<EOT
-->
								<form method="post" action="userpay.php?">
									<input type="hidden" name="action" value="pay" />
									<input type="hidden" name="verify" value="$verifyhash" />
									<div class="spaceTip"><div class="b s5">積分充值過程:</div><ol>
	<li>填寫信息:進入積分充值頁面，填寫充值金額，並選擇支付方式，提交進入下一步</li>
	<li>生成訂單:系統自動生成一條充值訂單記錄，等待用戶付款，此時訂單狀態為“未支付訂單”</li>
	<li>用戶付款:進入付款頁面，當您付款成功後，訂單信息會變為“已完成訂單”狀態，同時系統會給您的積分帳戶充入相應的金額</li></ol></div>
									<div class="p15">
										<table width="100%" class="setTable">
											<tr>
												<th class="th">充值積分名</th>
												<td class="td">
													<select name="paycredit" id="paycredit" onchange="payinfo(this.value);" class="select_wa">
<!--
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>
													<p><span id="payinfo"></span></p>
												</td>
											</tr>
											<tr>
												<th class="th">充值積分數</th>
												<td class="td">
													<input class="input input_wa" type="text" name="creditnumber" onkeyup="calculateMoney(this)" />
													&nbsp;&nbsp;<span class="s2"><span id="moneyinfo"></span></span>
													<input class="input input_wa" type="hidden" name="number" id="moneynumber" />
												</td>
											</tr>
										<tr>
											<th class="th">支付方式: </th>
											<td class="td" style="padding-left:10px;">
												<div class="fl mb10 mr20"><input id="radio_alipay" type="radio" name="method" value="2" checked /><label for="radio_alipay"><img src="$imgpath/post/alipay.gif" alt="支付寶" align="absmiddle" /></label></div>
<!--
EOT;
if($ol_tenpay && $ol_tenpaycode){print <<<EOT
-->
												<div class="fl mb10 mr20"><input id="radio_tenpay" type="radio" name="method" value="4" /><label for="radio_tenpay"><img src="$imgpath/post/tenpay.gif" alt="財付通" align="absmiddle" /></label></div>
<!--
EOT;
}if($ol_paypal && $ol_paypalcode){print <<<EOT
-->
												<div class="fl mb10 mr20"><input id="radio_paypal" type="radio" name="method" value="1" /><label for="radio_paypal"><img src="$imgpath/post/paypal.gif" alt="貝寶" align="absmiddle" /></label></div>
<!--
EOT;
}if($ol_99bill && $ol_99billcode){print <<<EOT
-->
												<div class="fl mb10"><input id="radio_99bill" type="radio" name="method" value="3" /><label for="radio_99bill"><img src="$imgpath/post/99bill.gif" alt="快錢" align="absmiddle" /></label></div>
<!--
EOT;
}print <<<EOT
-->
											</td>
										</tr>
										</table>
										<div class="tac" style="padding:1em;"><span class="btn"><span><button type="submit" id="buysubmit">提交訂單</button></span></span></div>
									</div>
								</form>
							<script>
								var creditinfo = $creditinfo;
								function payinfo(c) {
									getObj('payinfo').innerHTML = '當前匯率:' + creditinfo[c][0] + ' ' + creditinfo[c][2] + ' = ¥1（最低充值 ' + creditinfo[c][1] + ' 元人民幣 ）';
								}
								
								function calculateMoney(obj) {
									var radio = creditinfo[getObj('paycredit').value][0];
									var moneyNumber = Math.round(obj.value)/radio;
									if (isNaN(moneyNumber)) {
										getObj('moneyinfo').innerHTML = '請輸入數字';
										getObj('buysubmit').disabled = true;
										return false;
									}
									getObj('moneynumber').value = moneyNumber;
									getObj('moneyinfo').innerHTML = '需充值人民幣' + moneyNumber + '元';
									getObj('buysubmit').disabled = false;
								}
								payinfo(getObj('paycredit').value);
							</script>
<!--
EOT;
} elseif ($action == 'list') {
${'statestyle'.$state} = 'current';
print<<<EOT
-->
								<table width="100%" class="mb20 s5">
									<tr>
										<td><b>訂單狀態說明:</b><ol>
	<li>未完成訂單:未充值成功的訂單，用戶尚未付款成功</li>
	<li>已完成訂單:已充值成功的訂單，用戶已經完成付款，{$db_currencyname}充值成功.</li></ol></td>
									</tr>
								</table>
								<div class="navD mb10">
									<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>
								<table width="100%" class="tA">
									<tr class="tr">
										<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>
										<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><td colspan="6">$pages</td></tr>
								</table>
<!--
EOT;
} elseif ($action == 'log') {print<<<EOT
-->
								<script src="js/date.js"></script>
								<form action="userpay.php?action=log" method="post">
									<div class="p10">
									<table width="100%">
										<tr>
											<td>
												積分 <select class="input_wc" name="ctype">
												<option></option>
<!--
EOT;
foreach ($credit->cType as $key => $value) {
$ctypeSelect = ($key == $ctype) ? 'selected' : '';
print <<<EOT
-->
											<option value="$key" $ctypeSelect>$value</option>
<!--
EOT;
}print <<<EOT
-->
											</select>
											</td>
											<td>日期 <input class="input" type="text" name="stime" size="10" id="stime" onclick="ShowCalendar(this.id)"  value="$stimeView" />&nbsp;-&nbsp;<input class="input" type="text" name="etime" size="10" id="etime" onclick="ShowCalendar(this.id)" value="$etimeView" />
											</td>
											<td>操作 <select class="select_wa" name="logtype">
											<option></option>
<!--
EOT;
foreach($lang['logtype']['creditlog'] as $key => $value){
$logtypeSelect = ($key == $logtype) ? 'selected' : '';
if(strpos($key,'_') === false){print <<<EOT
-->
											<option value="$key" $logtypeSelect>&#62;&#62; $value</option>
<!--
EOT;
}else{print <<<EOT
-->
											<option value="$key" $logtypeSelect> &nbsp;|- $value</option>
<!--
EOT;
}}print <<<EOT
-->
										</select>
											</td>
											<td>
												<span class="btn2"><span><button type="submit">提 交</button></span></span>
											</td>
										</tr>
									</table>
									</div>
								</form>
								<table width="100%" class="tA">
									<tr class="tr">
										<td width="20">ID</td>
										<td width="75">操作</td>
										<td width="60">獎懲</td>
										<td>描述</td>
										<td width="150">時間</td>
									</tr>
<!--
EOT;
$id=($page-1)*$db_perpage;
foreach($logdb as $key => $value){
$value[affect] > 0 && $value[affect] = '+'.$value[affect];
$id++;
print <<<EOT
-->
									<tr>
										<td class="f10">$id</td>
										<td>{$lang[logtype][creditlog][$value[logtype]]}</td>
										<td>{$credit->cType[$value[ctype]]}{$value[affect]}</td>
										<td>$value[descrip]</td>
										<td class="gray">$value[adddate]</td>
									</tr>
<!--
EOT;
}print <<<EOT
-->
									<tr><td colspan="6">$pages</td></tr>
								</table>
<!--
EOT;
} elseif ($action == 'virement') {print<<<EOT
-->
								<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="mb20">
									<h5 class="h5 mb10"><strong>我的積分</strong></h5>
									<ul class="user-integral cc">
<!--
EOT;
foreach ($credit->cType as $key => $value) {
!isset($creditdb[$key]) && $creditdb[$key] = 0;
print <<<EOT
-->
											<li>{$value}︰$creditdb[$key]</li>
<!--
EOT;
}
if($db_virerate){
	$virerate = $db_virerate . '%';
} else {
	$virerate = '無';
}
print <<<EOT
-->
									</ul>
							</div>
									<div class="bor-t-c"></div>
										<table width="100%" class="setTable">
											<tr>
												<th class="th">轉帳手續費</th>
												<td class="td">$virerate</td>
											</tr>
											<tr>
												<th class="th">轉入用戶名</th>
												<td class="td"><input class="input input_wa" type="text" name="pwuser" size="20" /></td>
											</tr>
											<tr>
												<th class="th">轉帳積分名</th>
												<td class="td">
												<select name="vmcredit" class="select_wa">
<!--
EOT;
foreach ($vm_credit as $key => $value) {print <<<EOT
-->
													<option value="$value">{$credit->cType[$value]}</option>
<!--
EOT;
}print <<<EOT
-->
												</select>
												</td>
											</tr>
											<tr>
												<th class="th">轉帳金額數</th>
												<td class="td"><input class="input input_wa" type="text" name="paynum" size="20"/>&nbsp;&nbsp;<span class="s2">最低轉帳金額:{$db_virelimit}</span></td>
											</tr>
											<tr>
												<th class="th">請輸入密碼</th>
												<td class="td"><input class="input input_wa" type="password" name="pwpwd" size="20" value=""/></td>
											</tr>
										</table>
										<div class="tac" style="padding:1em"><span class="btn"><span><button type="submit">確認提交</button></span></span></div>
								</form>
<!--
EOT;
} elseif ($action == 'pay' && $method == 3) {print<<<EOT
-->
								<form action="https://www.99bill.com/gateway/recvMerchantInfoAction.htm" method="POST">
								$inputMsg
									<input type="hidden" name="signMsg" value="$signMsg" />
									<table width="100%" class="setTable">
										<tr>
											<th class="th">支付方式</th>
											<td class="td">快錢支付</td>
										</tr>
										<tr>
											<th class="th">訂單號:</th>
											<td class="td">$order_no</td>
										</tr>
										<tr>
											<th class="th">購買商品:</th>
											<td class="td">購買站點交易幣</td>
										</tr>
										<tr>
											<th class="th">總價格:</th>
											<td class="td s1">¥$number</td>
										</tr>
									</table>
									<div class="tac" style="padding:1em">
										<span class="button"><span><button type="submit">提 交</button></span></span>
									</div>
								</form>
<!--
EOT;
} elseif ($action == 'change') {print <<<EOT
-->
							<div class="mb20">
									<h5 class="h5 mb10"><strong>我的積分</strong></h5>
									<ul class="user-integral cc">
										<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){
$creditdb[$key] = intval($creditdb[$key]);
print <<<EOT
-->
										<li>$value[0] : {$creditdb[$key]} $value[1]</li>
<!--
EOT;
}print <<<EOT
-->
									</ul>
							</div>
								<div class="bor-t-c"></div>
								<table width="100%" class="setTable">
<!--
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>
											<th class="th">{$value[0]} <span class="gray">-&gt;</span> {$value[1]}</th>
											<td class="td">
											<input name="change" type="text" class="input" /> <span class="btn2"><span><button type="submit">兌換成{$value[1]}</button></span></span></td>
											<td class="td"><span class="s2">必須為{$value[2]}的整數倍</span><br />
											<span class="gray">行情:</span> {$value[2]}{$value[0]}={$value[3]}{$value[1]}</td>
										</tr>
									</form>
<!--
EOT;
}print <<<EOT
-->
								</table>
<!--
EOT;
}print<<<EOT
-->
						</div></td></tr>
					</table>
            </div>
        </div>
<!--
EOT;
require_once uTemplate::PrintEot('footer');
?>-->