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

<!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>
    <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" />
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />
    <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>
    <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 type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <script type="text/javascript" src="../jscript/export.js"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
</head>
<body style="overflow: hidden">
    <form id="frmForm" runat="server">
        <input id="IsFirstLoad" type="hidden" name="IsFirstLoad" value="1" runat="server" />
        <input id="hidCommId" type="hidden" name="hidCommId" value="" runat="server" />
        <input id="CommIds" type="hidden" name="CommIds" value="" 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: 680px; height: 240px; padding: 10px;">
            <table class="DialogTable" id="SearchTable">
                <tr>
                    <td class="TdTitle">收款年月</td>
                    <td class="TdContentSearch">
                        <input type="text" class="Wdate" style="width: 163px;" id="ChargeDate" onclick="WdatePicker({ dateFmt: 'yyyy-MM' })" runat="server" name="ChargeDate" />
                    </td>
                    <td class="TdTitle">收款方式</td>
                    <td class="TdContentSearch">
                        <select class="easyui-combobox" id="SelChargeMode" name="SelChargeMode" paneimaxheight="100px" runat="server" data-options="editable:false,panelHeight:'135px',multiple:true,">
                            <option selected></option>
                        </select>
                        <input type="hidden" id="ChargeMode" name="ChargeMode" />
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">管理项目</td>
                    <td class="TdContentSearch" colspan="3">
                        <textarea onclick="SelComm()" name="CommNames" id="CommNames" style="width: 91.7%; height: 60px; border: 1px solid #cccccc; font-size: 12px; padding: 2px; resize: none;" runat="server"></textarea>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" align="center"><a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick=" JavaScript:ExcuteStatistics(); ">统计</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>

        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                InitTableHeight();
                LoadList();
            });

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

            function SelComm() {
                if ($("#hidCommId").val() != '')
                    return;

                HDialog.Open(700, 400, '../DialogNew/SelComm.aspx?IsCheck=1', "选择管理项目", false, function callback(_Data) {
                    var arrRet = JSON.parse(_Data);
                    $("#CommIds").val(arrRet.id);
                    $("#CommNames").val(arrRet.name);
                });
            }

            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.open('./ChargeDailyReportByDay_Export.aspx');
                        }
                    }
                }
            ]

            var frozenColumns = [[
                { field: '管理单位', title: '管理单位', align: 'center', sortable: true, width: 280 },
                { field: '科目分类', title: '科目分类', align: 'center', sortable: true, width: 180 },
                {
                    field: '合计', title: '合计', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                }
            ]];

            var columns = [[
                {
                    field: 'day_1', title: '1日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_2', title: '2日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_3', title: '3日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_4', title: '4日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_5', title: '5日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_6', title: '6日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_7', title: '7日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_8', title: '8日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_9', title: '9日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_10', title: '10日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_11', title: '11日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_12', title: '12日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_13', title: '13日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_14', title: '14日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_15', title: '15日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_16', title: '16日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_17', title: '17日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_18', title: '18日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_19', title: '19日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_20', title: '20日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_21', title: '21日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_22', title: '22日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_23', title: '23日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_24', title: '24日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_25', title: '25日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_26', title: '26日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_27', title: '27日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_28', title: '28日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_29', title: '29日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_30', title: '30日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'day_31', title: '31日', align: 'center', sortable: true, width: 100, formatter: function (value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
            ]];

            function LoadList() {
                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    title: '',
                    nowrap: false,
                    pageSize: 200,
                    pageList: [200, 500, 800, 1000, 2000],
                    columns: columns,
                    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("ChargeDailyReportByDay", "LoadData", "TableContainer", param);
                    },
                    onLoadSuccess: function (data) { }
                });
            }

            var ProgressInterval;

            function ExcuteStatistics() {
                if ($("#ChargeDate").val() == '') {
                    HDialog.Info("请选择收款时间!");
                    return;
                }

                //if ($("#CommIds").val() == '') {
                //    HDialog.Info("请选择管理项目!");
                //    return;
                //}

                $("#ChargeMode").val($("#SelChargeMode").combobox('getValues'));

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

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

            //获取进度
            function TakeProgress() {
                $.tool.DataPostNoLoading('ChargeDailyReportByDay', 'TakeProgress', $('#frmForm').serialize(),
                    function Init() { },
                    function callback(_Data) {
                        var obj = JSON.parse(_Data);
                        if (obj.code == 200) {
                            if (obj.data == null || obj.data.length == 0) {
                                LoadList();
                                CloseProgress();
                            } else {
                                SetProgress(obj.data);
                                if (obj.data[0].Curr == 100) {
                                    $("#IsFirstLoad").val(0);
                                    LoadList();
                                    CloseProgress();
                                }
                            }
                        } else {
                            LoadList();
                            CloseProgress();
                        }
                    },
                    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) {
                var i = parseInt(Obj[0].Curr);
                $('#DivProgressBar').progressbar('setValue', Obj[0].Curr);
                $('#DivMsg').html(Obj[0].MessageInfo);
            }
        </script>
    </form>
</body>
</html>
