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

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="../jscript/DateControl.js"></script>
    <script type="text/javascript" src="../jscript/JSClient.js"></script>
    <script type="text/javascript" src="../jscript/ajax.js"></script>
    <script type="text/javascript" src="../jscript/Keydown.js" event="onkeydown" for="document"></script>

    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="../jscript/JSClient.js" type="text/javascript"></script>
    <script src="../jscript/jquery.tool.new.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/base.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>

    <link href="../css/button.css" rel="stylesheet" />
    <script src="../jscript/DateFormat.js" type="text/javascript"></script>
    <script src="../jscript/format.js" type="text/javascript"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
</head>
<body>
    <form id="frmForm" runat="server">


        <input type="hidden" id="unFreeze" name="unFreeze" runat="server" />
        <input type="hidden" id="AllFees" name="AllFees" runat="server" />

        <div class="SearchContainer" id="TableContainer">
        </div>
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 700px; height: 250px;"> 

            <table class="dlg_table">
                <tr>
                    <td class="title">费用日期从</td>
                    <td class="text">
                        <select id="CreYear1" name="CreYear1" runat="server" style="min-width:40px">
                            <option selected></option>
                        </select>年<select id="CreMonth1" name="CreMonth1" runat="server" style="min-width:40px">
                            <option selected></option>
                        </select>月<select id="CreDay1" name="CreDay1" runat="server" style="min-width:40px">
                            <option selected></option>
                        </select>日</td>
                    <td class="title">到</td>
                    <td class="text">
                        <select id="CreYear2" name="CreYear2" runat="server" style="min-width:40px">
                            <option selected></option>
                        </select>年<select id="CreMonth2" name="CreMonth2" runat="server" style="min-width:40px"> 
                            <option selected></option>
                        </select>月<select id="CreDay2" name="CreDay2" runat="server" style="min-width:40px">
                            <option selected></option>
                        </select>日</td>
                </tr>
                <tr>
                    <td class="title">客户名称</td>
                    <td class="text">
                        <input id="CustName" searcher="SelCust"
                            name="CustName" class="easyui-searchbox" runat="server" /><input id="CustID" style="width: 8px; height: 19px" type="hidden"
                                size="1" name="CustID" runat="server" /><input id="hiCustName" style="width: 12px; height: 19px" type="hidden"
                                    size="1" name="hiCustName" runat="server" /></td>
                    <td class="title">可选房号</td>
                    <td class="text">
                        <select id="SelectRoomID" style="width: 150px" class="easyui-combobox" data-options="editable:false,panelHeight: 'auto'" name="SelectRoomID" runat="server">
                            <option selected></option>
                        </select></td>
                </tr>
                <tr>
                    <td class="title">房屋编号</td>
                    <td class="text">
                        <input id="RoomSign" searcher="SelRoom"
                            name="RoomSign" class="easyui-searchbox" runat="server" /><input id="RoomID" style="width: 8px; height: 22px" type="hidden"
                                size="1" name="RoomID" runat="server" /><input id="hiRoomSign" style="width: 8px; height: 22px" type="hidden"
                                    size="1" name="hiRoomSign" runat="server" /></td>
                    <td class="title"></td>
                    <td class="text"></td>
                </tr>
                <tr>
                    <td class="title">费用项目</td>
                    <td class="text" colspan="3">
                        <input id="CostNames" style="width: 90%; height: 22px" class="easyui-searchbox" searcher="SelCost"
                            name="CostNames" runat="server" data-options="editable:false,icons:[{
                            iconCls:'icon-clear',
                            handler: function(e){
                            $(e.data.target).searchbox('clear');
                            }}]" /><input id="CostIDs" style="width: 16px; height: 22px" type="hidden" size="1" name="CostIDs"
                                runat="server" /><input id="hiCostNames" style="width: 16px; height: 22px" type="hidden" size="1" name="hiCostNames"
                                    runat="server" /><%--<input class="button_sel" id="btnSelCostIDs" style="height: 22px" onclick="javascript:if(btnSelCostIDs_OnClick()==false) return false;"
                                        type="button" name="btnSelCostIDs" runat="server">--%><input id="CostID" style="width: 16px; height: 22px" type="hidden" size="1" name="CostID"
                                            runat="server" /><input id="hiCostIDs" style="width: 16px; height: 22px" type="hidden" size="1" name="hiCostIDs"
                                                runat="server" /></td>
                </tr>
                <tr>
                    <td  class="btn" align="center" colspan="4">
                        <%--<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'" id="btnSearch"> 查询 </a>--%>
                                           <input class="button" id="btnSearch"
                            type="button" value="查询" name="btnSearch" runat="server" />

                    </td>
                </tr>
            </table>
        </div>
        <div id="FreezeDlg" class="easyui-dialog" title="批量修改日期" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 700px; height: 200px;">
            <table class="dlg_table">
                <tr>
                    <td class="text" colspan="4">
                        <p>温馨提示:为空的日期表示不修改!</p>
                    </td>
                </tr>
                <tr>
                    <td class="title">应收日期
                    </td>
                    <td class="text">
                        <input type="text" id="AccountsDueDate" name="AccountsDueDate" data-options="editable:false,required:false,icons:[{iconCls:'icon-clear',
                        handler: function(e){
                            $(e.data.target).datebox('clear');
                        }}]"
                            class="easyui-datebox" />
                        <%--<input class="Wdate" id="AccountsDueDate" onkeypress="CheckDate();" data-options="required:true" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" maxlength="50" name="AccountsDueDate" runat="server" type="text" />--%>
                    </td>
                    <td class="title">开始日期
                    </td>
                    <td class="text">
                        <input type="text" id="FeesStateDate" name="FeesStateDate" data-options="editable:false,required:false,icons:[{iconCls:'icon-clear',
                        handler: function(e){
                            $(e.data.target).datebox('clear');
                        }}]"
                            class="easyui-datebox" />
                        <%--<input class="Wdate" id="AccountsDueDate" onkeypress="CheckDate();" data-options="required:true" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" maxlength="50" name="AccountsDueDate" runat="server" type="text" />--%>
                    </td>
                </tr>
                <tr>
                    <td class="title">结束日期
                    </td>
                    <td class="text" colspan="3">
                        <input type="text" id="FeesEndDate" name="FeesEndDate" data-options="editable:false,required:false,icons:[{iconCls:'icon-clear',
                        handler: function(e){
                            $(e.data.target).datebox('clear');
                        }}]"
                            class="easyui-datebox" />
                        <%--<input class="Wdate" id="AccountsDueDate" onkeypress="CheckDate();" data-options="required:true" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" maxlength="50" name="AccountsDueDate" runat="server" type="text" />--%>
                    </td>
                </tr>
                <tr>
                    <td class="btn" colspan="4">
                        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="btnSave">确认修改</a>
                    </td>
                </tr>
            </table>
        </div>
        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">

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


            function SelCost() {
                var varReturn;

                var w = 700;
                var h = 400;


                HDialog.Open('700', '400', "../dialogNew/MultiCorpCommCostDlg.aspx", '收费项目选择', false, function callback(_Data) {


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

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

                    }
                });
            }

            function SelCust() {

                $('#CustName').searchbox("setValue", '');
                $('#CustID').val('');
                $('#RoomSign').searchbox("setValue", '');
                $('#RoomID').val('');
                $('#SelectRoomID').combobox({ data: [], valueField: 'RoomID', textField: 'RoomText' });


                var w = 700;
                var h = 400;

                var conent = "../DialogNew/CustDlg.aspx";

                HDialog.Open(w, h, conent, '客户选择', false, function callback(_Data) {
                    var data = JSON.parse(_Data);
                    $('#CustName').searchbox("setValue", data.CustName);
                    $('#CustID').val(data.CustID);


                    $.tool.DataGet('Choose', 'CustRoomSigns', "CustID=" + data.CustID,
                        function Init() {
                        },
                        function callback(_Data) {

                            varObjects = eval("(" + _Data.replace(/\\/g, "/") + ")"); //转换为json对象
                            if (varObjects.length > 0) {

                                var RoomData = [];
                                for (var i = 0; i < varObjects.length; i++) {

                                    var vIsDelLive = varObjects[i].IsDelLive;
                                    var strTmp = "";

                                    if (vIsDelLive == 1) {
                                        strTmp = "(历史)";
                                    }
                                    var RoomID = varObjects[i].RoomID;
                                    var RoomSign = varObjects[i].RoomSign;
                                    var Buildarea = varObjects[i].BuildArea;

                                    var RoomText = RoomSign + "(" + Buildarea + ")" + strTmp;

                                    RoomData.push({ "RoomText": RoomText, "RoomID": RoomID + "|" + Buildarea });

                                }
                                $('#SelectRoomID').combobox({
                                    data: RoomData,
                                    valueField: 'RoomID',
                                    textField: 'RoomText',
                                    onChange: function (n, o) {


                                        var data = $('#SelectRoomID').combobox('getData');
                                        if (data.length > 0) {
                                            for (var i = 0; i < data.length; i++) {
                                                if (n == data[i].RoomID) {

                                                    $('#RoomSign').searchbox('setValue', data[i].RoomText);
                                                    $('#RoomID').val(data[i].RoomID.split('|')[0]);

                                                    break;
                                                }
                                            }
                                        }
                                    }
                                });
                            }
                        },
                        function completeCallback() {
                        },
                        function errorCallback() {
                        });

                });
            }
            function SelRoom() {
                $('#CustName').searchbox("setValue", '');
                $('#CustID').val('');
                $('#RoomSign').searchbox("setValue", '');
                $('#RoomID').val('');
                $('#SelectRoomID').combobox({ data: [], valueField: 'RoomID', textField: 'RoomText' });

                var conent = "../DialogNew/RoomDlg.aspx";


                var w = $(window).width();
                var h = $(window).height();

                HDialog.Open(w, h, conent, '房屋选择', false, function callback(_Data) {
                    var data = JSON.parse(_Data);
                    $('#RoomSign').searchbox("setValue", data.RoomSign);
                    $('#CustName').searchbox("setValue", data.CustName);
                    $('#CustID').val(data.CustID);
                    $('#RoomID').val(data.RoomID);


                    $('#SelectRoomID').combobox({
                        data: '',
                        valueField: 'RoomID',
                        textField: 'RoomText'
                    });

                });
            }


            var column = [[

                    { field: 'FeesID', title: '', width: 100, align: 'left', sortable: true, hidden: true },
                    { field: 'CostSNum', title: '费用序号', width: 50, align: 'left', sortable: true },
                    { field: 'CostName', title: '费用名称', width: 100, align: 'left', sortable: true },
                    {
                        field: 'FeeDueYearMonth', title: '费用日期', width: 100, align: 'left', sortable: true
                    },
                    {
                        field: 'AccountsDueDate', title: '应收日期', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {

                            var str = formatDate(row.AccountsDueDate, "yyyy-MM-dd");
                            return str;
                        }
                    },
                    {
                        field: 'FeesStateDate', title: '开始日期', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {

                            var str = formatDate(row.FeesStateDate, "yyyy-MM-dd");
                            return str;
                        }
                    },
                    {
                        field: 'FeesEndDate', title: '结束日期', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {

                            var str = formatDate(row.FeesEndDate, "yyyy-MM-dd");
                            return str;
                        }
                    },
                    { field: 'DueAmount', title: '应收金额', width: 100, align: 'left', sortable: true },

                    { field: 'DebtsAmount', title: '欠收金额', width: 100, align: 'left', sortable: true },

                    { field: 'IsPrecName', title: '预交状态', width: 80, align: 'center', sortable: true }

            ]];

            var frozenColumns = [[
                 { field: 'ck', checkbox: true },
              { field: 'CustName', title: '客户名称', width: 100, align: 'left', sortable: true },
              { field: 'RoomSign', title: '房屋编号', width: 180, align: 'left', sortable: true },
               { field: 'RoomName', title: '房屋名称', width: 180, align: 'left', sortable: true },
            ]];
            var toolbar = [
                 {
                     text: '筛选',
                     iconCls: 'icon-search',
                     handler: function () {
                         $('#SearchDlg').parent().appendTo($("form:first"))
                         $('#SearchDlg').dialog('open');

                     }
                 }, '-',
                    {
                        text: '修改',
                        iconCls: 'icon-save',
                        handler: function () {
                            var rows = $('#TableContainer').datagrid('getChecked');
                            if (rows == "") {
                                HDialog.Info('请选择费用!');
                            }
                            else {

                                $('#FreezeDlg').parent().appendTo($("form:first"))
                                $('#FreezeDlg').dialog('open');


                                var SelData = JSON.stringify(rows);
                                $('#AllFees').val(SelData);



                            }

                        }
                    }
            ];


            function LoadList() {


                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    frozenColumns: frozenColumns,
                    fitColumns: true,
                    remoteSort: false,
                    singleSelect: true,
                    pagination: true,
                    width: "100%",
                    toolbar: toolbar,
                    sortOrder: "asc",
                    singleSelect: true,
                    selectOnCheck: false,
                    checkOnSelect: false,
                    rownumbers: true,
                    border: false,
                    toolbar: toolbar,
                    sortOrder: "asc",
                    onBeforeLoad: function (param) {
                        param = $.JQForm.GetParam("Fees", "FeesAccoutDuedateSearch", "TableContainer", param);
                    },
                    onLoadSuccess: function (data) {
                    }
                });

            }
            LoadList();
            $('#btnSearch').click(function () {

                LoadList();
                //Clear();
                $("#SearchDlg").dialog("close");
            });


            $('#btnSave').click(function () {
                $.messager.confirm("温馨提示", "确认修改的信息无误?", function (r) {
                    if (r) {
                        $.tool.DataPostChk('frmForm', 'Fees', 'FeesAccoutDuedate', $('#frmForm').serialize(),
                            function Init() {
                            },
                            function callback(_Data) {
                                var r = _Data.split('|');
                                if (r[0] == "true") {
                                    LoadList();
                                }
                                HDialog.Info(r[1]);
                                $("#FreezeDlg").dialog("close");
                            },
                            function completeCallback() {
                            },
                            function errorCallback() {
                            });
                    }
                });
            });


            function Clear() {
                $('#CustID').val('');
                $('#RoomID').val('');

                $('#CustName').val('');
                $('#RoomSign').val('');

                $('#hiCustName').val('');
                $('#hiRoomSign').val('');

                $('#CostIDs').val('');
                $('#CostNames').val('');
                $('#hiCostNames').val('');
                $('#ChangeMemo').val('');
            }
        </script>
    </form>
</body>
</html>

