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

        .butnbox {padding:10px 0 15px;}
        .butnbox .butnlist {overflow:hidden;clear:both;}
        .butnbox .butnlist .butn,.butnbox .butnlist .butn:hover {text-decoration:none;border:none;}
        .butnbox .butnlist .butn {display:inline-block;width:120px;height:28px;line-height:28px;text-align:center;color:#FFF;background:#3C95C8;border-radius:3px;}
        .butnbox .butnlist .butn.last {background:#009900;}
        .butnbox .butnlist .butn~.butn {margin-left:20px;}
    </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" style="margin-bottom: 10px;">
            <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="3" <if condition="I('type') && I('type') eq 3">selected
                        </if> >不包含绑币</option>
                    <option value="2" <if condition="I('type') && I('type') eq 2">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="butnbox">
        <div class="butnlist jscheckbutn" style="margin-left: 2px">
            <foreach name="menubtn" item="vo" >
                {$vo}
             </foreach>
        </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>
        <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.merchant.list" id="merchant" key="merchantkey">
                <tr>
                    <td>{$merchantkey}</td>
                    <td>{$merchant.name}</td>
                    <volist name="merchant.money" id="merchantmoney" >
                        <td><if condition="$merchantmoney neq 0">{$merchantmoney}<else/>0.00</if></td>
                    </volist>
                </tr>
            </volist>
            <tr class="data_summary">
                <td colspan="2" style="text-align: center;">合计:</td>
                <volist name="data.merchant.count" id="merchantcount" >
                    <td><if condition="$merchantcount neq 0">{$merchantcount}<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 () {
            
        });
    </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;
            });
            $("#updateStatement").on("click",function(){
                layer.confirm("重算需要花费2分钟左右时间,并且只统计上个月信息,无需重算请取消,上次重算时间【{$lastRecount}】",{title:false}, function(index){   
                    $.ajax({
                        type: 'post',
                        url: "{:U('updateStatement')}",
                        data:{},
                        success: function(data) {
                            if(data.success){
                                layer.alert('添加重算任务成功,请2分钟后刷新查看',function(){
                                    window.location.reload();
                                });
                            }else{
                                layer.alert('添加任务失败,已有重算任务。请等待上个重算任务完成');
                            }
                        },
                        error:function(){
                            layer.alert("网络错误或超时");
                            return false;
                        }
                    });
                }); 
            })
           
            //回车自动提交
            $('.jssearch').find('input').keyup(function (event) {
                if (event.keyCode === 13) {
                    $("#search").click();
                }
            });

        })
    </script>

</block>