<style>
    .dropdown-menu>li>a {
        cursor:pointer;
    }
    .inputIcon{
        width:30px;}
    </style>
    <div class="modal fade stick-up " id="add_Employee_Location" tabindex="-1" role="dialog" aria-hidden="true" style="width:30%;margin:0 auto">
    <div class="modal-dialog  width:5px;">
        <div class="modal-content width: 494px;">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h5><span class="semi-bold"><?php print CommonLanguage::getMessage('Location'); ?></span></h5>
                <div id="addAlertLcoation"></div>
            </div>
            <div class="modal-body">
                <form id="AddTypePostForm" method="POST" onsubmit="return false">
                    <div class="row">
                        <div class="col-md-12" >
                            <div class="col-md-8">
                                <div><label><?php print CommonLanguage::getMessage('Location'); ?></label></div>
                                <div class="input-group required">
                                    <span class="input-group-addon bg-success">
                                        <i class="fa fa-flag inputIcon" ></i>
                                    </span>
                                    <input type="text" placeholder="<?php print CommonLanguage::getMessage('Location'); ?>" id="Location_Name" name="Location_Name" class="form-control "  style="width: 252px; " required>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer ">
                <div class="pull-right">
                    <button class="btn btn-default" id="Close_Location"   > <?php print CommonLanguage::getMessage('Close'); ?> </button>
                    <button class="btn btn-success" id="SubmitLocation"  > <?php print CommonLanguage::getMessage('Save'); ?>   </button>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>;
    $(function () {
        $("#SubmitLocation").on("click", function () {
            $("#addAlertLcoation").attr("class", "").html("")

            $("#LocationIsBusy").remove();
            $("#add_Location").append('<div id="LocationIsBusy" style="position:absolute;left:0;right:0;top:0px;height:100%;background:rgba(255,255,255,0.9);z-index:9999;opacity:0"><img class="image-responsive-height demo-mw-50" src="img/demo/progress.svg" alt="Progress" style="position: absolute;left: 50%;top: 50%;margin: -25px 0 0 -25px;" /></div>');
            $("#LocationIsBusy").animate({opacity: 1});
            var Data = {
                Location_Name: $("#Location_Name").val()
            }
            $.ajax({
                url: "HRMAjax/addEmployeeLocation",
                method: "POST",
                data: Data,
                dataType: "JSON",
                complete: function (v1, v2) {
                    if (v2 == 'success') {
                        var newType = "<option value='" + v1.responseJSON[0]['Location_ID'] + "'>" + v1.responseJSON[0]['Location_Name'] + "</option>";
                        $("#Employee_Location").append($(newType))
                        $("#LocationIsBusy").remove();
                        $("#addAlertLcoation").addClass("alert alert-success").show().html(Submitted_Successfully);
                        setTimeout(function () {
                            $("#add_Employee_Location").modal('hide')
                        }, 1500)
                        setTimeout(function () {
                            $("#addAlertLcoation").hide()
                        }, 1500)
                    } else {

                        $("#addAlertLcoation").addClass("alert alert-danger").show().html(Failed_Submit+', '+v1.responseText);
                    }
                    $("#LocationIsBusy").remove();
                }
            })
        });
        $("#Close_Location").on("click", function () {
            $("#add_Employee_Location input").val('');
            //$("#AddProductPostForm").validate().resetForm();
            $("#add_Employee_Location").modal("hide");
        })
        $("#add_Employee_Location input").val('');
    });
</script>