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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .modalCss
        {
            display: none; /* Hidden by default */
            position: fixed; /* Stay in place */
            z-index: 1; /* Sit on top */
            padding-top: 80px; /* Location of the box */
            left: 0;
            top: 0;
            width: 100%; /* Full width */
            height: 100%; /* Full height */
            overflow: auto; /* Enable scroll if needed */
            background-color: rgb(0,0,0); /* Fallback color */
            background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
        }
        
        
        
        .modal-dialogCss
        {
        }
        
        /* Modal Content */
        .modal-contentCss
        {
            background-color: #fefefe;
            margin: auto;
            width: 800px;
            height: 400px;
            border-radius: 3px;
        }
        
        
        /* Create two equal columns that floats next to each other */
        .column
        {
            float: left;
            width: 40%;
            padding: 16px;
            height: auto; /* Should be removed. Only for demonstration */
        }
        
        /* Clear floats after the columns */
        .row:after
        {
            content: "";
            display: table;
            clear: both;
        }
        
        .ButtonSearch
        {
            background: #ffc108;
            margin: 0;
            font-family: Circular Std Book;
            font-size: 14px;
            line-height: inherit;
            border-width: thin;
            border-color: #212529;
            border-radius: 2px;
            color: #212529;
        }
    </style>
    <script type="text/jscript">
        function ShowModalItemList() {
            var Modal = document.getElementById("ModalItemList");
            Modal.style.display = "block";

        }

        function CloseModalItemList() {
            var Modal = document.getElementById("ModalItemList");
            Modal.style.display = "none";
            //location.reload();

            UncheckCheckbox();

        }

        function RemoveMessageBox() {
            var Selected = window.confirm("Are you sure you wan to remove this item as promotion?");
            if (Selected) {
                return true;
            }
            else {
                return false;
            }
        }

        function AddPromoMessageBox(objRef) {
            var Selected = window.confirm("Are you sure you want to add this item as promotion?");
            if (Selected) {
                return true;
            } else {
                return false;
            }
        }

        function UncheckCheckbox() {

            var gridView = document.getElementById("<%=grdItemList.ClientID %>");
            var checkBoxes = gridView.getElementsByTagName("input");

            for (var i = 0; i < checkBoxes.length; i++) {

                if (checkBoxes[i].type == "checkbox" && checkBoxes[i].checked) {
                    checkBoxes[i].checked = false;

                }
            }


        }

    </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%;">
                <td style="max-width: 50%; min-width: 50%; text-align: right; padding-bottom: 7px;">
                    <label for="validationCustom03">
                        Branch
                    </label>
                    
                    <asp:DropDownList ID="cmbBranches" CssClass="custom-select" runat="server" AutoPostBack="true"
                        OnSelectedIndexChanged="cmbBranches_SelectedIndexChanged" Width="200px" Height="35px">
                    </asp:DropDownList>
                </td>
            </table>--%>

            <div class="container-fluid">
                <div class="row mb-3 justify-content-end">
                    <div class="col-md-6 text-end">
                        <label for="cmbBranches" class="form-label">
                            Branch
                        </label>
                        <asp:DropDownList ID="cmbBranches" runat="server"
                            CssClass="form-select w-25 d-inline-block"
                            AutoPostBack="true"
                            OnSelectedIndexChanged="cmbBranches_SelectedIndexChanged">
                        </asp:DropDownList>
                    </div>
                </div>
            </div>



            <div class="row" style="display: none;">
                <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 DATE
                                        </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 DATE
                                    </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 Name"></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="btnGetReports" runat="server" Text="Apply" CssClass="btn btn-primary"
                                            OnClick="btnGetReports_Click" OnClientClick="return validate()" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="simple-card">
                  <div class="card">
                <h5 class="card-header" style="background-color: #4c4c4c; font-size: 14px; color: #F8F9FA">
                    Promotion &nbsp;&nbsp;
                </h5>
                <div class="card-body">
                    <div class="table-responsive">
                        <button type="button" class="btn btn-primary" onclick="ShowModalItemList()">
                            Add Promo Item
                        </button>
                        <table id="Table1" class="table table-striped table-bordered second" style="width: 100%">
                            <tbody>
                                <caption>
                                    <asp:Panel ID="Panel1" runat="server" BackColor="white" ScrollBars="Auto">
                                        <asp:GridView ID="grdPromotionPositioning" runat="server" AutoGenerateColumns="False"
                                            EmptyDataRowStyle-CssClass="alert-dark" Font-Size="11px" HeaderStyle-BackColor="RoyalBlue"
                                            EmptyDataText="No Record Found ! " DataKeyNames="ID" FooterStyle-BackColor="Green"
                                            FooterStyle-ForeColor="white" Width="900px" AllowPaging="false" BackColor="White"
                                            AllowSorting="true" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
                                            CellPadding="3" OnRowCommand="grdPromotionPositioning_RowCommand" OnRowDataBound="grdPromotionPositioning_RowDataBound">
                                            <%-- OnRowCommand="grdIniIndex_RowCommand"  OnRowDataBound="grdIniIndex_RowDataBound"--%>
                                            <Columns>
                                                <asp:TemplateField HeaderText="ID" Visible="false">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Barcode" ItemStyle-Width="150px">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblBarcode" runat="server" Text='<%#Eval("Barcode") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Name" ItemStyle-Width="200px">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Description" ItemStyle-Width="350px">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblDescription" runat="server" Text='<%#Eval("Description") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Main Position" ItemStyle-Width="100px">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="txtMainPosition" Width="100px" runat="server" MaxLength="2" Text='<%#Eval("MainPosition") %>'></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Sub Position" ItemStyle-Width="100px">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="txtSubPosition" Width="100px" runat="server" MaxLength="2" Text='<%#Eval("SubPosition") %>'></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="" ItemStyle-Width="100px">
                                                    <ItemTemplate>
                                                        <asp:Button ID="btnUpdate" runat="server" Width="100px" Text="Update" CssClass="btn btn-warning"
                                                            CommandName="UpdatePosition" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="" ItemStyle-Width="100px">
                                                    <ItemTemplate>
                                                        <asp:Button ID="btnRemove" runat="server" Width="100px" Text="Remove" CssClass="btn btn-danger"
                                                            OnClientClick="return RemoveMessageBox();" CommandName="Removeitem" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </asp:Panel>
                                </caption>
                        </table>
                    </div>
                </div>
            </div>
           </div>
            <div class="modalCss" id="ModalItemList">
                <div class="modal-dialogCss">
                    <div class="modal-contentCss">
                        <div class="modal-body" style="padding: 0px;">
                            <div class="card">
                                <h5 class="card-header" style="background-color: #4c4c4c; color: White;">
                                    SEARCH ITEM
                                    <button type="button" id="Button2" class="close" style="color: White; opacity: 1;"
                                        onclick="CloseModalItemList()">
                                        &times;</button></h5>
                                <div class="card-body" style="width: 100%">
                                    <div class="row">
                                        <div class="column">
                                            <div style="padding-top: 5px">
                                                <asp:DropDownList ID="cmbSearchType" CssClass="custom-select" Height="35px" runat="server">
                                                    <asp:ListItem Value="0" Text="All"></asp:ListItem>
                                                    <asp:ListItem Value="1" Text="Barcode"></asp:ListItem>
                                                    <asp:ListItem Value="2" Text="Name"></asp:ListItem>
                                                    <asp:ListItem Value="3" Text="Description"></asp:ListItem>
                                                </asp:DropDownList>
                                            </div>
                                            <%--OnSelectedIndexChanged="cmbSearchType_SelectedIndexChanged"--%>
                                        </div>
                                        <div class="column">
                                            <div style="padding-top: 5px">
                                                <asp:TextBox ID="txtInput" runat="server" class="form-control" Width="320px"> </asp:TextBox>
                                            </div>
                                        </div>
                                    </div>
                                    <div style="margin-top: 5px">
                                        <asp:Button ID="btnSearchItem" runat="server" class="btn btn-primary" Text="Apply"
                                            Height="40px" Width="80px" OnClick="btnApplySearch_Click" /><%-- OnClick="btnApplySearchCndimentGroup_Click"--%>
                                    </div>
                                    <br />
                                    <div class="table-responsive" style="height: 550px">
                                        <label for="validationCustom03">
                                            Search Result:
                                        </label>
                                        <table id="Table2" class="table table-striped table-bordered second" style="width: 100%">
                                            <tbody>
                                                <caption>
                                                    <asp:Panel ID="Panel2" runat="server" BackColor="white" ScrollBars="Auto">
                                                        <asp:GridView ID="grdItemList" runat="server" AutoGenerateColumns="False" EmptyDataRowStyle-CssClass="alert-dark"
                                                            Font-Size="11px" HeaderStyle-BackColor="RoyalBlue" EmptyDataText="No Record! "
                                                            DataKeyNames="InventoryID" FooterStyle-BackColor="Green" FooterStyle-ForeColor="white"
                                                            AllowPaging="false" PageSize="150" BackColor="White" AllowSorting="true" BorderColor="#CCCCCC"
                                                            BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="100%">
                                                            <Columns>
                                                                <asp:TemplateField ItemStyle-Width="5%">
                                                                    <ItemTemplate>
                                                                        <asp:CheckBox ID="chkSelect" runat="server" />
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="ID" Visible="false">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblInventoryID" runat="server" Text='<%#Eval("InventoryID") %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="Barcode" ItemStyle-Width="20%">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblBarcode" runat="server" Text='<%#Eval("Barcode") %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="Name" ItemStyle-Width="25%">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="Description" ItemStyle-Width="40%">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblDescription" runat="server" Text='<%#Eval("Description") %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                            </Columns>
                                                            <PagerStyle CssClass="gridview"></PagerStyle>
                                                            <FooterStyle BackColor="#006699" ForeColor="White"></FooterStyle>
                                                            <HeaderStyle BackColor="LightBlue" 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>
                                                    </asp:Panel>
                                                </caption>
                                            </tbody>
                                        </table>
                                    </div>
                                    <br />
                                    <div style="text-align: right">
                                        <asp:Button ID="btnAddPromoItem" runat="server" Text="Add Promo" OnClientClick="return AddPromoMessageBox();"
                                            OnClick="btnAddPromoItem_Click" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </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>
