<link rel="stylesheet" href="/public/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css">
<script src="/public/node_modules/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<!--<script type="text/javascript" src="/public/node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>-->
<!--<link rel="stylesheet" href="/public/node_modules/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" type="text/css"/>-->

<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/bootstrap-table.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/table-fix-column.css">

<script src="<?php echo base_url();?>public/js/vendor/bootstrap/src/bootstrap-table.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap/src/table-fix-column.js"></script>

<style type="text/css">
    table {
        table-layout:fixed !important;
    }

    th{
        background: rgb(146, 208, 80);
    }

    td,th{
        /*max-width: 400px;*/
        word-wrap: break-word;
    }
    /*
    .fixed-table-header .table{
        height: 100px;
    }
    */

    table{
        table-layout:auto !important;
    }

    .table-hover > tbody > tr:hover {
        background-color: #c8bd6d;
    }

    input {
        width:60px;
    }

    #roleTable tr:nth-child(5n){
        /*background:rgb(198, 239, 206);*/
    } /**隔五行*/

    .fixed-table-toolbar {
        display: none;
    }
    .fileinput-button {
        position: relative;
        top: -5px;
    }

    .fileinput-button input{
        position:absolute;
        right: 0px;
        top: 0px;
        opacity: 0;
        -ms-filter: 'alpha(opacity=0)';
    }
    #reportBody tr td:nth-child(6),#reportBody tr td:nth-child(11),#reportBody tr td:nth-child(12),#reportBody tr td:nth-child(15){
        color:red !important;
    }
    .fixed-table-body{
        /*overflow-x: visible;*/
        /*overflow-y: visible;*/
        /*height: auto;*/
    }
    .fixed-table-header{
        /*display: none;*/
        /*overflow:visible;*/
    }
    #roleTable{
        margin-top: -41px !important;
    }
    .user-all{
        background-color: #4ad2dd80 !important;
    }
</style>

<div class="content_wrapper">
    <div class="container-fluid">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i><?php echo $title; ?></header>
                    <section>
                        <div class="container-fluid">
                            <form class="form-inline" role="form" method="POST" action="#adjuststa/dayReportDetail/<?=$reportType?>" name="stanpform">


                                <div class="row">
                                    <label class="col-sm-1">开始时间</label>
                                    <div  class="col-sm-2">
                                        <input type="text" class="form-control datetimepicker" value="<?php if($stime) echo $stime;?>" placeholder="结束时间" name="stime" />
                                    </div>

                                    <label class="col-sm-1">结束时间</label>
                                    <div  class="col-sm-2">
                                        <input type="text" class="form-control datetimepicker" value="<?php if($etime) echo $etime;?>" placeholder="结束时间" name="etime" />
                                    </div>

                                    <label class="col-sm-1">版本</label>
                                    <div  class="col-sm-2">
                                        <select class="form-control" name="user_os">
<!--                                            <option value="all" --><?php //echo $user_os == ""?"selected":""; ?><!-- >all</option>-->
                                            <option value="android" <?php echo $user_os == "android"?"selected":""; ?> >android</option>
<!--                                            <option value="ios" --><?php //echo $user_os == "ios"?"selected":""; ?><!-- >ios</option>-->
<!--                                            <option value="windows" --><?php //echo $user_os == "windows"?"selected":""; ?><!-- >windows</option>-->
                                        </select>
                                    </div>

                                    <span class="gap"></span>
                                    <button type="submit" class="col-sm-1 btn btn-primary  col-sm-offset-1">查询</button>
                                </div>

                                <div class="row">
                                    <label  class="col-sm-1">国家</label>
                                    <div class="col-sm-2 selectGroup">
                                        <select class="selectpicker bla bla bli" multiple data-live-search="true" id="addressTemp">
                                            <option value="all" <?php echo $address == "all"?"selected":""; ?> >all</option>
                                                <?php
                                                foreach($addressList as $row){
                                                    $addressTempL = strtolower($row['code']);
                                                    $name = $row["country_name"];
                                                    echo '<option value="'.($addressTempL).'" '.($address == $addressTempL?"selected":"").'>'.$row['code'].'('.$name.')</option>';
                                                }
                                                ?>
                                        </select>
                                        <input type="hidden" class="formValue" name="address">
                                    </div>

                                    <label  class="col-sm-1">广告渠道</label>
                                    <div class="col-sm-2 selectGroup">
                                        <select class="selectpicker bla bla bli" multiple data-live-search="true" id="trackers_group_type">
                                            <option value="all" <?php echo $trackers_group_type == ""?"selected":""; ?> >all</option>
                                            <?php foreach($channels as $channel){ ?>
                                                <option value="<?=$channel?>" <?php echo $trackers_group_type == "$channel"?"selected":""; ?> ><?=$channel?></option>
                                            <?php } ?>
                                        </select>
                                        <input type="hidden" class="formValue" name="trackers_group_type">
                                    </div>

                                    <label  class="col-sm-1">投放人</label>
                                    <div class="col-sm-2 selectGroup">
                                        <select class="selectpicker bla bla bli" multiple data-live-search="true" id="users">
                                            <option value="all" <?php echo $users == ""?"selected":""; ?> >all</option>
                                            <?php foreach($adusers as $user){ ?>
                                                <option value="<?=$user?>" <?php echo $users == "$user"?"selected":""; ?> ><?=$user?></option>
                                            <?php } ?>
                                        </select>
                                        <input type="hidden" class="formValue" name="users">
                                    </div>

                                    <button type="button" class="col-sm-1 btn btn-success col-sm-offset-1" onclick="show(1)">导出</button>
                                </div>
                            </form>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <a href="#adjuststa/dayReportDetail/<?=$reportType?>/DESC" class="btn btn-success" target="_self">日期降序</a>
                    <a href="#adjuststa/dayReportDetail/<?=$reportType?>/ASC" class="btn btn-success" target="_self">日期升序</a>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <div class="table-responsive">
                        <table id="roleTable" class="table table-bordered table-hover"
                               data-toggle="table"
                               data-classes="table table-hover"
                               data-show-columns="true"
                               data-striped="true"
                               data-height="700">
                            <thead>
                            <tr>
                                <?php
                                    foreach($headerTable as $key => $name){
                                        echo '<th>'.$name.'</th>';
                                    }
                                ?>
                            </tr>
                            </thead>
                            <tbody id="reportBody">
                            <?php foreach ( $list as $data => $rows) { ?>
                                <?php foreach ( $rows as $userKey => $row) { ?>
                                <tr class='user-<?=$userKey?>' <?php if($userKey == 'all'){ ?>style="background-color: #0d8ddb" <?php }?>>

                                    <?php foreach ( $headerTable as $name) {?>
                                        <td style="text-align: center;vertical-align: middle;width:200px;"><?=$row[$name] ?? '-'?></td>
                                    <?php }?>
                                </tr>
                                <?php }?>
                            <?php }?>
                            </tbody>
                        </table>
                    </div>
                </aside>
            </div>
        </div>


    </div>
</div>
</div>
<script src="<?php echo base_url();?>public/js/common.js"></script>
<script>
    $('.selectpicker').on('changed.bs.select',function(e){
        console.log($(this).parents('.selectGroup').find('.formValue'))
        $(this).parents('.selectGroup').find('.formValue').val($(this).val())
    });
    $(document).ready(function() {
        $('.selectpicker').selectpicker({
            'selectedText': 'cat'
        });
        $('#addressTemp').selectpicker('val',['<?php echo is_array($address)?implode("','",$address):$address;?>']);
        $('#trackers_group_type').selectpicker('val',['<?php echo is_array($trackers_group_type) ? implode("','",$trackers_group_type):$trackers_group_type;?>']);
        $('#users').selectpicker('val',['<?php echo is_array($users) ? implode("','",$users):$users;?>']);
    });

    function show(){
        var url = "/adjuststa/exportAdjustDataDetail/<?=$reportType?>/<?php echo $stime; ?>/<?php echo $etime; ?>/<?php echo $user_os; ?>/<?php echo is_array($address) ? implode("___",$address):$address;?>/<?php echo is_array($trackers_group_type) ? implode("___",$trackers_group_type):$trackers_group_type;?>/<?php echo is_array($users) ? implode("___",$users):$users;?>"
        // window.location.href = url
        window.open(url)
    }
</script>
<script type="text/javascript">

    dateMonthConfig = {
        language: "zh-CN", //语言</span>
        todayHighlight: true, //是否今日高亮</span>
        format: 'yyyy-mm-dd', //点击月份后显示在input中的格式</span>
        autoclose: true, //是否开启自动关闭</span>
        startView: 'months', //开始视图层，为月视图层</span>
        maxViewMode:'years', //最大视图层，为年视图层</span>
        minViewMode:'months' //最小视图层，为月视图层</span>
    };
    dateMonthConfig = {
        language:'zh-CN',
        format:'yyyy-mm-dd',
        autoclose:true,
        zIndexOffset:906  //控制z-index
    }
        //选择日期
        $('.datetimepicker').datepicker(dateMonthConfig);


</script>