<?php include_once(mvc::$cfg['PATH_TPL'].'public/headBase2.php');?>
<div class="layui-card">
	<div class="layui-card-body">
		<div style="padding:0 10px 10px 0;">
			<form class="layui-form">
			  <div class="layui-inline">
				<label class="layui-form-label">时间区间</label>
				<div class="layui-input-inline">
					<input type="text" name="betime" id="betime" class="layui-input" value="<?php echo $Params['betime'];?>" placeholder=" ~ ">
				</div>
				<div class="layui-input-inline">
					<?php foreach($fastTime as $k=>$v){?>
					<a href="javascript:;" data-betime="<?php echo $v;?>" style="margin-left:10px;" class="a_blue"><?php echo $k;?></a>
				<?php }?>
				</div>

				<div class="layui-input-inline w100">
					<select lay-filter="fastYear">
						<option value="">按年度</option>
						<?php foreach($fastYear as $k=> $v){?>
						<option value="<?php echo $v;?>" <?php if($Params['betime'] === $v) echo ' selected'; ?>><?php echo $k;?></option>
						<?php }?>
					</select>
				</div>

			  </div>
			   <div class="layui-inline">
				<label class="layui-form-label">统计类型</label>
				<div class="layui-input-block w100">
					<select name="group">
						<?php foreach($groupByArr as $k=>$v){?>
						<option value="<?php echo $k;?>"<?php if($Params['group'] === $k) echo ' selected'; ?>><?php echo $v[0];?></option>
						<?php }?>
					</select>
				</div>
			  </div>
			  <div class="layui-inline">
				<button class="layui-btn act-btn" type="submit">
				  <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
				</button>
			  </div>
			</form>
		</div>
		<blockquote class="layui-elem-quote layui-quote-nm money-tj" style="width:1000px;">
			<label>总业绩：</label><span class="red"><?php echo sprintf('%.2f', $sum['yl_pay_money']);?></span>
			<label>归公司：</label><span class="red"><?php echo sprintf('%.2f', $sum['yl_com_money']);?></span>
		 </blockquote>

		 <blockquote class="layui-elem-quote layui-quote-nm money-tj" style="width:1000px;">
			<label>红利业绩：</label><span class="red"><?php echo sprintf('%.2f', $sum['hongli']['yl_pay_money']);?></span>
			<label>红利（已扣提成、税）：</label><span class="red"><?php echo sprintf('%.2f', $sum['hongli']['yl_com_money']);?></span>
			（ <?php echo implode('、', $hongLi);?> ）
		 </blockquote>
		<table class="layui-table" style="width:<?php echo (count($yjConfig['xiangmu'])*200+300);?>px">
		  <thead>
			<tr>
			  <th width="70" rowspan="2">日期</th>
			   <th colspan="2" class="center tdbg1">小计</th>
			  <?php $i= 0; foreach($yjConfig['xiangmu'] as $type){?>
			  <th colspan="3" class="center tdbg<?php echo $i%2;?>"><?php echo $type;?></th>
			  <?php $i++;}?>
			</tr> 
			<tr>
			  <th class="center tdbg1">金额</th>
			  <th class="center tdbg1">公司</th>
			  <?php $i= 0; foreach($yjConfig['xiangmu'] as $type){?>
			  <th class="center tdbg<?php echo $i%2;?>">金额</th>
			  <th class="center tdbg<?php echo $i%2;?>">公司</th>
			  <th class="center tdbg<?php echo $i%2;?>">单数</th>
			  <?php $i++;}?>
			</tr>
			<tr>
				<th>汇总</th>
				<th class="red  tdbg1"><b><?php if(!empty($sum['yl_pay_money'])) echo sprintf('%.2f', $sum['yl_pay_money']);?></b></th>
				<th class="red  tdbg1"><b><?php if(!empty($sum['yl_com_money'])) echo sprintf('%.2f', $sum['yl_com_money']);?></b></th>
				<?php $i= 0; foreach($yjConfig['xiangmu'] as $type){?>
				<th class="red tdbg<?php echo $i%2;?>"><?php if(!empty($sum[$type]['yl_pay_money'])) echo sprintf('%.2f', $sum[$type]['yl_pay_money']);?></th>
				<th class="red tdbg<?php echo $i%2;?>"><?php if(!empty($sum[$type]['yl_com_money'])) echo sprintf('%.2f', $sum[$type]['yl_com_money']);?></th>
				<th class="red tdbg<?php echo $i%2;?>"><?php if(!empty($sum[$type]['count'])) echo $sum[$type]['count'];?></th>
				<?php $i++;}?>
			</tr>
		  </thead>
		  <tbody>
			<?php foreach($tjArr as $k => $v ){ ?>
			<tr>
				<td><?php echo $k;?></td>
				<td class="tdbg1"><?php if(!empty($v['yl_pay_money'])) echo sprintf('%.2f', $v['yl_pay_money']);?></td>
				<td class="tdbg1"><?php if(!empty($v['yl_com_money'])) echo sprintf('%.2f', $v['yl_com_money']);?></td>
				<?php $i= 0; foreach($yjConfig['xiangmu'] as $type){?>
				<td class="tdbg<?php echo $i%2;?>"><?php if(!empty($v[$type]['yl_pay_money'])) echo sprintf('%.2f', $v[$type]['yl_pay_money']);?></td>
				<td class="tdbg<?php echo $i%2;?>"><?php if(!empty($v[$type]['yl_com_money'])) echo sprintf('%.2f', $v[$type]['yl_com_money']);?></td>
				<td class="tdbg<?php echo $i%2;?>"><?php if($v[$type]['count'] > 0) echo $v[$type]['count'];?></td>
				<?php $i++;}?>
			</tr>
			<?php }?>
		  </tbody>
		</table>
	</div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footBase.php');?>
<script>
layui.use(['table', 'laydate','form'], function(){
  var table = layui.table,laydate = layui.laydate,form = layui.form;
	laydate.render({
      elem: '#betime'
      ,range: '~'
    });
	$('[data-betime]').click(function(){
		$('[name="betime"]').val($(this).data('betime'));
		$("form").submit();
	});
	
	form.on('select(fastYear)', function(data){
		$('[name="betime"]').val(data.value);
		$("form").submit();
	})
});
</script>