<extend name="Public/promote_base"/>
<block name="css">
<link href="__CSS__/20180207/data.css" rel="stylesheet">
<link href="__CSS__/20180207/finance.css" rel="stylesheet">
<style type="text/css">
	.trunk-list{position: relative;min-height: 66vh;}
	
</style>
</block>

<block name="body">
    <div class="page-search normal_list query-recharge-search">
      <div class="trunk-title">
      	<div class="location">
		<div class="location-container">当前位置:<span>数据管理></span><span>留存统计</span></div>
		</div>
      	<img src="__IMG__/20180207/icon_normal_ARPU.png">
      	<span class="title_main">留存统计</span>
      	<span class="details">根据日期,游戏,推广员分析用户流程率信息</span>
      </div>
      <div class="trunk-content article">
          <div class="trunk-search clearfix">
            <form action="{:U('Query/retention_analysis')}" method="post" enctype="multipart/form-data">
              <div class="form-group normal_space fr">
                <input type="submit" class="submit" value="查询">
              </div>
              <div class="form-group normal_space fr">
                <label class="form-title select-title">结束时间:</label>
                <div class="select-time">
                  <input type="text" id="edate" class="txt" name="time-end" placeholder="结束时间" value="{$Think.request.time-end}">
                </div>
              </div>
              <div class="form-group normal_space fr">
                <label class="form-title select-title">开始时间:</label>
                <div class="select-time">
                  <input type="text" id="sdate" class="txt" name="time-start" placeholder="开始时间" value="{$Think.request.time-start}" >
                </div>
              </div>
              <div class="form-group normal_space fr">
                    <select id="promote_id" name="promote_id" class="reselect select_gallery" style="min-width:170px;width:185px;">
                        <option game-id="0" value="0">全部渠道</option>
                        <option game-id="{:session('promote_auth.pid')}" value="{:session('promote_auth.pid')}">自己</option>
                        <volist name=":get_promote_chlid_account(PID)" id="vo">
                            <option game-id="{$vo.id}" value="{$vo.id}">{$vo.account}</option>
                        </volist>
                    </select>
                    <input type="hidden" id="promote_account" name="promote_account" value='{:I("promote_account")}'>
              </div>
              <div class="form-group normal_space fr">
                    <select id="game_id" name="game_id" class="reselect select_gallery" style="width:200px;">
                        <option game-id="0" value="0">请选择游戏</option>
                        <volist name=":get_game_list()" id="vo">
                            <option game-id="{$vo.id}" value="{$vo.id}">{$vo.game_name}</option>
                        </volist>
                    </select>
                    <input type="hidden" id="game_name" name="game_name" value='{:I("game_name")}'>
              </div>
            </form>
          </div>
      </div>
    <div class="page-list query-recharge-list">
      <div class="trunk-content article">
          <div class="trunk-list">
            <table class="table normal_table" id="datacontent">
            <table class="table normal_table" id="datatable" style="<notempty name='list_data'>display:none;</notempty>"><thead>
                <tr class="odd">
                  <th>日期</th>
                  <if condition='empty(I("game_id")) != true'>
                    <th>游戏名称</th>
                  </if>
                  <if condition='empty(I("promote_id")) != true'>
                    <th>所属渠道</th>
                  </if>
                  <th>新增玩家</th>
                  <th>1日留存</th>
                  <th>2日留存</th>
                  <th>3日留存</th>
                  <th>4日留存</th>
                  <th>5日留存</th>
                  <th>6日留存</th>
                  <th>7日留存</th>
                  <th>15日留存</th>
                  <th>30日留存</th>
                </tr></thead><tbody>
                <empty name="list_data">
                <tr><td colspan="11" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
                <else />
                <volist name="list_data" id="vo" mod="2">
                <tr name="rows" class="<eq name='mod' value='1'>odd</eq>">
                  <td>{$key}</td>
                  <if condition='empty(I("game_id")) != true'>
                    <th>{:I("game_name")}</th>
                  </if>
                  <if condition='empty(I("promote_id")) != true'>
                    <th>{:I("promote_account")}</th>
                  </if>
                  <td>{$vo.newUsers}</td>
                  <td>{$vo.ratentionRate1}</td>
                  <td>{$vo.ratentionRate2}</td>
                  <td>{$vo.ratentionRate3}</td>
                  <td>{$vo.ratentionRate4}</td>
                  <td>{$vo.ratentionRate5}</td>
                  <td>{$vo.ratentionRate6}</td>
                  <td>{$vo.ratentionRate7}</td>
                  <td>{$vo.ratentionRate15}</td>
                  <td>{$vo.ratentionRate30}</td>
                </tr>
                </volist>
                </empty></tbody>
            </table>
            <notempty name="list_data">
            <div class="pagenation clearfix">
							<a class="sch-btn" id="export_data" href="{:U('Export/retention_analysis',array(
								'game_id'=>I('game_id'),
								'promote_id'=>I('promote_id'),
								'time-start'=>I('time-start'),
								'time-end'=>I('time-end'),'game_name'=>I('post.game_name'),'promote_account'=>I('post.promote_account'),
                'xlsname'=>'数据管理_留存统计'
                ))}" >导出</a>
							<div>
								<select id="pagechange" name="row" onchange="pagechange(this)"><option value="10">每页10条</option><option value="25">每页25条</option><option value="50">每页50条</option><option value="100">每页100条</option></select>
								<div id="pagenation">
								
								</div>
							</div>
						</div>
            </notempty>
          </div>
      </div>
    </div>
    </div> 
</block>
<block name="script">
<link rel="stylesheet" type="text/css" href="__CSS__/p_jquery.datetimepicker.css">
<script type="text/javascript" src="__JS__/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<script type="text/javascript" src="__JS__/20170831/pagination.js"></script>
<script type="text/javascript" src="__JS__/20170831/string.js"></script>
<script type="text/javascript" src="__JS__/20170831/tabpage.js"></script>
<script type="text/javascript">
setValue('promote_id',{$Think.request.promote_id|default=0});
setValue('game_id','{$Think.request.game_id|default=0}');
function pagechange(that){
	tablePage('datatable', 'datacontent', 'pagenation', [1, 2, 4, 5, 6, 10], false,that.value);
}
$().ready(function(){
   $("#pagehtml a").on("click",function(event){
    event.preventDefault();//使a自带的方法失效,即无法调整到href中的URL(http://www.baidu.com)
    var geturl = $(this).attr('href');
    $('#data_form').attr('action',geturl);
    $('#data_form').submit();
   });
   $('#sdate').datetimepicker({
    lang:'ch',
    format:'Y-m-d',
    formatDate:'Y-m-d',
    scrollMonth:false,
    scrollTime:false,
    scrollInput:false,
    timepicker:false
  });
  
  $(".select_gallery").select2();
  
  $('#edate').datetimepicker({
    lang:'ch',
    format:'Y-m-d',
    formatDate:'Y-m-d',
    scrollMonth:false,
    scrollTime:false,
    scrollInput:false,
    timepicker:false
  });
  $(".submit").click(function(){
      var sdate =$('#sdate').val();
      var edate =$('#edate').val();
      if(Date.parse(sdate) > Date.parse(edate)){
        layer.msg('开始时间必须小于等于结束时间');
        return false;
      }
  })
  tablePage('datatable', 'datacontent', 'pagenation', [1, 2, 4, 5, 6, 10], false); 
  
  $("#game_id").change(function(){
    var game_name = $('#game_id option:selected').text();
    $("#game_name").val(game_name);
  })

  $("#promote_id").change(function(){
    var account = $('#promote_id option:selected').text();
    $("#promote_account").val(account);
  })
});
    $(function () {
        $('.select2-container--above').prop('width','358px');
    })
</script>
    
</block>