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

<%@ 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>
    
     <%-- Loading  CSS :--%>
    <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">
    <div>

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



            <%--           <table style="margin-left: 1%; width: 98%;">
                <tr>
                    <td style="font-size:large; width: 50%; font-family:'Open Sans', sans-serif; font-weight:bolder;">
                       DETAILED STOCK REPORT
                       
                    </td>
              </tr>
            </table>--%>

            <div class="section-block">
                <h6 class="section-title">STOCK REPORT
                </h6>
            </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>
                                <%--onselectedindexchanged="cmbBranches_SelectedIndexChanged" --%>
                                <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">
                                    <label for="validationCustom03">
                                        Category Name 
                                        <asp:Label ID="lblCategoryName" ForeColor="Blue" runat="server"></asp:Label></label>
                                    <asp:DropDownList ID="cmbCategoryname" CssClass="custom-select"
                                        runat="server" AutoPostBack="true"
                                        OnSelectedIndexChanged="cmbSearchBy_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </div>

                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                    <label for="validationCustom03">
                                        Search By 
                                        <asp:Label ID="lblSearchBy" ForeColor="Blue" runat="server"></asp:Label></label>
                                    <asp:DropDownList ID="cmbSearchBy" CssClass="custom-select"
                                        runat="server" AutoPostBack="true" OnSelectedIndexChanged="cmbSearchBy_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </div>

                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                    <label for="validationCustom03">
                                        (Search) Like 
                                        <asp:Label ID="lblBarcode" ForeColor="Blue" runat="server"></asp:Label></label>
                                    <asp:TextBox ID="txtBarcode" runat="server" class="form-control"></asp:TextBox>
                                </div>
                                <div class="col-2 align-content-center text-right">
                                        <asp:Label ID="lblcurrentdb" runat="server" Style="color: transparent"></asp:Label>
                                    </div>
                            </div>
                        </div>

                        <table>
                            <tr>
                                <td>
                                    <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>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <br />

            <%--<div style="margin-left: 0px;">
<div class="container-fluid  dashboard-content">
<div class="row">--%>
            <%--<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">--%>
            <div class="card" style="display: block">
                 <h5 class="card-header" id="idGenReport" runat="server">

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

                <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="InventoryID" AutoGenerateColumns="false" Font-Size="13px"
                                                Width="98%" FooterStyle-ForeColor="white"
                                                OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="True" PageSize="20" >

                                               

                                                <Columns>

                                                    <asp:BoundField DataField="InventoryID" HeaderText="InvID" HeaderStyle-HorizontalAlign="Left" HtmlEncode="False" ItemStyle-HorizontalAlign="left" ItemStyle-Width="2%" />
                                                    <asp:BoundField DataField="Barcode" HeaderText="Barcode" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="11%" />
                                                    <asp:BoundField DataField="InventoryName" HeaderText="Name" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="18%" />
                                                    <asp:BoundField DataField="CategoryName" HeaderText="Category" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="14%" />
                                                    <asp:BoundField DataField="OpeningBalance" HeaderText="Op.Bal" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="StockIn" HeaderText="StockIn" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="PInvoice" HeaderText="P.Inv" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="Receive" HeaderText="Rec.Stk" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="TransferRet" HeaderText="Tfr.Ret" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="StockOut" HeaderText="Stk.Out" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="PReturn" HeaderText="P.Ret" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="Transfer" HeaderText="Tfr" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="RetailSales" HeaderText="R.Sales" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="Wastage" HeaderText="Wastage" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="StockCheck" HeaderText="StkChk" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="100px" />
                                                    <asp:BoundField DataField="ClosingBalance" HeaderText="Cl.Bal" HeaderStyle-HorizontalAlign="Right" HeaderStyle-CssClass="text-right" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px" DataFormatString="{0:n2}" />


                                                </Columns>

                                                 <HeaderStyle BackColor="White" Font-Size="13px" Font-Bold="True" ForeColor="Black"></HeaderStyle>
                                                <PagerStyle CssClass="gridview"></PagerStyle>
                                                <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 class="card d-none">
              <%--  <h5 class="card-header" id="idGenReport" runat="server">
                    <asp:Label ID="lblMsgTotalSelection" runat="server" CssClass="Labels"> </asp:Label>
                </h5>--%>
                <div class="container-fluid bg-white overflow-auto px-0">


                    <%--   <table id="tblinventory" class="table table-bordered">
                    <thead>
                        <tr>
                            <th class="col-2">Barcode</th>
                            <th class="col-2">Name</th>
                            <th class="col-2">Description</th>
                            <th class="col-1">Category</th>
                            <th class="col-1 text-nowrap">Openning Balance</th>
                            <th class="col-1 text-nowrap">Stock In</th>
                            <th class="col-1 text-nowrap">Stock Out</th>
                            <th class="col-1 text-nowrap">Retail Sales</th>
                            <th class="col-1 text-nowrap">Closing Balance</th>
                        </tr>
                    </thead>
                    <tbody id="tblbodyinventory" class="d-block">
                    </tbody>
                    <tbody id="tblbodyinventorydetail" class="d-none">
                    </tbody>

                </table>--%>

                    <table id="tblheader" class="table table-bordered">
                        <thead>
                            <tr>
                                <th style="width:10px;"></th>
                                <th class="col-2">Barcode</th>
                                <th class="col-2">Name</th>
                                <th class="col-2">Description</th>
                                <th class="col-1">Category</th>
                                <th class="col-1 text-nowrap">Openning Balance</th>
                                <th class="col-1 text-nowrap">Stock In</th>
                                <th class="col-1 text-nowrap">Stock Out</th>
                                <th class="col-1 text-nowrap">Retail Sales</th>
                                <th class="col-1 text-nowrap">Closing Balance</th>
                            </tr>
                        </thead>
                        <tbody id="tblbody">

                        </tbody>
                    </table>

                </div>
                <div class="container-fluid p-3 bg-white">
                    <section class="col-4 d-flex" id="inventory-list"></section>
                    <div id="paggination"></div>
                </div>
            </div>
            
            <%--</div>--%>
            <%--</div>
</div>
</div>--%>
       

   

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paginationjs/2.1.5/pagination.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/paginationjs/2.1.5/pagination.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/paginationjs/2.1.5/pagination.js"></script>
    <script src="sunScript/api.js"></script>
    <script src="sunScript/detailstockreport.js"></script>
    <script type="text/javascript">

        function loadDB() {         
            return document.getElementById("<%=lblcurrentdb.ClientID %>").innerHTML;
        }
        function readWebConfig() {
            var conStr = '<%=ConfigurationManager.ConnectionStrings["API_BaseURL"].ConnectionString %>'
            return conStr
        }

        function loadDate(fromdate,todate,category,searchby,inventory){
          <%--  let fromdate = document.getElementById('<%= txtFromDt.ClientID %>')
            let todate =  document.getElementById('<%= txtToDt.ClientID %>') 
          
            sessionStorage.setItem("fromdate",fromdate.value);
            sessionStorage.setItem("todate",todate.value);--%>
            loadData(fromdate,todate,category,searchby,inventory)
        }
    </script>



             <asp:UpdateProgress ID="UpdateProgress" runat="server" AssociatedUpdatePanelID="updatepanel174">
     <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>


 </ContentTemplate>
</asp:UpdatePanel>
 <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>
