<%@ page title="" language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_Components_Biometric_ShiftAllocation, App_Web_fo2mhtxy" enableEventValidation="false" viewStateEncryptionMode="Never" %>

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

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <%-- add for 28787 mantis start --%>
    <style>
        .chck-dropdown td {
            background: #f1f1f1 !important;
        }
    </style>
    <%-- add for 28787 mantis end --%>
    <asp:UpdatePanel ID="OTQueueListingUpdatePanel" runat="server">
        <ContentTemplate>
            <div id="divContentPage">
                <div class="dashBoardLeftCont">
                    <div class="himssuHeader3WireBox">
                        <table>
                            <tr>
                                <td>
                                    <div class="himsBoxContent">
                                        <div class="leftUlMenu">
                                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="166"
                                                Visible="true" runat="server" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="whiteboxpaddingleft row">
                    <div class="himssuHeader2WireBox card card-box" id="SearchDiv" runat="server">
                        <div class="himsBoxHeader card-head">
                            <asp:Panel ID="Panel1" runat="server">
                                <div class="leftdiv">
                                </div>
                                <div class="himsBoxTitle">
                                    <div class="headerText">
                                        <header>
                                            <i class="fas fa-gear"></i>
                                        </header>
                                    </div>
                                </div>
                            </asp:Panel>
                        </div>
                        <div class="himsBoxContent card-body padd-0">
                            <asp:Panel ID="DetailPanel" runat="Server">
                                <div class="col-md-12 bg-lghtgrey radiobtn">

                                    <asp:RadioButtonList ID="SourceTypeRadioButtonList" runat="server" RepeatDirection="Horizontal"
                                        OnSelectedIndexChanged="SourceTypeRadioButtonList_OnSelectedIndexChanged" AutoPostBack="true">
                                        <asp:ListItem Text="Employee" Value="95" Selected="True"></asp:ListItem>
                                        <asp:ListItem Text="Student" Value="2003"></asp:ListItem>
                                    </asp:RadioButtonList>

                                </div>
                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="OrganizationLabel" runat="server" Text="Organization"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList runat="server" ID="OrganizationDropDownList" SkinID="CustomWidthDropDownList"
                                            CssClass="form-control" onmouseleave="showHideTooltip()" AutoPostBack="true" onmouseenter="showHideTooltip()"
                                            OnSelectedIndexChanged="OrganizationDropDownList_SelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>
                                </div>
                                <div class="outerBox pTop5 col-md-3">
                                    <asp:RadioButtonList ID="ShiftAssignTypeRadioButtonList" runat="server" RepeatDirection="Vertical" AutoPostBack="true" OnSelectedIndexChanged="ShiftAssignTypeRadioButtonList_SelectedIndexChanged">
                                        <asp:ListItem Text="ByDay" Value="1" Selected="True"></asp:ListItem>
                                        <asp:ListItem Text="ByDate" Value="2"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </div>
                                <asp:Panel ID="SearchCriteriaPanel" runat="Server">
                                    <div id="Div1" class="himssuHeader1WireBox box-body box-solid gridviewfont" runat="server" visible="true">
                                        <asp:GridView ID="ShiftAllocationGridView" runat="server" Width="100%" AutoGenerateColumns="False"
                                            EmptyDataText="No Records Found !!" AllowPaging="false" ShowHeader="true"
                                            CssClass="table table-striped table-bordered" OnRowDataBound="ShiftAllocationGridView_OnRowDataBound" DataKeyNames="EmployeeId,StudentId,ShiftAllocationId">
                                            <Columns>
                                                <asp:TemplateField HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="3%">
                                                    <HeaderTemplate>
                                                        <label class="rt-chkbox rt-chkbox-outline">
                                                            <asp:CheckBox ID="HeaderSelectCheckBox" runat="server" onclick="checkAllRows(this);" />
                                                            <span></span>
                                                        </label>
                                                    </HeaderTemplate>
                                                    <ItemStyle HorizontalAlign="Center" />
                                                    <ItemTemplate>
                                                        <label class="rt-chkbox rt-chkbox-outline">
                                                            <asp:CheckBox ID="SelectCheckBox" runat="server" onClick="checkUncheckHeaderCheckBox(this);" />
                                                            <span></span>
                                                        </label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Employee Code" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="EmployeeCodeLabel" runat="server" Text='<%# Bind("EmployeeCode") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Employee Name" ItemStyle-Width="25%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="EmployeeNameLabel" runat="server" Text='<%# Bind("EmployeeName") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Student Code" Visible="false" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="StudentCodeLabel" runat="server" Text='<%# Bind("StudentCode") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Student Name" Visible="false" ItemStyle-Width="20%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="StudentNameLabel" runat="server" Text='<%# Bind("StudentName") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Current Shift" ItemStyle-Width="15%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="CurrentShiftLabel" runat="server" Text='<%# Bind("CurrentShiftId") %>' Visible="false"></asp:Label>
                                                        <asp:DropDownList ID="CurrentShiftDropDownList" Width="200px " runat="server" onmouseleave="showHideTooltip()"
                                                            onmouseenter="showHideTooltip()" SkinID="CustomWidthDropDownList" CssClass="form-control !important" Enabled="false">
                                                        </asp:DropDownList>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="New Shift" ItemStyle-Width="15%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="NewShiftLabel" runat="server" Text='<%# Bind("NewShiftId") %>' Visible="false"></asp:Label>
                                                        <asp:DropDownList ID="NewShiftDropDownList" Width="200px " runat="server" onmouseleave="showHideTooltip()"
                                                            onmouseenter="showHideTooltip()" SkinID="CustomWidthDropDownList" CssClass="form-control !important">
                                                        </asp:DropDownList>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="From Shift Date" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left" Visible="false">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="FromShiftDateTextBox" Text='<%# Bind("FromShiftDate") %>' placeholder="dd/MM/yyyy" runat="server" Width="80px" MaxLength="13" onkeyup="FormatIt(this);"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="To Shift Date" ItemStyle-Width="10%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left" Visible="false">
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="ToShiftDateTextBox" Text='<%# Bind("ToShiftDate") %>' placeholder="dd/MM/yyyy" runat="server" Width="80px" MaxLength="13" onkeyup="FormatIt(this);"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <%--<asp:TemplateField HeaderText="ShiftDay" ItemStyle-Width="5%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="ShiftDayLabel" runat="server" Text='<%# Bind("ShiftDay") %>' Visible="false"></asp:Label>
                                                        <asp:DropDownList ID="ShiftDayDropDownList" Width="200px " runat="server" onmouseleave="showHideTooltip()"
                                                            onmouseenter="showHideTooltip()" SkinID="CustomWidthDropDownList" CssClass="form-control !important">
                                                        </asp:DropDownList>
                                                    </ItemTemplate>
                                                </asp:TemplateField>--%>
                                                <%-- add for 28787 mantis start --%>
                                                <asp:TemplateField HeaderText="ShiftDay" ItemStyle-Width="20%" ItemStyle-Wrap="true" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Label ID="ShiftDayLabel" runat="server" Text='<%# Bind("ShiftDay") %>' Visible="false"></asp:Label>
                                                        <div class="select-hover">
                                                            <asp:CheckBox ID="ShiftDayCheckBox" runat="server" AutoPostBack="false" Text="Select All" onclick="checkAllDays(this);" />
                                                            <div class="bg-lghtgrey">
                                                                <div id="ShiftDayDiv" runat="server" class="fLeft pRight5 chck-dropdown">
                                                                    <asp:CheckBoxList ID="ShiftDayCheckBoxList" runat="server" onclick="checkDays(this);">
                                                                    </asp:CheckBoxList>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <%-- add for 28787 mantis end --%>
                                            </Columns>
                                            <PagerSettings Visible="False" />
                                        </asp:GridView>
                                    </div>
                                </asp:Panel>
                            </asp:Panel>
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--   <script data-main="../../../JavaScript/rjs/encrypt/shift-allocation-encrypt" src="../../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/shift-allocation")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script type="text/javascript">
        function FormatIt(obj) {
            if (obj.value.length == 2)
                obj.value = obj.value + "/";
            if (obj.value.length == 5)
                obj.value = obj.value + "/";
        }
        function isValidDatepicker(inputText) {

            if (inputText.value != '') {
                var t = '<div class="messageHolder newmsg"><div class="himsWireBox"><div class="himsBoxHeader"><div></div></div><div class="himsBoxContent messageMessage whiteboxpaddingleft"><div class="errorContainer"><div class="fLeft statusImage"><div></div></div><div class="statusMessage fLeft"><div>';
                t += 'Date should be in the format of dd/MM/yyyy</div><div id="hideShowError">';
                t += '</div></div><div align="right" class="pRight5 cursorHand" id="maxmin"><div id="hideShowImg" class="fRight"></div></div><div class="cBoth"></div></div></div><div class="himsBoxFooter"><div></div></div></div></div>';

                var dateformat = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
                if (inputText.value.match(dateformat)) {
                    var pdate = inputText.value.split('/');
                    var dd = parseInt(pdate[0]);
                    var mm = parseInt(pdate[1]);
                    var yy = parseInt(pdate[2]);
                    var ListofDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
                    if (mm == 1 || mm > 2) {
                        if (dd > ListofDays[mm - 1]) {
                            var r = document.getElementById("MessageBoxDiv");
                            r.innerHTML = t
                            inputText.value = '';
                            inputText.focus();
                            return false;
                        }
                        if (mm == 2) {
                            var lyear = false;
                            if ((!(yy % 4) && yy % 100) || !(yy % 400)) {
                                lyear = true;
                            }
                            if ((lyear == false) && (dd >= 29)) {
                                var r = document.getElementById("MessageBoxDiv");
                                r.innerHTML = t
                                inputText.value = '';
                                inputText.focus();
                                return false;
                            }
                            if ((lyear == true) && (dd > 29)) {
                                var r = document.getElementById("MessageBoxDiv");
                                r.innerHTML = t
                                inputText.value = '';
                                inputText.focus();
                                return false;
                            }
                        }
                        if (inputText.value <= '01/01/1753') {
                            var t = '<div class="messageHolder newmsg"><div class="himsWireBox"><div class="himsBoxHeader"><div></div></div><div class="himsBoxContent messageMessage whiteboxpaddingleft"><div class="errorContainer"><div class="fLeft statusImage"><div></div></div><div class="statusMessage fLeft"><div>Date should be greater than  ';
                            t += ' 01/01/1753</div><div id="hideShowError">';
                            t += '</div></div><div align="right" class="pRight5 cursorHand" id="maxmin"><div id="hideShowImg" class="fRight"></div></div><div class="cBoth"></div></div></div><div class="himsBoxFooter"><div></div></div></div></div>';
                            var r = document.getElementById("MessageBoxDiv");
                            r.innerHTML = t
                            inputText.value = '';
                            inputText.focus();
                            return false;
                        }
                        if (inputText.value >= '31/12/9999') {
                            var t = '<div class="messageHolder newmsg"><div class="himsWireBox"><div class="himsBoxHeader"><div></div></div><div class="himsBoxContent messageMessage whiteboxpaddingleft"><div class="errorContainer"><div class="fLeft statusImage"><div></div></div><div class="statusMessage fLeft"><div>Date should be less than  ';
                            t += ' 31/12/9999</div><div id="hideShowError">';
                            t += '</div></div><div align="right" class="pRight5 cursorHand" id="maxmin"><div id="hideShowImg" class="fRight"></div></div><div class="cBoth"></div></div></div><div class="himsBoxFooter"><div></div></div></div></div>';
                            var r = document.getElementById("MessageBoxDiv");
                            r.innerHTML = t
                            inputText.value = '';
                            inputText.focus();
                            return false;
                        }
                        var r = document.getElementById("MessageBoxDiv");
                        r.innerHTML = '';
                    }
                }
                else {
                    var r = document.getElementById("MessageBoxDiv");
                    r.innerHTML = t
                    inputText.value = '';
                    inputText.focus();
                    return false;
                }

            }
        }
        function checkAllRows(obj) {
            var objGridview = obj.closest('table');
            var list = objGridview.getElementsByClassName("rt-chkbox");
            for (var i = 0; i < list.length; i++) {
                var objRow = list[i].parentNode;
                if (list[i].childNodes[1].type == "checkbox" && obj != list[i]) {
                    if (obj.checked) {
                        list[i].childNodes[1].checked = true;
                    }
                    else {
                        list[i].childNodes[1].checked = false;
                    }
                }
            }
        }
        function checkUncheckHeaderCheckBox(obj) {
            var objGridView = obj.closest('table');
            var list = objGridView.getElementsByTagName("input");
            for (var i = 0; i < list.length; i++) {
                var objHeaderChkBox = list[0];
                var checked = true;
                if (list[i].type == "checkbox" && list[i] != objHeaderChkBox) {
                    if (!list[i].checked) {
                        checked = false;
                        break;
                    }
                }
            }
            objHeaderChkBox.checked = checked;
        }
        //add for 28787 mantis start
        function checkAllDays(obj) {
            var objGridview = obj.closest('td');
            var list = objGridview.getElementsByTagName("input");
            for (var i = 0; i < list.length; i++) {
                var objRow = list[i].parentNode.parentNode;
                if (list[i].type == "checkbox" && obj != list[i]) {
                    if (obj.checked) {
                        list[i].checked = true;
                    }
                    else {
                        list[i].checked = false;
                    }
                }
            }
        }
        function checkDays(obj) {
            var objGridView = obj.closest('td');
            var list = objGridView.getElementsByTagName("input");
            for (var i = 0; i < list.length; i++) {
                var objHeaderChkBox = list[0];
                var checked = true;
                if (list[i].type == "checkbox" && list[i] != objHeaderChkBox) {
                    if (!list[i].checked) {
                        checked = false;
                        break;
                    }
                }
            }
            objHeaderChkBox.checked = checked;
        }
        //add for 28787 mantis end
    </script>
</asp:Content>
