<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" validaterequest="false" autoeventwireup="true" inherits="Organization_Settings_Organization_Tempweekdaylist, App_Web_zwx4uwl3" %>

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web"
    TagPrefix="devxEditors" %>
<%@ Register Src="~/UserControls/TA_uc_OrganizationLevels.ascx" TagName="OrganizationLevel"
    TagPrefix="uc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">

    <script src="../plugins/datepicker/jquery-1.11.1.min.js"></script>

    <script language="javascript" src="../js/jquery.autocomplete.js" type="text/javascript"></script>

    <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>

    <script>

        $(function () {
            $('#ctl00_BodyContentPH_txtStartDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txtEndDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
        });
    </script>

    <div class="content-header">
        <h1 style="background-image: url(../dist/img/temporary-weekday.png); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_Header" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div class="inr-ftr">
            <div class="row">
                <div class="col-sm-12">
                    <div class="inr-fil-text pull-left">
                        <asp:Label ID="lblFilter" runat="server" Text="Filters"></asp:Label>
                    </div>
                    <div class="pull-right">
                        <h6></h6>
                        <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
                        <asp:HiddenField ID="Hidden1" runat="server" />
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div class="form-horizontal">
            <div class="emp-filter">
                <div class="row form-group">
                    <div class="col-md-12">
                        <div class="row">
                            <div class="col-md-12">
                                <asp:UpdatePanel ID="upOrgLevel" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <asp:PlaceHolder ID="PlaceHolderLateEntry" runat="server">
                                            <uc:OrganizationLevel ID="ucOrganizationLevel" runat="server" />
                                        </asp:PlaceHolder>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </div>
                        <div class="row">
                            <div class="row">
                                <div class="line16">
                                </div>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblStartDate" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtStartDate" runat="server" CssClass="form-control"
                                    EnableViewState="False" onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblEndDate" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtEndDate" runat="server" CssClass="form-control"
                                    EnableViewState="False" onCut="return false" onDrop="return false" MaxLength="11"></asp:TextBox>
                            </div>
                        </div>
                        <div id="trSearchButton" runat="server" class="row">
                            <div class="col-md-6">
                            </div>
                            <div class="col-md-5">
                                <div class="pull-right-button">
                                    <asp:LinkButton ID="btn_Search" CssClass="btn save-btn fa-search" runat="server"
                                        OnClick="btn_Search_Click" OnClientClick="return WeekdayValidation()" />
                                    <asp:LinkButton ID="btn_Clear" CssClass="btn save-btn fa-refresh" runat="server"
                                        OnClick="btn_Clear_Click" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="border-table new-space">
                <div class="row">
                    <div class="col-md-12" style="overflow: auto; overflow-y: hidden; padding-bottom: 15px">
                        <asp:HiddenField ID="hdnSelectRow" runat="server" />
                        <asp:HiddenField ID="hdnGetAllid" runat="server" />
                        <dxGridview:ASPxGridView ID="grv_TempWeekDay" EnableCallBacks="false" runat="server"
                            ClientInstanceName="grv_TempWeekDay" DataSourceID="ObjectDataSource1" AutoGenerateColumns="false"
                            KeyFieldName="tempWeekday_Id" Width="100%" OnHtmlRowCreated="grv_TempWeekDay_HtmlRowCreated">
                            <Columns>
                                <dxGridview:GridViewDataTextColumn FieldName="TempWeekday_Id" VisibleIndex="0" Visible="false">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblWeekdayID" Text='<%# Eval("tempWeekday_Id") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn VisibleIndex="1" Width="34px" HeaderStyle-VerticalAlign="Middle"
                                    HeaderStyle-HorizontalAlign="Center" CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center">
                                    <Settings AllowAutoFilter="false" />
                                    <HeaderTemplate>
                                        <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAllOnThisPage(this)" />
                                    </HeaderTemplate>
                                    <DataItemTemplate>
                                        <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRow(this)"
                                            accesskey='<%# Eval("tempWeekday_Id") %>' />
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="TempWeekday_FromDate" Caption="Temporary Weekday From Date"
                                    VisibleIndex="2" Width="200px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblTemporaryFromDate" Text='<%# Eval("TempWeekday_FromDate") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="TempWeekday_ToDate" Caption="To Date"
                                    VisibleIndex="3" Visible="false">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblTemporaryToDate" Text='<%# Eval("TempWeekday_ToDate") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="ClosingTime" Caption="Closing Time"
                                    VisibleIndex="4" Width="100px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblclosingtime" Text='<%# Eval("ClosingTime") %>' runat="server">
                                        </asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="Reason" Caption="Reason" VisibleIndex="5"
                                    Width="200px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblreason" Text='<%# Eval("Reason") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; width: 100%; word-wrap: break-word; display: inline-block;">
                                        </asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="true" />
                                    <CellStyle HorizontalAlign="Left">
                                    </CellStyle>
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn FieldName="IsDeleted" Caption="Deleted" VisibleIndex="6"
                                    Visible="false">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblIsDeleted" runat="server" Text='<%# Bind("IsDeleted") %>'></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="40px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <a data-toggle="tooltip" title='<%# Session["View"] %>' data-placement="top" href="Organization_TemporaryWeekday.aspx?TempWeekDayId=<%# Eval("tempWeekday_Id") %>"
                                            href="#"><span class="btn btn-defalut view-icons"></span></a>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                            </Columns>
                            <SettingsPager PageSize="10">
                            </SettingsPager>
                            <Settings ShowFilterRow="true" />
                            <SettingsBehavior SortMode="Value" AllowSort="true" AllowDragDrop="false" />
                            <Styles AlternatingRow-CssClass="table-bg">
                            </Styles>
                        </dxGridview:ASPxGridView>
                    </div>
                </div>
                <div class="row" style="padding-top: 10px">
                    <div class="col-md-12">
                        <div class="pull-right-button">
                            <asp:LinkButton ID="btn_add" CssClass="btn add-btn fa-plus" runat="server" OnClick="btn_add_Click" />
                            <asp:LinkButton ID="btn_Delete" CssClass="btn save-btn fa-trash-o" runat="server"
                                OnClientClick="return Permanentconfirmdelete(this.form);" OnClick="btn_PermanentDelete_Click" />
                            <asp:LinkButton ID="btn_Restore" CssClass="btn btn-primary fa fa-refresh" runat="server"
                                OnClientClick="return RestoreData();" OnClick="btn_Restore_Click" />
                            <asp:HiddenField ID="hdnDeletedData" runat="server" />
                            <asp:LinkButton ID="btn_PermanentDelete" CssClass="btn btn-primary " runat="server"
                                Visible="false" />
                            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SelectTempweekday"
                                TypeName="TempWeekdayEvendata">
                                <SelectParameters>
                                    <asp:SessionParameter Name="UserGroupName" Type="String" SessionField="UserGroupName" />
                                    <asp:SessionParameter Name="ParentId" Type="int32" SessionField="parentLevelId" DefaultValue="0" />
                                    <asp:SessionParameter Name="FromDate" Type="string" DefaultValue="01/01/1900" SessionField="strStartDate" />
                                    <asp:SessionParameter Name="ToDate" Type="string" DefaultValue="01/01/9999" SessionField="strEndDate" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" language="javascript">
        function OnInit(s, e) {

            AdjustSize();
        }
        function OnEndCallback(s, e) {
            AdjustSize();
        }

        function OnColumnSorting(s, e) {
            AdjustSize();
        }
        function AdjustSize() {

            var height = Math.max(0, document.documentElement.clientHeight);
            var width = Math.max(0, document.documentElement.clientWidth);
            grid.SetHeight(height);
        }
        //values for check date
        //Added by Manjula.P on 09-Apr-2014  for Getting From Date and To Date Validation
        var Monthfourdigit = 'Please enter valid date as month, day, and four digit year : Format MM/dd/yyyy.';
        //Adding this line var Datefourdigit='Please enter valid date with correct format dd/MM/yyyy'; as newly
        var Datefourdigit = 'Please enter valid date with correct format dd/MM/yyyy';
        var Invalidyearentry = 'Invalid year entry';
        var Invalidmonthentry = 'Invalid month entry';
        var Invaliddateentry = 'Invalid date entry';
        var DateformatDDMONYYYY = 'Incorrect date format. Enter as DD-MON-YYYY';
        var Entertime = 'Enter time';
        var Valueforhours = 'Invalid value for hours:';
        var Invalidvalueforminutes = 'Invalid value for minutes:';
        var Invalidtimeformat = 'Invalid time format:';
        var EntervalidDateandTime = 'Please enter valid Date and Time';
        var ValiddatemonthMMDDYYHHMM = 'Please enter valid Date and Time MM/dd/yyyy HH:mm';
        var ValiddatemonthMMDDYYHHMMTT = 'Please enter valid Date and Time MM/dd/yyyy hh:mm tt';
        var EntervalidDateandTime = 'Please enter valid Date and Time';
        var Invalidvalueforhours = 'Invalid value for hours:';
        var Invalidvalueforminites = 'Invalid value for minutes:';

        function SelectAllOnThisPage(chkSelectAll) {

            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
            if (chkSelectAll.checked == true) {
                for (var i = 0; i < grv_TempWeekDay.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_cell' + (i + grv_TempWeekDay.visibleStartIndex) + '_1_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_cell' + (i + grv_TempWeekDay.visibleStartIndex) + '_1_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_cell' + (i + grv_TempWeekDay.visibleStartIndex) + '_1_chkSelect').accessKey;
                        var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                        var removeId = hdnSelectRow.value.split(",");
                        if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                            if (hdnSelectRow.value != "")
                                hdnSelectRow.value += ",";
                            hdnSelectRow.value += hdnUserId;
                        }
                    }
                }
            }
            else {
                for (var i = 0; i < grv_TempWeekDay.pageRowCount; i++) {
                    document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_cell' + (i + grv_TempWeekDay.visibleStartIndex) + '_1_chkSelect').checked = false;
                }
                hdnSelectRow.value = '';
            }
        }

        function SelectOnRow(chkOnSelect) {
            var hdnUserId = chkOnSelect.accessKey;
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var removeId = hdnSelectRow.value.split(",");

            if (chkOnSelect.checked) {
                if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                    if (hdnSelectRow.value != "")
                        hdnSelectRow.value += ",";
                    hdnSelectRow.value += hdnUserId;
                }

                var varTotalCheckedCount = 0;
                for (var i = 0; i < grv_TempWeekDay.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_cell' + (i + grv_TempWeekDay.visibleStartIndex) + '_1_chkSelect').checked)
                        varTotalCheckedCount = varTotalCheckedCount + 1;
                    else
                        break;
                }
                if (varTotalCheckedCount == grv_TempWeekDay.pageRowCount)
                    document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_header1_chkSelectAll').checked = true;
                else
                    document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_header1_chkSelectAll').checked = false;
            }
            else {
                if (Array.contains(removeId, hdnUserId)) {
                    Array.remove(removeId, hdnUserId);
                }
                hdnSelectRow.value = removeId;

                document.getElementById('ctl00_BodyContentPH_grv_TempWeekDay_header1_chkSelectAll').checked = false;
            }
        }
        var Norecordsavailable = "No records available ";
        var AreyousuretoRestore = "Are you sure to Restore? ";
        var Selecteddataisnotindeletedstatus = "Selected data is not in deleted status ";
        var Selectdatatorestore = "Select data to restore ";
        var Nodeletedrecordsavailable = "No deleted records available ";

        function RestoreAlert(norecordsavailable, areyousuretoRestore, selecteddataisnotindeletedstatus, selectdatatorestore, nodeletedrecordsavailable) {
            Norecordsavailable = norecordsavailable;
            AreyousuretoRestore = areyousuretoRestore;
            Selecteddataisnotindeletedstatus = selecteddataisnotindeletedstatus;
            Selectdatatorestore = selectdatatorestore;
            Nodeletedrecordsavailable = nodeletedrecordsavailable;
        }

        function RestoreData() {
            var rowscount = grv_TempWeekDay.pageRowCount;
            if (rowscount == 0) {
                alert(Norecordsavailable);
                return false;
            }

            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var DeleteDataRow = document.getElementById('<%= hdnDeletedData.ClientID %>');
            if (DeleteDataRow.value != '') {
                if (hdnSelectRow.value != '') {
                    var selectedRow = new Array();
                    selectedRow = hdnSelectRow.value.split(",");

                    var deletedRow = new Array();
                    deletedRow = DeleteDataRow.value.split(",");
                    var Status = false;
                    for (var i = 0; i < selectedRow.length; i++) {
                        if (Array.contains(deletedRow, selectedRow[i])) {
                            Status = true;
                        }
                    }

                    if (Status == true) {
                        return confirm(AreyousuretoRestore);
                    }
                    else {
                        alert(Selecteddataisnotindeletedstatus);
                        return false;
                    }
                }
                else {
                    alert(Selectdatatorestore);
                    return false;
                }
            }
            else {
                if (hdnSelectRow.value == '') {
                    alert(Nodeletedrecordsavailable);
                    return false;
                }
                else {
                    alert(Selecteddataisnotindeletedstatus);
                    return false;
                }
            }
        }
        function WeekdayValidation() {
            var weekDay = document.aspnetForm.ctl00_BodyContentPH_txtStartDate;
            var weekDay2 = document.aspnetForm.ctl00_BodyContentPH_txtEndDate;
            var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

            var rangeDemoFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

            if (weekDay.value != '') {
                if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
     ) {
                    if (weekDay2.value != '') {
                        if (checkDate(weekDay2, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
         ) {
                        }
                        else {
                            return false;
                        }
                    }
                }
                else {
                    return false;
                }
            }
            return true;
        }
        function SetAlertCheckDate(monthfourdigit, datefourdigit, invalidyearentry, invalidmonthentry, invaliddateentry, dateformatDDMONYYYY, entertime, valueforhours, invalidvalueforminutes, invalidtimeformat, entervalidDateandTime, validdatemonthMMDDYYHHMM, validdatemonthMMDDYYHHMMTT, entervalidDateandTime, invalidvalueforhours, invalidvalueforminites) {
            Monthfourdigit = monthfourdigit;
            Datefourdigit = datefourdigit;
            Invalidyearentry = invalidyearentry;
            Invalidmonthentry = invalidmonthentry;
            Invaliddateentry = invaliddateentry;
            DateformatDDMONYYYY = dateformatDDMONYYYY;
            Entertime = Entertime;
            Valueforhours = valueforhours;
            Invalidvalueforminutes = invalidvalueforminutes;
            Invalidtimeformat = invalidtimeformat;
            EntervalidDateandTime = entervalidDateandTime;
            ValiddatemonthMMDDYYHHMM = validdatemonthMMDDYYHHMM;
            ValiddatemonthMMDDYYHHMMTT = validdatemonthMMDDYYHHMMTT;
            EntervalidDateandTime = entervalidDateandTime;
            Invalidvalueforhours = invalidvalueforhours;
            Invalidvalueforminites = invalidvalueforminites;
        }
    </script>

</asp:Content>
