<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>订单来源页面搜索</title>
    <link href="/css/webht/bootstrap.min.css" rel="stylesheet">
    <link href="/css/nav/nav.css?v=20150723" rel="stylesheet">
    <link href="/css/webht/jquery-ui-1.10.0.custom.css" rel="stylesheet">
    <script src="/min?f=/js/jquery.min.js,/js/bootstrap.min.js,/js/navigation.js,/js/jquery.form.min.js"></script>
    <script src="/js/jquery-ui.min.js?v=1"></script>
<!--[if lt IE 9]>
<script src="/js/respond.min.js" type="text/javascript"></script>
<![endif]-->

</head>
<body>
<nav class="navbar navbar-inverses" style="margin-bottom:0;border-bottom:1px solid #ddd;">
  <div class="container-fluid search_container nopadding">
    <div class="navbar-header" style="float:none;">
      <a class="navbar-brand text-muted" style="padding-top: 7px;padding-left: 30px;" href="<?php echo site_url('index/index'); ?>">
          <img width="150" style="height:40px;" src="/css/nav/img/6000.png">
      </a>
    </div>
  </div>
</nav>

<div class="container">
	<h1 class="text-center">订单来源页面查询</h1>
	<div class="content" style="margin-top:20px;">
		<form method="post" class="form-inline" action="http://www.mycht.cn/webht.php/apps/ordersfrom/index/"> 
			<div class="col-sm-8">
				<div class="form-group">
					<label for="startime">开始时间</label>
					<input id="startime" name="startime" class="form-control" type="text" value="<?php echo empty($startime) ? '' :$startime;?>" autocomplete="off"/>
				</div>
			</div>
			<div class="col-sm-8">
				<div class="form-group">
					<label for="endtime">结束时间</label>
					<input id="endtime" name="endtime" class="form-control" type="text" value="<?php echo empty($endtime) ? '' :$endtime;?>" autocomplete="off"/>
				</div>
			</div>
			<div class="col-sm-8">
				<div class="form-group">
					<label for="webcode">站点选择</label>
						<select class="form-control" name="webcode" id="webcode">
							<option value="gm">GM</option>
							<option value="cht">CH</option>
							<option value="ah">AH</option>
							<option value="CT">CT</option>
							<option value="YZ">YZ</option>
							<option value="SHT">SHT</option>
							<option value="GL">GL</option>
							<option value="MBJ">MBJ</option>
							<option value="TBT">TBT</option>
						</select>
				</div>
				<button id="ordersfrom" type="submit" class="btn btn-default">查询</button>
			</div>
		</form>
	</div>
</div>

<?php if(!empty($orders)){?>
<div class="orderscontent">
	<div>
		<h3 class="text-center">统计分组结果</h3>
		<p class="text-center">总订单数:<?php echo $total_nums;?></p>
	</div>	
	<div class="table-responsive">
		<table class="table table-bordered">
			<tr>
				<th>订单来源</th>
				<th>订单数量</th>
				<th>具体订单号</th>
			</tr>
			<?php 
			$table_body = '';
			foreach ($orders as $key=>$items){
				$table_body .= '<tr>';
				$table_body .= '<td>'.$key.'</td>';
				$table_body .= '<td>'.$items['num'].'</td>';
				$table_body .= '<td class="order_detail">';
				$orders_num = 0;
				foreach ($items['order'] as $value){
					$orders_num++;
					if($orders_num == count($items['order'])){
						$table_body .= $value;
					}else{
						$table_body .= $value.'、';
					}
				}
				
				$table_body .= '</td>';
				$table_body .= '</tr>';
			}
			echo $table_body;
			?>
		</table>
	</div>
</div>
<?php }?>
<script>
$(function(){
	$('#startime,#endtime').datepicker({
		dateFormat: "yy-mm-dd",
		changeMonth: true,
		changeYear: true
	});
	
	//获取站点
	var sitecode = "<?php echo $webcode;?>";
	if(sitecode != ''){
		$('#webcode option[value='+sitecode+']').attr("selected","selected");
	}
});
</script>
</html>