<div class="modal fade modal-sm stick-up " id="add_volunteer_skills" tabindex="-1" role="dialog" aria-hidden="true" style="
     margin: 0 auto;">
    <div class="modal-dialog ">
        <div class="modal-content">
            <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 echo CommonLanguage::getMessage('volunteer_skills') ?></span></h5>
                <div id="alertl_skills"></div>
                <input type="hidden" id="IS_Edit" value="0" />
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row">
                            <label><?php echo CommonLanguage::getMessage('skills_name') ?></label><span class="red-star">*</span>
                            <input type="text" class="form-control skills_name" id="skills_name"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-success" id="submit_skills"><?php echo CommonLanguage::getMessage('Save') ?></button>
                <button class="btn btn-danger" data-dismiss="modal"  id="cancel_skills"><?php echo CommonLanguage::getMessage('Close') ?></button>
            </div>
        </div>
    </div>
</div>


<script>
    var title = <?php echo json_encode(CommonLanguage::getMessage('volunteer_team')); ?>;
    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            Required_Fields = <?php echo json_encode(CommonLanguage::getMessage('Required_Fields')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>;
    var CurrentID;
    $(function () {

        $("#AddVolunteerSkills").on("click", function () {
            $("#IS_Edit").val(0);
        });
        $("#tableWithSearch").on("click", ".Action .Edit", function () {
            CurrentID = $(this).parents('div.Action').attr('data-id');
            var name = $(this).parents("tr").find("td:eq(0)").text();
            $("#IS_Edit").val(1);
            $("#add_volunteer_skills").modal('show');
            $('#skills_name').val(name);
        });
        $('#submit_skills').on('click', function () {
            var Data = {
                skills_name: $('#skills_name').val(),
                Is_Edit: $("#IS_Edit").val()
            };
            if ($("#IS_Edit").val() == 1) {
                Data.skills_id = CurrentID;
            }
            if (Data.skills_name == '') {
                $('#alertl_skills').attr('class', 'alert alert-warning').empty().html(Required_Fields);
                return false;
            }
            $.ajax({
                url: 'HRMAjax/addVolunteerSkillsRequest',
                data: Data,
                type: 'POST',
                dataType: 'JSON',
                complete: function (v1, v2) {
                    if (v2 == 'success') {
                        if (v1.responseJSON[0] == 'ok') {
                            $('#alertl_skills').attr('class', 'alert alert-success').empty().html(Submitted_Successfully);
                            RebuildDataTable(title, [0], 'HRMAjax/ViewVolunteerSkillsRequest');
                            setTimeout(function () {
                                $("#alertl_skills").addClass('hidden');
                                $("#add_volunteer_skills").modal('hide');
                                $('#skills_name').val('');
                            }, 1500);
                            $('#IS_Edit').val(0)
                        } else {
                            $('#alertl_skills').attr('class', 'alert alert-danger').empty().html(v1.responseJSON[1]);
                        }
                    } else {
                        $('#alertl_skills').attr('class', 'alert alert-danger').empty().html(Failed_Submit);
                        $('#alertl_skills').addClass('hidden');
                    }
                }
            });
        });
        $('#cancel_skills').on('click', function () {
            $('#alertl_skills').addClass('hidden');
            $('#skills_name').val('');
            $('#IS_Edit').val(0);
        });
    });
</script>