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

<!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>（3）预存费用统计表（T+1）</title>
    <link href="/HM/M_Main/css/base.css" rel="stylesheet" />
    <link href="/HM/M_Main/css/button.css" rel="stylesheet" />
    <link href="/HM/M_Main/Jscript-Ui/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="/HM/M_Main/Jscript-Ui/jquery-easyui-1.7.6/themes/bootstrap/easyui.css" />
    <link rel="stylesheet" type="text/css" href="/HM/M_Main/Jscript-Ui/jquery-easyui-1.4.4/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="/HM/M_Main/Jscript-Ui/jquery-easyui-1.7.6/themes/color.css" />
    <script type="text/javascript" src="/HM/M_Main/Jscript-Ui/jquery-easyui-1.7.6/jquery.min.js"></script>
    <script type="text/javascript" src="/HM/M_Main/Jscript-Ui/jquery-easyui-1.7.6/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/HM/M_Main/Jscript-Ui/jquery-easyui-1.7.6/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/HM/M_Main/Jscript-Ui/jquery-easyui-1.4.4/jquery.extend.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>
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <style type="text/css">
        .dlg_table tr td.title {
            width: 12%;
            text-align: right;
            color: #7f7f7f;
        }

        .dlg_table tr td.text {
            width: 20%;
            text-align: left;
        }

        .textbox-label {
            cursor: pointer;
        }

        .datagrid-mask-msg {
            height: 40px;
        }
    </style>
</head>
<body style="margin: 0px; padding: 0px; overflow: hidden;">
    <table id="TableContainer" style="width: 100%; height: 100%; background-color: #cccccc;"></table>
    <div id="dlg_search" class="easyui-dialog" title="筛选" style="width: 600px; padding: 5px;" data-options="iconCls:'icon-search',modal:true,closed:true">
        <form id="frm">
            <table class="dlg_table" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="title">项目名称</td>
                    <td class="text" colspan="3">
                        <input type="text" id="CommName" name="CommName" class="easyui-textbox" runat="server"
                            data-options="prompt:'请单击右侧\'放大镜\'按钮!',editable:false,tipPosition:'bottom',width:'96%',height:'50px',multiline:true,required:true,
                                        buttonText:'',buttonIcon:'icon-search',onClickButton:function(){SelComm();}" />
                        <input type="hidden" id="CommID" name="CommID" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="title"><span>费用科目</span></td>
                    <td class="text" colspan="3">
                        <input type="text" id="CorpCostNames" name="CorpCostNames" class="easyui-textbox" runat="server"
                            data-options="prompt:'请单击右侧\'放大镜\'按钮!',editable:false,tipPosition:'bottom',width:'96%',height:'50px',multiline:true,required:false,
                                        buttonText:'',buttonIcon:'icon-search',onClickButton:function(){SelCost();}" />
                        <input type="hidden" id="CorpCostIds" name="CorpCostIds" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="title"><span>收款时间</span></td>
                    <td class="text">
                        <input type="text" id="ChargeStartDate" name="ChargeStartDate" class="easyui-datebox" runat="server" data-options="editable:false,required:true" />
                    </td>
                    <td class="title"><span>至</span></td>
                    <td class="text">
                        <input type="text" id="ChargeEndDate" name="ChargeEndDate" class="easyui-datebox" runat="server" data-options="editable:false,required:true" />
                    </td>
                </tr>
                <tr>
                    <td class="title">房屋状态</td>

                    <td class="text" colspan="3">
                        <input type="text" id="StateNames" name="StateNames" class="easyui-textbox" runat="server"
                            data-options="prompt:'请单击右侧\'放大镜\'按钮!',editable:false,tipPosition:'bottom',width:'96%',height:'50px',multiline:true,required:false,
                       buttonText:'',buttonIcon:'icon-search',onClickButton:function(){SelStateName();}" />
                        <input id="RoomStates" name="RoomStates" runat="server" value="" type="hidden" />
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center" class="text" colspan="4">
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',width:80" onclick="StartTask();">统计</a>
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',width:80" onclick="ClearWhere()">清空</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <script type="text/javascript">
        //选择项目
        function SelComm() {
            var w = $(window).width() * 0.7;
            HDialog.Open(w, 500, '../DialogNew/SelComm.aspx?IsCheck=1', "选择管理项目", false, function callback(_Data) {
                if (_Data) {
                    var arrRet = JSON.parse(_Data);
                    $("#CommID").val(arrRet.id);
                    $("#CommName").textbox('setValue', 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");
                    $('#CorpCostIds').val(varObjects[0]);
                    $('#CorpCostNames').textbox('setValue', varObjects[1]);
                }
            });
        }


        //选择交房状态
        function SelStateName() {
            HDialog.Open('700', '450', "../dialogNew/RoomStateDlg.aspx",
                '交房状态选择', false, function (_data) {
                    var varReturn = _data;
                    if (varReturn != "") {//**获得返回 刷新
                        var varObjects = varReturn.split("\t");
                        $('#StateNames').textbox('setValue', varObjects[0]);
                        $("#RoomStates").val(varObjects[1]);
                    }
                });
        }

        function ClearWhere() {
            $('#frm').form('clear');
        }

        var column = [
            [

                { field: 'OrganName', title: '管理单位', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 150 },
                { field: 'CommName', title: '项目名称', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 150 },
                {
                    field: 'StartDate', title: '预收费用起算日期', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return formatDate(value, "yyyy-MM-dd");
                    }
                },
                { field: '全年应收金额', title: '全年应收金额', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: 'Targetamount', title: '目标金额<br/>(1)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: '本期预收金额', title: '本期预收金额<br/>(2)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: '本期退款后期金额', title: '本期退款后期金额<br/>(3)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: '本期预存金额', title: '本期预存金额<br/>(4)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: '本期预存退款金额', title: '本期预存退款金额<br/>(5)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: '预收户数分析', title: '预收户数分析', colspan: 7, align: 'center', sortable: true, width: 140 },
                { field: '预收金额分析', title: '预收金额分析', colspan: 7, align: 'center', sortable: true, width: 140 },
                { field: '完成金额', title: '完成金额<br/>(6=2-3+4-5)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 },
                { field: '完成率', title: '完成率<br/>(7=6/1)', colspan: 1, rowspan: 2, align: 'center', sortable: true, width: 140 }
            ],
            [
                { field: '预收1至3月户数', title: '预收1至3月户数', align: 'center', width: 100 },
                { field: '预收4至6月户数', title: '预收4至6月户数', align: 'center', width: 100 },
                { field: '预收7至9月户数', title: '预收7至9月户数', align: 'center', width: 100 },
                { field: '预收10至12月户数', title: '预收10至12月户数', align: 'center', width: 100 },
                { field: '预收1至2年户数', title: '预收1至2年户数', align: 'center', width: 100 },
                { field: '预收2至3年户数', title: '预收2至3年户数', align: 'center', width: 100 },
                { field: '预收3年以上户数', title: '预收3年以上户数', align: 'center', width: 100 },

                { field: '预收1至3月金额', title: '预收1至3月金额', align: 'center', width: 100 },
                { field: '预收4至6月金额', title: '预收4至6月金额', align: 'center', width: 100 },
                { field: '预收7至9月金额', title: '预收7至9月金额', align: 'center', width: 100 },
                { field: '预收10至12月金额', title: '预收10至12月金额', align: 'center', width: 100 },
                { field: '预收1至2年金额', title: '预收1至2年金额', align: 'center', width: 100 },
                { field: '预收2至3年金额', title: '预收2至3年金额', align: 'center', width: 100 },
                { field: '预收3年以上金额', title: '预收3年以上金额', align: 'center', width: 100 }

            ]
        ];

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

        function StartTask() {
            if ($('#frm').form("validate")) {
                $("#dlg_search").dialog("close");
                //启动一个任务
                $.tool.DataPost('PreTargetReport', 'StartTask', $('#frm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                        if (_Data == "true") {
                            LoadData();
                        }
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            }
        }

        //加载数据
        function LoadData() {
            //加载已经统计了的数据
            $("#TableContainer").datagrid({
                url: '/HM/M_Main/HC/DataPostControl.aspx',
                method: "post",
                fitColumns: false,
                nowrap: true,
                pageSize: [100],
                pageList: [100, 200, 500, 1000],
                columns: column,
                singleSelect: true,
                pagination: true,
                remoteSort: false,
                rownumbers: true,
                toolbar: toolbar,
                border: false,
                fit: true,
                width: "100%",
                onLoadSuccess: function (data) {
                    $.tool.MergeEasyUiGrid("TableContainer", "OrganName");
                },
                onBeforeLoad: function (param) {
                    param = $.JQForm.GetParam("PreTargetReport", "LoadData", "TableContainer", param);
                },
                rowStyler: function (index, row) {
                }
            });
            $("#dlg_search").dialog("close");
        }


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

        $(function () {
            LoadData();
        });

    </script>
</body>
</html>


