<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CommFeesDebtsCutSearch_Stat.aspx.cs" Inherits="M_Main.StatisReport.CommFeesDebtsCutSearch_Stat" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>项目欠费统计表</title>
    <script type="text/javascript" src="../jscript/jquery-1.11.3.min.js"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <script src="../jscript/format.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/icon.css" />
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        #SearchDlg {
            padding: 10px;
            width: 550px;
            height: 250px;
        }

        .SearchTable {
            width: 550px;
            height: auto;
        }

        .SearchTable .TdTitle {
            width: 15%;
        }

        .SearchTable .TdContent {
            width: 35%;
        }

        td {
            padding: 3px 0;
        }

        #CommNames {
            width: 91.7%;
            height: 60px;
            border: 1px solid #cccccc;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <form id="frmForm" runat="server">
        <!-- 隐藏域 Start -->
        
        <input id="IsInitLoad" type="hidden" name="IsInitLoad" value="1" />
        <input id="CommID" name="CommID" value="" type="hidden" runat="server" />
        <!-- 隐藏域 End -->

        <!-- 进度条 Start -->
        <div class="datagrid-mask" style="height: 100%; width: 100%;"></div>
        <div class="datagrid-mask-msg" style='font-size: 12px; height: 55px; border: 1px solid #cccccc; z-index: 999999;'>
            <div id='DivProgressBar' class='easyui-progressbar' style='width: 200px; border: 1px solid #cccccc; margin-top: 10px;'></div>
            <div id='DivMsg' style='width: 200px; text-align: center; margin-top: 5px;'></div>
        </div>
        <!-- 进度条 End -->

        <!-- 筛选条件弹窗 Start -->
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" style="overflow: hidden;" data-options="iconCls:'icon-search',closed: true,modal:true">
            <table class="SearchTable">
                <tr>
                    <td class="TdTitle">项目名称</td>
                    <td class="TdContent" colspan="3">
                        <textarea id="CommNames" name="CommNames" onclick="SelComm();" runat="server" ru="server" readonly></textarea>
                        <input id="CommIDs" name="CommIDs" value="" type="hidden" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">费用开始时间</td>
                    <td class="TdContentSearch">
                        <input id="StartFeesDueDate" name="StartFeesDueDate" class="Wdate" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" runat="server" style="width: 80%;" />
                    </td>
                    <td class="TdTitle">费用结束时间</td>
                    <td class="TdContentSearch">
                        <input id="EndFeesDueDate" name="EndFeesDueDate" class="Wdate" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" runat="server" style="width: 80%;" />
                    </td>
                </tr>
                 <tr>
                    <td class="TdTitle">收款截止时间</td>
                    <td class="TdContentSearch">
                       <input id="CutEndDate" name="CutEndDate" class="Wdate" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" runat="server" style="width: 80%;" />
                    </td>
                    <td class="TdTitle">房屋状态</td>
                    <td class="TdContentSearch">
                        <input id="RoomStateNames" class="easyui-searchbox" searcher="SelRoomState" name="RoomStateNames" runat="server" />
                        <input id="RoomStates" type="hidden" name="RoomStates" runat="server" />
                        <input id="hiRoomStateNames" type="hidden" name="hiRoomStateNames" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">费用科目</td>
                    <td class="TdContentSearch">
                        <input id="CostNames" class="easyui-searchbox" searcher="SelCost" data-options="editable:false" name="CostNames" runat="server" style="width: 95%;" />
                        <input id="CostIDs" type="hidden" name="CostIDs" runat="server" />
                    </td>
                    <td class="TdTitle">账龄计算时间</td>
                    <td class="TdContentSearch">
                        <input type="text" class="Wdate" style="width: 100px;" onclick="WdatePicker({ startDate: '%y-%M', dateFmt: 'yyyy-MM', alwaysUseStartDate: true })" id="YearMonth"   name="YearMonth" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align: center; padding-top: 5px;">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="SearchData();">统计</a>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" onclick="ResetFilter();">清空</a>
                    </td>
                </tr>
            </table>
        </div>
        <!-- 筛选条件弹窗 End -->

        <div id="TableContainer" style="width: 100%;"></div>
        <script type="text/javascript" src="../jscript/Cache.js"></script>
        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">

            $(function () {
                var currentMonthFirst = getCurrentMonthFirst();
                var currentMonthLast = getCurrentMonthLast();

                $("#StartFeesDueDate").val(currentMonthFirst);
                $("#EndFeesDueDate").val(currentMonthLast);
                $("#CutEndDate").val(currentMonthLast + " 23:59:59");

                InitFunction();
                LoadData();
            });

            function SelComm() {

                if ($('#CommID').val() == '0' || $('#CommID').val() == '') {
                    var w = $(window).width() * 0.7;
                    HDialog.Open(w, 500, '../DialogNew/SelComm.aspx?IsCheck=1', "选择管理项目", false, function callback(_Data) {
                        var arrRet = JSON.parse(_Data);
                        $("#CommIDs").val(arrRet.id);
                        $("#CommNames").val(arrRet.name);
                    });
                }
            }

            //选择费用项目
            function SelCost() {

                HDialog.Open('700', '450', "../dialogNew/MultiCorpCostDlg.aspx" + "?Ram=" + Math.random(), '收费项目选择', false, function (_data) {
                    var varReturn = _data;
                    if (varReturn != "") {//**获得返回 刷新
                        var varObjects = varReturn.split("\t");
                        $('#CostIDs').val(varObjects[0]);
                        $('#CostNames').searchbox('setValue', varObjects[1]);
                    }
                });
            }

            function SelRoomState() {

                var strRoomStates = "";
                var strCommIDs = $("#CommIDs").val();

                HDialog.Open('700', '450', "../dialogNew/MultiRoomStateDlg.aspx"
                    + "?RoomStates=" + strRoomStates + "&CommIDs=" + strCommIDs + "&Ram=" + Math.random(), '房屋状态选择', false, function (_data) {
                    var varReturn = _data;

                    if (varReturn != "") {//**获得返回 刷新
                        var varObjects = varReturn.split("\t");

                        $('#RoomStates').val(varObjects[0]);
                        $('#RoomStateNames').searchbox('setValue', varObjects[1]);
                        $('#hiRoomStateNames').val(varObjects[0]);
                    }

                });
            }

            //重置筛选条件
            function ResetFilter() {
               
                var currentMonthFirst = getCurrentMonthFirst();
                var currentMonthLast = getCurrentMonthLast();

                //$("#CommNames").val("");
                //$("#CommIDs").val("");

                $("#StartFeesDueDate").val(currentMonthFirst);
                $("#EndFeesDueDate").val(currentMonthLast);
                $("#CutEndDate").val(currentMonthLast + " 23:59:59");

                $("#CostIDs").val("");
                $("#CostNames").searchbox("setValue", "");

                $("#RoomStates").val("");
                $("#RoomStateNames").searchbox("setValue", "");

                $("#YearMonth").val("");

            }

            //获取当月最后一天
            function getCurrentMonthLast() {
                var date = new Date();
                var currentMonth = date.getMonth();
                var nextMonth = ++currentMonth;
                var nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);
                var oneDay = 1000 * 60 * 60 * 24;
                var lastTime = new Date(nextMonthFirstDay - oneDay);
                var month = parseInt(lastTime.getMonth() + 1);
                var day = lastTime.getDate();
                if (month < 10) {
                    month = '0' + month
                }
                if (day < 10) {
                    day = '0' + day
                }
                return date.getFullYear() + '-' + month + '-' + day;
            }

            function getCurrentMonthFirst() {
                var date = new Date();
                var currentMonth = date.getMonth();

                var nextMonthFirstDay = new Date(date.getFullYear(), currentMonth, 1);
                
                var firstTime = new Date(nextMonthFirstDay);
                var month = parseInt(firstTime.getMonth() + 1);
                var day = firstTime.getDate();
                if (month < 10) {
                    month = '0' + month
                }
                if (day < 10) {
                    day = '0' + day
                }
                return date.getFullYear() + '-' + month + '-' + day;
            }

            //网格初始化
            function InitFunction() {
                var h = $(window).height();
                var w = $(window).width();
                $("#TableContainer").css("height", h + "px");
                $("#TableContainer").css("width", w + "px");
            }

            var frozenColumns = [[
                { field: '序号', title: '序号', align: 'left', sortable: true, width: 100 },
                { field: '区域名称', title: '区域名称', align: 'left', sortable: true, width: 150 },
                { field: '项目名称', title: '项目名称', align: 'left', sortable: true, width: 150  }
            ]];

            var column = [
                [
                    { colspan: 18, title: '欠费账龄分析' },
                    { colspan: 14, title: '欠费结构分析' },
                    { colspan: 6, title: '缴费习惯分析' },
                    { colspan: 34, title: '未缴费原因分析' }
                ],
                [
                    { colspan: 2, title: '欠费总额' },
                    { colspan: 2, title: '前期欠费' },
                    { colspan: 2, title: '本期欠费' },
                    { colspan: 2, title: '欠费1至3月' },
                    { colspan: 2, title: '欠费4至6月' },
                    { colspan: 2, title: '欠费7至12月' },
                    { colspan: 2, title: '欠费1至2年' },
                    { colspan: 2, title: '欠费2至3年' },
                    { colspan: 2, title: '欠费3年以上' },

                    { colspan: 2, title: '已入住' },
                    { colspan: 2, title: '装修中' },
                    { colspan: 2, title: '出租中' },
                    { colspan: 2, title: '已交空置' },
                    { colspan: 2, title: '未售空置' },
                    { colspan: 2, title: '已售未交' },
                    { colspan: 2, title: '地产出租' },

                    { colspan: 2, title: '月付' },
                    { colspan: 2, title: '季付' },
                    { colspan: 2, title: '年付' },

                    { colspan: 2, title: '底商欠费类' },
                    { colspan: 2, title: '地产遗留问题类' },
                    { colspan: 2, title: '法院拍卖/断供' },
                    { colspan: 2, title: '客户失联类' },
                    { colspan: 2, title: '工程管理类' },

                    { colspan: 2, title: '清洁环境类' },
                    { colspan: 2, title: '物业服务类' },
                    { colspan: 2, title: '交付空置类' },
                    { colspan: 2, title: '装修管理类' },
                    { colspan: 2, title: '邻里纠纷类' },

                    { colspan: 2, title: '市政影响类' },
                    { colspan: 2, title: '安全管理类' },
                    { colspan: 2, title: '公摊/公共收益类' },
                    { colspan: 2, title: '业委会管理类' },
                    { colspan: 2, title: '无理由主观拒缴' },

                    { colspan: 2, title: '未交付天问系统费用生成' },
                    { colspan: 2, title: '其他类' }
                ],
                [
                    { field: '户数总额', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费总额', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '前期户数', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '前期欠费', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '本期户数', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '本期欠费', title: '金额', align: 'left', sortable: true, width: 80 },

                    { field: '户数1', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费1', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数2', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费2', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数3', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费3', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数4', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费4', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数5', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费5', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数6', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费6', title: '金额', align: 'left', sortable: true, width: 80 },

                    { field: '户数11', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费11', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数12', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费12', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数13', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费13', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数14', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费14', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数15', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费15', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数16', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费16', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数17', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费17', title: '金额', align: 'left', sortable: true, width: 80 },

                    { field: '户数21', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费21', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数22', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费22', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数23', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费23', title: '金额', align: 'left', sortable: true, width: 80 },

                    { field: '户数31', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费31', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数32', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费32', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数33', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费33', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数34', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费34', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数35', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费35', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数36', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费36', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数37', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费37', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数38', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费38', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数39', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费39', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数40', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费40', title: '金额', align: 'left', sortable: true, width: 80 },

                    { field: '户数41', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费41', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数42', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费42', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数43', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费43', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数44', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费44', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数45', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费45', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数46', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费46', title: '金额', align: 'left', sortable: true, width: 80 },
                    { field: '户数47', title: '户数', align: 'left', sortable: true, width: 80 },
                    { field: '欠费47', title: '金额', align: 'left', sortable: true, width: 80 }
                ]
            ];

            var toolbar = [
                {
                    text: '筛选',
                    iconCls: 'icon-search',
                    handler: function () {
                        $('#SearchDlg').parent().appendTo($("form:first"));
                        $('#SearchDlg').dialog('open');
                    }
                }, '-',
                {
                    text: 'Excel导出',
                    iconCls: 'icon-page_white_excel',
                    handler: function () {
                        var rowData = $('#TableContainer').datagrid('getData');
                        if (rowData == '') {
                            HDialog.Info('请先生成报表');
                        }
                        else {
                            window.location.href = "CommFeesDebtsCutSearch_StatToExcel.aspx";
                        }
                    }
                }
            ];

            var ProgressInterval;

            function SearchData() {
               
                if ($("#CutEndDate").val() == "") {
                    HDialog.Info("请选择收款截止时间");
                    return;
                }

                $("#IsInitLoad").val(-1);
                $("#SearchDlg").dialog("close");
                //启动任务
                StartTask();
                //展示进度
                ShowProgress();
                //获取执行情况进度
                ProgressInterval = setInterval("TakeProgress()", 1000);
            }

            function StartTask() {
                //启动一个任务
                $.tool.DataPostNoLoading('CommFeesDebtsCutSearch_Stat', 'StartTask', $('#frmForm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            }

            //加载数据
            function LoadData() {
                //加载已经统计了的数据
                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    frozenColumns: frozenColumns,
                    fitColumns: false,
                    remoteSort: false,
                    singleSelect: true,
                    pagination: true,
                    width: "100%",
                    toolbar: toolbar,
                    sortOrder: "asc",
                    singleSelect: true,
                    selectOnCheck: false,
                    checkOnSelect: false,
                    rownumbers: true,
                    border: false,
                    view: myview,
                    showFooter: true,
                    onBeforeLoad: function (param) {
                        param = $.JQForm.GetParam("CommFeesDebtsCutSearch_Stat", "LoadData", "TableContainer", param);
                    },
                    onLoadSuccess: function (data) {
                        $("#SearchDlg").dialog("close");
                        //$.tool.MergeEasyUiGrid("TableContainer", "片区名称");
                        //$.tool.MergeEasyUiGrid("TableContainer", "项目名称");
                        //$.tool.MergeEasyUiGrid("TableContainer", "客户名称");
                        
                        //加载页脚
                        $('#TableContainer').datagrid('reloadFooter', [
                            {
                                项目名称: "<span style='color:red'>累计合计</span>",
                                户数总额: "<span style='color:red'>0</span>",
                                欠费总额: "<span style='color:red'>0</span>",
                                户数0: "<span style='color:red'>0</span>",
                                欠费0: "<span style='color:red'>0</span>",
                                户数1: "<span style='color:red'>0</span>",
                                欠费1: "<span style='color:red'>0</span>",
                                户数2: "<span style='color:red'>0</span>",
                                欠费2: "<span style='color:red'>0</span>",
                                户数3: "<span style='color:red'>0</span>",
                                欠费3: "<span style='color:red'>0</span>",
                                户数4: "<span style='color:red'>0</span>",
                                欠费4: "<span style='color:red'>0</span>",
                                户数5: "<span style='color:red'>0</span>",
                                欠费5: "<span style='color:red'>0</span>",
                                户数6: "<span style='color:red'>0</span>",
                                欠费6: "<span style='color:red'>0</span>",
                                户数7: "<span style='color:red'>0</span>",
                                欠费7: "<span style='color:red'>0</span>",

                                户数11: "<span style='color:red'>0</span>",
                                欠费11: "<span style='color:red'>0</span>",
                                户数12: "<span style='color:red'>0</span>",
                                欠费12: "<span style='color:red'>0</span>",
                                户数13: "<span style='color:red'>0</span>",
                                欠费13: "<span style='color:red'>0</span>",
                                户数14: "<span style='color:red'>0</span>",
                                欠费14: "<span style='color:red'>0</span>",
                                户数15: "<span style='color:red'>0</span>",
                                欠费15: "<span style='color:red'>0</span>",
                                户数16: "<span style='color:red'>0</span>",
                                欠费16: "<span style='color:red'>0</span>",
                                户数17: "<span style='color:red'>0</span>",
                                欠费17: "<span style='color:red'>0</span>",

                                户数21: "<span style='color:red'>0</span>",
                                欠费21: "<span style='color:red'>0</span>",
                                户数22: "<span style='color:red'>0</span>",
                                欠费22: "<span style='color:red'>0</span>",
                                户数23: "<span style='color:red'>0</span>",
                                欠费23: "<span style='color:red'>0</span>",

                                户数31: "<span style='color:red'>0</span>",
                                欠费31: "<span style='color:red'>0</span>",
                                户数32: "<span style='color:red'>0</span>",
                                欠费32: "<span style='color:red'>0</span>",
                                户数33: "<span style='color:red'>0</span>",
                                欠费33: "<span style='color:red'>0</span>",
                                户数34: "<span style='color:red'>0</span>",
                                欠费34: "<span style='color:red'>0</span>",
                                户数35: "<span style='color:red'>0</span>",
                                欠费35: "<span style='color:red'>0</span>",
                                户数36: "<span style='color:red'>0</span>",
                                欠费36: "<span style='color:red'>0</span>",
                                户数37: "<span style='color:red'>0</span>",
                                欠费37: "<span style='color:red'>0</span>",
                                户数38: "<span style='color:red'>0</span>",
                                欠费38: "<span style='color:red'>0</span>",
                                户数39: "<span style='color:red'>0</span>",
                                欠费39: "<span style='color:red'>0</span>",
                                户数40: "<span style='color:red'>0</span>",
                                欠费40: "<span style='color:red'>0</span>",

                                户数41: "<span style='color:red'>0</span>",
                                欠费41: "<span style='color:red'>0</span>",
                                户数42: "<span style='color:red'>0</span>",
                                欠费42: "<span style='color:red'>0</span>",
                                户数43: "<span style='color:red'>0</span>",
                                欠费43: "<span style='color:red'>0</span>",
                                户数44: "<span style='color:red'>0</span>",
                                欠费44: "<span style='color:red'>0</span>",
                                户数45: "<span style='color:red'>0</span>",
                                欠费45: "<span style='color:red'>0</span>",
                                户数46: "<span style='color:red'>0</span>",
                                欠费46: "<span style='color:red'>0</span>",
                                户数47: "<span style='color:red'>0</span>",
                                欠费47: "<span style='color:red'>0</span>"
                            }
                        ]);
                        if (document.getElementById('IsInitLoad').value != "1") {
                            $.tool.DataPostNoLoading('CommFeesDebtsCutSearch_Stat', "LoadSumData", $('#frmForm').serialize(),
                                function Init() {
                                    //加载页脚
                                    $('#TableContainer').datagrid('reloadFooter', [
                                        {
                                            项目名称: "<span style='color:red'>累计合计</span>",
                                            户数总额: "<span style='color:red'>0</span>",
                                            欠费总额: "<span style='color:red'>0</span>",
                                            户数0: "<span style='color:red'>0</span>",
                                            欠费0: "<span style='color:red'>0</span>",
                                            户数1: "<span style='color:red'>0</span>",
                                            欠费1: "<span style='color:red'>0</span>",
                                            户数2: "<span style='color:red'>0</span>",
                                            欠费2: "<span style='color:red'>0</span>",
                                            户数3: "<span style='color:red'>0</span>",
                                            欠费3: "<span style='color:red'>0</span>",
                                            户数4: "<span style='color:red'>0</span>",
                                            欠费4: "<span style='color:red'>0</span>",
                                            户数5: "<span style='color:red'>0</span>",
                                            欠费5: "<span style='color:red'>0</span>",
                                            户数6: "<span style='color:red'>0</span>",
                                            欠费6: "<span style='color:red'>0</span>",
                                            户数7: "<span style='color:red'>0</span>",
                                            欠费7: "<span style='color:red'>0</span>",

                                            户数11: "<span style='color:red'>0</span>",
                                            欠费11: "<span style='color:red'>0</span>",
                                            户数12: "<span style='color:red'>0</span>",
                                            欠费12: "<span style='color:red'>0</span>",
                                            户数13: "<span style='color:red'>0</span>",
                                            欠费13: "<span style='color:red'>0</span>",
                                            户数14: "<span style='color:red'>0</span>",
                                            欠费14: "<span style='color:red'>0</span>",
                                            户数15: "<span style='color:red'>0</span>",
                                            欠费15: "<span style='color:red'>0</span>",
                                            户数16: "<span style='color:red'>0</span>",
                                            欠费16: "<span style='color:red'>0</span>",
                                            户数17: "<span style='color:red'>0</span>",
                                            欠费17: "<span style='color:red'>0</span>",

                                            户数21: "<span style='color:red'>0</span>",
                                            欠费21: "<span style='color:red'>0</span>",
                                            户数22: "<span style='color:red'>0</span>",
                                            欠费22: "<span style='color:red'>0</span>",
                                            户数23: "<span style='color:red'>0</span>",
                                            欠费23: "<span style='color:red'>0</span>",

                                            户数31: "<span style='color:red'>0</span>",
                                            欠费31: "<span style='color:red'>0</span>",
                                            户数32: "<span style='color:red'>0</span>",
                                            欠费32: "<span style='color:red'>0</span>",
                                            户数33: "<span style='color:red'>0</span>",
                                            欠费33: "<span style='color:red'>0</span>",
                                            户数34: "<span style='color:red'>0</span>",
                                            欠费34: "<span style='color:red'>0</span>",
                                            户数35: "<span style='color:red'>0</span>",
                                            欠费35: "<span style='color:red'>0</span>",
                                            户数36: "<span style='color:red'>0</span>",
                                            欠费36: "<span style='color:red'>0</span>",
                                            户数37: "<span style='color:red'>0</span>",
                                            欠费37: "<span style='color:red'>0</span>",
                                            户数38: "<span style='color:red'>0</span>",
                                            欠费38: "<span style='color:red'>0</span>",
                                            户数39: "<span style='color:red'>0</span>",
                                            欠费39: "<span style='color:red'>0</span>",
                                            户数40: "<span style='color:red'>0</span>",
                                            欠费40: "<span style='color:red'>0</span>",

                                            户数41: "<span style='color:red'>0</span>",
                                            欠费41: "<span style='color:red'>0</span>",
                                            户数42: "<span style='color:red'>0</span>",
                                            欠费42: "<span style='color:red'>0</span>",
                                            户数43: "<span style='color:red'>0</span>",
                                            欠费43: "<span style='color:red'>0</span>",
                                            户数44: "<span style='color:red'>0</span>",
                                            欠费44: "<span style='color:red'>0</span>",
                                            户数45: "<span style='color:red'>0</span>",
                                            欠费45: "<span style='color:red'>0</span>",
                                            户数46: "<span style='color:red'>0</span>",
                                            欠费46: "<span style='color:red'>0</span>",
                                            户数47: "<span style='color:red'>0</span>",
                                            欠费47: "<span style='color:red'>0</span>"
                                        }
                                    ]);
                                },
                                function callback(_Data) {
                                    var Data = eval("(" + _Data + ")"); //转换为json对象
                                    if (Data.rows.length > 0) {
                                        var obj = Data.rows[0];
                                        //加载页脚
                                        $('#TableContainer').datagrid('reloadFooter', [
                                            {
                                                项目名称: "<span style='color:red'>累计合计</span>",
                                                户数总额: "<span style='color:red'>" + obj["户数总额"] + "</span>",
                                                欠费总额: "<span style='color:red'>" + obj["欠费总额"] + "</span>",
                                                户数0: "<span style='color:red'>" + obj["户数0"] + "</span>",
                                                欠费0: "<span style='color:red'>" + obj["欠费0"] + "</span>",
                                                户数1: "<span style='color:red'>" + obj["户数1"] + "</span>",
                                                欠费1: "<span style='color:red'>" + obj["欠费1"] + "</span>",
                                                户数2: "<span style='color:red'>" + obj["户数2"] + "</span>",
                                                欠费2: "<span style='color:red'>" + obj["欠费2"] + "</span>",
                                                户数3: "<span style='color:red'>" + obj["户数3"] + "</span>",
                                                欠费3: "<span style='color:red'>" + obj["欠费3"] + "</span>",
                                                户数4: "<span style='color:red'>" + obj["户数4"] + "</span>",
                                                欠费4: "<span style='color:red'>" + obj["欠费4"] + "</span>",
                                                户数5: "<span style='color:red'>" + obj["户数5"] + "</span>",
                                                欠费5: "<span style='color:red'>" + obj["欠费5"] + "</span>",
                                                户数6: "<span style='color:red'>" + obj["户数6"] + "</span>",
                                                欠费6: "<span style='color:red'>" + obj["欠费6"] + "</span>",
                                                户数7: "<span style='color:red'>" + obj["户数7"] + "</span>",
                                                欠费7: "<span style='color:red'>" + obj["欠费7"] + "</span>",

                                                户数11: "<span style='color:red'>" + obj["户数11"] + "</span>",
                                                欠费11: "<span style='color:red'>" + obj["欠费11"] + "</span>",
                                                户数12: "<span style='color:red'>" + obj["户数12"] + "</span>",
                                                欠费12: "<span style='color:red'>" + obj["欠费12"] + "</span>",
                                                户数13: "<span style='color:red'>" + obj["户数13"] + "</span>",
                                                欠费13: "<span style='color:red'>" + obj["欠费13"] + "</span>",
                                                户数14: "<span style='color:red'>" + obj["户数14"] + "</span>",
                                                欠费14: "<span style='color:red'>" + obj["欠费14"] + "</span>",
                                                户数15: "<span style='color:red'>" + obj["户数15"] + "</span>",
                                                欠费15: "<span style='color:red'>" + obj["欠费15"] + "</span>",
                                                户数16: "<span style='color:red'>" + obj["户数16"] + "</span>",
                                                欠费16: "<span style='color:red'>" + obj["欠费16"] + "</span>",
                                                户数17: "<span style='color:red'>" + obj["户数17"] + "</span>",
                                                欠费17: "<span style='color:red'>" + obj["欠费17"] + "</span>",

                                                户数21: "<span style='color:red'>" + obj["户数21"] + "</span>",
                                                欠费21: "<span style='color:red'>" + obj["欠费21"] + "</span>",
                                                户数22: "<span style='color:red'>" + obj["户数22"] + "</span>",
                                                欠费22: "<span style='color:red'>" + obj["欠费22"] + "</span>",
                                                户数23: "<span style='color:red'>" + obj["户数23"] + "</span>",
                                                欠费23: "<span style='color:red'>" + obj["欠费23"] + "</span>",

                                                户数31: "<span style='color:red'>" + obj["户数31"] + "</span>",
                                                欠费31: "<span style='color:red'>" + obj["欠费31"] + "</span>",
                                                户数32: "<span style='color:red'>" + obj["户数32"] + "</span>",
                                                欠费32: "<span style='color:red'>" + obj["欠费32"] + "</span>",
                                                户数33: "<span style='color:red'>" + obj["户数33"] + "</span>",
                                                欠费33: "<span style='color:red'>" + obj["欠费33"] + "</span>",
                                                户数34: "<span style='color:red'>" + obj["户数34"] + "</span>",
                                                欠费34: "<span style='color:red'>" + obj["欠费34"] + "</span>",
                                                户数35: "<span style='color:red'>" + obj["户数35"] + "</span>",
                                                欠费35: "<span style='color:red'>" + obj["欠费35"] + "</span>",
                                                户数36: "<span style='color:red'>" + obj["户数36"] + "</span>",
                                                欠费36: "<span style='color:red'>" + obj["欠费36"] + "</span>",
                                                户数37: "<span style='color:red'>" + obj["户数37"] + "</span>",
                                                欠费37: "<span style='color:red'>" + obj["欠费37"] + "</span>",
                                                户数38: "<span style='color:red'>" + obj["户数38"] + "</span>",
                                                欠费38: "<span style='color:red'>" + obj["欠费38"] + "</span>",
                                                户数39: "<span style='color:red'>" + obj["户数39"] + "</span>",
                                                欠费39: "<span style='color:red'>" + obj["欠费39"] + "</span>",
                                                户数40: "<span style='color:red'>" + obj["户数40"] + "</span>",
                                                欠费40: "<span style='color:red'>" + obj["欠费40"] + "</span>",

                                                户数41: "<span style='color:red'>" + obj["户数41"] + "</span>",
                                                欠费41: "<span style='color:red'>" + obj["欠费41"] + "</span>",
                                                户数42: "<span style='color:red'>" + obj["户数42"] + "</span>",
                                                欠费42: "<span style='color:red'>" + obj["欠费42"] + "</span>",
                                                户数43: "<span style='color:red'>" + obj["户数43"] + "</span>",
                                                欠费43: "<span style='color:red'>" + obj["欠费43"] + "</span>",
                                                户数44: "<span style='color:red'>" + obj["户数44"] + "</span>",
                                                欠费44: "<span style='color:red'>" + obj["欠费44"] + "</span>",
                                                户数45: "<span style='color:red'>" + obj["户数45"] + "</span>",
                                                欠费45: "<span style='color:red'>" + obj["欠费45"] + "</span>",
                                                户数46: "<span style='color:red'>" + obj["户数46"] + "</span>",
                                                欠费46: "<span style='color:red'>" + obj["欠费46"] + "</span>",
                                                户数47: "<span style='color:red'>" + obj["户数47"] + "</span>",
                                                欠费47: "<span style='color:red'>" + obj["欠费47"] + "</span>"

                                            }
                                        ]);
                                    }
                                },
                                function completeCallback() {
                                },
                                function errorCallback() {
                                    //加载页脚
                                    $('#TableContainer').datagrid('reloadFooter', [
                                        {
                                            项目名称: "<span style='color:red'>累计合计</span>",
                                            户数总额: "<span style='color:red'>0</span>",
                                            欠费总额: "<span style='color:red'>0</span>",
                                            户数0: "<span style='color:red'>0</span>",
                                            欠费0: "<span style='color:red'>0</span>",
                                            户数1: "<span style='color:red'>0</span>",
                                            欠费1: "<span style='color:red'>0</span>",
                                            户数2: "<span style='color:red'>0</span>",
                                            欠费2: "<span style='color:red'>0</span>",
                                            户数3: "<span style='color:red'>0</span>",
                                            欠费3: "<span style='color:red'>0</span>",
                                            户数4: "<span style='color:red'>0</span>",
                                            欠费4: "<span style='color:red'>0</span>",
                                            户数5: "<span style='color:red'>0</span>",
                                            欠费5: "<span style='color:red'>0</span>",
                                            户数6: "<span style='color:red'>0</span>",
                                            欠费6: "<span style='color:red'>0</span>",
                                            户数7: "<span style='color:red'>0</span>",
                                            欠费7: "<span style='color:red'>0</span>",

                                            户数11: "<span style='color:red'>0</span>",
                                            欠费11: "<span style='color:red'>0</span>",
                                            户数12: "<span style='color:red'>0</span>",
                                            欠费12: "<span style='color:red'>0</span>",
                                            户数13: "<span style='color:red'>0</span>",
                                            欠费13: "<span style='color:red'>0</span>",
                                            户数14: "<span style='color:red'>0</span>",
                                            欠费14: "<span style='color:red'>0</span>",
                                            户数15: "<span style='color:red'>0</span>",
                                            欠费15: "<span style='color:red'>0</span>",
                                            户数16: "<span style='color:red'>0</span>",
                                            欠费16: "<span style='color:red'>0</span>",
                                            户数17: "<span style='color:red'>0</span>",
                                            欠费17: "<span style='color:red'>0</span>",

                                            户数21: "<span style='color:red'>0</span>",
                                            欠费21: "<span style='color:red'>0</span>",
                                            户数22: "<span style='color:red'>0</span>",
                                            欠费22: "<span style='color:red'>0</span>",
                                            户数23: "<span style='color:red'>0</span>",
                                            欠费23: "<span style='color:red'>0</span>",

                                            户数31: "<span style='color:red'>0</span>",
                                            欠费31: "<span style='color:red'>0</span>",
                                            户数32: "<span style='color:red'>0</span>",
                                            欠费32: "<span style='color:red'>0</span>",
                                            户数33: "<span style='color:red'>0</span>",
                                            欠费33: "<span style='color:red'>0</span>",
                                            户数34: "<span style='color:red'>0</span>",
                                            欠费34: "<span style='color:red'>0</span>",
                                            户数35: "<span style='color:red'>0</span>",
                                            欠费35: "<span style='color:red'>0</span>",
                                            户数36: "<span style='color:red'>0</span>",
                                            欠费36: "<span style='color:red'>0</span>",
                                            户数37: "<span style='color:red'>0</span>",
                                            欠费37: "<span style='color:red'>0</span>",
                                            户数38: "<span style='color:red'>0</span>",
                                            欠费38: "<span style='color:red'>0</span>",
                                            户数39: "<span style='color:red'>0</span>",
                                            欠费39: "<span style='color:red'>0</span>",
                                            户数40: "<span style='color:red'>0</span>",
                                            欠费40: "<span style='color:red'>0</span>",

                                            户数41: "<span style='color:red'>0</span>",
                                            欠费41: "<span style='color:red'>0</span>",
                                            户数42: "<span style='color:red'>0</span>",
                                            欠费42: "<span style='color:red'>0</span>",
                                            户数43: "<span style='color:red'>0</span>",
                                            欠费43: "<span style='color:red'>0</span>",
                                            户数44: "<span style='color:red'>0</span>",
                                            欠费44: "<span style='color:red'>0</span>",
                                            户数45: "<span style='color:red'>0</span>",
                                            欠费45: "<span style='color:red'>0</span>",
                                            户数46: "<span style='color:red'>0</span>",
                                            欠费46: "<span style='color:red'>0</span>",
                                            户数47: "<span style='color:red'>0</span>",
                                            欠费47: "<span style='color:red'>0</span>"
                                        }
                                    ]);
                                });
                        }
                    },
                    rowStyler: function (index, row) {
                        return 'height:20px;';
                    }
                });
            }

            //重写DataGrid,支持更改页脚样式
            var myview = $.extend({}, $.fn.datagrid.defaults.view, {
                renderFooter: function (target, container, frozen) {
                    var opts = $.data(target, 'datagrid').options;
                    var rows = $.data(target, 'datagrid').footer || [];
                    var fields = $(target).datagrid('getColumnFields', frozen);
                    var table = ['<table class="datagrid-ftable" cellspacing="0" cellpadding="0" border="0"><tbody>'];

                    for (var i = 0; i < rows.length; i++) {
                        var styleValue = opts.rowStyler ? opts.rowStyler.call(target, i, rows[i]) : '';
                        var style = styleValue ? 'style="' + styleValue + '"' : '';
                        table.push('<tr class="datagrid-row" datagrid-row-index="' + i + '"' + style + '>');
                        table.push(this.renderRow.call(this, target, fields, frozen, i, rows[i]));
                        table.push('</tr>');
                    }
                    table.push('</tbody></table>');
                    $(container).html(table.join(''));
                }
            });

            //获取进度
            function TakeProgress() {
                $.tool.DataPostNoLoading('CommFeesDebtsCutSearch_Stat', 'TakeProgress', $('#frmForm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                        var Obj = JSON.parse(_Data);
                        if (_Data == '[]') {
                            LoadData();
                            CloseProgress();
                        }
                        else {
                            SetProgress(Obj);
                            if (Obj[0].Curr == '100') {
                                $('#hiIsSQLData').val('1');
                                LoadData();
                                CloseProgress();
                            }
                            else {
                            }
                        }
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            }

            //显示进度
            function ShowProgress() {
                var h = parseInt($(window).height()) + parseInt($(window).scrollTop());
                var ht = parseInt($(window).scrollTop());
                $(".datagrid-mask").css({ display: "block", width: "100%", height: h });
                $(".datagrid-mask-msg").css({ display: "block", left: ($(document.body).outerWidth(true) - 350) / 2, top: ht + 240 });
            }
            //关闭进度
            function CloseProgress() {
                clearInterval(ProgressInterval);
                $(".datagrid-mask").hide();
                $(".datagrid-mask-msg").hide();
            }
            //设置进度
            function SetProgress(Obj) {
                $('#DivProgressBar').progressbar('setValue', Obj[0].Curr);
                $('#DivMsg').html(Obj[0].MessageInfo);
            }

            function formatNumberRgx(num) {
                var parts = num.toString().split(".");
                parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                return parts.join(".");
            };
        </script>
    </form>
</body>
</html>
