<extend name="Public/base" />

<block name="body">
    <link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
    <script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
    <script type="text/javascript" src="__JS__/select2.min.js"></script>
    <script type="text/javascript" src="__STATIC__/layer3/layer.js"></script>

    <style>
        .select2-container--default .select2-selection--single {
            color: #000;
            resize: none;
            border-width: 1px;
            border-style: solid;
            border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
            box-shadow: 0px 3px 3px #F7F8F9 inset;
            height: 35px;
            height: 28px;
            border-radius: 3px;
            font-size: 12px;
        }

        .select2-container--default .select2-selection--single .select2-selection__rendered {
            line-height: 35px;
            line-height: 28px;
        }

        .select2-container--default .select2-selection--single .select2-selection__arrow {
            height: 26px;
        }

        .select2-container--default .select2-search--dropdown .select2-search__field {
            height: 26px;
            line-height: 26px;
            font-size: 12px;
        }

        .select2-results__option[aria-selected] {
            font-size: 12px;
        }

        .tooltip {
            position: relative;
            /* display: block; */
            /* color: #056dae; */
        }

        .tooltip .tooltiptext {
            display: none;
            width: 100%;
            background-color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px 10px 5px 5px;
            position: absolute;
            z-index: 1;
            bottom: 80%;
            left: 0;
            border: #000 solid 1px;
            line-height: 20px;
        }

        .tooltip .tooltiptext::after {
            content: "";
            position: absolute;
            top: 100%;
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: black transparent transparent transparent;
        }

        .tooltip:hover .tooltiptext {
            color: #333;
            display: block;

        }
    </style>
    <!-- 标题栏 -->
    <div class="cf main-place top_nav_list navtab_list">

        <h3 class="page_title">财务汇总统计</h3>
        <p class="description_text"></p>
    </div>
    <style>


    </style>
    <div class="cf top_nav_list">
        <!-- 高级搜索 -->
        <div class="jssearch search_list fl cf">
            <div class="input-list search-title-box">
                <label>搜索:</label>
            </div>
            <div class="input-list input-list-resway search_label_rehab">
                <select id="year" name="year" class="select_gallery" style="width:150px;">
                    <volist name="YearList" id="vo">
                        <option value="{$vo.value}" <if condition="I('year') && $vo.value eq I('year')">selected
                            </if> >{$vo.name}</option>
                    </volist>
                </select>
            </div>
            <div class="input-list input-list-resway search_label_rehab">
                <select id="type" name="type" class="select_gallery" style="width:150px;">
                    <option value="2" <if condition="I('type') && $vo.value eq 2">selected
                        </if> >不包含绑币</option>
                    <option value="3" <if condition="I('type') && $vo.value eq 3">selected
                        </if> >包含绑币</option>
                </select>
            </div>
            
            <input type="hidden" name="" value="" class="sortBy">
            <div class="input-list">
                <a class="sch-btn" href="javascript:;" id="search"
                    url="{:U('FinancialSummary/index','model='.$model['name'] .'&row='.I('row'),false)}">
                    搜索</a>
            </div>

        </div>
    </div>


    <!-- 数据列表 -->
    <div class="data_list">
        <table>
            <caption class="" style="text-align: left;font-size: 20px;font-weight: 600;">按收入类型</caption>
            <thead>
                <tr>
                    <th>序号</th><th>流水类型</th><th>1月</th><th>2月</th><th>3月</th><th>4月</th><th>5月</th><th>6月</th><th>7月</th><th>8月</th><th>9月</th><th>10月</th><th>11月</th><th>12月</th><th>年度合计</th>
                </tr>
            </thead>
            <tbody>
                <volist name="data.income.list" id="income" key="incomekey">
                    <tr>
                        <td>{$incomekey}</td>
                        <td>{$income.name}</td>
                        <volist name="income.money" id="incomemoney" >
                            <td><if condition="$incomemoney neq 0">{$incomemoney}<else/>0.00</if></td>
                        </volist>
                    </tr>
                </volist>
                <tr class="data_summary">
                    <td colspan="2" style="text-align: center;">合计:</td>
                    <volist name="data.income.count" id="incomecount" >
                        <td><if condition="$incomecount neq 0">{$incomecount}<else/>0.00</if></td>
                    </volist>
                </tr>
            </tbody>
        </table>
        <table style="margin-top: 30px;">
            <caption class="" style="text-align: left;font-size: 20px;font-weight: 600;">按合作方类型</caption>
            <thead>
                <tr>
                    <th>序号</th><th>流水类型</th><th>1月</th><th>2月</th><th>3月</th><th>4月</th><th>5月</th><th>6月</th><th>7月</th><th>8月</th><th>9月</th><th>10月</th><th>11月</th><th>12月</th><th>年度合计</th>
                </tr>
            </thead>
            <tbody>
                <volist name="data.promote.list" id="promote" key="promotekey">
                    <tr>
                        <td>{$promotekey}</td>
                        <td>{$promote.name}</td>
                        <volist name="promote.money" id="promotemoney" >
                            <td><if condition="$promotemoney neq 0">{$promotemoney}<else/>0.00</if></td>
                        </volist>
                    </tr>
                </volist>
                <tr class="data_summary">
                    <td colspan="2" style="text-align: center;">合计:</td>
                    <volist name="data.promote.count" id="promotecount" >
                        <td><if condition="$promotecount neq 0">{$promotecount}<else/>0.00</if></td>
                    </volist>
                </tr>
            </tbody>
        </table>
        <table style="margin-top: 30px;">
            <caption class="" style="text-align: left;font-size: 20px;font-weight: 600;">按支付渠道类型</caption>
            <thead>
                <tr>
                    <th>序号</th><th>流水类型</th><th>1月</th><th>2月</th><th>3月</th><th>4月</th><th>5月</th><th>6月</th><th>7月</th><th>8月</th><th>9月</th><th>10月</th><th>11月</th><th>12月</th><th>年度合计</th>
                </tr>
            </thead>
            <tbody>
                <volist name="data.channel.list" id="channel" key="channelkey">
                    <tr>
                        <td>{$channelkey}</td>
                        <td>{$channel.name}</td>
                        <volist name="channel.money" id="channelmoney" >
                            <td><if condition="$channelmoney neq 0">{$channelmoney}<else/>0.00</if></td>
                        </volist>
                    </tr>
                </volist>
                <tr class="data_summary">
                    <td colspan="2" style="text-align: center;">合计:</td>
                    <volist name="data.channel.count" id="channelcount" >
                        <td><if condition="$channelcount neq 0">{$channelcount}<else/>0.00</if></td>
                    </volist>
                </tr>
            </tbody>
        </table>
        <table style="margin-top: 30px;">
            <caption class="" style="text-align: left;font-size: 20px;font-weight: 600;">支付类型类型</caption>
            <thead>
                <tr>
                    <th>序号</th><th>流水类型</th><th>1月</th><th>2月</th><th>3月</th><th>4月</th><th>5月</th><th>6月</th><th>7月</th><th>8月</th><th>9月</th><th>10月</th><th>11月</th><th>12月</th><th>年度合计</th>
                </tr>
            </thead>
            <tbody>
                <volist name="data.payway.list" id="payway" key="paywaykey">
                    <tr>
                        <td>{$paywaykey}</td>
                        <td>{$payway.name}</td>
                        <volist name="payway.money" id="paywaymoney" >
                            <td><if condition="$paywaymoney neq 0">{$paywaymoney}<else/>0.00</if></td>
                        </volist>
                    </tr>
                </volist>
                <tr class="data_summary">
                    <td colspan="2" style="text-align: center;">合计:</td>
                    <volist name="data.payway.count" id="paywaycount" >
                        <td><if condition="$paywaycount neq 0">{$paywaycount}<else/>0.00</if></td>
                    </volist>
                </tr>
            </tbody>
        </table>
        <div style="width: 100%;height: 50px;"></div>
    </div>

</block>

<block name="script">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '
        <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
        charset="UTF-8"></script>
    <script type="text/javascript">
    </script>
    <script type="text/javascript">

        //导航高亮
        highlight_subnav('{:U("FinancialSummary/index")}');
        $(function () {
            <volist name=":I('get.')" id="vo">
                Think.setValue('{$key}',"{$vo}");
    </volist>
        });
    </script>
    <script type="text/javascript">
        $(function () {
            $(".coin-detail").click(function () {
                var pay_type = $(this).data('pay_type');
                var url = $(this).data('url');
                var title = pay_type == -1 ? '内充支出明细' :(pay_type == 0 ? '平台币直充明细': '平台币内充明细');
                layer.open({
                    type: 2,
                    title: title,
                    shadeClose: true,
                    shade: 0.8,
                    area: ['70%', '80%'],
                    content: url
                });
            });
            $(".select_gallery").select2();
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.jssearch').find('input').serialize();
                query += "&" + $('.jssearch').find('select').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                var start = $("#time_start").val();
                var end = $("#time_end").val();
                if (start != '' && end != '') {
                    if (Date.parse(start) > Date.parse(end)) {
                        layer.msg('开始时间必须小于等于结束时间');
                        return false;
                    }
                }
                window.location.href = url;
            });
            $(".paixu").click(function () {
                var that = $(this);
                $data_order = that.attr('data-order');
                $order_type = '{$userarpu_order}';
                if ($order_type == '' || $order_type == '4') {
                    $(".sortBy").attr('name', 'data_order');
                    val = '3,' + $data_order;
                    $(".sortBy").attr('value', val);
                    $("#search").click();
                } else if ($order_type == '3') {
                    $(".sortBy").attr('name', 'data_order');
                    val = '4,' + $data_order;
                    $(".sortBy").attr('value', val);
                    $("#search").click();
                }
            });

            $('.jssamlllist').click(function () {
                var that = $(this), url = that.attr('data-url');
                var url =
                    layer.open({
                        type: 2,
                        title: "【" + that.attr('data-account') + "】小号列表",
                        shadeClose: true,
                        shade: 0.8,
                        area: ['1062px', '80%'],
                        content: url,//iframe的url
                    });

                return false;
            });

            $(".paixu").click(function () {
                var val = $(this).attr('data-order');
                if (val == 1) {
                    val = 2;
                } else if (val == 2) {
                    val = 1;
                }
                var name = $(this).attr('name');
                if (name == 'balance_status') {
                    $('#key').val(1);
                } else {
                    $('#key').val(2);
                }
                $("#" + name).val(val);
                $("#search").click();
            });
            //回车自动提交
            $('.jssearch').find('input').keyup(function (event) {
                if (event.keyCode === 13) {
                    $("#search").click();
                }
            });

            $("#total_status").click(function () {
                $("#search").click();
            })


            $('#time_start').datetimepicker({
                format: 'yyyy-mm-dd',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });

            $('#datetimepicker').datetimepicker({
                format: 'yyyy-mm-dd',
                language: "zh-CN",
                minView: 2,
                autoclose: true,
                pickerPosition: 'bottom-left'
            })
            
            var promote_id = "{:I('promote_id')}";
            var company_id = "{:I('company_id')}";
            function getPromotersByCompanyid() {
                var company_id = $("#company_id option:selected").val();
                if(!company_id){
                    company_id = -1;
                }
                $.ajax({
                    url: "{:U('Ajax/getPromotersByCompanyid')}",
                    type: "get",
                    data: { company_id:company_id},
                    dataType: 'json',
                    success: function (response) {
                        str = '<option value="">请选择会长</option>';
                        if(company_id == 0 || company_id ==-1){
                            str +='<option value="0"' + (promote_id && 0 == promote_id ? 'selected' : '') + '>官方渠道</option>';
                        }
                        data = response.data;
                        for (var i in data) {
                            str += "<option value='" + data[i].id + "' " + (promote_id && data[i].id == promote_id ? 'selected' : '') + ">" + data[i].nickname + "</option>"
                        }
                        $("#promote_id").empty();
                        $("#promote_id").append(str);
                        $("#promote_id").select2();
                    }
                })
            }
            getPromotersByCompanyid();

            $("#company_id").change(function(){
                getPromotersByCompanyid();
            })
        })


        function shenhe(status) {
            var text = $("input:checkbox[name='ids[]']:checked").map(function (index, elem) {
                return $(elem).val();
            }).get().join("\n");
            var desc = '';
            if (status == 0) {
                desc = '锁定';
            } else {
                desc = '开启';
            }
            layer.prompt({
                formType: 2,
                value: text,
                placeholder: '玩家账号(一个账号一行)',
                title: '请输入要' + desc + '的玩家账号(一个账号一行)',
                area: ['800px', '350px'] //自定义文本域宽高
            }, function (value, index, elem) {
                if (value == '') {
                    layer.msg("请输入账户ID");
                    return;
                }

                $.ajax({
                    cache: true,
                    type: "POST",
                    url: "{:U('Member/lock_status')}",
                    data: { accounts: value, lock_status: status },// 你的formid
                    async: false,
                    error: function (data) {
                        layer.alert("服务器故障,请稍后重试!", { icon: 2 });
                    },
                    success: function (data) {
                        // var obj = JSON.parse(data);
                        // layer.alert(obj.info,{icon:obj.status})
                        layer.alert(data.info, { icon: data.status })
                        window.location.reload()
                    }
                });
                layer.close(index);
            });
        }
    </script>

</block>