<%@ page clientidmode="static" language="C#" masterpagefile="~/MasterPages/Main.master" autoeventwireup="true" inherits="Business_MonthlySettlement, App_Web_monthlysettlement.aspx.36edc644" viewStateEncryptionMode="Always" maintainScrollPositionOnPostBack="true" %>

<%@ Register Src="../UserControls/DatePicker.ascx" TagName="DatePicker" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script language="javascript" type="text/javascript">
        function noCopyMouse(e) {
            var isRight = (e.button) ? (e.button == 2) : (e.which == 3);
            if (isRight) {
                alert("Not Allowed to copy");
                return false;
            }
            return true;
        }

        function noCopyKey(e) {
            var forbiddenKeys = new Array('c', 'x', 'v');
            var keyCode = (e.keyCode) ? e.keyCode : e.which;
            var isCtrl;

            if (window.event)
                isCtrl = e.ctrlKey;
            else
                isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false;

            if (isCtrl) {
                for (i = 0; i < forbiddenKeys.length; i++) {
                    if (forbiddenkeys[i] == String.fromCharCode(keyCode).toLowerCase()) {
                        alert("Not Allowed to Copy");
                        return false;
                    }
                }
            }
            return true;
        }

        function validateDate() {
            var message = "";
            if (document.getElementById("<%=dtp_filter_sttlDate.TextBoxClientID%>").value == "") {
                message += "You have to at enter the transaction date\n";
            }
            if (message.length > 0) {
                message = "please notice the following requirments:\n\n" + message;
                alert(message);
                return false;
            }
            return true;
        }

        function UserConfirmation() {
            var userSelection;

            userSelection = confirm("Are you sure you want to Process ?");

            if (userSelection) {
                return true;
            } else {
                return false;
            }
        }

        function GenerateConfirmation() {
            var userSelection;

            userSelection = confirm("Are you sure you want to Generate ?");

            if (userSelection) {
                return true;
            } else {
                return false;
            }
        }

        function UserReprocessConfirm() {
            var userSelection;
            var vdate = document.getElementById("<%=dtp_filter_sttlDate.TextBoxClientID%>").value;

            if (vdate != "") {
                userSelection = confirm("Are you sure you want to Re-Process the file for " + vdate + " ?");
            }
            else {
                userSelection = confirm("Are you sure you want to Re-Process ?");
            }

            if (userSelection) {
                return true;
            } else {
                return false;
            }
        }

        function DiffConfirmation(settl_category, diff_sum_amt) {
            var userSelection;

            //var confirm_value = document.createElement("INPUT");
            //confirm_value.type = "hidden";
            //confirm_value.name = "confirm_value";

            //userSelection = confirm("Are you sure you want to Process the difference " + diff_sum_amt + " of " + settl_category);
            userSelection = confirm("Are you sure you want to Process the difference ?");

            if (userSelection) {
                return true;
            } else {
                return false;
            }
        }

        <%--function DiffConfirm(settl_category, diff_sum_amt) {
            var userSelection;

            userSelection = confirm("Are you sure you want to Process the difference " + diff_sum_amt + " of " + settl_category);

            if (userSelection) {
                '<%Session["DiffConfirm"] = "Ok"; %>'
                var session_value = '<%=Session["DiffConfirm"]%>';
                console.log(session_value);
            }
            else {
                '<%Session["DiffConfirm"] = "Cancel"; %>'
                var session_value = '<%=Session["DiffConfirm"]%>';
                console.log(session_value);
            }
        }--%>
    </script>
    <style type="text/css">
        .style2
        {
            width: 15%;
            height: 20px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server"></asp:ScriptManager>
    <p id="demo"></p>
    <asp:Label ID="Label1" runat="server"></asp:Label>
    <table class="body_MainTB" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <!------------------------------------body St  ---------------------------------------------->
                <table border="0" cellpadding="0" cellspacing="0" class="body_formTitle">
                    <tr>
                        <td>MADA Monthly Settlement
                        </td>
                    </tr>
                </table>
                <br />
                <!------------------------------------body End1 ----------------------------------------------->
                <div style="text-align:center"><asp:Label ID="lbl_error" runat="server" class="fieldError"></asp:Label></div>
                <asp:Panel ID="pnl_searchCriteria" runat="server" Width="100%">
                    <table border="0" cellpadding="0" cellspacing="0" class="add_ItemTB1" style="width: 100%">
                        <tr>
                            <td class="tdNormal" style="width: 15%">Settlement Date:
                            </td>
                            <td class="tdNormal" style="width: 30%">
                                <uc1:DatePicker ID="dtp_filter_sttlDate" runat="server" width="50%" />
                            </td>
                            <td class="tdNormal" style="width: 10%">
                                <asp:Label ID="lbl_File_Number" runat="server" class="fieldNormal" Text="" Visible="false"></asp:Label>
                                <asp:Label ID="lbl_Status" runat="server" class="fieldNormal" Text="" Visible="false"></asp:Label>
                                <asp:Label ID="lbl_FSResponse" runat="server" class="fieldNormal" Text="" Visible="false"></asp:Label>
                            </td>
                            <td class="tdNormal" style="width: 15%"></td>
                            <td class="tdNormal" style="width: 30%"></td>
                        </tr>
                        <tr>
                            <td class="tdNormal" style="width: 15%"></td>
                            <td class="tdNormal" style="width: 30%">
                                <asp:Button ID="btn_search" runat="server" Text="   Search   " class="Btn_M_Normal"
                                    OnClientClick="return validateDate()" OnClick="btnSearch_Click" />
                                <asp:Button ID="btn_SummaryRPT" runat="server" Text="Summary Report" CssClass="Btn_L_Normal1"
                                    OnClientClick="" OnClick="btnSummaryRPT_Click" Width="128px" />
                                <asp:Button ID="btnGenReport" runat="server" Text="Settlement Report" CssClass="Btn_L_Normal1"
                                    OnClientClick="" OnClick="btnGenReport_Click" Width="128px" />
                            </td>
                            <td class="tdNormal" style="width: 10%"></td>
                            <td class="tdNormal" style="width: 15%"></td>
                            <td class="tdNormal" style="width: 30%; text-align:right;">
                                <asp:Label ID="Lbl_Exchg_Limit" runat="server" Visible="false"></asp:Label>
                                <asp:Label ID="Lbl_Limit_Warning" runat="server" ForeColor="OrangeRed" Font-Size="Small"></asp:Label>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
                <asp:Panel ID="pnl_result" runat="server" Width="100%">
                    <table dir="ltr" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <table border="0" cellpadding="0" cellspacing="0" class="grid_TitleBG_B">
                                    <tr>
                                        <td>MADA Monthly Settlement
                                        </td>
                                        <td style="text-align:right;">
                                            <asp:Button ID="btn_Generate" runat="server" Text="   Generate   " class="Btn_M_Normal"
                                                OnClientClick="return GenerateConfirmation()" Visible="false" OnClick="btn_Generate_Click" />
                                            <asp:Button ID="btn_Reprocess" runat="server" Text="   Re-Process   " class="Btn_M_Normal" 
                                            OnClientClick="return UserReprocessConfirm()" OnClick="btn_Reprocess_Click" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <%--<tr>
                            <td>
                                <table border="0" width="100%" cellpadding="0" cellspacing="0" class="add_ItemTB">
                                    
                                </table>
                            </td>
                        </tr>--%>
                        <tr>
                            <td class="tdNormal" colspan="5">
                                <asp:GridView ID="GV_Settlement" CssClass="gridMaster" Width="100%" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="FILE_NUMBER" AllowPaging="false" AllowSorting="True" ShowFooter="true"
                                    CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCreated="GV_Settlement_RowCreated" OnRowCommand="GV_Settlement_RowCommand"
                                    OnRowDataBound="GV_Settlement_RowDataBound" EmptyDataText="There are no Results">
                                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Right" />
                                    <Columns>
                                        <asp:BoundField DataField="SETTL_DATE" HeaderText="Settlement Date" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="FILE_NUMBER" HeaderText="File Number" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="SETTL_FILE_NAME" HeaderText="File Name" />
                                        <asp:BoundField DataField="SETTL_DESC" HeaderText="Description" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="SETTL_CATEGORY" HeaderText="Category" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="SETTL_AMOUNT" HeaderText="Settl Amount" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="NET_SUM_AMT" HeaderText="Net Summary" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="" HeaderText="Settl Diff" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="VAT_AMOUNT" HeaderText="VAT Amount" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="NETVAT_AMOUNT" HeaderText="VAT Summary" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="" HeaderText="VAT Diff" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="CS_EVNT_CODE" HeaderText="Event Code" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="PRD_GRP_ID" HeaderText="Group Id" HeaderStyle-CssClass="header-center" />
                                        <%--<asp:TemplateField HeaderText="Exchg Diff">  
                                            <EditItemTemplate>  
                                                <asp:CheckBox ID="Chk_Diff" runat="server" />  
                                            </EditItemTemplate>  
                                            <ItemTemplate>  
                                                <asp:CheckBox ID="Chk_Diff" runat="server" />  
                                            </ItemTemplate>  
                                        </asp:TemplateField>--%>

                                        <asp:TemplateField HeaderText="Action" Visible="True" ItemStyle-Width="40">
                                           <ItemTemplate>
                                               <%--<asp:ButtonField ButtonType="Image" ItemStyle-Width="30px" HeaderText="Check Diff" CommandName="cd" ImageUrl="~/Images/view.jpg" ItemStyle-HorizontalAlign="Center"></asp:ButtonField>--%>
                                               <%--<asp:Button ID="out" runat="server" Text="Sign out" CommandName="SignOut"  CommandArgument='<%#Eval("SN") %>' CssClass="active"/> OnClientClick='<%#Eval("DIFF_SUM_AMT", "return DiffConfirmation1({0});") %>'--%>
                                               <%--<asp:ImageButton ID="Chk_Diff" runat="server" CommandName="diff" ImageUrl="~/Images/trans.jpg" OnClientClick='<%# "return DiffConfirmation(" + Eval("SETTL_CATEGORY") + "," + Eval("DIFF_SUM_AMT") + ");" %>' />--%>
                                               <asp:ImageButton ID="Chk_Diff" runat="server" CommandArgument="<%# Container.DataItemIndex %>" OnClientClick="return DiffConfirmation(1,2)" CommandName="diff" ImageUrl="~/Images/trans.jpg" /> 
                                               <%--OnClientClick="return DiffConfirmation(1,2)"--%>

                                               <%--<asp:TextBox ID="settl_category" Text='<%# Eval("SETTL_CATEGORY") %>' runat="server" Visible="false"></asp:TextBox>
                                               <asp:TextBox ID="diff_sum_amt" Text='<%# Eval("DIFF_SUM_AMT") %>' runat="server" Visible="false"></asp:TextBox>

                                               <a id='<%# Eval("DIFF_SUM_AMT") %>' onclick="return DiffConfirmation(this.id);">View</a>
                                               <asp:ImageButton ID="Chk_Diff" runat="server" CommandArgument="<%# Container.DataItemIndex %>" OnClientClick='<%# "return DiffConfirmation(" + this.Eval("SETTL_CATEGORY") + ",2)" %>' CommandName="diff" ImageUrl="~/Images/trans.jpg" />--%>
                                               <asp:ImageButton ID="RPT_Summary" runat="server" CommandArgument="<%# Container.DataItemIndex %>" CommandName="r" ImageUrl="~/Images/document_view.jpg" />
                                           </ItemTemplate>
                                       </asp:TemplateField>

                                        <%--<asp:ButtonField ButtonType="Image" ItemStyle-Width="30px" HeaderText="Summary" CommandName="r" ImageUrl="~/Images/document_view.jpg" ItemStyle-HorizontalAlign="Center"></asp:ButtonField>--%>
                                        <asp:BoundField DataField="STATUS" HeaderText="Status" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Center" />
                                    </Columns>
                                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="Black" />
                                    <EditRowStyle BackColor="#999999" />
                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" HorizontalAlign="Right" />
                                </asp:GridView>
                            </td>
                            <asp:LinkButton ID="btnOnConfirm" runat="server" OnClick="OnConfirm_Click" Visible="false" />
                            <%--<input type="hidden" runat="server" name="confirmSelection" />
                            <asp:HiddenField runat="server" ID="ConfirmValue"/>--%>
                        </tr>
                    </table>
                    <%--<table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <asp:Button ID="btn_Generate" runat="server" Text="Generate Settlement" OnClientClick="return UserConfirmation()" OnClick="btn_Generate_Click" />
                            </td>
                        </tr>
                    </table>--%>
                </asp:Panel>

                <%--<asp:Panel ID="pnl_confirmation" runat="server" Width="100%">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0" class="add_ItemTB">
                        <tr>
                            <td colspan="2" class="tdNormal" align="center">
                                <asp:Label runat="server" Text="Are you sure you want to Process the Difference ?"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="tdNormal">
                                <asp:Button ID="btn_conf_ok" runat="server" Text="OK" CssClass="Btn_L_Normal"
                                    OnClick="btn_conf_ok_Click" />
                            </td>

                            <td class="tdNormal">
                                <asp:Button ID="btn_conf_cancel" runat="server" Text="Cancel"
                                    CssClass="Btn_L_Normal" OnClick="btn_conf_cancel_Click" />
                            </td>
                        </tr>
                    </table>
                </asp:Panel>--%>

                <asp:Panel ID="pnlResult_TicketEntry" runat="server" Width="100%" Visible="false">
                    <table dir="ltr" width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <table border="0" cellpadding="0" cellspacing="0" class="grid_TitleBG_B">
                                    <tr>
                                        <td>MADA Monthly Settlement Ticket Entry
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <%--<tr>
                            <td>
                                <table border="0" width="100%" cellpadding="0" cellspacing="0" class="add_ItemTB">
                                    
                                </table>
                            </td>
                        </tr>--%>
                        <tr>
                            <td class="tdNormal" colspan="5">
                                <asp:GridView ID="GV_TicketEntry" CssClass="gridMaster" Width="100%" runat="server" AutoGenerateColumns="False"
                                    DataKeyNames="Event_Name" AllowPaging="false" AllowSorting="True" ShowFooter="true"
                                    CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCreated="GV_TicketEntry_RowCreated"
                                    OnRowDataBound="GV_TicketEntry_RowDataBound" EmptyDataText="There are no Results">
                                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Right" />
                                    <Columns>
                                        <asp:BoundField DataField="Event_Name" HeaderText="Account&nbsp;Name" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="From_Account" HeaderText="Debit&nbsp;Account" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="To_Account" HeaderText="Credit&nbsp;Account" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="DbAmt" HeaderText="Debit" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="CRAmt" HeaderText="Credit" DataFormatString="{0:n}" HeaderStyle-CssClass="header-center" ItemStyle-HorizontalAlign="Right" />
                                        <asp:BoundField DataField="Narrative" HeaderText="Narratives" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="CS_GL_Desc" HeaderText="Status" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="CS_GL_Code" HeaderText="" HeaderStyle-CssClass="header-center" />
                                        <asp:BoundField DataField="file_number" HeaderText="File&nbsp;Number" HeaderStyle-CssClass="header-center" />
                                        
                                    </Columns>
                                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="Black" />
                                    <EditRowStyle BackColor="#999999" />
                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" HorizontalAlign="Right" />
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left">
                                <% if (GV_TicketEntry.Rows.Count >= 1)
                                    { %>
                                <% if (lbl_Status.Text == "000" || lbl_Status.Text == "008")
                                    { %>
                                <asp:Button ID="btn_SubmitForApproval" runat="server" Text="Submit for Approval" CssClass="Btn_L_Normal1"
                                    OnClick="ButtonSubmitForApproval_Click" OnClientClick="return SaveConfirmation('Are you sure to send all the entries for approval')" />
                                <%} %>
                                <% if (lbl_Status.Text == "001")
                                    { %>
                                <asp:Button ID="btn_ApproveAndCreateGL" runat="server" Text="Approve" CssClass="Btn_L_Normal1"
                                    OnClick="bttn_ApproveAndCreateGL" OnClientClick="return SaveConfirmation('Are you sure to process the GL')" />
                                <asp:Button ID="btn_RejectForApproval" runat="server" Text="Reject" CssClass="Btn_L_Normal1"
                                    OnClick="ButtonRejectForApproval_Click" OnClientClick="return SaveConfirmation('Are you sure to cancel all the entries')" />
                                <%} %>
                                <%} %>
                                <%--<asp:Button ID="bttn_GenerateGL0" runat="server" Text="Generate GL" CssClass="btn btn-primary btn-l"
                                            OnClick="ButtonGenerateGL_Click" OnClientClick="return SaveConfirmation('Are you sure to send all the entries for approval')" />--%>
                            </td>
                            <%--<td style="text-align: right">
                                <b>Total VAT Debit &nbsp; : &nbsp;</b><asp:Label ID="lbl_VAT_DBAmt" runat="server"></asp:Label>
                                <b>Total VAT Credit &nbsp; : &nbsp;</b><asp:Label ID="lbl_VAT_CDAmt" runat="server"></asp:Label>
                                <b>Difference(CR-DB) &nbsp; : &nbsp;</b><asp:Label ID="lbl_CR_DR_Diff" runat="server"></asp:Label>
                            </td>--%>
                        </tr>
                    </table>
                </asp:Panel>
                <br />
                <asp:Label ID="Lbl_MannualDif" runat="server" Text="" class="fieldError"></asp:Label>
            </td>
        </tr>
    </table>
</asp:Content>