<extend name="Public:base" />

<block name="content">

<div class="row">
	<div class="col-xs-12">
		<div class="alert alert-block alert-success">
			1、状态显示已打款只是系统标记状态，线下还需平台给商家账户打款。以实际打款凭证为准
		</div>
	</div>
	<table class="table table-striped table-bordered table-hover search-form">
	<thead>
		<th><input name="name" type="text" placeholder="输入商家名称" value="{:I('name')}" />
			&nbsp;&nbsp;
			<a class="btn btn-primary" href="javascript:;" id="search" url="{:U('Balance/assets')}">查询</a>
		</th>
		
	</thead>
</table>
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>											
						<th>ID</th>
						<th>卖家</th> 
						<th>提现金额</th>		
						<th>状态</th>
						<th>收款银行</th>
						<th>收款账号</th>
						<th>收款名称</th>
						<th>提现时间</th>	
						<th>操作</th>			
					</tr>
				</thead>
				<tbody>
						<volist name="list" id="data" empty="$empty">
						<tr>						
							<td>{$data.id}</td>
							<td>
								<?php echo $data['seller']['s_true_name']; ?>
							</td>
							<td>
								<?php echo round($data['money'],2); ?>
							</td>
							<td>
								<?php if($data['state'] == 0){ ?>
									<span class="blue">申请中</span>
								<?php }else if($data['state'] == 1){ ?>
									<span class="red">已打款</span>
								<?php } ?>
							</td>
							<td>
								<?php echo $data['seller']['s_cardname']; ?>
							</td>
							<td>
								<?php echo $data['seller']['s_cardnumber']; ?>
							</td>
							<td>
								<?php echo $data['seller']['s_cardrealname']; ?>
							</td>
							<td>
								<?php echo date('Y-m-d H:i:s',$data['addtime']); ?>
							</td>
							<td>
								<?php if($data['state'] == 0){ ?>
								<a class="delete btn btn-xs btn-danger" href='{:U("Balance/suretixianmoney",array("id"=>$data["id"]))}' >
									<i class="icon-edit bigger-120">确认打款</i>
								</a>
								<?php } ?>
							</td>
						</tr>
						</volist>	
						
						<tr>
							<td colspan="20" class="page">{$page}</td>
						</tr>
				</tbody>
				
			</table>
		</div>
	</div>
</div>
</block>
<block name="javascript">
<script>
var shenurl = "{:U('Balance/shenqing')}";
$(function(){
	$("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });
	
	//关闭弹出层
	$('#dialog').on('click','.ks-ext-close',function(){	
	    $("#dialog").css('display','none');
	    $('.ks-ext-mask').css('display','none');
	    return false;
	});
	//关闭弹出层
	$('#dialog').on('click','.J_Cancel',function(){	
	    $("#dialog").css('display','none');
	    $('.ks-ext-mask').css('display','none');
	    return false;
	});
	$('#shenqing').click(function(){
		$("#dialog").css({'position' : 'fixed','display' : 'block', 'z-index' : '9999'});
	});
	$('.J_SubmitPL').click(function(){
		var shenmoney = parseFloat($('#shenmoney').val());
		var max_shenmoney = parseFloat($('#shenmoney').attr('data-max-money'));
		if(shenmoney == 0) {
			alert('申请金额必须大于0元');
			return false;
		}
		if(max_shenmoney < shenmoney){
			alert('申请金额不能大于可提现金额');
			return false;
		}
		$.ajax({
			url:shenurl,
			type:'post',
			dataType:'json',
			data:{shenmoney:shenmoney},
			success:function(ret){
				if(ret.code == 1) {
					alert('提现成功');
					location.href = location.href;
					return false;
				} else {
					alert('提现失败');
				}
				
			}
			
		})
		
	})
	//shenmoney  data-max-money
	
})
</script>
</block>