<?php
if (!defined('ROOT')) exit ;
?>
<!DOCTYPE html>
<html>

	<head>
		<title>软件购买订单</title>
		<meta name="description" content="">
		<meta name="keywords" content="">
		<?php
		include 'Inc_files.php';
		?>
		<style type="text/css">
		#search_form .order{ width: 200px;  margin-left: 5px; float:right;}
		#search_form .am-selected{ width: 100px;}
		#search_form .time{ width: 120px; margin-left: 5px; float:right; height: 33px; border: 1px solid #c2cad8;}
		#tongji{ padding: 10px 0 5px;}
		</style>
	</head>

	<body data-type="index">
		<script src="<?php echo C('TMPL_PARSE_STRING.__TPL__'); ?>/assets/js/theme.js"></script>
		<div class="am-g tpl-g">
			<?php include 'Inc_head.php'?>
			<!-- 侧边导航栏 -->
			<?php
				include 'Inc_left.php';
			?>

			<!-- 内容区域 -->
			<div class="tpl-content-wrapper">
				<div class="row-content am-cf">
					<div class="row">
						<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
							<div class="widget am-cf">
								<div class="widget-head am-cf">
									<div class="widget-title  am-cf">
										软件购买订单
									</div>
								</div>
								<div class="widget-body  am-fr">
									<form id="search_form" class="form-horizontal am-form" method="get" role="form" action="/v/lists">
										<input type="hidden" name="model_id" value="58" />
										<input type="hidden" name="status" value="1" />
										<input type="hidden" name="row" value="<?php echo I('row',20);?>" />
										<input type="hidden" name="uid" value="<?php echo session('user_auth.id');?>" />
										<div class="am-u-sm-12 form" style="display:inline-block; text-align:right;">
											<select data-am-selected="{btnSize: 'sm'}" name="pay_way" placeholder="支付方式">
												<option value="" selected="selected">支付方式</option>
												<option value="alipay" <?php echo $_GET['pay_way']=='alipay'?'selected':'';?> >支付宝</option>
												<option value="wxpay" <?php echo $_GET['pay_way']=='wxpay'?'selected':'';?> >微信</option>
												<option value="qqpay"<?php echo $_GET['pay_way']=='qqpay'?'selected':'';?> >QQ钱包</option>
											</select>
											<div class="am-input-group am-input-group-sm tpl-form-border-form cl-p order" >
												<input type="text" name="no" value="<?php echo I('no','');?>" class="am-form-field" placeholder="订单号">
												<span class="am-input-group-btn">
												<button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="submit"></button> </span>
											</div>
											<input type="text" name="code" value="<?php echo I('code','');?>" class="am-form-field time" placeholder="文件提取码">
											<input type="hidden"  name="ctime_max" value="<?php echo I('ctime_max','');?>" class="am-form-field time" placeholder="结束时间">
											<input type="hidden"  name="ctime_min" value="<?php echo (I('first','')==1)?'':I('ctime_min','');?>" class="am-form-field time" placeholder="起始时间">
											<input type="text" id="ctime_max"  value="<?php echo wd_date('Y-m-d',I('ctime_max',''));?>" class="am-form-field time" placeholder="结束时间">
											<input type="text" id="ctime_min"  value="<?php echo (I('first','')==1)?'':wd_date('Y-m-d',I('ctime_min',''));?>" class="am-form-field time" placeholder="起始时间">
										</div>
									</form>
									<div class="am-u-sm-12" id="tongji">
										<?php
										$uid=session("user_auth.id");
										if(I('first',false)){
										    $where['ctime']=array('gt',I('ctime_min',0));
											$tongji=M('file_log')->where($where)->field("sum(price) as price,sum(money) as money,sum(feilv) as feilv")->find();
											if($count>0){
											    echo "今日订单{$count}个，总金额：{$tongji['price']}元，商户提成{$tongji['money']}元，平台利率{$tongji['feilv']}元 ";
											}else{
												echo "今日订单{$count}个 ";
											}	
										}else{
											if(!I('ctime_min',false) && !I('ctime_max',false)){
											    unset($where['ctime']);
											}else if(I('ctime_min',false)){
											    $where['ctime']=array('egt',I('ctime_min',0));
											}else if(I('ctime_max',false)){
											    $where['ctime']=array('elt',I('ctime_max',0));
											}
											$tongji=M('file_log')->where($where)->field("sum(price) as price,sum(money) as money,sum(feilv) as feilv")->find();	
											if($count>0){
												echo "本次查询订单{$count}个，总金额：{$tongji['price']}元，商户提成{$tongji['money']}元，平台利率{$tongji['feilv']}元 ";
											}else{
												echo "本次查询订单{$count}个 ";
											}
										}
										
										?>
										
									</div>
									<div class="am-u-sm-12 am-scrollable-horizontal">
										<table width="100%" class="am-table am-table-compact tpl-table-black am-table-hover am-text-nowrap" >
											<colgroup>
												<col width="175" />
												<col width="70" />
												<col width="70" />
												<col width="70" />
												<col width="70" />
												<col width="70" />
												<col width="100" />
												<col width="50" />
												<col />
											</colgroup>
											<thead>
												<tr>
													<th class="tc">订单号</th>
													<th class="tc">软件价格</th>
													<th class="tc">商户提成</th>
													<th class="tc">平台利率</th>
													<th class="tc">支付方式</th>
													<th class="tc">提取码</th>
													<th class="tc">下单时间</th>
													<th class="tc">赠品</th>
													<th class="tc">软件名称</th>
												</tr>
											</thead>
											<tbody>
												<?php foreach($list as $k=>$v){?>
												<tr>
													<td class="tc"><?php echo $v['no'];?></td>
													<td class="tc"><?php echo $v['price'];?></td>
													<td class="tc"><?php echo $v['money'];?></td>
													<td class="tc"><?php echo $v['feilv'];?></td>
													<td class="tc">
														<?php
														switch ($v['pay_way']) {
															case 'alipay':
																echo '支付宝';
																break;
															case 'wxpay':
																echo '微信';
																break;
															case 'qqpay':
																echo 'QQ钱包';
																break;
															default:
																echo '其他';
																break;
														}	
														?>
													</td>
													<td class="tc"><?php echo $v['code'];?></td>
													<td class="tc"><?php echo date('Y-m-d H:i',$v['ctime']);?></td>
													<td class="tc">
														<?php if(empty($v['card'])){
															echo '--';
														}else{?>
															<a href="javascipt:;" class="btn_card_show"   data-text='<?php echo $v['card'];?>'>查看</a>
														<?php }?>
													</td>
													<td><div align="center"><?php echo $v['name'];?></div>
											        <div align="center"></div></td>
												</tr>
												<?php }?>
											</tbody>
										</table>
									</div>
									<div class="am-u-lg-12 am-cf">
										<div class="am-fr">
											<div class="am-pagination tpl-pagination">
												<?php echo $page;?>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="am-modal am-modal-no-btn" tabindex="-1" id="card_modal">
		  	<div class="am-modal-dialog">
		    	<div class="am-modal-hd">赠品
		      		<a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
		    	</div>
		    	<div class="am-modal-bd" ng-bind-html="card|html" id="card_content">
		    	</div>
		    	<div class="am-modal-bd">
		    		<button type="button" class="am-btn am-btn-secondary am-btn-sm btn_copy" data-clipboard-target="#card_content">点击复制</button>
		    	</div>
		  	</div>
		</div>
		<?php
		include 'Inc_files_boot.php';
		?>
		<script src="/static/public/js/clipboard.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			new ClipboardJS('.btn_copy').on('success',function () {
				wd_alert({
	    			msg:"复制成功"
	    		});
			});
			jQuery('#ctime_min').datepicker().on('changeDate.datepicker.amui', function(event) {
				var mydate = new Date(event.date);
				jQuery("[name='ctime_min']").val(mydate.getTime()/1000);
		    });
		    jQuery('#ctime_max').datepicker().on('changeDate.datepicker.amui', function(event) {
		    	var mydate = new Date(event.date);
		        jQuery("[name='ctime_max']").val(mydate.getTime()/1000+86399);
		    });
		    jQuery(document).on('blur','#ctime_min',function () {
		    	var the=jQuery(this);
		    	if (the.val()=='') {
		    		jQuery("[name='ctime_min']").val('');
		    	}          
		    });
		    jQuery(document).on('blur','#ctime_max',function () {
		    	var the=jQuery(this);
		    	if (the.val()=='') {
		    		jQuery("[name='ctime_max']").val('');
		    	}          
		    });
		    jQuery(document).on('click','.btn_card_show',function () {
		    	var the=jQuery(this);
		    	if (the.data('text')!='') {
		    		jQuery("#card_modal").modal().on('opened.modal.amui',function () {
			    		scope.card=the.data('text');
			    		scope.$apply();
			    	}); 
		    	}
		    })
		</script>
	</body>

</html>