<%@ page autoeventwireup="true" inherits="Masters_TA_UI_Master_ShiftPatternAdd, App_Web_w1mfnset" language="C#" masterpagefile="~/MasterFile/TimeCheck.master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="server">
    <!--[if gt IE 5.5]>
	<link rel="stylesheet" type="text/css" href="../css/ProgressforIE.css" />
 <![endif]-->
    <script type="text/javascript" language="javascript" src="../js/ShiftPatternNameValid.js"></script>
    <input type="hidden" name="hidFlag" id="hidFlag" />
    <script language="javascript" type="text/javascript">
        var ClickGobutton = "Select Number of Days and then Click Go button to Generate Days";
        var SelectDay = "Select Day";
        var ConfirmSave = "Are you sure, to Save?";
        var MaxLength = "Maximum length is ";
        var SelectCompany = "Select Company";
        var EnterPatternName = "Enter Pattern Name";
        function MaxLengthh(maxLength) {
            MaxLength = maxLength;
        }
        function SetAlertMessages(clickGobutton, selectDay, confirmSave, selectcompany, enterPatternName) {
            ClickGobutton = clickGobutton;
            SelectDay = selectDay;
            ConfirmSave = confirmSave;
            SelectCompany = selectcompany;
            EnterPatternName = enterPatternName;
        }
        function ShiftPatternValidation() {
            var PatternIndex = document.aspnetForm.ctl00_BodyContentPH_ddlCompany.selectedIndex;
            var PatternType = document.aspnetForm.ctl00_BodyContentPH_ddlCompany.options[PatternIndex].text;
            if (PatternType == "-Select-") {
                alert(SelectCompany);
                document.aspnetForm.ctl00_BodyContentPH_ddlCompany.focus();
                return false;
            }
            var PatternName = document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.value;
            if (PatternName == "") {
                alert(EnterPatternName);
                document.aspnetForm.ctl00_BodyContentPH_txt_PatternName.focus();
                return false;
            }
            var ShiftCount = document.getElementById('ctl00_BodyContentPH_ddl_NoDays').selectedIndex;
            var increment;
            if (document.getElementById('ctl00_BodyContentPH_ddl_Pattern' + ShiftCount) == null) {
                alert(ClickGobutton);
                document.getElementById('ctl00_BodyContentPH_ddl_NoDays').focus();
                return false;
            }
            for (increment = 1; increment <= ShiftCount; increment++) {
                if (document.getElementById('ctl00_BodyContentPH_ddl_Pattern' + increment + '').selectedIndex == 0) {
                    alert(SelectDay + ' ' + increment + '');
                    return false;
                }
            }
            if (document.getElementById("hidFlag").value != 0) {
                alert(document.getElementById("hidFlag").value);
                return false;
            }
            return confirm(ConfirmSave);
        }
        function CheckShift(ctrl, ctrlID, totCtrl) {
            str = '';
            for (i = 1; i <= totCtrl; i++) {
                shift1ID = document.getElementById("ctl00_BodyContentPH_ddl_Pattern" + i).value;
                if (shift1ID == '-Select-')
                    shift1ID = 0;
                str = str + shift1ID + '*';
            }
            if (str != '') {
                CheckShiftPatternTime(str)
            }
        }
        function checkGo() {
            if (document.getElementById("hidFlag").value != 0) {
                alert(document.getElementById("hidFlag").value);
                return false;
            }
            else {
                return true;
            }
        }
    </script>
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/shift-pattern.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_HeaderShiftPattern" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <asp:UpdatePanel ID="upLeave" runat="server">
            <ContentTemplate>
                <asp:Panel ID="pnlProgress" runat="server" Style="display: none;">
                    <asp:Panel ID="pnlLoading" runat="server" HorizontalAlign="center">
                        <div class="InsideProgressBar">
                            <div class="row" style="margin-top: 10px">
                                <img src="../dist/img/logo-Progress.png" />
                            </div>
                            <div class="row" style="min-width: 280px">
                                <img src="../dist/img/default.gif" style="width: 100px" />
                            </div>
                            <div class="row" style="margin-bottom: 10px">
                                <asp:Label ID="lblLoading" runat="server" ForeColor="black" Style="text-align: center"
                                    Text="Please Wait..." Font-Bold="true" Font-Size="12px" Font-Italic="true" Font-Family="Arial"></asp:Label>
                            </div>
                            <div class="clear clearfix">
                            </div>
                        </div>
                    </asp:Panel>
                </asp:Panel>
                <asp:HiddenField ID="hdnProgress" runat="server" />
                <cc1:ModalPopupExtender ID="popupProgress" runat="server" TargetControlID="hdnProgress"
                    BackgroundCssClass="ModalPopup" PopupControlID="pnlProgress" BehaviorID="popupProgress">
                </cc1:ModalPopupExtender>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div class="inr-ftr">
            <div class="row">
                <div class="col-sm-12">
                    <div class="pull-right">
                        <h6>
                            <span style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px"><asp:Label
                                ID="lbl_IndicatesMandatoryFields" runat="server"></asp:Label>
                                (3 No.)</span>
                        </h6>
                    </div>
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="form-horizontal">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblCompany" runat="server" Text="Company"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddlCompany" runat="server" AppendDataBoundItems="true" CssClass="form-control select2 Man-dat"
                                    OnDataBound="ddlCompany_DataBound">
                                    <asp:ListItem Value="0" Text="-Select-"></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlCompany"
                                    InitialValue="0" ErrorMessage="Select Company" SetFocusOnError="True" ValidationGroup="vpattern"
                                    Display="none">*</asp:RequiredFieldValidator>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbl_PatternName" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_PatternName" runat="server" CssClass="form-control mandatory"
                                    MaxLength="30" onkeypress="return chkMaxLen(event,this,30,MaxLength);"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_PatternName"
                                    ValidationGroup="vpattern" ErrorMessage="Enter Pattern Name" Display="none">*</asp:RequiredFieldValidator>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_NumberOfDays" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:DropDownList ID="ddl_NoDays" runat="server" CssClass="form-control select2 Man-dat"
                                    AutoPostBack="true" OnSelectedIndexChanged="ddl_NoDays_SelectedIndexChanged">
                                    <asp:ListItem Value="0" Text="-Select-"></asp:ListItem>
                                    <asp:ListItem>1</asp:ListItem>
                                    <asp:ListItem>2</asp:ListItem>
                                    <asp:ListItem>3</asp:ListItem>
                                    <asp:ListItem>4</asp:ListItem>
                                    <asp:ListItem>5</asp:ListItem>
                                    <asp:ListItem>6</asp:ListItem>
                                    <asp:ListItem>7</asp:ListItem>
                                    <asp:ListItem>8</asp:ListItem>
                                    <asp:ListItem>9</asp:ListItem>
                                    <asp:ListItem>10</asp:ListItem>
                                    <asp:ListItem>11</asp:ListItem>
                                    <asp:ListItem>12</asp:ListItem>
                                    <asp:ListItem>13</asp:ListItem>
                                    <asp:ListItem>14</asp:ListItem>
                                    <asp:ListItem>15</asp:ListItem>
                                    <asp:ListItem>16</asp:ListItem>
                                    <asp:ListItem>17</asp:ListItem>
                                    <asp:ListItem>18</asp:ListItem>
                                    <asp:ListItem>19</asp:ListItem>
                                    <asp:ListItem>20</asp:ListItem>
                                    <asp:ListItem>21</asp:ListItem>
                                    <asp:ListItem>22</asp:ListItem>
                                    <asp:ListItem>23</asp:ListItem>
                                    <asp:ListItem>24</asp:ListItem>
                                    <asp:ListItem>25</asp:ListItem>
                                    <asp:ListItem>26</asp:ListItem>
                                    <asp:ListItem>27</asp:ListItem>
                                    <asp:ListItem>28</asp:ListItem>
                                    <asp:ListItem>29</asp:ListItem>
                                    <asp:ListItem>30</asp:ListItem>
                                    <asp:ListItem>31</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddl_NoDays"
                                    ValidationGroup="vpattern" InitialValue="0" ErrorMessage="Select Number Of Days"
                                    SetFocusOnError="True" Display="None">*</asp:RequiredFieldValidator>
                                <asp:HiddenField ID="hid" runat="server" />
                            </div>
                            <div class="col-md-2 src-margintop" style="display:none">
                                <asp:LinkButton ID="butSelect" runat="server" CssClass="btn save-btn fa-angle-right"
                                    OnClientClick="return checkGo();" OnClick="butSelect_Click" />
                            </div>
                        </div>
                        <div class="row form-group">
                            <asp:Panel ID="Table1" runat="server" Style="overflow: auto;">
                            </asp:Panel>
                        </div>
                        <div class="row">
                            <div class="col-md-5">
                            </div>
                            <div class="col-md-6">
                                <div class="pull-right-button">
                                    <asp:LinkButton ID="btn_Add" runat="server" CssClass="btn save-btn fa-floppy-o" OnClientClick="return ShiftPatternValidation();"
                                        OnClick="btn_Add_Click" />
                                    <asp:LinkButton ID="btn_Cancel" CssClass="btn save-btn fa-angle-left" runat="server"
                                        CausesValidation="False" OnClick="btn_Cancel_Click" />
                                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                                        ShowSummary="False" ValidationGroup="vpattern" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
