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

<%@ 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="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">

    <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/jquery.autocomplete.js" type="text/javascript"></script>

    <script src="../plugins/datepicker/jquery-1.11.1.min.js"></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>

    <script type="text/javascript">
        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:';
        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, 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;
        }
        var MaxLength = "Maximum length is ";
        function MaxLengthh(maxLength) {
            MaxLength = maxLength;
        }
        function WeekdayValidation() {
            var EmpId = document.getElementById('ctl00_BodyContentPH_txtEmployeeId');
            var EmpName = document.getElementById('ctl00_BodyContentPH_txt_EmpName');
            var weekDay = document.aspnetForm.ctl00_BodyContentPH_txtStartDate;
            var weekDay2 = document.aspnetForm.ctl00_BodyContentPH_txtEndDate;
            var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

            var strSwipCard = document.getElementById('ctl00_BodyContentPH_txtSwipeCard').value;

            if (EmpName == null && EmpId == null && weekDay.value == '' && weekDay2.value == '' && strSwipCard == '') {
                alert(EnterDetails);
                return false;
            }
            else if ((weekDay.value == '' && weekDay2.value != '') || (weekDay.value != '' && weekDay2.value == '')) {
                alert(FillFromandToDate);
                return false;
            }
            else {
                // Nothing
            }
           
            var DateFormat = 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 {
                        document.getElementById('ctl00_BodyContentPH_txtLeaveEndDate').focus();
                        return false;
                    }
                }
                else {
                    return false;
                }
            }
            //if (weekDay.value != '') {
            //    if (checkDate(weekDay, DateFormat)) {
            //        if (weekDay2.value != '') {
            //            if (checkDate(weekDay2, DateFormat)) {
            //            }
            //            else {
            //                return false;
            //            }
            //        }
            //    }
            //    else {
            //        return false;
            //    }
            //}
        }

    </script>
    <script type="text/javascript">


        function navi(loc) {
            document.getElementById('ctl00_BodyContentPH_iframePopup').src = loc;
            //            window.location=loc;
            return false;
        }
        function Delete_Conf() {
            //Alert_AreyousuretoDelete
            return confirm('Are you sure to Delete ?');
        }
        function ShowPopup() {
            $("#btnShowPopup").click();
        }
    </script>
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/onduty-icons.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_Header" runat="server" Text="Compensation Leave Entry"></asp:Label>
            <asp:HiddenField ID="Hidden1" runat="server" />
        </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-2">
                    <div class="inr-fil-text">
                        <asp:Label ID="lblFilter" runat="server" Text="Filter"></asp:Label>
                    </div>
                </div>

            </div>
        </div>
        <div id="myModal" class="modal modal-default fade" role="dialog">
            <div class="modal-dialog" style="min-width: 85%;">
                <!-- Modal content-->
                <div class="modal-content" style="margin-top: 100px">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" style="border-radius: 50px;">
                            &times;</button>
                        <h4 class="modal-title" style="padding-bottom: 10px">
                            <asp:Label ID="lblDataView" runat="server" Text="Data View"></asp:Label>
                        </h4>
                    </div>
                    <div class="modal-body">
                        <iframe id="iframePopup" runat="server" scrolling="auto" width="100%" height="300px"
                            style="border-style: none"></iframe>
                    </div>
                    <div class="modal-footer" style="display: none">
                        <button type="button" class="btn btn-primary pull-right" data-dismiss="modal">
                            Close</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="row">
                <div class="form-horizontal">
                    <div class="col-md-12">
                        <div class="row form-group" style="display: none">
                            <div class="col-md-2">
                                <asp:Label ID="lblEmpSwipe" runat="server" Text="Card No"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtSwipeCard" MaxLength="20" runat="server" CssClass="textbox_3"></asp:TextBox>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                            </div>
                            <div class="col-md-3">
                            </div>
                        </div>
                        <div class="row form-group" id="divAdmin" runat="server">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_EmployeeName" runat="server" Text="Employee First Name "></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_EmpName" runat="server" CssClass="form-control"
                                    MaxLength="50" 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 / PEN"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txtEmployeeId" runat="server" CssClass="form-control"
                                    MaxLength="15" 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 class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lblTimePeriod" runat="server" Text="Date"></asp:Label>
                                <asp:Label ID="lblStartDate" runat="server" Text="From"></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">
                                </asp:TextBox>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblEndDate" runat="server" Text="To"></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">
                                </asp:TextBox>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-8">
                            </div>
                            <div class="col-md-3">
                                <div class="pull-right-button">
                                    <%--Add serach button here--%>
                                    <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 WeekdayValidation();" />
                                    <asp:LinkButton ID="btn_Clear" CssClass="btn clr-btn fa-refresh" runat="server" OnClick="btn_Clear_Click" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="border-table new-space form-group">
            <div class="table-responsive" style="padding-bottom: 10px">
                <%--Grid Add Here--%>
                <asp:HiddenField ID="hdnSelectRow" runat="server" />
                <asp:HiddenField ID="hdnGetAllid" runat="server" />

                <dxGridview:ASPxGridView ID="gvCompensationList" runat="server" ClientInstanceName="grv_LeaveApplication"
                    KeyFieldName="LeaveApplication_Id" EnableCallBacks="False" AutoGenerateColumns="False"
                    OnHtmlRowCreated="gvCompensationList_HtmlRowCreated" Width="100%">
                    <Columns>
                          <dxGridview:GridViewDataTextColumn FieldName="ApplicationDate" VisibleIndex="0" Caption="Application Date"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lbl_InDate" Text='<%# Eval("ApplicationDate") %>' runat="server"></asp:Label>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>
                        <dxGridview:GridViewDataTextColumn FieldName="Employee_Id" VisibleIndex="1" Width="100px">
                            <DataItemTemplate>
                                <asp:Label ID="lbl_Mid" Text='<%# Eval("Employee_Id") %>' runat="server"></asp:Label>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>
                        <dxGridview:GridViewDataTextColumn FieldName="Employee_FirstName" VisibleIndex="2" Caption="Employee Name"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lbl_EmpName" Text='<%# Eval("Employee_FirstName") %>' runat="server"></asp:Label>
                                <asp:HiddenField ID="hdnCompId" runat="server" Value='<%# Eval("Compensation_Id") %>' />
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>
                        <dxGridview:GridViewDataTextColumn FieldName="LevelName" VisibleIndex="2" Caption="Level Name">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lbl_LevelName" Text='<%# Eval("LevelName") %>' 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 FieldName="FromDate" VisibleIndex="3" Caption="Date of Duty"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lbl_FromDate" Text='<%# Eval("FromDate") %>' runat="server"></asp:Label>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>

                        <dxGridview:GridViewDataTextColumn FieldName="DayWorked" VisibleIndex="4" Caption="Day Worked"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lblDayWorked" Text='<%# Eval("DayWorked") %>' runat="server"></asp:Label>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>

                        <dxGridview:GridViewDataTextColumn FieldName="WorkedHours" VisibleIndex="5" Caption="Extra Worked Hours"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lblWorkedHrs" Text='<%# Eval("WorkedHours") %>' runat="server"></asp:Label>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>

                        <dxGridview:GridViewDataTextColumn FieldName="Comp_Status" VisibleIndex="6" Caption="Status"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lblStatus" Text='<%# Eval("Comp_Status") %>' runat="server"></asp:Label>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Wrap="True" />
                        </dxGridview:GridViewDataTextColumn>

                        <dxGridview:GridViewDataTextColumn FieldName="Reason" VisibleIndex="7" Caption="Reason"
                            Width="100px">
                            <Settings AllowDragDrop="False" />
                            <DataItemTemplate>
                                <asp:Label ID="lblRemarks" Text='<%# Eval("Reason") %>' 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:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                            CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="32px">
                            <Settings AllowAutoFilter="false" />
                            <DataItemTemplate>
                                <a data-toggle="modal" title='<%# Session["View"] %>' data-placement="top" data-target="#myModal" onclick="return navi('TA_UI_Transactions_ManualCompensationEntry_View.aspx?CoffId=<%# Eval("Compensation_Id") %>')"
                                    href="#"><span class="btn btn-defalut view-icons"></span></a>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                        </dxGridview:GridViewDataColumn>

                         <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                            CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="35px">
                            <Settings AllowAutoFilter="false" />
                            <DataItemTemplate>
                                <asp:LinkButton ID="btnEdit" runat="server" ToolTip='<%# Session["Edit"] %>' data-toggle="tooltip"
                                    OnClick="EditLinkButton_Click" CommandName='<%# Eval("Compensation_Id") %>'
                                    CommandArgument='<%# Eval("Comp_Status") %>' data-placement="top"
                                    CssClass="btn btn-defalut edit-icons" Style="color: #3C8DBC"></asp:LinkButton>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="center" Wrap="true" CssClass="empheader" />
                        </dxGridview:GridViewDataColumn>

                        <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                            CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="32px">
                            <Settings AllowAutoFilter="false" />
                            <DataItemTemplate>
                                <asp:LinkButton ID="btnDelete" runat="server" OnClick="btn_delete_Click_1"
                                    ToolTip='<%# Session["Delete"] %>' data-toggle="tooltip" CommandName='<%# Eval("Compensation_Id") %>'
                                    CommandArgument='<%# Bind("Employee_FirstName") %>' data-placement="top" CssClass="btn btn-defalut del-icons"
                                    Style="color: Red" OnClientClick="return Delete_Conf();"></asp:LinkButton>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                        </dxGridview:GridViewDataColumn>
                    </Columns>
                    <SettingsText EmptyDataRow="No Records Found" />
                    <Settings ShowFilterRow="True" />
                    <SettingsBehavior SortMode="Value" />
                    <Styles AlternatingRow-CssClass="table-bg">
                    </Styles>
                </dxGridview:ASPxGridView>
                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="CompensationListing"
                    TypeName="LeaveApplicationEventData">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txt_EmpName" Type="string" Name="EmployeeName" PropertyName="Text" />
                        <asp:ControlParameter ControlID="txtEmployeeId" Type="string" Name="EmployeeId" PropertyName="Text" />
                        <asp:ControlParameter ControlID="txtStartDate" Type="string" DefaultValue="01/01/1900"
                            Name="FromDate" />
                        <asp:ControlParameter ControlID="txtEndDate" Type="string" DefaultValue="01/01/1900"
                            Name="Todate" />
                        <asp:SessionParameter Name="UserGroupName" SessionField="UserGroupName" Type="string" />
                        <asp:SessionParameter Name="parentLevelId" Type="Int32" />
                        <asp:SessionParameter Name="EmpAutoID" SessionField="EmpAutoId" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>

                <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="SelectCompensationListingDetails"
                    TypeName="LeaveApplicationEventData">
                    <SelectParameters>
                        <asp:SessionParameter Name="Employee_Id" SessionField="EmpAutoId" Type="Int32" />
                        <asp:SessionParameter Name="GradeLevel" SessionField="GradeLevel" Type="String" />
                        <asp:ControlParameter ControlID="txtStartDate" Type="string" DefaultValue="01/01/1900" Name="LeaveStartDate" />
                        <asp:ControlParameter ControlID="txtEndDate" Type="string" DefaultValue="01/01/1900" Name="LeaveEndDate" />
                        <asp:SessionParameter Name="UserGroupName" SessionField="UserGroupName" Type="string" />
                        <asp:SessionParameter Name="parentLevelId" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>

            </div>
            <div class="clearfix">
            </div>
            <div class="row page-nos">
                <div class="col-md-6">
                </div>
                <div class="col-md-6 page-button">
                    <asp:LinkButton ID="btn_Add" CssClass="btn add-btn fa-plus" runat="server" OnClick="btn_Add_Click" />
                    <asp:Button ID="btn_Cancel" CssClass="but" runat="server" CausesValidation="False" Visible="false" />
                    <%--Add Cancel button Add button here--%>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
