<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" enableeventvalidation="false" autoeventwireup="true" inherits="Transactions_TA_UI_Transaction_ShiftExchange, App_Web_dihzv11n" %>

<%@ 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" />
	<link rel="stylesheet" type="text/css" href="../css/anytimeIE.css" />
<![endif]-->

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

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

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

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

    <script>

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

    <script type="text/javascript">

        //values for check date
        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 EnterDate = "Enter Date.";
        var SelectCompany = "Select Company";
        var FillEmployee1Code = "Fill Employee1 Code";
        var Selectshiftdate = "Select shift date";
        var FillEmployee2Code = "Fill Employee2 Code";
        var EmployeeId = "Employee Id should not be same";
        var Employee1ActualShift = "Employee1 Actual Shift Should not be empty";
        var Employee2ActualShift = "Employee2 Actual Shift Should not be empty";
        var BothEmployee = "Actual Shifts for both Employee should not be unique";
        var Confirm = "Are sure to Exchange the shifts?";
        var Shiftnotallocated = "Shift not allocated";


        var MaxLength = "Maximum length is ";


        function MaxLengthh(maxLength) {

            MaxLength = maxLength;
        }

        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;
        }


        function SetAlertMessages(enterDate, selectCompany, fillEmployee1Code, selectshiftdate, fillEmployee2Code, employeeId, employee1ActualShift, employee2ActualShift, bothEmployee, confirm, shiftnotallocated) {
            EnterDate = enterDate;
            SelectCompany = selectCompany;
            FillEmployee1Code = fillEmployee1Code;
            Selectshiftdate = selectshiftdate;
            FillEmployee2Code = fillEmployee2Code;
            EmployeeId = employeeId;
            Employee1ActualShift = employee1ActualShift;
            Employee2ActualShift = employee2ActualShift;
            BothEmployee = bothEmployee;
            Confirm = confirm;
            Shiftnotallocated = shiftnotallocated;
        }

        function CheckDate() {

            if (document.aspnetForm.ctl00_BodyContentPH_txt_E1Date.value != "") {
                var weekDay = document.aspnetForm.ctl00_BodyContentPH_txt_E1Date;
                var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

                if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
     ) {
                    OpenWindowShiftExchange('txt_Ecode1', 'ShiftExchange');
                    $('#myModal').modal('show');
                    //$('#myModal1').modal('hide');
                    //return false;
                }
                else {
                    return false;
                }

            }
            else {
                alert(EnterDate);
                $('#myModal').modal('hide');
                // $('#myModal1').modal('hide');
                return false;
            }
            return false;
        }

        function CheckDate1() {
            if (document.aspnetForm.ctl00_BodyContentPH_txt_E1Date.value != "") {
                var weekDay = document.aspnetForm.ctl00_BodyContentPH_txt_E1Date;
                var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

                if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
     ) {
                    OpenWindowShiftExchange('txt_Ecode2', 'ShiftExchange');
                    $('#myModal').modal('show');
                    //return false;
                }
                else {
                    return false;
                }
            }
            else {
                alert(EnterDate);
                $('#myModal').modal('hide');
                return false;
            }
            return false;
        }
        function Validation() {
            var TypeIndex = document.aspnetForm.ctl00_BodyContentPH_ddlCompany.selectedIndex;
            var Type = document.aspnetForm.ctl00_BodyContentPH_ddlCompany.options[TypeIndex].value;

            if (Type == "0") {
                alert(SelectCompany);
                return false;
            }
            if (document.aspnetForm.ctl00_BodyContentPH_txt_Ecode1.value == "") {
                alert(FillEmployee1Code);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_E1Date.value == "") {
                alert(Selectshiftdate);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_Ecode2.value == "") {
                alert(FillEmployee2Code);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_Ecode1.value == document.aspnetForm.ctl00_BodyContentPH_txt_Ecode2.value) {
                alert(EmployeeId);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_E1ActualShift.value == "") {
                alert(Employee1ActualShift);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_E2ActualShift.value == "") {
                alert(Employee2ActualShift);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_E1ActualShift.value == document.aspnetForm.ctl00_BodyContentPH_txt_E2ActualShift.value) {
                alert(BothEmployee);
                return false;
            }
            else if (document.aspnetForm.ctl00_BodyContentPH_txt_E1Date.value != "") {
                var weekDay = document.aspnetForm.ctl00_BodyContentPH_txt_E1Date;
                var DateFormat = document.getElementById('ctl00_BodyContentPH_Hidden1').value;

                if (checkDate(weekDay, DateFormat, Monthfourdigit, Datefourdigit, Invalidyearentry, Invalidmonthentry, Invaliddateentry, DateformatDDMONYYYY, Entertime, Valueforhours, Invalidvalueforminutes, Invalidtimeformat, EntervalidDateandTime, ValiddatemonthMMDDYYHHMM, ValiddatemonthMMDDYYHHMMTT, EntervalidDateandTime, Invalidvalueforhours, Invalidvalueforminites)
     ) {
                }
                else {
                    return false;
                }
            }

            return confirm(Confirm);

            //return true;   
        }


    </script>

    <div class="content-header">
        <h1 style="background-image: url('../dist/img/shift-exe.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">
        <asp:UpdatePanel>
            <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>
            <Triggers>
                <asp:PostBackTrigger ControlID="btn_Save" />
            </Triggers>
        </asp:UpdatePanel>
        <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" id="closemodal" class="close" data-dismiss="modal" style="border-radius: 50px;">
                            &times;</button>
                        <h4 class="modal-title">
                            <asp:Label ID="lblSelectEmployee" runat="server" Text="Select Employee"></asp:Label></h4>
                    </div>
                    <div class="modal-body">
                        <iframe id="iframePopup" runat="server" scrolling="auto" width="100%" height="620px"
                            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="inr-ftr">
            <div class="row">
                <div class="col-sm-2">
                </div>
                <div class="col-sm-2 col-sm-offset-8">
                    <div class="pull-right">
                        <h6>
                            <span style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px">
                                <asp:Label ID="lbl_Mandatory" runat="server" Text="Mandatory"></asp:Label>
                                (4 No.)</span>
                        </h6>
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="form-horizontal">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row" style="display: none">
                            <div class="col-md-12" style="color: Red">
                                <span class="fa fa-asterisk"></span>
                                <asp:Label ID="lbl_IndicatesMandatoryFields" runat="server"></asp:Label>
                                <asp:Label ID="lbl_Error" runat="server"></asp:Label>
                                <asp:HiddenField ID="Hidden1" runat="server" />
                            </div>
                        </div>
                        <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">
                                    <asp:ListItem Value="0" Text="-Select-"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Date1" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_E1Date" runat="server" CssClass="form-control mandatory"
                                    onCut="return false" onDrop="return false"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Employee1Code" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <div class="input-group input-group-sm">
                                    <asp:TextBox onpaste="return true" ID="txt_Ecode1" runat="server" CssClass="form-control mandatory"
                                        onblur="EmpName_Exchange('1',SelectCompany,Shiftnotallocated);" onCut="return false"
                                        onDrop="return false" onkeypress="return chkMaxLen(event,this,15,MaxLength)"
                                        MaxLength="15"></asp:TextBox>
                                    <span class="input-group-btn">
                                        <asp:LinkButton ID="btn_Search" CssClass="btn save-btn fa-search" runat="server"
                                            OnClientClick="return CheckDate();" />
                                    </span>
                                </div>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Employee1Name" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_Emp1Name" runat="server" CssClass="form-control"
                                    onCut="return false" onDrop="return false" onkeydown="return key_press_nokey(event)"
                                    onkeypress="return AcceptTab(event);"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_ActualShift1" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_E1ActualShift" runat="server" CssClass="form-control"
                                    onCut="return false" onDrop="return false" onkeydown="return key_press_nokey(event)"
                                    onkeypress="return AcceptTab(event);" BackColor="#d3dbe7" BorderStyle="None"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Employee2Code" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <div class="input-group input-group-sm">
                                    <asp:TextBox onpaste="return true" ID="txt_Ecode2" runat="server" CssClass="form-control mandatory"
                                        onblur="EmpName_Exchange('2',SelectCompany,Shiftnotallocated);" onCut="return false"
                                        onDrop="return false" onkeypress="return chkMaxLen(event,this,15,MaxLength)"
                                        MaxLength="15"></asp:TextBox>
                                    <span class="input-group-btn">
                                        <asp:LinkButton ID="btn_search2" CssClass="btn save-btn fa-search" runat="server"
                                            OnClientClick="return CheckDate1();" />
                                    </span>
                                </div>
                            </div>
                            <div class="col-md-1">
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbl_Employee2Name" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_Emp2Name" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-2">
                                <asp:Label ID="lbl_ActualShift2" runat="server"></asp:Label>
                            </div>
                            <div class="col-md-3">
                                <asp:TextBox onpaste="return true" ID="txt_E2ActualShift" runat="server" CssClass="form-control"
                                    onCut="return false" onDrop="return false" onkeydown="return key_press_nokey(event)"
                                    onkeypress="return AcceptTab(event);" BackColor="#d3dbe7" BorderStyle="None"></asp:TextBox></td>
                            </div>
                            <div class="col-md-12">
                            </div>
                        </div>
                        <div class="row" style="display: none">
                            <div class="col-md-12">
                                <asp:Label ID="lbl_Info" runat="server" CssClass="form-control"></asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix">
                    </div>
                    <div class="col-md-12">
                    </div>
                    <div class="col-md-5">
                    </div>
                    <div class="col-md-6">
                        <div class="pull-right-button">
                            <asp:LinkButton ID="btn_Save" CssClass="btn save-btn fa-floppy-o" runat="server"
                                OnClick="btn_Save_Click" OnClientClick="if(Validation()) $find('popupProgress').show(); else return false;" />
                            <asp:LinkButton ID="btn_Back" CssClass="btn save-btn fa-angle-left" CausesValidation="false"
                                runat="server" OnClick="btn_Back_Click" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
