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

<%@ Register Assembly="AjaxControlToolkit" TagPrefix="asp" Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.min.css">
    <link href="../assets/vendor/fonts/circular-std/style.css" rel="stylesheet">
    <link rel="stylesheet" href="../assets/libs/css/style.css">
    <link rel="stylesheet" href="../assets/vendor/fonts/fontawesome/css/fontawesome-all.css">
    <link rel="stylesheet" type="text/css" href="../assets/vendor/datatables/css/dataTables.bootstrap4.css">
    <link rel="stylesheet" type="text/css" href="../assets/vendor/datatables/css/buttons.bootstrap4.css">
    <link rel="stylesheet" type="text/css" href="../assets/vendor/datatables/css/select.bootstrap4.css">
    <link rel="stylesheet" type="text/css" href="../assets/vendor/datatables/css/fixedHeader.bootstrap4.css">
    <link type="text/css" rel="Stylesheet" href="css/style.css" />

    <%--<script type="text/javascript">
    function showProgress() 
    {
        var updateProgress = $get("<%= UpdateProgress.ClientID %>");
        updateProgress.style.display = "block";
    }
    </script>--%>
    <script type="text/javascript">
        $("[src*=plus]").live("click", function () {
            $(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
            $(this).attr("src", "IMG/minus.gif");
        });
        $("[src*=minus]").live("click", function () {
            $(this).attr("src", "IMG/plus.gif");
            $(this).closest("tr").next().remove();
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%-- <asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">
  <ContentTemplate>--%>
    <%-- <table style="margin-left: 1%; width: 98%;">
        <tr>
            <td style="font-size: x-large; width: 50%; font-family: 'Open Sans', sans-serif;
                font-weight: bolder;">
                STOCK RECEIVING
            </td>
            <td align="right" style="font-family: 'Open Sans',Sans-Serif; font-size: small;">
                Branch
                <asp:DropDownList ID="cmbBranches" CssClass="custom-select" Width="250px" runat="server"
                    AutoPostBack="true" OnSelectedIndexChanged="cmbBranches_SelectedIndexChanged">
                </asp:DropDownList>
                &nbsp;&nbsp;
                <asp:Label ID="lblBranchAliasName" ForeColor="Blue" runat="server"></asp:Label>
            </td>
        </tr>
    </table>--%>
    <div class="section-block">
        <h5 class="section-title">STOCK RECEIVING
        </h5>
    </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="txtStartDt" class="form-control" runat="server"></asp:TextBox>
                                <asp:CalendarExtender ID="calFirstDueDate" Format="yyyy-MM-dd" runat="server" TargetControlID="txtStartDt"
                                    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="txtEndDt" class="form-control" runat="server"></asp:TextBox>
                            <asp:CalendarExtender ID="CalendarExtender1" Format="yyyy-MM-dd" runat="server" TargetControlID="txtEndDt"
                                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">
                                <asp:Label ID="lblBranchAliasName" ForeColor="Gray" runat="server" Text="Branch"></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 d-none">
                            <asp:Button ID="btnApplySearch" runat="server" Text="Apply" CssClass="btn btn-primary" OnClick="btnApplySearch_Click" />
                        </div>
                        <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                            <button type="button" class="btn btn-primary btn-sm" id="button-apply">Apply</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <br />
    <div>
        <div class="row d-none">
            <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                <div class="card">
                    <div class="card-header">
                    </div>
                    <div class="card-body">


                        <%--                                    <asp:GridView ID="grdStockReceiving" EmptyDataText="No Record found" runat="server"
                                        CellPadding="4" ForeColor="#333333" AutoGenerateColumns="False" Height="68px"
                                        Width="818px" OnSelectedIndexChanged="grdStockReceiving_SelectedIndexChanged"
                                        ShowHeaderWhenEmpty="true">
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />--%>
                        <div class="table-responsive">
                            <div>
                                <asp:GridView ID="grdStockReceiving" EmptyDataText="No Record found" runat="server"
                                    AutoGenerateColumns="False" EmptyDataRowStyle-CssClass="alert-dark" Font-Size="15px"
                                    HeaderStyle-BackColor="RoyalBlue" FooterStyle-BackColor="Green" FooterStyle-ForeColor="white"
                                    Width="920px" AllowPaging="true" PageSize="15" BackColor="White" AllowSorting="true"
                                    BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" OnSelectedIndexChanged="grdStockReceiving_SelectedIndexChanged"
                                    OnRowDataBound="OnRowDataBound"
                                    ShowHeaderWhenEmpty="true" OnPageIndexChanging="grdStockReceiving_PageIndexChanging">
                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    <Columns>
                                        <asp:TemplateField HeaderText="Transfer No.">
                                            <ItemTemplate>
                                                <asp:Label ID="lblTransferID" runat="server" Text='<%#Eval("TransferNo") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="From">
                                            <ItemTemplate>
                                                <asp:Label ID="lblBranchID" runat="server" Text='<%#Eval("BranchName") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="To">
                                            <ItemTemplate>
                                                <asp:Label ID="lblBranchFullName" runat="server" Text='<%#Eval("BranchFullName") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>

                                        <asp:TemplateField HeaderText="" ItemStyle-Width="0" Visible="false">
                                            <ItemTemplate>
                                                <asp:Label ID="lblToBranchID" runat="server" Visible="false" Width="0px" Text='<%#Eval("ToBranch") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Transfer Date">
                                            <ItemTemplate>
                                                <asp:Label ID="lblTransderDate" runat="server" Text='<%#Eval("TransferDate") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Status">
                                            <ItemTemplate>
                                                <asp:Label ID="lblTranferStatus" runat="server" Text='<%#Eval("Status") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="">
                                            <ItemTemplate>
                                                <!--<asp:Label ID="lbl" runat="server" Text='<%#Eval("Status") %>'></asp:Label>-->
                                                <asp:Button ID="btnView" runat="server" Text="View Details" PostBackUrl='<%# "ReceivingStockTransfer.aspx?TransferNo=" + Eval("TransferNo") + "&ToBranch="+ Eval("ToBranch") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <FooterStyle BackColor="#006699" ForeColor="White"></FooterStyle>
                                    <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black"></HeaderStyle>
                                    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                    <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>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container-fluid bg-white p-2">
       
        <div class="container-fluid" style="overflow-x: auto">
            <table class="table table table-bordered">
                <thead>
                    <tr>
                        <th scope="col" class="text-center">#</th>
                        <th scope="col">Transfer #</th>
                        <th scope="col">Date</th>
                        <th scope="col">Branch From</th>
                        <th scope="col">Branch To</th>
                        <th scope="col">Status</th>
                        <th scope="col">Action</th>
                    </tr>
                </thead>
                <tbody id="table-body-receivestock">
                </tbody>
            </table>
        </div>
    </div>
    <script src="sunScript/stockreceive.js"></script>
    <script>
        function getSelectedBranch(){      
            return $("#<%=cmbBranches.ClientID %> option:selected").text();          
        }

        let selectedbranch = $("#<%=cmbBranches.ClientID %> option:selected").text();
        let fromdate = $("#<%=txtStartDt.ClientID %>").val();
        let todate = $("#<%=txtStartDt.ClientID %>").val();

        ini_data(selectedbranch,fromdate,todate)

        $( "#button-apply" ).on( "click", function() {
            let branch =  $("#<%=cmbBranches.ClientID %> option:selected").text();     
            let fromdate = $("#<%=txtStartDt.ClientID %>").val();
            let todate = $("#<%=txtEndDt.ClientID %>").val();
            ini_data(branch,fromdate,todate);
           
        });
    </script>

  s<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>
