<?
/**
 * 代金券使用
 * $Id: user_use_coupon_list.inc,v 1.1
 * @author taocy
 * @package src.admin.templates
 */
?>
<b>代金券使用</b><br /><br />

<form action="user_use_coupon_list.php" method="post" name="user_use_coupon_list">
	<input type="hidden" name="search_flg" value="true" />
	<table>
		<tr>
			<td>代金券状态</td>
			<td>
				<select name="status">
					<?
						foreach ($coupon_status_list as $coupon_status_obj) {
					?>
						<option value="<?=$coupon_status_obj->name ?>"<?=$coupon_status_obj->name == $status ? " selected " : "" ?>><?=$coupon_status_obj->title ?></option>
					<?
						}
					?>
				</select>
			</td>
			<td><input type="button" value="搜索" onclick="searchUserUseCoupon()" /></td>
		</tr>
	</table>
	
</form><br />
<div style="text-align:center;float: right;font-size:18px;">共<?=$total_count ?>件记录</div>
<div style="clear:both"></div>
<!--page end-->
<div id="result_list">
<?
if ($total_count > 0) {
?>
<table>
<tr>
	<th class="contents_title">ID</th>
	<th class="contents_title">申请时间</th>
	<th class="contents_title">姓名</th>
	<th class="contents_title">手机号码</th>
	<th class="contents_title">代金券名称</th>
	<th class="contents_title">状态</th>
	<th class="contents_title">操作</th>
</tr>

<?
	foreach($user_use_coupon_list as $tmp) {
		//代金券名称
		$user = UserMst::getById($tmp->user_id);
?>
<tr>
    <td align="center"><?=$tmp->id ?></td>
    <td align="center"><?=$tmp->registration_date ?></td>
    <td align="center"><?=$user->nickname ?></td>
	<td align="center"><?=$user->mobile ?></td>
	<td align="center"><?=Coupon::getTitleById($tmp->coupon_id) ?></td>
	<td align="center"><?=CouponStatus::getTitleByName($tmp->status) ?></td>
    <td align="center">
		<?
			if (checkAuthority("ADMIN,MANAGER")) {
		?>
			<?
				//新申请的可以进行 【退回代金券】【申请返现】
				if($tmp->status=="APPLY") {
			?>
				<a class="flatbutton" href="user_use_coupon_exec.php?id=<?=$tmp->id ?>&status_to=BACK">退回代金券</a>
				<a class="flatbutton" href="user_use_coupon_exec.php?id=<?=$tmp->id?> ?>&status_to=CASHING">申请返现</a>
			<?
				}
			?>
			<?
				//返现申请的可以进行 【成功使用】
				if($tmp->status=="CASHING") {
			?>
				<a class="flatbutton" href="user_use_coupon_exec.php?id=<?=$tmp->id?> ?>&status_to=SUCCESS">使用完成</a>
			<?
				}
			?>
		<?
			}
		?>
    </td>
</tr>
<?
    }
?>
</table>

<?
} else {
    echo '<div align="center"><font color="red">暂无数据……</font></div>';
}
?>
</div>