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

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">
    <script src="../plugins/datepicker/jquery-1.11.1.min.js"></script>
    <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>

    <div class="content-header">
        <h1>
            <asp:Label ID="lbl_Header" runat="server" Text="Policy Configuration"></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="pull-right">
                        <h6>
                            <span style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px">
                                Mandatory (1 No.) </span>
                        </h6>
                    </div>
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="form-horizontal">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:Label ID="lblProcessDate" runat="server" Text="Process Date"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtProcessDate" MaxLength="11" runat="server" CssClass="form-control mandatory"></asp:TextBox>
                                <asp:HiddenField ID="hdnProcessDate" runat="server" />
                            </div>
                            <div class="col-md-5"></div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:CheckBox ID="chkboxDailyRqrd" runat="server" onclick="EnableDisableControls(1);" CssClass="checkbox checkbox-primary" Text="Daily Hours Exceeded is required"></asp:CheckBox>
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbldayhours" runat="server" Text="How many Hour(s)"></asp:Label>
                            </div>
                            <div class="col-md-2">
                                <asp:TextBox ID="txtDailyHrs" MaxLength="5" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:CheckBox ID="chkboxDayDeviation" runat="server" onclick="EnableDisableControls(2);" Text="Day Deviation is required" CssClass="checkbox checkbox-primary"></asp:CheckBox>
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lbldayDevitiondays" runat="server" Text="How many day(s)"></asp:Label>
                            </div>
                            <div class="col-md-2">
                                <asp:TextBox ID="txtdayDeviation" MaxLength="2" onDrop="return false" onkeypress="return numbers_dot(event,this)" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:CheckBox ID="chkboxWeeklyDeviation" runat="server" onclick="EnableDisableControls(3);" Text="Weekly Hours Exceeded is required" CssClass="checkbox checkbox-primary"></asp:CheckBox>
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblWeeklyDeviationHrs" runat="server" Text="How many hour(s)"></asp:Label>
                            </div>
                            <div class="col-md-2">
                                <asp:TextBox ID="txtWeeklyDeviationHrs" MaxLength="2" onDrop="return false" onkeypress="return numbers_dot(event,this)" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:CheckBox ID="chkboxQuarterlyDeviation" runat="server" onclick="EnableDisableControls(4);" Text="Quarterly OT Hours Exceeded is required" CssClass="checkbox checkbox-primary"></asp:CheckBox>
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblQuarterlyDeviationhrs" runat="server" Text="How many hour(s)"></asp:Label>
                            </div>
                            <div class="col-md-2">
                                <asp:TextBox ID="txtQuarterDeviationHrs" MaxLength="2" runat="server" onDrop="return false" onkeypress="return numbers_dot(event,this)" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:CheckBox ID="chkboxContinuousAbsent" runat="server" onclick="EnableDisableControls(5);" CssClass="checkbox checkbox-primary" Text="Continuous Absent is required"></asp:CheckBox>
                            </div>
                            <div class="col-md-2">
                                <asp:Label ID="lblContinuousAbsentDays" runat="server" Text="How many day(s)"></asp:Label>
                            </div>
                            <div class="col-md-2" align="left">
                                <asp:TextBox ID="txtContinuousAbsentdays" MaxLength="2" onDrop="return false" onkeypress="return numbers_dot(event,this)" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:Label ID="Label3" runat="server" Text="Approved Attendance"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtApprovedAttendance" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:Label ID="lblEmpServer1" runat="server" Text="Employee Master API - Server 1 (Main Server)"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtboxEMPServer1" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group" style="display:none">
                            <div class="col-md-5">
                                <asp:Label ID="lblEmpServer2" runat="server" Text="Employee Master API - Server 2"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtboxEmpServer2" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group" style="display:none">
                            <div class="col-md-5">
                                <asp:Label ID="Label7" runat="server" Text="Employee Master API - Server 3"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtboxEmpServer3" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group" style="display: none">
                            <div class="col-md-5">
                                <asp:Label ID="lblblockingUnblocking" runat="server" Text="User Blocking And Unblocking API"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtblockingUnblocking" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group" style="display: none">
                            <div class="col-md-5">
                                <asp:Label ID="lblLogDownloading" runat="server" Text="Log Downloading API"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtlogDownloading" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:Label ID="lblUserName" runat="server" Text="Biostar API User Name"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtuserName" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row form-group">
                            <div class="col-md-5">
                                <asp:Label ID="lblPwd" runat="server" Text="BIostar API Password"></asp:Label>
                            </div>
                            <div class="col-md-7">
                                <asp:TextBox ID="txtpwd" TextMode="Password" runat="server" CssClass="form-control"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="callout callout-info" style="margin-bottom: 0!important;">
                                    <asp:Label ID="lblImportNote" runat="server" Text="Notes:"></asp:Label>
                                </div>
                                <br />
                                <ul>
                                    <li>
                                        <asp:Label ID="Label1" runat="server" Text="Copy and paste the folder path into corresponding field in above."></asp:Label>
                                    </li>
                                    <li>
                                        <asp:Label ID="lblnotes1" runat="server" Text="The above specified folder(s) should contain only one CSV file for data pulling."></asp:Label></li>
                                    <li>
                                        <asp:Label ID="Label2" runat="server" Text="If any folder contain more than one CSV file, that case it will refer only latest file data and it will not read the remaining file datas for data pulling"></asp:Label></li>
                                    <li>
                                        <asp:Label ID="lblcon" runat="server" Text="For data pulling, the system will refer only CSV file format, not any other file format."></asp:Label>
                                    </li>
                                    <li>
                                        <asp:Label ID="Label4" runat="server" Text="After Successful data reading and storing into the database, the file will be moved to complete folder in the same location."></asp:Label>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9" align="right">
                                <asp:LinkButton ID="btn_save" CssClass="btn save-btn fa-floppy-o"
                                    Text="&nbsp;&nbsp;Save" runat="server"
                                    ValidationGroup="vgLeaveType"
                                    OnClick="btn_save_Click"
                                    OnClientClick="return ValidateControl();" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function ValidateControl() {

            if (document.getElementById('ctl00_BodyContentPH_txtProcessDate').value == "") {
                alert("Enter Process Date before saving");
                document.getElementById('ctl00_BodyContentPH_txtProcessDate').focus();
                return false;
            }

            if (document.aspnetForm.ctl00_BodyContentPH_chkboxDailyRqrd.checked == true) {
                if (document.getElementById('ctl00_BodyContentPH_txtDailyHrs').value == "" || document.getElementById('ctl00_BodyContentPH_txtDailyHrs').value == "00:00") {
                    alert("Enter Hours value before saving");
                    document.getElementById('ctl00_BodyContentPH_txtDailyHrs').focus();
                    return false;
                }
            }
            if (document.aspnetForm.ctl00_BodyContentPH_chkboxDayDeviation.checked == true) {
                if (document.getElementById('ctl00_BodyContentPH_txtdayDeviation').value == "" || document.getElementById('ctl00_BodyContentPH_txtdayDeviation').value == "0") {
                    document.getElementById('ctl00_BodyContentPH_txtdayDeviation').focus();
                    alert("Enter day value before saving"); return false;
                }
            }
            if (document.aspnetForm.ctl00_BodyContentPH_chkboxWeeklyDeviation.checked == true) {
                if (document.getElementById('ctl00_BodyContentPH_txtWeeklyDeviationHrs').value == "" || document.getElementById('ctl00_BodyContentPH_txtWeeklyDeviationHrs').value == "0") {
                    document.getElementById('ctl00_BodyContentPH_txtWeeklyDeviationHrs').focus();
                    alert("Enter Weekly Hours value before saving"); return false;
                }
            }
            if (document.aspnetForm.ctl00_BodyContentPH_chkboxQuarterlyDeviation.checked == true) {
                if (document.getElementById('ctl00_BodyContentPH_txtQuarterDeviationHrs').value == "" || document.getElementById('ctl00_BodyContentPH_txtQuarterDeviationHrs').value == "0") {
                    document.getElementById('ctl00_BodyContentPH_txtQuarterDeviationHrs').focus();
                    alert("Enter Quarterly OT Hours value before saving"); return false;
                }
            }
            if (document.aspnetForm.ctl00_BodyContentPH_chkboxContinuousAbsent.checked == true) {
                if (document.getElementById('ctl00_BodyContentPH_txtContinuousAbsentdays').value == "" || document.getElementById('ctl00_BodyContentPH_txtContinuousAbsentdays').value == "0") {
                    document.getElementById('ctl00_BodyContentPH_txtContinuousAbsentdays').focus();
                    alert("Enter Day value before saving"); return false;
                }
            }
            return confirm("Are your sure to save Policy Configuration?")
        }
        function EnableDisableControls(controlID) {
            //alert(controlID);
            //debugger;
            switch (controlID) {
                case 1:
                    if (document.aspnetForm.ctl00_BodyContentPH_chkboxDailyRqrd.checked == true) {
                        document.getElementById('ctl00_BodyContentPH_txtDailyHrs').disabled = false;
                    }
                    else {
                        document.getElementById('ctl00_BodyContentPH_txtDailyHrs').disabled = true;
                    }
                    break;
                case 2:
                    if (document.aspnetForm.ctl00_BodyContentPH_chkboxDayDeviation.checked == true) {
                        document.getElementById('ctl00_BodyContentPH_txtdayDeviation').disabled = false;
                    }
                    else {
                        document.getElementById('ctl00_BodyContentPH_txtdayDeviation').disabled = true;
                    }
                    break;
                case 3:
                    if (document.aspnetForm.ctl00_BodyContentPH_chkboxWeeklyDeviation.checked == true) {
                        document.getElementById('ctl00_BodyContentPH_txtWeeklyDeviationHrs').disabled = false;
                    }
                    else {
                        document.getElementById('ctl00_BodyContentPH_txtWeeklyDeviationHrs').disabled = true;
                    }
                    break;
                case 4:
                    if (document.aspnetForm.ctl00_BodyContentPH_chkboxQuarterlyDeviation.checked == true) {
                        document.getElementById('ctl00_BodyContentPH_txtQuarterDeviationHrs').disabled = false;
                    }
                    else {
                        document.getElementById('ctl00_BodyContentPH_txtQuarterDeviationHrs').disabled = true;
                    }
                    break;
                case 5:
                    if (document.aspnetForm.ctl00_BodyContentPH_chkboxContinuousAbsent.checked == true) {
                        document.getElementById('ctl00_BodyContentPH_txtContinuousAbsentdays').disabled = false;
                    }
                    else {
                        document.getElementById('ctl00_BodyContentPH_txtContinuousAbsentdays').disabled = true;
                    }
                    break;
            }
        }
        function number_dot(e, ctrl) {
            dec_limit = arguments[1];
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;
            if ((keycode == 8) || (keycode == 0)) {
                return true;
            }
            val = ctrl.value;
            dot_index = val.indexOf('.');
            if (dot_index != -1) {
                dec_pts = (val.length - dot_index);
                if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
            }
            if (document.selection) {
                var selection = document.selection.createRange();
                var selected_text = selection.text;
            }
            else if (document.getSelection) {
                var start = ctrl.selectionStart;
                var end = ctrl.selectionEnd;
                var selected_text = ctrl.value.substring(start, end);
            }
            if ((val.length == 0 || selected_text != "") && (keycode == 46))	// || keycode==48
            {
                return false;
            }
            else if (dot_index != -1 && keycode == 46) {
                return false;
            }
            else if (!(keycode >= 48 && keycode <= 58) && (keycode != 13) && (keycode != 46) && (keycode = 36) && (keycode != 8) && (keycode != 0) && (keycode = 45) && (keycode = 47)) {
                return false;
            }
            else return true;
        }
        function numbers_dot(e, ctrl) {
            dec_limit = arguments[1];
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;
            if ((keycode == 8) || (keycode == 0)) {
                return true;
            }
            val = ctrl.value;
            dot_index = val.indexOf('.');
            if (dot_index != -1) {
                dec_pts = (val.length - dot_index);
                if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
            }
            if (document.selection) {
                var selection = document.selection.createRange();
                var selected_text = selection.text;
            }
            else if (document.getSelection) {
                var start = ctrl.selectionStart;
                var end = ctrl.selectionEnd;
                var selected_text = ctrl.value.substring(start, end);
            }
            if ((val.length == 0 || selected_text != "") && (keycode == 46))	// || keycode==48
            {
                return false;
            }
            else if (dot_index != -1 && keycode == 46) {
                return false;
            }
            else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 46) && (keycode = 36) && (keycode != 8) && (keycode != 0)) {
                return false;
            }
            else return true;
        }
        $(function () {
            $('#ctl00_BodyContentPH_txtDailyHrs').datetimepicker({ format: 'HH:mm' });
            $('#ctl00_BodyContentPH_txtProcessDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_hdnProcessDate').value });
        });
    </script>
</asp:Content>
