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

<!DOCTYPE html>

<html>
<head>
    <title></title>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="../jscript/jquery.tool.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>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />
    <script src="../jscript/format.js" type="text/javascript"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
    <script src="../jscript/export.js"></script>

    <style type="text/css">
        #SearchDlg {
            padding: 10px;
            width: 700px;
            height: 230px;
        }

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

            .SearchTable .TdTitle {
                width: 15%;
            }

            .SearchTable .TdContent {
                width: 35%;
            }

        #CostNames {
            width: 550px;
            height: 30px;
            border: 1px solid #cccccc;
            font-size: 12px;
            padding: 2px;
            resize: none;
        }

        #CommNames {
            width: 550px;
            height: 60px;
            border: 1px solid #cccccc;
            font-size: 12px;
            padding: 2px;
            resize: none;
        }
    </style>

</head>
<body scroll="no">
    <form id="ContFees" runat="server">
        <div style="width: 100%; background-color: #cccccc;" id="TableContainer"></div>

        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true" style="width: 820px; height: 260px; padding: 10px;">
            <table style="width: 100%; overflow: hidden;" class="DialogTable">

                <tr>
                    <td class="TdTitle" style="width: 200px;">管理项目</td>
                    <td class="TdContentSearch" colspan="3">
                        <textarea id="CommNames" name="CommNames" runat="server" onclick="SelCommInfo();"></textarea>
                        <input id="CommIDs" type="hidden"
                            name="CommIDs" runat="server"></td>
                </tr>
                <tr>
                    <td class="TdTitle">费用项目</td>
                    <td class="TdContentSearch" colspan="3">
                        <input class="easyui-searchbox" searcher="SelCost" id="CostNames"
                            name="CostNames" runat="server" /><input id="CorpCostIDs" type="hidden"
                                name="CorpCostIDs" runat="server" /></td>
                </tr>
                <tr>
                    <td class="TdTitle">收款时间从</td>
                    <td class="TdContentSearch">
                        <input type="text" class="Wdate" style="width: 163px;" onclick="WdatePicker({ startDate: '%y-%M-01 00:00:00', dateFmt: 'yyyy-MM-dd HH:mm:ss', alwaysUseStartDate: true })" id="ChargeBeginDate" runat="server" name="ChargeBeginDate" /></td>
                    <td class="TdTitle">到</td>
                    <td class="TdContentSearch">
                        <input type="text" class="Wdate" style="width: 163px;" runat="server" onclick="WdatePicker({ startDate: '%y-%M-01 23:59:59', dateFmt: 'yyyy-MM-dd HH:mm:ss', alwaysUseStartDate: true })" id="ChargeEndDate" name="ChargeEndDate" /></td>
                </tr>
                <tr>
                    <%--<td class="TdTitle">费用年度
                    </td>
                    <td class="TdContent">
                        <input id="ChargeYear" name="ChargeYear" onclick="WdatePicker({ readOnly: true, dateFmt: 'yyyy '})" runat="server" />
                    </td>--%>

                    <td class="TdTitle">费用时间从</td>
                    <td class="TdContentSearch">
                        <input type="text" class="Wdate" style="width: 163px;" onclick="WdatePicker({ startDate: '%y-%M-01 00:00:00', dateFmt: 'yyyy-MM-dd HH:mm:ss', alwaysUseStartDate: true })" id="FeedDueBeginDate" runat="server" name="FeedDueBeginDate" /></td>
                    <td class="TdTitle">到</td>
                    <td class="TdContentSearch">
                        <input type="text" class="Wdate" style="width: 163px;" runat="server" onclick="WdatePicker({ startDate: '%y-%M-01 23:59:59', dateFmt: 'yyyy-MM-dd HH:mm:ss', alwaysUseStartDate: true })" id="FeedDueEndDate" name="FeedDueEndDate" /></td>
                </tr>


                <tr>
                    <td colspan="4" style="text-align: center">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="JavaScript:ExcuteOnServer();">统计</a>
                    </td>
                </tr>
            </table>
        </div>


        <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>
        <input type="hidden" id="IsFirstLoad" name="IsFirstLoad" value="1" runat="server" />
        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">

            $(function () {

            });

            function InitTableHeight() {
                var h = $(window).height();
                $("#TableContainer").css("height", h + "px");
            }

            InitTableHeight();
            var frozenColumns = [[
                { field: 'OrganName', title: '区域', align: 'left', sortable: true, width: 120 },
                { field: 'CommName', title: '项目名称', align: 'left', sortable: true, width: 120 },
                { field: 'RegionName', title: '公司名称', align: 'center', sortable: true, width: 120 },
                { field: 'PartnerName', title: '合作方名称', align: 'center', sortable: true, width: 120 }
            ]];
            var column = [
                [
                    { field: 'ContStartDate', title: '合同开始时间', align: 'center', sortable: true, width: 120, colspan: 1, rowspan: 2 },
                    { field: 'ContEndDate', title: '合同结束时间', align: 'center', sortable: true, width: 120, colspan: 1, rowspan: 2 },
                    { field: 'CostName', title: '费项', align: 'center', sortable: true, width: 120, colspan: 1, rowspan: 2 },
                    { field: '期初金蝶账面应收账款余额', title: '期初金蝶账面应收账款余额', align: 'center', sortable: true, width: 80, colspan: 1, rowspan: 2, width: 120 },

                    { colspan: 4, field: '本年费用', title: '本期费用', align: 'center' },

                    { colspan: 4, field: '往年费用', title: '往期费用', align: 'center' },

                    { colspan: 2, field: '已开票金额', title: '已开票金额', align: 'center' },

                    { colspan: 3, field: '已开票未回款金额', title: '已开票未回款金额', align: 'center' },


                    { field: '往年应收未开票金额', title: '往欠应收未开票金额', align: 'center', sortable: true, width: 120, colspan: 1, rowspan: 2 },
                    { field: '期末金蝶账面应收账款余额', title: '期末金蝶账面应收账款余额', align: 'center', sortable: true, width: 120, colspan: 1, rowspan: 2 },
                    { field: '税率', title: '税率', align: 'center', sortable: true, width: 80, colspan: 1, rowspan: 2 },
                    { field: '不含税开票收入', title: '不含税开票收入', align: 'center', sortable: true, width: 80, colspan: 1, rowspan: 2 },

                    { colspan: 2, field: '对应金蝶科目', title: '对应金蝶科目', align: 'center' },
                ]
                , [
                    { field: '本年应收', title: '本期应收', align: 'center', sortable: true, width: 120 },
                    { field: '本年实收', title: '本期实收', align: 'center', sortable: true, width: 120 },
                    { field: '本年未收', title: '本期未收', align: 'center', sortable: true, width: 120 },
                    { field: '本年收费率', title: '收费率', align: 'center', sortable: true, width: 120 },

                    { field: '往年应收', title: '往期应收', align: 'center', sortable: true, width: 80 },
                    { field: '往年实收', title: '往期实收', align: 'center', sortable: true, width: 80 },
                    { field: '往年未收', title: '往期未收', align: 'center', sortable: true, width: 80 },
                    { field: '往年收费率', title: '收费率', align: 'center', sortable: true, width: 80 },

                    { field: '本年已开当年', title: '本期已开当年', align: 'center', sortable: true, width: 80 },
                    { field: '本年已开往年', title: '本期已开往年', align: 'center', sortable: true, width: 80 },

                    { field: '本年已开本年未回款', title: '本期已开本年未回款', align: 'center', sortable: true, width: 100 },
                    { field: '本年已开往年未回款', title: '本期已开往年未回款', align: 'center', sortable: true, width: 100 },
                    { field: '去年已开票未回款', title: '去年已开票未回款', align: 'center', sortable: true, width: 100 },

                    { field: '对应金蝶科目', title: '科目', align: 'center', sortable: true, width: 80 },
                    { field: '对应金蝶金额', title: '金额', align: 'center', 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 = "../ChargesNew/ContChargeFeesSummaryToExcel.aspx";
                        }
                    }
                }
            ];



        </script>

        <script type="text/javascript">
            var ProgressInterval;
            function ExcuteOnServer() {
                var tmpCommID = $('#CommIDs').val();
                if (tmpCommID == '') {
                    HDialog.Info('请选择管理项目！');
                    return false;
                }
                $("#SearchDlg").dialog("close");
                //启动任务
                StartTask();
                //展示进度
                ShowProgress();
                //获取执行情况进度
                ProgressInterval = setInterval("TakeProgress()", 1000);
            }

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

            function LoadList(page, rows) {
                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    title: '',
                    nowrap: false,
                    pageSize: 200,
                    pageList: [200, 500, 800, 1000, 2000],
                    columns: column,
                    frozenColumns: frozenColumns,
                    fitColumns: false,
                    remoteSort: false,
                    pagination: true,
                    width: "100%",
                    toolbar: toolbar,
                    sortOrder: "asc",
                    singleSelect: true,
                    selectOnCheck: false,
                    checkOnSelect: false,
                    rownumbers: true,
                    border: false,
                    sortOrder: "asc",
                    onBeforeLoad: function (param) {
                        param = $.JQForm.GetParam("ContChargeFeesSummary", "LoadData", "TableContainer", param);
                    },
                    onLoadSuccess: function (data) {

                    }
                });

            }

            LoadList(1, 500);

            //获取进度
            function TakeProgress() {
                $.tool.DataPostNoLoading('ContChargeFeesSummary', 'TakeProgress', $('#ContFees').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                        var Obj = JSON.parse(_Data);
                        if (_Data == '[]') {
                            LoadList(1, 500);
                            CloseProgress();
                        }
                        else {
                            SetProgress(Obj);

                            if (Obj[0].Curr == '100') {
                                LoadList(1, 500);
                                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) - 250) / 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 SelCommInfo() {
                var w = $(window).width() * 0.8;
                var h = $(window).height() * 0.8;
                HDialog.Open(w, h, '../DialogNew/SelComm.aspx?IsCheck=1&isCommID=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");

                        $('#CorpCostIDs').val(varObjects[0]);
                        $('#CostNames').searchbox('setValue', varObjects[1]);
                    }

                });

            }

        </script>

    </form>
</body>
</html>


