<%@ page language="C#" autoeventwireup="true" inherits="Pages_MaterialManagement_Procurement_StockInwardBulk, App_Web_s0hsxyrh" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" uiculture="auto" meta:resourcekey="PageResource1" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl" TagPrefix="ScreenGroup" %>
<%@ Register Src="~/UserControls/DatePicker/DatePickerControl.ascx" TagName="DatePickerControl" TagPrefix="DPC" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/Common/Stock/StockDetailBoxControl.ascx" TagName="StockControl" TagPrefix="Stock" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">

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

            <input type="hidden" id="hdnSessionid" runat="server" />
            <table border="0" style="vertical-align: top; margin-top: -1px; border-collapse: collapse;">
                <tr>
                    <td class="dashBoardLeftCont">
                        <div class="himssuHeader3WireBox">
                            <table>
                                <tr>
                                    <td>
                                        <div class="himsBoxContent">
                                            <div class="leftUlMenu">
                                                <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="160"
                                                    Visible="true" runat="server" />
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>

            <div class="whiteboxpaddingleft row">
                <Stock:StockControl ID="StockUserControl" runat="server" Visible="true" />
                <div class="card card-box">
                    <div class="card-body">
                        <div class="outerBox pTop5 col-md-3">
                            <div class="controlLabelWidth">
                                <asp:Label ID="MainGroupLabel2" runat="server" Text="Main Group" SkinID="mandatoryLabel"></asp:Label>
                            </div>
                            <asp:DropDownList ID="MainGroupDropDownList2" runat="server" CssClass="form-control"
                                onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()" OnSelectedIndexChanged="MainGroupDropDownList2_SelectedIndexChanged" AutoPostBack="true" />
                        </div>
                        <div class="outerBox pTop5 col-md-3">
                            <div class="controlLabelWidth">
                                <asp:Label ID="InwarddByLabel" runat="server" Text="Inward By" meta:resourcekey="InwarddByLabelResource1"></asp:Label>
                            </div>
                            <div class="fLeft pRight5">
                                <asp:TextBox ID="InwarddByTextBox" SkinID="CustomWidthTextBox" runat="server"
                                    MaxLength="100" onmouseleave="showHideTooltip()" onmouseenter="showHideTooltip()"
                                    meta:resourcekey="InwarddByTextBoxResource1"></asp:TextBox>
                            </div>
                        </div>

                        <div class="cBoth">
                        </div>

                        <div class="outerBox pTop5 col-md-3">
                            <div class="controlLabelWidth">
                                <asp:Label ID="SearchSubGroupLabel" runat="server" Text="Sub Group"
                                    meta:resourcekey="Label11Resource1"></asp:Label>
                            </div>
                            <div class="fLeft pRight5">
                                <asp:DropDownList ID="SearchSubGroupDropDownList"
                                    runat="server" onmouseleave="showHideTooltip()" AutoPostBack="false" SkinID="CustomWidthDropDownList" CssClass="form-control" onmouseenter="showHideTooltip()"
                                    meta:resourcekey="MainGroupDropDownListResource1">
                                </asp:DropDownList>
                            </div>
                        </div>

                        <div class="outerBox pTop5 col-md-3">
                            <div class="controlLabelWidth">
                                <asp:Label ID="ItemCatagoryLabel" runat="server" Text="Item Category"
                                    meta:resourcekey="Label11Resource1"></asp:Label>
                            </div>
                            <div class="fLeft pRight5">
                                <asp:DropDownList ID="ItemCategoryDropDownList"
                                    runat="server" onmouseleave="showHideTooltip()" AutoPostBack="false" SkinID="CustomWidthDropDownList" CssClass="form-control" onmouseenter="showHideTooltip()"
                                    meta:resourcekey="MainGroupDropDownListResource1">
                                </asp:DropDownList>
                            </div>
                        </div>
                        <div class="outerBox pTop5 col-md-3">
                            <div class="controlLabelWidth">
                                <asp:Label ID="lblitemNameLike" runat="server" Text="Item Name Like" meta:resourcekey="ItemName1"></asp:Label>
                            </div>
                            <div class="fLeft pRight5">
                                <asp:TextBox ID="txtitemlike" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="outerBox pTop5 col-md-6">
                            <div class="controlLabelWidth">
                                <asp:Label ID="lblCode" runat="server" Text="Code" meta:resourcekey="codelike"></asp:Label>
                            </div>
                            <div class="fLeft pRight5">
                                <asp:TextBox ID="txtcodelike" runat="server"></asp:TextBox>
                                <br />
                                <b>
                                    <asp:Label ID="Label1" runat="server" ForeColor="#a94442" Text="For Search Multiple Record (Eg.2,5,20)"></asp:Label></b>
                                <br />
                            </div>
                        </div>
                        <div class="cBoth">
                        </div>
                        <div class="outerBox pTop10 col-md-3" style="padding-left: 10px; padding-top: 20px">
                            <a href="javascript:;" onclick="OpenFileUpload();" class="btn btn-browser">
                                <i class="fa fa-arrow-down"></i>Browse</a>
                            <asp:FileUpload ID="flUpload" runat="server" onChange="readURL(this);" ClientIDMode="Static" Style="display: none;" />
                            <asp:Label ID="Label2" runat="server" Text="" Style="padding-left: 10px; font-size: medium;"></asp:Label>
                        </div>
                        <div class="alignCenter col-md-12">
                            <asp:Button ID="BtnSearch" runat="server" CssClass="fas btn btn-search" Text="&#xf002; Search" OnClick="BtnSearch_Click" SkinID="0" />
                            <asp:Button ID="ImportButton" runat="server" OnClick="ImportButton_Click" SkinID="0" Text="&#xf019; Import" CssClass="btn btn-examcommon fas" />
                            <asp:Button ID="ExportButton" runat="server" OnClick="ExportButton_Click" Enabled="false" SkinID="0" Text="&#xf093; Export" CssClass="btn btn-examcommon fas" />
                        </div>
                        <div class="cBoth">
                        </div>
                        <div id="ExaminationAreaListingGridDiv" runat="server">
                            <div class="spacer">
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/spacer.gif" meta:resourcekey="Image1Resource1" />
                            </div>

                            <div class="himssuHeader1WireBox">

                                <div class="himsBoxHeader card-head inner" id="GridViewPagerDiv" runat="server" visible="True">
                                    <div class="himsBoxTitle pLeft10">
                                        <div class="gridHeaderText fLeft" id="GridDiv" runat="server" visible="false">
                                            <header>
                                                <asp:Label ID="GridViewLabel" Text="Available item List To Select" runat="server"
                                                    Font-Bold="True" meta:resourcekey="GridViewLabelResource1" ForeColor="Black" />
                                            </header>
                                        </div>

                                        <div class="fRight">
                                            <uc1:GridViewPager ID="MedicineGridViewPager" Visible="false" runat="server" ParentGridView="MedicineGridView" />
                                        </div>
                                    </div>
                                </div>

                                <div class="himsBoxContent col-md-12 pTop5">
                                    <div id="ApplyDiv" runat="server" visible="false">
                                        <div class="pull-right col-md-5 display-flex" id="ApllyAll" runat="server">
                                            <asp:DropDownList ID="ApplyAllDropDownList" runat="server" CssClass="form-control mt-10" SkinID="CustomWidthDropDownList"
                                                meta:resourcekey="DepartmentDropDownListResource1">
                                                <asp:ListItem Value="--Select--">Select</asp:ListItem>
                                                <asp:ListItem Value="Quantity">Quantity</asp:ListItem>
                                                <asp:ListItem Value="Price">Price</asp:ListItem>
                                            </asp:DropDownList>
                                            &nbsp;&nbsp;&nbsp;&nbsp; 
                                        <asp:TextBox ID="ApplyAllTextBox" SkinID="CustomWidthTextBox" Width="150px" runat="server" ondrag="return false" onPaste="return false" autocomplete="off" ondrop="return false"
                                            onKeypress="javascript:return MaskDecimal(event,12,2)" meta:resourcekey="SearchCodeTextBoxResource1" MaxLength="100" class="pTop5"></asp:TextBox>
                                            &nbsp;&nbsp;
                                        <input type="button" class="btn btn-apply fas" value="Apply All" onclick="ValidateApply();" id="ApplyAllButton">
                                        </div>
                                    </div>
                                    <div id="Div2" runat="server" class="table-responsive pTop5">
                                        <asp:GridView ID="MedicineGridView" runat="server" Width="100%" AutoGenerateColumns="False" CssClass="table table-striped table-bordered table-hover"
                                            ShowHeader="true" EmptyDataText="No Records Found !!" AllowPaging="False" OnRowDataBound="MedicineGridView_RowDataBound"
                                            DataKeyNames="Id,StockItemId,StockItemCode,StockItemName,InwardQuantity,InwardValue, IsBatchWiseTracking">
                                            <Columns>
                                                <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="Id" HeaderText="Id" Visible="false"></asp:BoundField>
                                                <asp:TemplateField HeaderText="StockItemId" ItemStyle-Width="15%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left" Visible="false">

                                                    <ItemTemplate>
                                                        <asp:Label ID="StockItemIdLabel" runat="server" Text='<%#Eval("StockItemId") %>' Visible="false"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField ItemStyle-Width="5%">
                                                    <HeaderTemplate>
                                                        <label class="rt-chkbox rt-chkbox-outline">
                                                            <asp:CheckBox ID="ChkAll" AutoPostBack="true" OnCheckedChanged="chckchanged" runat="server" />
                                                            <span></span>
                                                        </label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <label class="rt-chkbox rt-chkbox-outline">
                                                            <asp:CheckBox ID="chkItem" runat="server" />
                                                            <span></span>
                                                        </label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="StockItemCode" ItemStyle-Width="15%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="StockItemCodeLabel" runat="server" Text='<%#Eval("StockItemCode") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="StockItemName" ItemStyle-Width="15%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="StockItemNameLabel" runat="server" Text='<%#Eval("StockItemName") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>

                                                <asp:TemplateField HeaderText="Batch Wise Track" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="BatchWiseTrackLabel" runat="server" Text='<%#Eval("IsBatchWiseTracking") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>

                                                <asp:TemplateField HeaderText="Quantity" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="QuantityTextBox" CssClass="qtytxtbox" runat="server" onblur="sum()" ClientIDMode="Static" Enabled="false"
                                                            SkinID="MultilineTextBox" onKeypress="javascript:return MaskDecimal(event,10,2)"
                                                            Width="60px" MaxLength="13"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Price" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="PriceTextBox" CssClass="prctxtbox" runat="server" ClientIDMode="Static" onblur="sum()" Text='' onfocusout="CalculateTotals()"
                                                            SkinID="MultilineTextBox" onKeypress="javascript:return MaskDecimal(event,10,2)"
                                                            Width="60px" MaxLength="13"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Total Value" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="ValueTextBox" CssClass="ValueBox" runat="server" ClientIDMode="Static" Text='' Enabled="false"
                                                            SkinID="MultilineTextBox" onKeypress="javascript:return MaskDecimal(event,10,2)"
                                                            Width="60px" MaxLength="23"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Batch" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="BatchTextBox" runat="server" ClientIDMode="Static" Text='' Enabled="true"
                                                            SkinID="MultilineTextBox"
                                                            Width="60px" MaxLength="23"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Expiry Date" ItemStyle-Width="15%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <DPC:DatePickerControl ID="ExpiryDateDatePickerControl" runat="server" DisplayDatePicker="true" Enabled="true"
                                                            class="datepick" style="display: initial !important; width: 80% !important;" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                            <PagerSettings Visible="False" />
                                        </asp:GridView>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--<script data-main="../../../JavaScript/rjs/stock-inward-bulk" src="../../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/stock-inward-bulk")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script type="text/javascript">
        $("[id*=ChekHeder]").live("click", function () {
            var chkHeader = $(this);
            var grid = $(this).closest("table");
            $('#ctl00_CP_MedicineGridView tr').each(function () {
                if (chkHeader.is(":checked")) {
                    $(this).find('input[type=checkbox]').prop('checked', true);
                }
                else {
                    $(this).find('input[type=checkbox]').prop('checked', false);
                }
            });
        });
    </script>
    <script type="text/javascript">
        function sum() {
            $('#ctl00_CP_MedicineGridView tr').each(function () {
                var qty = $(this).find('.qtytxtbox').val();
                var price = $(this).find('.prctxtbox').val();

                if ((qty != '') && (price != '')) {
                    var valueTotal = (qty * price);

                    $(this).find('.ValueBox').val(valueTotal);

                }
            });
        }
        function ValidateApply() {
            var chcnt = 0
            $('#ctl00_CP_MedicineGridView tr').each(function () {
                if ($(this).find('input[type=checkbox]').is(':checked')) {
                    chcnt = chcnt + 1;
                }
            });
            if (chcnt == 0) {
                alert('please select atleast one checkbox');
            }
            else {
                var value = document.getElementById('<%=ApplyAllTextBox.ClientID%>').value;
                var mydropdown = document.getElementById('<%=ApplyAllDropDownList.ClientID%>').value;
                if ((mydropdown != '--Select--') && (value != '')) {


                    if (document.getElementById('<%=ApplyAllDropDownList.ClientID%>').value == "Quantity") {
                        $('#ctl00_CP_MedicineGridView tr').each(function () {
                            if ($(this).find('input[type=checkbox]').is(':checked')) {
                                $(this).find('.qtytxtbox').val($('#ctl00_CP_ApplyAllTextBox').val());
                            }
                        });
                    }
                    else if (document.getElementById('<%=ApplyAllDropDownList.ClientID%>').value == "Price") {
                        $('#ctl00_CP_MedicineGridView tr').each(function () {
                            if ($(this).find('input[type=checkbox]').is(':checked')) {
                                $(this).find('.prctxtbox').val($('#ctl00_CP_ApplyAllTextBox').val());
                            }
                        });
                    }

                    $('#ctl00_CP_MedicineGridView tr').each(function () {
                        var qty = $(this).find('.qtytxtbox').val();
                        var price = $(this).find('.prctxtbox').val();

                        if ((qty != '') && (price != '')) {
                            var valueTotal = (qty * price);

                            $(this).find('.ValueBox').val(valueTotal);

                        }
                    });

                }
                else {
                    if ((mydropdown = "--Select--") && (value = " ")) {
                        alert("Please Enter Value and Select Apply All DropDown.");
                    }
                    else {
                        if (mydropdown != "--Select--") {
                            alert("Please Select Apply All Dropdown.");
                        }
                        if (value != " ") {
                            alert("Please Enter Apply All Value.");
                        }
                    }
                }
            }
        }
        function FormatIt(obj) {
            if (obj.value.length == 2) // Day
                obj.value = obj.value + "/";
            if (obj.value.length == 5) // month
                obj.value = obj.value + "/";
        }
    </script>
</asp:Content>
