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

<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web" TagPrefix="dxe" %>
<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="conCWHApplication" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <!--[if gt IE 5.5]>
    <link rel="stylesheet" type="text/css" href="../css/anytimeIE.css" />
    <link rel="stylesheet" type="text/css" href="../css/ProgressforIE.css" />
    <![endif]-->

    <script src="../plugins/daterangepicker/moment.js" type="text/javascript"></script>
    <link href="../css/ProgressBar.css" rel="stylesheet" type="text/css" />
    <script src="../plugins/datepicker/jquery-1.11.1.min.js"></script>
    <script language="javascript" src="../js/DateTimeValidation.js" type="text/javascript"></script>
    <script language="javascript" src="../js/jquery.autocomplete.js" type="text/javascript"></script>
    <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>
    <script language="javascript" src="../js/EmployeeNameAjax.js" type="text/javascript"></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>

    <script type="text/javascript">
        var Monthfourdigit = 'Please enter valid date as month, day, and four digit year : Format MM/dd/yyyy.';
        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 Invalidvalueforhours = 'Invalid value for hours:';
        var Invalidvalueforminites = 'Invalid value for minutes:';
        var MaxLength = "Maximum length is ";
        var EnterDetails = 'Please enter any of the above details';
        var FillFromandToDate = 'Please enter both the From and To Date';

        function SetAlertCheckDate(monthfourdigit, datefourdigit, invalidyearentry, invalidmonthentry, invaliddateentry,
            dateformatDDMONYYYY, entertime, valueforhours, invalidvalueforminutes, invalidtimeformat,
            entervalidDateandTime, validdatemonthMMDDYYHHMM, validdatemonthMMDDYYHHMMTT,
            entervalidDateandTime2, 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;
            Invalidvalueforhours = invalidvalueforhours; Invalidvalueforminites = invalidvalueforminites;
        }
        function SetAlertMessages(enterDetails, fillFromandToDate) {
            EnterDetails = enterDetails;
            FillFromandToDate = fillFromandToDate;
        }

        function Delete_Conf(status) {
            if (status === 'Approved') {
                alert('Approved records cannot be deleted.');
                return false;
            }
            return confirm('Are you sure you want to Delete?');
        }

        function SearchValidation() {
            var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;
            var fromDate = document.aspnetForm.ctl00_BodyContentPH_txtStartDate;
            var toDate = document.aspnetForm.ctl00_BodyContentPH_txtEndDate;

            if ((fromDate.value == '' && toDate.value != '') || (fromDate.value != '' && toDate.value == '')) {
                alert(FillFromandToDate);
                return false;
            }
            if (fromDate.value != '') {
                if (!checkDate(fromDate, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry,
                    Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours,
                    Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime,
                    ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime,
                    Invalidvalueforhours, Invalidvalueforminites)) return false;
            }
            if (toDate.value != '') {
                if (!checkDate(toDate, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry,
                    Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours,
                    Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime,
                    ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime,
                    Invalidvalueforhours, Invalidvalueforminites)) return false;
            }
            return true;
        }
    </script>

    <!-- PAGE HEADER -->
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/compressedworkHours.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_Header" runat="server" Text="Compressed Work Hours Entry"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>

    <div class="content">

        <!-- FILTER SECTION -->
        <div class="inr-ftr">
            <div class="row">
                <div class="col-sm-2">
                    <div class="inr-fil-text">
                        <asp:Label ID="lblFilter" runat="server" Text="Filter"></asp:Label>
                    </div>
                </div>
            </div>
        </div>

        <div class="emp-filter">
            <div class="row">
                <div class="form-horizontal">
                    <asp:HiddenField ID="Hidden1" runat="server" />

                    <div class="col-md-12">
                        <!-- Employee Name / ID filters — visible to SuperAdmin only -->
                        <div runat="server" id="trEmployeeDetails">
                            <div class="row form-group">
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_EmployeeName" runat="server" Text="Employee Name"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txt_EmpName" runat="server" CssClass="form-control" MaxLength="50"
                                        onpaste="return true"
                                        onkeypress="return employeename_singlequotes_maxlength(event,this,50,MaxLength);"></asp:TextBox>
                                    <cc1:AutoCompleteExtender ID="acEmpName" runat="server"
                                        CompletionInterval="10" CompletionSetCount="10"
                                        CompletionListItemCssClass="item"
                                        CompletionListHighlightedItemCssClass="AutocompleteCSS"
                                        Enabled="true" FirstRowSelected="true" MinimumPrefixLength="1"
                                        ServicePath="../WebServices/AutoCompleteExtender.asmx"
                                        ServiceMethod="GetEmployeeName"
                                        CompletionListCssClass="autocomplete_completionListElement"
                                        TargetControlID="txt_EmpName">
                                    </cc1:AutoCompleteExtender>
                                </div>
                                <div class="col-md-1"></div>
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_EmployeeId" runat="server" Text="Employee ID"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txtEmployeeId" runat="server" CssClass="form-control" MaxLength="15"
                                        onpaste="return true"
                                        onkeypress="return acceptCharsNum_MaxLength(event,this,15,MaxLength);"></asp:TextBox>
                                    <cc1:AutoCompleteExtender ID="acEmployeeId" runat="server"
                                        CompletionSetCount="10"
                                        CompletionListItemCssClass="item"
                                        CompletionListHighlightedItemCssClass="AutocompleteCSS"
                                        CompletionInterval="10" Enabled="true" MinimumPrefixLength="1"
                                        TargetControlID="txtEmployeeId"
                                        ServicePath="../WebServices/AutoCompleteExtender.asmx"
                                        ServiceMethod="GetEmployeeId"
                                        CompletionListCssClass="autocomplete_completionListElement"
                                        FirstRowSelected="true">
                                    </cc1:AutoCompleteExtender>
                                </div>
                            </div>
                        </div>

                        <!-- Date range filter -->
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblTimePeriod" runat="server" Text="From Date"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox ID="txtStartDate" runat="server" CssClass="form-control"
                                    EnableViewState="False" onCut="return false" onDrop="return false"
                                    onpaste="return true"></asp:TextBox>
                            </div>
                            <div class="col-md-1"></div>
                            <div class="col-md-2">
                                <asp:Label ID="lblLeaveEndDate" runat="server" Text="To Date"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox ID="txtEndDate" runat="server" CssClass="form-control"
                                    EnableViewState="False" onCut="return false" onDrop="return false"
                                    onpaste="return true"></asp:TextBox>
                            </div>
                        </div>
                        <div id="trSwipeCardNo" runat="server" style="display: none;">
                            <div class="row">
                                <div class="col-md-12">
                                    <asp:Label ID="lblEmpSwipe" runat="server"></asp:Label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <asp:TextBox onpaste="return true" ID="txtSwipeCard" MaxLength="20" runat="server"
                                        CssClass="form-control" onkeypress="return acceptCharsNum_MaxLength(event,this,20,MaxLength);"></asp:TextBox>
                                    <cc1:AutoCompleteExtender ID="acSwipeCardNo" runat="server" CompletionSetCount="10"
                                        CompletionListItemCssClass="item" CompletionListHighlightedItemCssClass="AutocompleteCSS"
                                        CompletionInterval="10" Enabled="true" MinimumPrefixLength="1" TargetControlID="txtSwipeCard"
                                        ServicePath="../WebServices/AutoCompleteExtender.asmx" ServiceMethod="GetCardNo"
                                        CompletionListCssClass="autocomplete_completionListElement" FirstRowSelected="true">
                                    </cc1:AutoCompleteExtender>
                                </div>
                            </div>
                        </div>
                        <!-- Search / Clear buttons -->
                        <div class="row">
                            <div class="col-md-6"></div>
                            <div class="col-md-5" runat="server" id="td1">
                                <div class="pull-right-button">
                                    <asp:Label ID="lbl_Error" runat="server" ForeColor="Red"></asp:Label>
                                    <asp:LinkButton ID="btn_Search" CssClass="btn src-btn fa-search" runat="server"
                                        OnClick="btn_Search_Click" OnClientClick="return SearchValidation()" />
                                    <asp:LinkButton ID="btn_Clear" CssClass="btn clr-btn fa-refresh" runat="server"
                                        OnClick="btn_Clear_Click" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- GRID TABLE -->
        <div class="border-table new-space form-group">
            <div class="row form-group">
                <div class="col-md-12 page-button col-sm-12">
                    <asp:LinkButton ID="btn_Add" CssClass="btn add-btn fa-plus" runat="server"
                        OnClick="btn_Add_Click" />
                </div>
            </div>
            <div class="table-responsive">
                <asp:HiddenField ID="hdnSelectRow" runat="server" />
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <dxGridview:ASPxGridView ID="gvCWHApplication" runat="server"
                            ClientInstanceName="GridView1"
                            EnableCallBacks="False"
                            AutoGenerateColumns="False"
                            Width="100%"
                            DataSourceID="ObjectDataSource1"
                            KeyFieldName="CWH_App_Id">
                            <Columns>
                                <dxGridview:GridViewDataTextColumn FieldName="CWH_App_Id" Visible="False">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_Id" Text='<%# Eval("CWH_App_Id") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                </dxGridview:GridViewDataTextColumn>


                                <dxGridview:GridViewDataTextColumn Caption="Application Date" FieldName="ApplicationDate"
                                    VisibleIndex="1" Width="160px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_AppDate" Text='<%# Eval("ApplicationDate") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>

                                <dxGridview:GridViewDataTextColumn FieldName="EmployeeID" Caption="Employee ID"
                                    VisibleIndex="2" Width="110px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_EmployeeId" Text='<%# Eval("EmployeeID") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>

                                <dxGridview:GridViewDataTextColumn Caption="Employee Name" FieldName="Employee_Name"
                                    VisibleIndex="3" Width="250px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_EmpName" Text='<%# Eval("Employee_Name") %>' runat="server"
                                            Style="word-break: break-all; word-wrap: break-word; cursor: pointer; display: inline-block;"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>

                                <dxGridview:GridViewDataTextColumn Caption="From Date" FieldName="FromDate"
                                    VisibleIndex="4" Width="150px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_FromDate" Text='<%# Eval("FromDate") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>

                                <dxGridview:GridViewDataTextColumn Caption="To Date" FieldName="ToDate"
                                    VisibleIndex="5" Width="150px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_ToDate" Text='<%# Eval("ToDate") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>

                                <dxGridview:GridViewDataTextColumn Caption="Compressed Work Hours" FieldName="CompressedWorkHour"
                                    VisibleIndex="5" Width="200Px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_Compressedwork" Text='<%# Eval("CompressedWorkHour") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>

                                <dxGridview:GridViewDataTextColumn Caption="Reason" FieldName="Reason"
                                    VisibleIndex="6" Width="250px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_Status" Text='<%# Eval("Reason") %>' runat="server"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                                </dxGridview:GridViewDataTextColumn>


                                <dxGridview:GridViewDataTextColumn Caption="Status" FieldName="Status"
                                    VisibleIndex="7" Width="150px">
                                    <DataItemTemplate>
                                        <asp:Label ID="lbl_Status" Text='<%# Eval("Status") %>' runat="server"></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" VisibleIndex="8">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnDelete" runat="server"
                                            ToolTip='<%# Session["Delete"] %>'
                                            data-toggle="tooltip" data-placement="top"
                                            OnClick="btn_Delete_Click"
                                            CommandName='<%# Eval("CWH_App_Id") %>'
                                            ValidationGroup='<%# Eval("EmpID") %>'
                                            CommandArgument='<%# Eval("Status") %>'
                                            CssClass="btn btn-defalut del-icons"
                                            Style="color: Red"
                                            OnClientClick='<%# "return Delete_Conf(\"" + Eval("Status") + "\");" %>'>
                                        </asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                            </Columns>

                            <SettingsPager PageSize="9">
                                <PageSizeItemSettings Visible="true" ShowAllItem="true" Items="10,20,50,100,200" />
                            </SettingsPager>
                            <Settings ShowFilterRow="true" ShowFilterRowMenu="true"
                                HorizontalScrollBarMode="Auto" ShowGroupPanel="true"
                                VerticalScrollBarMode="Hidden" VerticalScrollableHeight="400" />
                            <SettingsText EmptyDataRow="No Records Found" />
                            <SettingsBehavior AutoExpandAllGroups="false" ColumnResizeMode="Control" AllowDragDrop="true" />
                            <Styles AlternatingRow-CssClass="table-bg"></Styles>
                        </dxGridview:ASPxGridView>

                        <dxGridview:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" GridViewID="gvCWHApplication">
                            <PageFooter Right="[Page # of Pages #]"></PageFooter>
                        </dxGridview:ASPxGridViewExporter>

                        <!-- ObjectDataSource 1 : SuperAdmin — all employees -->
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
                            SelectMethod="SelectCompressedWorkHoursApplicationAll"
                            TypeName="CompressedWorkHoursApplicationEventData">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="txt_EmpName" Type="string" Name="EmpFirstName" PropertyName="Text" />
                                <asp:ControlParameter ControlID="txtEmployeeId" Type="string" Name="EmpCodeId" PropertyName="Text" />
                                <asp:ControlParameter ControlID="txtStartDate" DefaultValue="01/01/1900" Type="string" Name="StartDate" />
                                <asp:ControlParameter ControlID="txtEndDate" DefaultValue="01/01/1900" Type="string" Name="EndDate" />
                                <asp:ControlParameter ControlID="txtSwipeCard" Type="string" Name="EmpSwipeCard" PropertyName="Text" />
                                <asp:SessionParameter Name="UserGroupName" SessionField="UserGroupName" Type="string" />
                                <asp:SessionParameter Name="UserLevels" SessionField="LevelRights" Type="string" />
                                <asp:SessionParameter Name="GradeLevel" SessionField="GradeLevel" Type="string" />
                                <asp:SessionParameter Name="EmpAutoId" SessionField="EmpAutoID" Type="string" />
                                <asp:SessionParameter Name="ParentId" SessionField="parentLevelId" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>

                        <!-- ObjectDataSource 2 : Normal user — own records only -->
                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
                            SelectMethod="SelectCompressedWorkHoursApplicationByEmpId"
                            TypeName="CompressedWorkHoursApplicationEventData">
                            <SelectParameters>
                                <asp:SessionParameter Name="EmployeeCodeId" SessionField="EmployeeId" Type="string" />
                                <asp:ControlParameter ControlID="txt_EmpName" Type="string" Name="EmpFirstName" PropertyName="Text" />
                                <asp:ControlParameter ControlID="txtEmployeeId" Type="string" Name="EmpCodeId" PropertyName="Text" />
                                <asp:ControlParameter ControlID="txtStartDate" DefaultValue="01/01/1900" Type="string" Name="StartDate" />
                                <asp:ControlParameter ControlID="txtEndDate" DefaultValue="01/01/1900" Type="string" Name="EndDate" />
                                <asp:SessionParameter Name="UserGroupName" SessionField="UserGroupName" Type="string" />
                                <asp:SessionParameter Name="UserLevels" SessionField="LevelRights" Type="string" />
                                <asp:SessionParameter Name="GradeLevel" SessionField="GradeLevel" Type="string" />
                                <asp:SessionParameter Name="EmpAutoId" SessionField="EmpAutoID" Type="string" />
                                <asp:SessionParameter Name="ParentId" SessionField="parentLevelId" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
        <!-- END GRID TABLE -->

    </div>
</asp:Content>
