<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>

<div class="content_wrapper">
    <div class="container-fluid">
        <div class="row">
          <div class="col-sm-12">
            <aside>
              <header><i class="fa fa-fw fa-file"></i>查询</header>
              <section>
                <div class="container-fluid">
                  <form class="form-inline" role="form" method="POST" action="#invitecode/index" name="adinfo">
                      <div class="form-group">
                              <label>开始时间</label>
                              <input type="text" class="form-control datetimepicker" value="<?php echo $stime;?>" placeholder="开始时间" name="ic_start_time" />
                      </div>
                      <span class="gap"></span>
                      <div class="form-group">
                              <label>结束时间</label>
                              <input type="text" class="form-control datetimepicker" value="<?php echo $etime;?>" placeholder="结束时间" name="ic_end_time" />
                      </div>
                      <span class="gap"></span>
                      <button type="submit" class="btn btn-primary">查询</button>
                  </form>
                </div>
              </section>
            </aside>
          </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="table-responsive">
                          <table class="table table-striped table-bordered table-hover">
                            <thead>
                              <tr>
                                <th>UID</th>
                                <th>邀请总数</th>
                                <th>真实玩家</th>
                              </tr>
                            </thead>
                            <tbody>
                              <?php foreach ($list as $uid => $v) {?>
                              <tr>
                                <td><?php echo '<a target = "_blank" href="#user/index/'.$uid.'">'.$uid.'</a>';?></td>
                                <td><?php echo $v['nums'];?></td>
                                <td><?php echo isset($v['realplayer']) ? $v['realplayer'] : 0;?></td>
                              </tr>
                              <?php } ?>
                            </tbody>
                          </table> 
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>

<div class="modal fade addadvertiser" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">添加广告商</h4>
      </div>
    <form action="<?php echo base_url('advertiser/addadver');?>" method="post" class="form-horizontal" data-sendingText="提交中">
      <div class="modal-body">
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">广告商名称:</label>
            <div class="col-sm-9">
                <label class="input-inline">
                    <input type="text" class="form-control" name="adname">
                </label>
            </div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
      </div>
    </form>
    </div>
  </div>
</div>

<div class="modal fade adddailydata" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">添加广告商数据</h4>
      </div>
    <form action="<?php echo base_url('advertiser/addInfo');?>" method="post" class="form-horizontal" data-sendingText="提交中">
      <div class="modal-body">
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">广告商名称:</label>
            <div class="col-sm-9">
                <label class="select-inline">
                    <select class="form-control" name="ad_id">
                    <?php foreach($adList as $adinfo){?>
                      <option value="<?php echo $adinfo['id'];?>"><?php echo $adinfo['ad_name'];?></option>
                    <?php } ?>
                    </select>
                </label>
            </div>
          </div>
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">安装量:</label>
            <div class="col-sm-9">
                <label class="input-inline">
                    <input type="text" class="form-control" name="ad_num">
                </label>
            </div>
          </div>
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">花费:</label>
            <div class="col-sm-9">
                <label class="input-inline">
                    <input type="text" class="form-control" name="ad_money">
                </label>
            </div>
          </div>
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">安装留存:</label>
            <div class="col-sm-9">
                <label class="input-inline">
                    <input type="text" class="form-control" name="ad_install_lc">
                </label>
            </div>
          </div>
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">自然新增留存:</label>
            <div class="col-sm-9">
                <label class="input-inline">
                    <input type="text" class="form-control" name="ad_zr_lc">
                </label>
            </div>
          </div>
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">投放平台:</label>
            <div class="col-sm-9">
                <label class="input-inline">
                    <select class="form-control" name="ad_platform">
                    <?php foreach($platform as $k => $v){?>
                      <option value="<?php echo $k;?>"><?php echo $v;?></option>
                    <?php } ?>
                    </select>
                </label>
            </div>
          </div>
          <div class="form-group">
            <label for="message-text" class="col-sm-3 control-label">时间:</label>
            <div class="col-sm-5">
                <input type="text" class="form-control datetimepicker" value="" placeholder="记录时间" name="ad_time" />
            </div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
      </div>
    </form>
    </div>
  </div>
</div>
<script>
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    //变input框
    $('.changeinput').dblclick(function(){
      var colId = $(this).parent().attr('colid');
      var colName = $(this).attr('colname');

      var td = $(this);
      var tbVal = td.text();
      var txt = $("<input type='text'>").val(tbVal);
      txt.blur(function(){
          var newText = $(this).val();
          $.post(
            "<?php echo base_url('advertiser/ajaxEdit');?>",
            {adid:colId, colname:colName, val:newText}
          );
          // 移除文本框,显示新值
          $(this).remove();
          td.text(newText);
      });
      td.text("");
      td.append(txt);

    });

    //删除操作
    $('.delad').click(function(){
      if (confirm('确定删除吗?') == true) {
       var adId = $(this).attr('adid');
       $.post(
            "<?php echo base_url('advertiser/delAd');?>",
            {adid:adId},
          );
       alert('删除成功');
       $(this).parent().parent().remove();
       //window.location.reload();
      }
    });
</script>