<%@ page title="" language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_FinancialManagement_Accounting_BankReconsilation, App_Web_qm1ylumw" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl" TagPrefix="ScreenGroup" %>
<%@ Register Src="~/UserControls/DatePicker/DatePickerControl.ascx" TagName="DatePickerControl" TagPrefix="Date" %>
<%@ Register Src="~/UserControls/AutoComplete/AutoCompleteTextBoxForGridView.ascx" TagName="AutoCompleteTextBoxForGridView" TagPrefix="acc" %>
<%@ Register Src="~/UserControls/Common/CommonSearch/CommonSearch.ascx" TagName="CommonSearchUserControl" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/Common/Account/AccountDetailBoxControl.ascx" TagName="AccountControl" TagPrefix="Acnt" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <asp:UpdatePanel ID="OTQueueListingUpdatePanel" runat="server">
        <ContentTemplate>
            <uc1:CommonSearchUserControl ID="CommonSearchControl" Visible="false" runat="server" />
            <div id="divContentPage" class="divcontentpagemargin">

                <div class="dashBoardLeftCont">
                    <div class="himssuHeader3WireBox">
                        <table>
                            <tr>
                                <td>
                                    <div class="himsBoxContent">
                                        <div class="leftUlMenu">
                                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="148"
                                                Visible="true" runat="server" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="whiteboxpaddingleft row">
                    <Acnt:AccountControl ID="AccountUserControl" runat="server" Visible="true" />
                    <div class="himssuHeader5WireBox card card-box">
                        <div class="himsBoxHeader card-head">
                            <asp:Panel ID="Panel1" runat="server">
                                <div class="himsBoxTitle">
                                    <div class="headerText">
                                        <header>
                                            <i class="fas fa-search"></i>
                                            <asp:Label ID="Label3" runat="server" Text="Search"></asp:Label>
                                        </header>
                                    </div>
                                </div>
                            </asp:Panel>
                        </div>
                        <div class="himsBoxContent card-body">
                            <asp:Panel ID="SearchPanel" runat="Server">
                                <div class="contentHolder">

                                    <div class="outerBox pTop5 col-md-3">
                                        <div class="controlLabelWidth">
                                            <asp:Label ID="VoucherDateSearchFromLabel" runat="server" Text="From Date"></asp:Label>
                                        </div>
                                        <div class="fLeft pRight5">
                                            <Date:DatePickerControl DisplayDatePicker="true" ID="VoucherDateSearchFromDatePickerControl" Text='' Visible="True" runat="Server"></Date:DatePickerControl>
                                        </div>
                                    </div>
                                    <div class="outerBox pTop5 col-md-3">
                                        <div class="controlLabelWidth">
                                            <asp:Label ID="VoucherDateSearchToLabel" runat="server" Text="To Date"></asp:Label>
                                        </div>
                                        <div class="fLeft pRight5">
                                            <Date:DatePickerControl DisplayDatePicker="true" ID="VoucherDateSearchToDatePickerControl" Text='' Visible="True" runat="Server"></Date:DatePickerControl>
                                        </div>
                                    </div>
                                    <div class="outerBox pTop5 col-md-3">
                                        <div class="controlLableWidth">
                                            <asp:Label ID="LedgerSearchLabel" runat="server" Text="Ledger" SkinID="MandatoryLabel"></asp:Label>
                                        </div>
                                        <div class="fLeft pRight5">
                                            <asp:DropDownList runat="server" ID="LedgerSearchDropDownList" SkinID="CustomWidthDropDownList"
                                                CssClass="form-control" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                                DataValueField="LedgerId" AutoPostBack="false">
                                            </asp:DropDownList>
                                        </div>
                                    </div>

                                    <div class="outerBox pTop5 col-md-3">
                                        <div class="controlLabelWidth">
                                            <asp:Label ID="ChequeClearDateLabel" runat="server" Text="Cheque Clear Date"></asp:Label>
                                        </div>
                                        <div class="fLeft pRight5">
                                            <Date:DatePickerControl DisplayDatePicker="true" ID="ChequeClearDateDatePickerControl" Text='' Visible="True" runat="Server"></Date:DatePickerControl>
                                        </div>
                                    </div>
                                    <div class="outerBox pTop5 col-md-3">
                                        <div class="fLeft pTop5">
                                            <asp:CheckBox ID="AllCheckBox" runat="server" Text="All" />
                                        </div>
                                    </div>

                                    <div class="alignCenter pTop5 col-md-12 center">
                                        <asp:Button ID="SearchButton" Text="&#xf002; Search" runat="Server" OnClick="SearchButton_Click" SkinID="0" class="btn-search btn fas" />
                                        <asp:Button ID="SaveButton" Text="&#xf0c7; Save" runat="Server" OnClick="SaveButton_Click" SkinID="0" CssClass="btn-save btn fas" />
                                        <asp:Button ID="ResetButton" runat="server" Text="&#xf0e2; Reset" OnClick="ResetButton_Click" SkinID="0" class="btn-reset btn fas" />
                                        <asp:Button ID="PrintButton" runat="server" Text="&#xf15b; Print" OnClick="PrintButton_Click" SkinID="0" class="btn-report btn fas" />
                                    </div>

                                    <div id="BalanceDiv" runat="server" visible="false" style="padding-left: 870px">
                                        <div>
                                            <asp:Label ID="OpeningBalanceNameLabel" Font-Bold="true" runat="server" Text="Opening Balance = ">                                                                        
                                            </asp:Label>
                                            <asp:Label ID="OpeningBalanceId" runat="server" Font-Bold="true">
                                            </asp:Label>
                                        </div>

                                        <div>
                                            <asp:Label ID="ClosingBalanceNameLabel" Font-Bold="true" runat="server" Text="Closing Balance = ">                                                                        
                                            </asp:Label>
                                            <asp:Label ID="ClosingBalanceId" runat="server" Font-Bold="true">
                                            </asp:Label>
                                        </div>
                                        <div>
                                            <asp:Label ID="DifferenceBalanceNameLabel" Font-Bold="true" runat="server" Text="Clear Balance = ">                                                                        
                                            </asp:Label>
                                            <asp:Label ID="DifferenceBalanceNameId" runat="server" Font-Bold="true">
                                            </asp:Label>
                                        </div>

                                    </div>

                                    <div id="Div2" class="himssuHeader1WireBox col-md-12" runat="server">
                                        <div id="CashBankBookListDetailDiv" runat="server" visible="false">

                                            <div class="himsBoxContent card-body">
                                                <div id="Div5" runat="server" visible="false" class="table-responsive">
                                                    <asp:GridView ID="VoucherSearchGridView" runat="server" AutoGenerateColumns="False"
                                                        AllowPaging="false" SkinID="" PagerSettings-Visible="false" EmptyDataText="No Records Found !!" CssClass="table table-striped table-bordered table-hover"
                                                        DataKeyNames="Id" OnRowDataBound="VoucherSearchGridView_RowDataBound">
                                                        <Columns>
                                                            <asp:TemplateField HeaderText="TransactionDate" ItemStyle-Width="10%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="TransactionDateLabel" runat="server" Text='<%# Bind("TransactionDate","{0:d}") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Width="10%" Wrap="True" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Ledger" ItemStyle-Width="15%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="LedgerNameLabel" runat="server" Text='<%# Bind("Ledger") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Width="15%" Wrap="True" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="ChequeNo" ItemStyle-Width="10%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="ChequeNoLabel" runat="server" Text='<%# Bind("ChequeNo") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Width="10%" Wrap="True" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="CheuqeDate" ItemStyle-Width="10%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="CheuqeDateLabel" runat="server" Text='<%# Bind("ChequeDate","{0:d}") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Width="10%" Wrap="True" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Dr Balance" ItemStyle-Width="10%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="DrBalanceLabel" runat="server" Text='<%# Bind("Debit") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Width="10%" Wrap="True" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Cr Balance" ItemStyle-Width="10%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                ItemStyle-Wrap="true">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="CrBalanceLabel" runat="server" Text='<%# Bind("Credit") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Width="10%" Wrap="True" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Cheque Clear">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <ItemStyle HorizontalAlign="Center" Width="5%" Wrap="True" />
                                                                <ItemTemplate>
                                                                    <label class="rt-chkbox rt-chkbox-outline">
                                                                        <asp:CheckBox ID="IsChequeClearedCheckBox" SkinID="CustomWidthCheckBox"
                                                                            Checked='<%# Bind("IsChequeCleared") %>'
                                                                            runat="server" AutoPostBack="false"
                                                                            OnCheckedChanged="IsChequeClearedCheckBox_CheckedChanged" onclick="ClearCheck(this);" />
                                                                        <span></span>
                                                                    </label>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Cheque Clear Date" ItemStyle-Width="15%">
                                                                <ItemTemplate>
                                                                    <Date:DatePickerControl DisplayDatePicker="true" ID="ChequeClearDateDatePickerControl"
                                                                        Visible="True" runat="Server" Text='<%# Bind("ChequeClearDate","{0:d}") %>' Width="100px"></Date:DatePickerControl>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Left" />
                                                                <ItemStyle Wrap="True" />
                                                            </asp:TemplateField>

                                                            <%--                                                                        <asp:TemplateField HeaderText="Closing Balance" ItemStyle-Width="10%" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                                                                            ItemStyle-Wrap="true">
                                                                            <ItemTemplate>
                                                                                <asp:Label ID="ClosingBalanceLabel" runat="server" Text=''></asp:Label>
                                                                            </ItemTemplate>
                                                                            <HeaderStyle HorizontalAlign="Left" />
                                                                            <ItemStyle Width="10%" Wrap="True" />
                                                                        </asp:TemplateField>--%>
                                                        </Columns>
                                                        <PagerSettings Visible="False" />
                                                    </asp:GridView>
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                    <table style="width: 100%">
                                        <tr>
                                            <td align="right" style="width: 53%">
                                                <asp:Label ID="Totallbl" runat="server" Text="Total :   " Visible="false"></asp:Label>
                                                &nbsp;
                                            </td>
                                            <td align="left" style="width: 15%">
                                                <asp:Label ID="DebitLabel1" runat="server" Text="" Visible="false"></asp:Label>
                                            </td>
                                            <td align="left" style="width: 32%">
                                                <asp:Label ID="CreditLabel1" runat="server" Text="" Visible="false"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </asp:Panel>
                        </div>
                    </div>
                </div>
                </tr>
                    </table>
            </div>
            </div>           
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--<script data-main="../../../JavaScript/rjs/encrypt/cash-bank-book-encrypt" src="../../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/cash-bank-book")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script>
        function ClearCheck(obj) {

            var row = obj.parentNode.parentNode.parentNode.rowIndex;

            var VoucherTable = document.getElementById('<%=VoucherSearchGridView.ClientID %>');
            var OpeningBalance = document.getElementById('<%=OpeningBalanceId.ClientID%>').innerText;
            var OpeningBalanceConvert = parseInt(OpeningBalance);

            var count = 0;
            var Total = 0;

            for(var i=1; i < VoucherTable.rows.length; i++)
            { 
                var CrBalance = VoucherTable.rows[i].cells[5].innerText;
                var CrBalanceConvert = parseInt(CrBalance);
                var DrBalance = VoucherTable.rows[i].cells[4].innerText;
                var DrBalanceConvert = parseInt(DrBalance);
                var chk = false;
                if (VoucherTable.rows[i].cells[6].childNodes[1].firstElementChild.checked)
                    chk = true;
                else
                    chk = false;

                if (chk == true) {
                    if (Total == 0)
                        Total = (CrBalanceConvert - DrBalanceConvert) + OpeningBalanceConvert;
                    else
                        Total = Total + (CrBalanceConvert - DrBalanceConvert);

                    document.getElementById('<%=DifferenceBalanceNameId.ClientID %>').innerText = Total;
                }
                else
                    count += 1;

                if(count == VoucherTable.rows.length - 1)
                    document.getElementById('<%=DifferenceBalanceNameId.ClientID %>').innerText = OpeningBalanceConvert
            }
            
            
        }
    </script>
</asp:Content>
