<%@ Page Language="C#" MasterPageFile="~/MasterPages/Main.master" AutoEventWireup="true"
    CodeFile="MerchantSettle.aspx.cs" Inherits="POS_MerchantSettle"  %>

<%@ Register Src="../UserControls/DatePicker.ascx" TagName="DatePicker" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table class="body_MainTB" border="0" cellpadding="0" cellspacing="0">
        <tr align="center">
            <td valign="top">
                <!------------------------------------body St  ---------------------------------------------->
                <table border="0" cellpadding="0" cellspacing="0" class="body_formTitle">
                    <tr>
                        <td>
                            Merchant Settlements
                        </td>
                    </tr>
                </table>
                <br>
                <!------------------------------------body End1 ----------------------------------------------->
                <table border="0" cellpadding="0" cellspacing="0" class="contTB">
                    <tr>
                        <td align="center">
                            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="Frow">
                                <tr>
                                    <td>
                                    </td>
                                </tr>
                            </table>
                            <br />
                            <table border="0" width="100%" style="width: 80%" cellpadding="0" cellspacing="0"
                                class="add_ItemTB">
                                <tr>
                                    <td class="tdNormal" style="width: 20%">
                                        Search By
                                    </td>
                                    <td >
                                        <asp:RadioButton ID="rdTerminalNo" Text="Terminal" GroupName="rd" 
                                            runat="server" OnCheckedChanged="rdTerminalNo_CheckedChanged"
                                            AutoPostBack="true" Visible="True" />
                                        <asp:RadioButton ID="rdMerchants" Text="Merchant" GroupName="rd" runat="server" OnCheckedChanged="rdMerchants_CheckedChanged" Checked=true
                                            AutoPostBack="true" />
                                    </td>
                                     <td class="tdNormal" style="width:15%"> Select Service
                                    </td>
                                    <td class="tdNormal" style="width:30%"><asp:DropDownList ID="ddlServices" runat="server" DataTextField="service_name"
                                            DataValueField="service_code" class="fieldNormal" AutoPostBack="False">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr runat="server" id="rowAccount">
                                    <td class="tdNormal">
                                        Terminal Number
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtTerminalNo" runat="server" class="fieldNormal" Width="250" MaxLength="8"></asp:TextBox>
                                    </td>
                                    <td class="tdNormal">
                                    </td>
                                   
                                </tr>
                                <tr runat="server" id="rowMerchant">
                                    <td class="tdNormal">
                                        Client Number
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtClientNumber" runat="server" class="fieldNormal" Width="250"
                                            MaxLength="19"></asp:TextBox>
                                    </td>
                                    <td class="tdNormal">
                                    </td>
                                </tr>
                                <tr runat="server" id="rowDates">
                                    <td class="tdNormal" style="width: 15%">
                                        From Date
                                    </td>
                                    <td class="tdNormal" style="width: 30%">
                                        <uc1:DatePicker ID="dtFrom" runat="server" width="250" />
                                    </td>
                                    <td class="tdNormal" style="width: 10%">
                                    </td>
                                    <td class="tdNormal" style="width: 15%">
                                        To Date
                                    </td>
                                    <td class="tdNormal" style="width: 30%">
                                        <uc1:DatePicker ID="dtTo" runat="server" width="250" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="5" style="text-align: center">
                                        <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="Btn_L_Normal" OnClientClick=""
                                            OnClick="btnSearch_Click" />
                                    </td>
                                </tr>
                            </table>
                            <br />
                            <asp:Label ID="lblError" runat="server" Text="" class="fieldError"></asp:Label>
                            <asp:Panel ID="pnlTerminals" runat="server" Visible="false">
                                <fieldset id="addItem">
                                    <legend id="addItem">Terminals</legend>
                                </fieldset>
                                <table border="0" width="100%" cellpadding="0" cellspacing="0" class="add_ItemTB">
                                    <tr>
                                        <td class="tdNormal" colspan="5">
                                            <asp:GridView ID="gvTerminals" CssClass="gridMaster" Width ="100%" runat="server" AutoGenerateColumns="False"
                                                DataKeyNames="term_id" AllowPaging="False" AllowSorting="True" CellPadding="4"
                                                ForeColor="#333333" GridLines="None" EmptyDataText="There are no Results" OnRowCommand="gvTerminals_RowCommand"
                                                OnRowCreated="gvTerminals_RowCreated">
                                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Right" />
                                                <Columns>
                                                    <asp:BoundField DataField="term_id" HeaderText="Terminal Id" />
                                                    <asp:BoundField DataField="txn_date" HeaderText="Date" />
                                                    <asp:BoundField DataField="txn_time" HeaderText="Time" />
                                                    <asp:BoundField DataField="srv_cnt" HeaderText="L1 Count" />
                                                    <asp:BoundField DataField="srv_amt" HeaderText="L1 Amount" />
                                                    <asp:BoundField DataField="fee_amt" HeaderText="Fee" />
                                                    <asp:BoundField DataField="net_amt" HeaderText="L2 Amount" />
                                                    <asp:BoundField DataField="settl_cnt" HeaderText="Mada Count" />
                                                    <asp:BoundField DataField="settl_amt" HeaderText="Mada Amount" />
                                                    <asp:BoundField DataField="tr_date" HeaderText="123456" />
                                                    <asp:BoundField DataField="tr_time" HeaderText="" /> 
                                                    <asp:BoundField DataField="acct_number" HeaderText="Account No" />
                                                    <asp:BoundField DataField="RETAILER_ID" HeaderText="Retailer ID" />
                                                    <asp:BoundField DataField="vat_fee_per" HeaderText="Total VAT Amount" />
                                                    <asp:BoundField DataField="settlement_method" HeaderText="Settle Method" />

                                                    
                                                    <asp:ButtonField ButtonType="Image" ItemStyle-Width="30px" CommandName="v" Text="View Services"
                                                        ImageUrl="~/Images/document_view.jpg"></asp:ButtonField>
                                                    <asp:ButtonField ButtonType="Image" ItemStyle-Width="30px" CommandName="p" Text="Print Statment"
                                                        ImageUrl="~/Images/print.jpg"></asp:ButtonField>
                                                </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>
                                </table>
                            </asp:Panel>
                            <asp:Panel ID="pnlServices" runat="server" Visible="false">
                                <fieldset id="addItem">
                                    <legend id="addItem">Services</legend>
                                </fieldset>
                                <table border="0" width="100%" cellpadding="0" cellspacing="0" class="add_ItemTB">
                                    <tr>
                                        <td class="tdNormal" colspan="5">
                                            <asp:GridView ID="gvServices" CssClass="gridMaster" Width ="100%" 
                                                runat="server" AutoGenerateColumns="False"
                                                DataKeyNames="pts_code" AllowPaging="True" AllowSorting="True" CellPadding="4"
                                                ForeColor="#333333" GridLines="None" EmptyDataText="There are no Results" OnRowCommand="gvServices_RowCommand"
                                                OnPageIndexChanging="gvServices_PageIndexChanging" 
                                                onrowcreated="gvServices_RowCreated">
                                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Right" />
                                                <Columns>
                                                    <asp:BoundField DataField="term_id" HeaderText="Term ID" />
                                                    <asp:BoundField DataField="txn_date" HeaderText="Date" />
                                                    <asp:BoundField DataField="tr_time" HeaderText="Time" />
                                                    <asp:BoundField DataField="srv_type" HeaderText="Service" />
                                                    <asp:BoundField DataField="srv_cnt" HeaderText="L1 Count" />
                                                    <asp:BoundField DataField="srv_amt" HeaderText="L1 Amount" />
                                                    <asp:BoundField DataField="fee_amt" HeaderText="Fee" />
                                                    <asp:BoundField DataField="net_amt" HeaderText="L2 Amount" />
                                                    <asp:BoundField DataField="settl_cnt" HeaderText="Mada Count" />
                                                    <asp:BoundField DataField="settl_amt" HeaderText="Mada Amount" />
                                                    <asp:BoundField DataField="acct_number" HeaderText="Account No" />
                                                    <asp:BoundField DataField="REC_TYPE" HeaderText="REC Type" />
                                                    <asp:BoundField DataField="Status" HeaderText="Status" />
                                                      <asp:BoundField DataField="vat_fee_per" HeaderText="VAT Rate %" />

                                                    <asp:ButtonField ButtonType="Image" ItemStyle-Width="30px" CommandName="v" Text="View Transaction"
                                                        ImageUrl="~/Images/document_view.jpg"></asp:ButtonField>
                                                        <asp:ButtonField ButtonType="Image" ItemStyle-Width="30px" CommandName="p" Text="Print Statment"
                                                        ImageUrl="~/Images/print.jpg"></asp:ButtonField>
                                                </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>
                                </table>
                            </asp:Panel>
                            <!------------------------------------body End2 ----------------------------------------------->
                            <br>
                            <asp:Panel ID="pnlTxn" runat="server" Visible="false">
                                <fieldset id="addItem">
                                    <legend id="addItem">Transactions</legend>
                                </fieldset>
                                <table border="0" width="100%" cellpadding="0" cellspacing="0" class="add_ItemTB">
                                    <tr>
                                        <td class="tdNormal" colspan="5">
                                            <asp:GridView ID="gvTxn" CssClass="gridMaster" Width ="100%" runat="server" AutoGenerateColumns="False"
                                                AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None"
                                                DataKeyNames="mt_code" EmptyDataText="There are no results" 
                                                onpageindexchanging="gvTxn_PageIndexChanging">
                                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                <Columns>
                                                    <asp:BoundField DataField="Pts_Code" HeaderText="PTS Code" />
                                                    <asp:BoundField DataField="TRAN_DATE" HeaderText="TRAN Date" />
                                                    <asp:BoundField DataField="TRAN_TIME" HeaderText="TRAN Time" />
                                                    <asp:BoundField DataField="msg_type" HeaderText="Txn type" />
                                                    <asp:BoundField DataField="pcode" HeaderText="Txn Desc" />
                                                    <asp:BoundField DataField="CARD_NUMBER" HeaderText="CARD NUMBER" />
                                                    <asp:BoundField DataField="FINANCIAL_FLAG" HeaderText="Financial flag" />
                                                    <asp:BoundField DataField="TERM_ID" HeaderText="TERM ID" />
                                                    <asp:BoundField DataField="TRAN_SOURCE" HeaderText="TRAN_SOURCE" />
                                                    <asp:BoundField DataField="TRAN_DEST" HeaderText="TRAN_DEST" />
                                                    <asp:BoundField DataField="RRN" HeaderText="Reference No" />
                                                    <asp:BoundField DataField="product" HeaderText="Merchant Fees" />
                                                    <asp:BoundField DataField="TRAN_AMOUNT" HeaderText="AMOUNT" />
                                                    <asp:BoundField DataField="TRAN_CURR" HeaderText="Txn. Curr" />
                                                    <asp:BoundField DataField="vat_fee" HeaderText="VAT Amount" />
                                                    <asp:BoundField DataField="Pos_Settled" HeaderText="Settle Flag" />
                                                    <asp:BoundField DataField="Vat_Inv_Status" HeaderText="VAT Status" />

                                                </Columns>
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </td>
                    </tr>
                </table>
                <!------------------------------------body End2 ----------------------------------------------->
            </td>
        </tr>
    </table>
</asp:Content>
