<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;
    }
</style>

<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><?php echo $title; ?></header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#adjuststa/dayReport2/<?php echo $type; ?>" name="stanpform">
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>开始时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php if($stime) echo $stime;?>" placeholder="结束时间" name="stime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>结束时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php if($etime) echo $etime;?>" placeholder="结束时间" name="etime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>版本</label>
                                            <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>
                                        <div class="form-group">
                                            <label>国家</label>
<!--                                            <select class="multiselect" multiple data-live-search="false" name="address" id="address">-->
                                                <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>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>广告渠道</label>
                                            <select class="form-control 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 ($trackTokens as $trackName => $trackTokenArr){ ?>
                                                    <option value="<?=$trackName?>" ><?=$trackName?></option>
                                                <?php }?>
<!--                                                <option value="Facebook" --><?php //echo $trackers_group_type == "Facebook"?"selected":""; ?><!-- >Facebook</option>-->
<!--                                                <option value="Google_ads" --><?php //echo $trackers_group_type == "Google_ads"?"selected":""; ?><!-- >Google_ads</option>-->
<!--                                                <option value="IronSource" --><?php //echo $trackers_group_type == "IronSource"?"selected":""; ?><!-- >IronSource</option>-->
<!--                                                <option value="Organic_all" --><?php //echo $trackers_group_type == "Organic_all"?"selected":""; ?><!-- >Organic_all</option>-->
<!--                                                <option value="Organic" --><?php //echo $trackers_group_type == "Organic"?"selected":""; ?><!-- >Organic</option>-->
<!--                                                <option value="Share" --><?php //echo $trackers_group_type == "Share"?"selected":""; ?><!-- >Share</option>-->
<!--                                                <option value="Unity" --><?php //echo $trackers_group_type == "Unity"?"selected":""; ?><!-- >Unity</option>-->
<!--                                                <option value="Virgrilmedia" --><?php //echo $trackers_group_type == "Virgrilmedia"?"selected":""; ?><!-- >Virgrilmedia</option>-->
<!--                                                <option value="Linkme" --><?php //echo $trackers_group_type == "Linkme"?"selected":""; ?><!-- >Linkme</option>-->
<!--                                                <option value="Applovin" --><?php //echo $trackers_group_type == "Applovin"?"selected":""; ?><!-- >Applovin</option>-->
<!--                                                <option value="Vungle" --><?php //echo $trackers_group_type == "Vungle"?"selected":""; ?><!-- >Vungle</option>-->
<!--                                                <option value="Chartboost" --><?php //echo $trackers_group_type == "Chartboost"?"selected":""; ?><!-- >Chartboost</option>-->
<!--                                                <option value="Mintegral" --><?php //echo $trackers_group_type == "Mintegral"?"selected":""; ?><!-- >Mintegral</option>-->
<!--                                                <option value="Tecdo" --><?php //echo $trackers_group_type == "Tecdo"?"selected":""; ?><!-- >Tecdo</option>-->
<!--                                                <option value="Inplayable" --><?php //echo $trackers_group_type == "Inplayable"?"selected":""; ?><!-- >Inplayable</option>-->
                                            </select>
                                            <input type="hidden" class="formValue" name="trackers_group_type">
                                        </div>
                                        <span class="gap"></span>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                        <button type="button" class="btn btn-success" onclick="show(1)">导出</button>
                                    </form>

                                </div>
                            </div>

                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <a href="#adjuststa/dayReport2/<?php echo $type; ?>/DESC" class="btn btn-success" target="_self">日期降序</a>
                    <a href="#adjuststa/dayReport2/<?php echo $type; ?>/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) { ?>
                            <tr>
                                <?php foreach ( $rows as $row) {?>
                                <?php foreach ( $headerTable as $name) {?>
                                    <td style="text-align: center;vertical-align: middle;width:200px;"><?=$row[$name] ?? '-'?></td>
                                <?php }?>
                                <?php }?>
                            </tr>
                            <?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('.form-group').find('.formValue'))
        $(this).parents('.form-group').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;?>']);
    });

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

        //选择日期
        $('.datetimepicker').datepicker({
            language:'zh-CN',
            format:'yyyy-mm-dd',
            autoclose:true,
            zIndexOffset:906  //控制z-index
        });


</script>