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

<%--<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>--%>
<%@ Register Assembly="AjaxControlToolkit" TagPrefix="asp" Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        
    <link type="text/css" rel="Stylesheet" href="css/style.css" />
     <script type="text/javascript">
        function switchViews(obj, row) {
            var div = document.getElementById(obj);
            var img = document.getElementById('img' + obj);

            if (div.style.display == "none") {
                div.style.display = "inline";
                img.src = "IMG/minus.gif";
            } else {
                div.style.display = "none";
                img.src = "IMG/plus.gif";
            }
        }

        function CheckOne(obj) {
            var grid = obj.parentNode.parentNode.parentNode;
            var inputs = grid.getElementsByTagName("input");
            for (var i = 0; i < inputs.length; i++) {
                if (inputs[i].type == "checkbox") {
                    if (obj.checked && inputs[i] != obj && inputs[i].checked) {
                        inputs[i].checked = false;
                    }
                }
            }
        }  


    </script>
     <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>


</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div align="left">
    <asp:Button ID="btnExcel" runat="server" CssClass="btn btn-success btn-xs"  onclick="btnExcel_Click" Text="Excel" BackColor="Green" BorderColor="Green" ToolTip="To Export the Report Click Here" />      
    </div>

    <asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">
        <ContentTemplate>

              <div class="section-block">
                <h6 class="section-title">
                INVENTORY LIST 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="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">
                                    <label for="validationCustom03">
                                        <asp:Label ID="Label2" ForeColor="Gray" runat="server" Text="Inventory"></asp:Label></label>
                                    <asp:DropDownList ID="cmbInventory" CssClass="custom-select" runat="server" AutoPostBack="true"
                                        OnSelectedIndexChanged="cmbInventory_SelectedIndexChanged">
                                        <asp:ListItem Text="All Inventory" Value="0" />
                                        <asp:ListItem Text="Category" Value="1" />
                                    </asp:DropDownList>
                                </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="lblCategory" ForeColor="Gray" runat="server" Text="Category"></asp:Label></label>
                                    <asp:DropDownList ID="cmbCategory" CssClass="custom-select" runat="server" AutoPostBack="true"
                                        OnSelectedIndexChanged="cmbCategory_SelectedIndexChanged">
                                        <asp:ListItem Text="--Select----" Value="0" />
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div>
                                <asp:Button ID="btnGetReports" runat="server" Text="Apply" CssClass="btn btn-primary"
                                    OnClick="btnGetReports_Click" OnClientClick="return validate()" />
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <asp:Button ID="btnGenerateRpt" runat="server" class="btn btn-primary" Text="Generate Report" Visible="false" />
                                    
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div>
                <h4>&nbsp;<asp:Label ID="lblGreeting" runat="server"></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"/>--%>
            </div>
            <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>
                            </b> </p>
                        </h4>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table id="Table1" class="table table-striped table-bordered second" style="width: 100%">
                                    <tbody>
                                        <caption>
                                            <div align="left">
                                                <asp:Panel ID="Panel8" runat="server" BackColor="white" Height="520px" ScrollBars="Auto"
                                                 Width="1550px">
                                                 <asp:GridView ID="gvInventoryList" runat="server" AutoGenerateColumns="False" Font-Size="12px"
                                                    AllowSorting="true" EmptyDataText="No Data Found !" DataKeyNames="CategoryID" PageSize="500000"
                                                    Width="950px" ShowFooter="True" OnRowDataBound="gvInventoryList_RowDataBound"
                                                    BorderWidth="1px" CellPadding="3">
                                                    <Columns>

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

                                                      <asp:TemplateField HeaderText="CATEGORY NAME">
                                                            <ItemTemplate>
                                                                <asp:Label ID="lblCategoryName" runat="server" Text='<%#Eval("CategoryName") %>'></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterTemplate>
                                                             <b style="margin-left:400px">GRAND TOTAL </b>   
                                                            </FooterTemplate>
                                                        </asp:TemplateField>

                                                         <asp:TemplateField HeaderText="ON HAND QTY" FooterStyle-HorizontalAlign="Center" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center">
                                                            <ItemTemplate>
                                                                <asp:Label ID="lblOnhndqty" runat="server" Text='<%# string.Format("{0:n2}",Eval("OnHandQty")) %>'></asp:Label>
                                                            </ItemTemplate>
                                                              <FooterTemplate>
                                                            
                                                             <asp:Label ID="lblOnHandTotal" runat="server"  Width="100px"/>
                                                            </FooterTemplate>
                                                        </asp:TemplateField>

                                                          <asp:TemplateField>
                                                          <ItemTemplate>
                                                              <tr>
                                                                <td colspan="100%" style="padding-left:60px">
                                                                <div id="div<%# Eval("CategoryID") %>" style="display: none; left: 80px;">

                                                                <asp:GridView ID="gvchild" runat="server" AutoGenerateColumns="false" Font-Size="12px"
                                                                        Width="850px" PageSize="5000000">
                                                                        <Columns>
                                                                            <asp:BoundField ItemStyle-Width="170px" DataField="Inventoryid" HeaderText="INVEN.ID" />
                                                                            <asp:BoundField ItemStyle-Width="170px" DataField="Barcode" HeaderText="BARCODE" />
                                                                            <asp:BoundField ItemStyle-Width="150px" DataField="Stockcode" HeaderText="STOCK CODE" />
                                                                            <asp:BoundField ItemStyle-Width="250px" DataField="Description" HeaderText="DESCRIPTION" />
                                                                            <asp:BoundField ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Right" DataField="class"
                                                                                HeaderText="CLASS" />
                                                                            <asp:BoundField ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Center" DataField="unit"
                                                                                HeaderText="UNIT" />                                                                         
                                                                                                                                                      

                                                                            <asp:TemplateField HeaderText="PRICE" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right">
                                                                                <ItemTemplate>
                                                                                    <asp:Label ID="lblRDiscTotAmt" runat="server" Text='<%#Eval("price","{0:F2}") %>'></asp:Label>
                                                                                </ItemTemplate>
                                                                                <FooterTemplate>
                                                                                    <asp:Label ID="lblGrandDiscAMT" runat="server" />
                                                                                </FooterTemplate>
                                                                                <FooterStyle HorizontalAlign="Right" />
                                                                                <ItemStyle Width="80px"></ItemStyle>
                                                                            </asp:TemplateField>
                                                                               <asp:TemplateField HeaderText="PRICE2" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right">
                                                                               <ItemTemplate>
                                                                               <asp:Label ID="lblPRICE2" runat="server" Text='<%#Eval("PRICE2","{0:F2}") %>'></asp:Label>
                                                                               </ItemTemplate>
                                                                               </asp:TemplateField>
                                                                               <asp:TemplateField HeaderText="PRICE3" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right">
                                                                               <ItemTemplate>
                                                                               <asp:Label ID="lblPRICE3" runat="server" Text='<%#Eval("PRICE3","{0:F2}") %>'></asp:Label>
                                                                               </ItemTemplate>
                                                                               </asp:TemplateField>
                                                                               <asp:TemplateField HeaderText="PRICE4" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right">
                                                                               <ItemTemplate>
                                                                               <asp:Label ID="lblPRICE4" runat="server" Text='<%#Eval("PRICE4","{0:F2}") %>'></asp:Label>
                                                                               </ItemTemplate>
                                                                               </asp:TemplateField>

                                                                               <asp:BoundField ItemStyle-Width="200px" ItemStyle-HorizontalAlign="Center" DataField="OnHandQty" HeaderText="ONHANDQTY"/>
                                                                               <asp:BoundField ItemStyle-Width="200px" ItemStyle-HorizontalAlign="Center" DataField="Unitcost" HeaderText="UNITCOST"/> 
                                                                               <asp:BoundField ItemStyle-Width="200px" ItemStyle-HorizontalAlign="Center" DataField="TotalCost" HeaderText="TOTALCOST"/> 
                                                                             
                                                                        </Columns>
                                                                        <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>
                                                              </td>
                                                            </tr>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>



                                                    </Columns>
                                                    <FooterStyle BackColor="White" ForeColor="Black"></FooterStyle>
                                                    <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>
                                                </asp:Panel>
                                            </div>
                                        </caption>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
           <%-- <div align="left">
                <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
            </div>--%>
        </ContentTemplate>
    </asp:UpdatePanel>

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


    <br />

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