<%@ Page Title="Journal Report" Language="C#" MasterPageFile="~/SunMaster.Master" AutoEventWireup="true" CodeBehind="JournalReport.aspx.cs" Inherits="SUNWEB.JournalReport" %>

<%@ Register Assembly="AjaxControlToolkit" TagPrefix="asp" Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
    <link type="text/css" rel="Stylesheet" href="css/NestedDG.css" />
    <style type="text/css">
        @media only screen and (max-width: 600px) {
            table, th, td {
                font-size: 10px;
                font-weight: bold;
            }

            .Labels {
                font-size: 10px;
            }

            .alnright {
                text-align: right;
            }
        }
    </style>
    <style type="text/css">
        .overlay {
            position: fixed;
            top: 0px;
            left: 0px;
            z-index: 0;
            height: 100%;
            width: 100%;
            top: 0;
            background-color: White;
            filter: alpha(opacity=60);
            opacity: 0.9;
            -moz-opacity: 1;
        }

        .LoadingDivCss {
            margin: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-right: -50%;
            transform: translate(-50%, -50%);
        }

        .LoadingImgCss {
            height: 100px;
            width: 100px;
        }
    </style>


    
    <%--Grid Pager CSS :--%>
    <style>
        .GridPager a,
        .GridPager span {
            display: inline-block;
            padding: 0px 9px;
            margin-right: 4px;
            border-radius: 3px;
            border: solid 1px #c0c0c0;
            background: #e9e9e9;
            box-shadow: inset 0px 1px 0px rgba(255,255,255, .8), 0px 1px 3px rgba(0,0,0, .1);
            font-size:12PX;
            font-weight: bold;
            text-decoration: none;
            color: #717171;
            text-shadow: 0px 1px 0px rgba(255,255,255, 1);
        }

        .GridPager a {
            background-color: #f5f5f5;
            color: #969696;
            border: 1px solid #969696;
        }

        .GridPager span {

            background: #616161;
            box-shadow: inset 0px 0px 8px rgba(0,0,0, .5), 0px 1px 0px rgba(255,255,255, .8);
            color: #f0f0f0;
            text-shadow: 0px 0px 3px rgba(0,0,0, .5);
            border: 1px solid #3AC0F2;
        }

    </style>


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%--  <table style="margin-left: 1%; width: 98%;">
                <tr>
                    <td style="font-size:large; width: 50%; font-family:'Open Sans', sans-serif; font-weight:bolder;">
                        JOURNAL REPORT                      
                    </td>
              </tr>
            </table>--%>

    <div align="left">

        <asp:Button ID="btnExcel" runat="server" Text="Export"
            ToolTip="To Export the Report Click Here" CssClass="btn btn-success btn-xs"
            OnClick="btnExcel_Click" />

        <asp:Button ID="btnExportChangePaymentLog" runat="server" Text="Change Payment Log"
            ToolTip="To Export the Report Click Here" CssClass="btn btn-success btn-xs"
            OnClick="btnLog_Click" />
    </div>

    <asp:UpdatePanel ID="Upanel" runat="server">
        <ContentTemplate>


            <div class="section-block">
                <h7 class="section-title">JOURNAL REPORT     
                </h7>
            </div>
            <div class="row">

                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="card">

                        <div class="card-body">
                            <div class="form-row">
                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                    <caption>
                                        <label for="validationCustom03">
                                            From
                                        </label>

                                        <asp:TextBox ID="txtFromDt" class="form-control" runat="server"
                                            Font-Size="Small"></asp:TextBox>
                                        <asp:CalendarExtender ID="calFirstDueDate" Format="yyyy-MM-dd" runat="server" TargetControlID="txtFromDt"
                                            PopupPosition="BottomLeft" FirstDayOfWeek="Sunday"></asp:CalendarExtender>


                                    </caption>



                                </div>
                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                    <label for="validationCustom03">
                                        To
                                    </label>

                                    <asp:TextBox ID="txtToDt" runat="server" class="form-control"></asp:TextBox>
                                    <asp:CalendarExtender ID="CalendarExtender1" Format="yyyy-MM-dd" runat="server" TargetControlID="txtToDt"
                                        PopupPosition="BottomLeft" FirstDayOfWeek="Sunday"></asp:CalendarExtender>




                                </div>
                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                    <label for="validationCustom03">
                                        Branch
                                               <asp:Label ID="lblBranchAliasName" ForeColor="Blue" runat="server"></asp:Label></label>
                                    <asp:DropDownList ID="cmbBranches" CssClass="custom-select"
                                        runat="server" AutoPostBack="true"
                                        OnSelectedIndexChanged="cmbBranches_SelectedIndexChanged">
                                    </asp:DropDownList>

                                </div>
                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                    <asp:Button ID="btnGenerate" runat="server" Text="Apply" Class="btn btn-primary"
                                        OnClick="btnGenerate_Click" />
                                </div>

                            </div>

                        </div>



                    </div>
                </div>
            </div>
            <br />

            <%--<div style="margin-left: 0px;">
<div class="container-fluid  dashboard-content">
<div class="row">--%>

            <div class="row">
                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="card">


                        <h4 class="card-header" id="idGenReport" runat="server">
                            <asp:Label ID="lblMsgTotalSelection" runat="server" CssClass="Labels"> </asp:Label></h4>
                        <%--<asp:Button ID="btnPdf" runat="server" Text="PDF" 
            ToolTip="To Export  the Report Click Here"  CssClass="btn btn-secondary" 
            onclick="btnPdf_Click"/>--%>  
        </h4>
 


                        <div class="card-body">
                            <div class="table-responsive">
                                <div align="center">
                                    <table id="example4" class="table table-striped table-bordered" style="width: 100%">
                                        <tbody>
                                            <caption>
                                                <div align="center">

                                                    <asp:GridView ID="GridView1"
                                                        runat="server" ShowFooter="true" BorderColor="Transparent"
                                                        DataKeyNames="TransID" AutoGenerateColumns="false" Font-Size="13px"
                                                        OnRowDataBound="GridView1_RowDataBound" Width="100%" EmptyDataText="No Record Found !"
                                                        OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="True" PageSize="20">

                                                        <HeaderStyle CssClass="dataTable" />
                                                        <HeaderStyle BackColor="White" ForeColor="Black" />
                                                        <FooterStyle BackColor="White" ForeColor="Black" />
                                                        <%--<AlternatingRowStyle CssClass="dataTableAlt" />--%>
                                                        <RowStyle CssClass="dataTable" />

                                                        <Columns>
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <a href="javascript:switchViews('div<%# Eval("TransID") %>', 'one');">
                                                                        <img id="imgdiv<%# Eval("TransID") %>" alt="Click to show/hide Details" border="0" src="IMG/plus.gif" />
                                                                    </a>
                                                                </ItemTemplate>
                                                                <AlternatingItemTemplate>
                                                                    <a href="javascript:switchViews('div<%# Eval("TransID") %>', 'alt');">
                                                                        <img id="imgdiv<%# Eval("TransID") %>" alt="Click to show/hide Details" border="0" src="IMG/plus.gif" />
                                                                    </a>
                                                                </AlternatingItemTemplate>
                                                            </asp:TemplateField>

                                                            <asp:BoundField DataField="TransID" HeaderText="TransID" HeaderStyle-HorizontalAlign="Left" HtmlEncode="False" ItemStyle-HorizontalAlign="left" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="TransNo" HeaderText="TransNo" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="10%" />
                                                            <asp:BoundField DataField="TStatus" HeaderText="TStatus" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="TDate" HeaderText="T.Date" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="15%" />
                                                            <asp:BoundField DataField="LDate" HeaderText="L.Date" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="25%" />
                                                            <asp:BoundField DataField="CName" HeaderText="Cashier" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="SPName" HeaderText="SP.Name" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="CNo" HeaderText="Cus.No" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="SubTotal" HeaderText="SubTotal" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="Disc" HeaderText="Disc" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="Tax1" HeaderText="Tax1" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="Tax2" HeaderText="Tax2" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-Width="5%" />
                                                            <asp:BoundField DataField="Total" HeaderText="Total" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-Width="5%" />
                                                            <asp:TemplateField ShowHeader="False">
                                                                <ItemTemplate>
                                                                    <%--   <asp:Button ID="btnEdit" runat="server" CausesValidation="false"  CommandArgument='<%# Container.DataItemIndex%>'  CommandName="Edit"
                                                                                                    Text="Edit" />--%>
                                                                    <button type="button" id="btnEdit" class="btn btn-primary" onclick="editPayment(this)">Edit</button>
                                                                    <%-- john added on 24-Dec-2024 for change paymenttype--%>
                                                                    <%-- <asp:Button  id="btnEdit" class="btn btn-primary" runat="server" OnClientClick="editPayment(this)" Text="Edit"/>--%>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <tr>
                                                                        <td colspan="100%">
                                                                            <div id="div<%# Eval("TransID") %>" style="display: none; position: relative; left: 93px;">

                                                                                <asp:GridView ID="GridView2" runat="server" Width="85%"
                                                                                    AutoGenerateColumns="false" DataKeyNames="ItemID"
                                                                                    EmptyDataText="No Details">
                                                                                    <HeaderStyle CssClass="dataTable" />
                                                                                    <RowStyle CssClass="dataTable" />
                                                                                    <Columns>
                                                                                        <asp:BoundField DataField="ItemID" HeaderText="ItemID" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="10%" />
                                                                                        <asp:BoundField DataField="IBarcode" HeaderText="Barcode" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="15%" />
                                                                                        <asp:BoundField DataField="IName" HeaderText="Name" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="15%" />
                                                                                        <asp:BoundField DataField="IDesc" HeaderText="Desc" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="15%" />
                                                                                        <asp:BoundField DataField="IQty" HeaderText="Qty" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-Right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="IActualPrice" HeaderText="A.Price" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="IPrice" HeaderText="S.Price" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="IPriceType" HeaderText="P.Type" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="IDisc" HeaderText="ItemDisc" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="MIDisc" HeaderText="MItemDisc" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="IAmount" HeaderText="Amount" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="5%" />
                                                                                        <asp:BoundField DataField="ISTA" HeaderText="IStatus" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-Left" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="10%" />

                                                                                    </Columns>
                                                                                </asp:GridView>

                                                                                <asp:GridView ID="GridView3" runat="server" Width="85%"
                                                                                    AutoGenerateColumns="false" DataKeyNames="PaymentID"
                                                                                    EmptyDataText="No Details">
                                                                                    <HeaderStyle CssClass="dataTable" />
                                                                                    <RowStyle CssClass="dataTable" />
                                                                                    <Columns>
                                                                                        <asp:BoundField DataField="PaymentID" HeaderText="PaymentID" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="10%" />
                                                                                        <asp:BoundField DataField="PPayDate" HeaderText="PayDate" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="20%" />
                                                                                        <asp:BoundField DataField="PPaymentType" HeaderText="PaymentType" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="10%" />
                                                                                        <asp:BoundField DataField="PPaymentAmount" HeaderText="PaymentAmount" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-Right" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="15%" />
                                                                                        <asp:BoundField DataField="PCardNumber" HeaderText="CardNumber" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-Left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="25%" />
                                                                                        <asp:BoundField DataField="PCardName" HeaderText="CardName" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="20%" />
                                                                                        <%--<asp:BoundField DataField="PAction" HeaderText="Action" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" ItemStyle-HorizontalAlign="left" ItemStyle-Width="20%" />--%>
                                                                                    </Columns>
                                                                                </asp:GridView>

                                                                            </div>

                                                                        </td>
                                                                    </tr>
                                                                    </tr>
                                                                </ItemTemplate>
                                                            </asp:TemplateField>

                                                        </Columns>

                                                        <PagerStyle HorizontalAlign="Left" CssClass="GridPager" />
                                                        <RowStyle ForeColor="#000066" />
                                                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                                                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                                        <SortedAscendingHeaderStyle BackColor="#007DBB" />
                                                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                                        <SortedDescendingHeaderStyle BackColor="#00547E" />
                                                    </asp:GridView>
                                                </div>
                                            </caption>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Modal change aymenttype-->
            <div class="modal fade" id="modaleditpayment" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog ">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h3 class="modal-title text-black fw-light">Edit Payment Type</h3>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            <div class="d-flex justify-content-start">
                                <div class="col px-2 align-content-around text-end">
                                    <label for="inputtransid" class="form-label m-0 px-2">Trans ID :</label>
                                </div>
                                <div class="col px-2 align-content-around text-end">
                                    <input type="text" id="inputtransid" readonly class="form-control-plaintext fs-6 fw-bold">
                                </div>
                            </div>
                            <div class="d-flex justify-content-start">
                                <div class="col px-2 align-content-around text-end">
                                    <label for="inputtransno" class="form-label m-0 px-2">Trans No :</label>
                                </div>
                                <div class="col px-2 align-content-around text-end">
                                    <input type="text" id="inputtransno" readonly class="form-control-plaintext fs-6 fw-bold">
                                </div>
                            </div>
                            <div class="d-flex justify-content-start">
                                <div class="col px-2 align-content-around text-end">
                                    <label for="inputtransdate" class="form-label m-0 px-2">Trans Date :</label>
                                </div>
                                <div class="col px-2 align-content-around text-end">
                                    <input type="text" id="inputtransdate" readonly class="form-control-plaintext fs-6 fw-bold">
                                </div>
                            </div>
                            <div class="d-flex justify-content-start">

                                <div class="col px-2 align-content-around text-end">
                                    <label for="inputcurrent" class="form-label m-0 px-2">Current Payment Type :</label>
                                </div>
                                <div class="col px-2 align-content-around">
                                    <input type="text" id="inputcurrent" readonly class="form-control-plaintext fs-6 fw-bold" value="Coke">
                                </div>
                            </div>

                            <div class="d-flex justify-content-start">
                                <div class="col px-2 align-content-around text-end">
                                    <label for="inputchangeto" class="form-label m-0 px-2">Change to :</label>
                                </div>
                                <div class="col px-2 align-content-around">
                                    <asp:DropDownList ID="cmbpaymenttypes" CssClass="custom-select" runat="server">
                                    </asp:DropDownList>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-outline-danger btn-md m-0" onclick="updatePaymenttype()">Confirm</button>
                            <button type="button" class="btn btn-warning" data-bs-dismiss="modal">Close</button>

                        </div>
                    </div>
                </div>
            </div>

            <script type="text/javascript">
                 function switchViews(obj, row) {
                     var div = document.getElementById(obj);
                     var img = document.getElementById('img' + obj);
                     console.log('click')
                     if (div.style.display == "none") {
                         div.style.display = "inline";
                         img.src = "IMG/minus.gif";
                     } else {
                         div.style.display = "none";
                         img.src = "IMG/plus.gif";
                     }
                 }
            </script>

            <!--john added on 24-Dec-2024 for change paymenttype-->
            <script type="text/javascript">          
                $( document ).ready(function() {
                  
                });
                
                function GetCurrentDateTime() {                  
                    var CurrentDate = new Date().getFullYear() + '-' + ("0" + (new Date().getMonth() + 1)).slice(-2) + '-' + ("0" + new Date().getDate()).slice(-2);
                    let date = new Date();
                    let HH = date.getHours();
                    let MM = date.getMinutes();
                    let ss = date.getSeconds();
                    let session = "AM";

                    HH = (HH < 10) ? "0" + HH : HH;
                    MM = (MM < 10) ? "0" + MM : MM;                 
                    let time = HH + ":" + MM;
                                   
                    return CurrentDate + " " + time;
                }
      
                function checkButtonPermission(){                     
                    $('#<%=GridView1.ClientID %> tr td button').addClass('d-none');
                }

                function editPayment(el){
                    let transid = $(el).closest("tr").find("td:eq(1)").text();
                    let transno = $(el).closest("tr").find("td:eq(2)").text();
                    let transdate = $(el).closest("tr").find("td:eq(4)").text();
                    let currentpaymenttype =  getTransIDPaymentType(transid);

                    $('#inputtransid').val(transid);
                    $('#inputtransno').val(transno);
                    $('#inputtransdate').val(transdate);
                    $('#inputcurrent').val(currentpaymenttype);
                    $('#modaleditpayment').modal('show');                        
                }
                             
                function getTransIDPaymentType(transid){
                    var response = $.ajax({
                        type: "POST",
                        url: "JournalReport.aspx/getCurrentPaymentType",
                        async: false,
                        data: "{transid:'" + transid + "'}",
                        contentType: 'application/json;charset=utf8',
                        beforeSend: function () {
                            //$('#modalspinner').modal('show');
                        },
                        complete: function (result) {
                            // modalLoad.style.display = "none";
                        },
                        dataType: 'json',
                        error: function (jqXHR, textStatus, errorThrown) {
                            console.log(errorThrown);
                        },
                        success: function (result) {
                            
                        }
                    });
                    return response.responseJSON.d;
                }

                function updatePaymenttype(){
                    let transid =  $('#inputtransid').val()
                    
                    let paymenttype = $('#<%=cmbpaymenttypes.ClientID %>').val();
                    //let transid = 1;

                    var answer = confirm('Are you sure you want to change paymenttype?');
                    if (!answer)
                    {
                        return;
                    }


                   $.ajax({
                        type: "POST",
                        url: "JournalReport.aspx/putPaymentType",
                        async: false,
                        data: "{transid:'" + transid + "',paymenttype:'" + paymenttype + "'}",
                        contentType: 'application/json;charset=utf8',
                        beforeSend: function () {
                            //$('#modalspinner').modal('show');
                        },
                        complete: function (result) {
                            // modalLoad.style.display = "none";
                        },
                        dataType: 'json',
                        error: function (jqXHR, textStatus, errorThrown) {
                            console.log(errorThrown);
                        },
                        success: function (result) {                          
                            postLog();
                            $('#modaleditpayment').modal('hide');                             
                            alert('Paymenttype successfully change!')                     
                            sessionStorage.setItem("transid",transid);                      
                            $('#<%=btnGenerate.ClientID %>').trigger('click');                                                     
                        }
                    });
                      
                }

                function postLog(){
                    let transid = $('#inputtransid').val();
                    let transno = $('#inputtransno').val();
                    let transactiondate = $('#inputtransdate').val();
                    let frompaymenttype =  $('#inputcurrent').val();
                    let changepaymenttypedate = GetCurrentDateTime();
                    let topaymenttype = $('#<%=cmbpaymenttypes.ClientID %>').find(":selected").val();         
                    $.ajax({
                        type: "POST",
                        url: "JournalReport.aspx/postLog",
                        async: false,                                                
                        data:"{transid:'" + transid + "',transno:'" + transno + "',transactiondate:'" + transactiondate + "',frompaymenttype:'" + frompaymenttype + "',changepaymenttypedate:'" + changepaymenttypedate + "',topaymenttype:'" + topaymenttype + "'}",
                        contentType: 'application/json;charset=utf8',
                        beforeSend: function () {
                            //$('#modalspinner').modal('show');
                        },
                        complete: function (result) {
                            // modalLoad.style.display = "none";
                        },
                        dataType: 'json',
                        error: function (jqXHR, textStatus, errorThrown) {
                            console.log(errorThrown);
                        },
                        success: function (result) {                          
                          <%--  $('#modaleditpayment').modal('hide'); 
                            alert('Paymenttype successfully change!')                     
                            sessionStorage.setItem("transid",transid);                      
                            $('#<%=btnGenerate.ClientID %>').trigger('click');           --%>                                          
                        }
                    });
                }

                function collapse(){
                    let transid = sessionStorage.getItem("transid");
                    $("#div" + transid).attr("style", "display: inline; position: relative; left: 93px;")    
                    sessionStorage.removeItem("transid");
  
                }

            </script>
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="Upanel">
        <ProgressTemplate>
            <div class="overlay">
                <%--  <div style="z-index: 1000; margin-left: 450px; margin-top: 0; opacity: 1; -moz-opacity: 1;">--%>
                <div class="LoadingDivCss">
                    <img alt="" src="IMG/Spinner.gif" class="LoadingImgCss" />
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>


 <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css?v=1.1" rel="stylesheet" />
  <!-- Bootstrap 5 -->
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
 <!-- Optional Bootstrap Icons -->
 <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" />
</asp:Content>
