﻿function SetJobStatus(JobId, JobStatus) {    
    var Action = "SetJobStatus";
    var dt = new Date();

    var flagActiveJob = false;
    
    if (JobStatus == 'False') {        
        flagActiveJob = confirm("האם להפוף משרה ללא פעילה");
    }
    else {
        flagActiveJob = confirm("האם להפוף משרה לפעילה");
    }

    if (flagActiveJob) {
        $.ajax({
            type: "GET",
            url: "../AJactions/EmployerJobs_Ajax.aspx",
            cache: false,
            async: false,
            data: "JobId=" + JobId + "&JobStatus=" + JobStatus + "&Action=" + Action + "&TimeToSend=" + dt.getMilliseconds(),
            success: function(res) {
                if (res == "1") {
                    parent.window.location = JsConfiguration["HomePage"] + 'Members/EmployerJobsMain.aspx';
                }
                else {
                    parent.window.location = JsConfiguration["HomePage"];
                }

            },
            error: function() {
                alert('זמנית לא ניתן לספק שירות זה')
            }
        });
    }
}


function SendSeekerDetailsForJob(UserId, JobId, dvId) {

        var AjPath = $('input[id*="hdJobSearchAjPath"]').attr('value');

        if (AjPath != "") {
            var dt = new Date();
            $.ajax({
                type: "GET",
                url: AjPath,
                cache: false,
                async: false,
                data: "UserId=" + UserId + "&JobId=" + JobId + "&Action=SendSeekerDetailsForJob" + "&TimeToSend=" + dt.getMilliseconds(),
                success: function(res) {
                    if (res == "1") {
                        $('#' + dvId).html("נשלח בהצלחה");
                        $('#' + dvId).show();
                    }
                    else if (res == "0") {                        
                        $('#' + dvId).html("שלחת בעבר מועמדות למשרה זו")
                        $('#' + dvId).show();
                    }
                    else if (res == "2") {
                        parent.window.location = JsConfiguration["HomePage"];
                    }
                },
                error: function() {
                    alert('זמנית לא ניתן לספק שירות זה')
                }
            });
        }
}

function deleteJobById(JobId) {
    var Action = "deleteJobById";
    var dt = new Date();

    var flagDeleteJob = confirm("? מחיקת משרה זו תגרום למחיקת כל המועמדים למשרה זו האם להמשיך");

    if (flagDeleteJob) {
        $.ajax({
            type: "GET",
            url: "../AJactions/EmployerJobs_Ajax.aspx",
            cache: false,
            async: false,
            data: "JobId=" + JobId + "&Action=" + Action + "&TimeToSend=" + dt.getMilliseconds(),
            success: function(res) {
                if (res == "1") {                    
                    parent.window.location = JsConfiguration["HomePage"] + 'Members/EmployerJobsMain.aspx';
                }
                else {
                    parent.window.location = JsConfiguration["HomePage"];
                }

            },
            error: function() {
                alert('זמנית לא ניתן לספק שירות זה')
            }
        });
    }
}

function JumpJobById(JobId) {
    var Action = "JumpJobById";
    var dt = new Date();

    $.ajax({
        type: "GET",
        url: "../AJactions/EmployerJobs_Ajax.aspx",
        cache: false,
        async: false,
        data: "JobId=" + JobId + "&Action=" + Action + "&TimeToSend=" + dt.getMilliseconds(),
        success: function(res) {
            if (res == "1") {
                $("#spn" + JobId).html("המשרה הוקפצה בהצלחה");
            }
            else {                
                parent.window.location = JsConfiguration["HomePage"];
            }

        },
        error: function() {
            alert('זמנית לא ניתן לספק שירות זה')
        }
    });    
}
                                    
function deleteSeekerFromJobById(UserId, JobId) {

    var Action = "deleteSeekerFromJobById";
    var dt = new Date();

    var flagDeleteJob = confirm("? האם למחוק משתמש זה ממשרה זו");

    if (flagDeleteJob) {
        $.ajax({
            type: "GET",
            url: "../AJactions/EmployerJobs_Ajax.aspx",
            cache: false,
            async: false,
            data: "UserId=" + UserId + "&JobId=" + JobId + "&Action=" + Action + "&TimeToSend=" + dt.getMilliseconds(),
            success: function(res) {
                if (res == "1") {
                    $("#tb" + UserId).slideUp();
                }
                else {
                    parent.window.location = JsConfiguration["HomePage"];
                }

            },
            error: function() {
                alert('זמנית לא ניתן לספק שירות זה')
            }
        });
    }
}


