public/js/env-employee.js
// toggle active status of an employee
toggle active status of an employee
toggle active status of an employee
function toggleActiveStatus() {
    $(".toggle").on("click", function (e) {
        $tr = $(this).closest("tr");
        var data = $tr
            .children("td")
            .map(function () {
                return $(this).text();
            })
            .get();
        let statValue = $("#" + data[0]).val();
        if (statValue == 0) {
            $("#" + data[0]).attr("checked", true);
            statValue = 1;
        } else {
            $("#" + data[0]).attr("checked", true);
            statValue = 0;
        }
        $.ajax({
            url: "/update-employee-status/" + data[0] + "/" + statValue,
            type: "PUT",
            data: { statValue: statValue, id: data[0] },
            success: function (response) {
                successNotification("Account has been Activated!");
                $("#" + data[0]).attr("checked", false);
            },
            error: function (req, err) {
                dangerNotification("Error!");
            },
        });
    });
}
function toggleActiveStatus ( ) { $ ( ".toggle" ) . on ( "click" , function ( e ) { $tr = $ ( this ) . closest ( "tr" ) ; var data = $tr . children ( "td" ) . map ( function ( ) { return $ ( this ) . text ( ) ; } ) . get ( ) ; let statValue = $ ( "#" + data [ 0 ] ) . val ( ) ; if ( statValue == 0 ) { $ ( "#" + data [ 0 ] ) . attr ( "checked" , true ) ; statValue = 1 ; } else { $ ( "#" + data [ 0 ] ) . attr ( "checked" , true ) ; statValue = 0 ; } $ . ajax ( { url : "/update-employee-status/" + data [ 0 ] + "/" + statValue , type : "PUT" , data : { statValue : statValue , id : data [ 0 ] } , success : function ( response ) { successNotification ( "Account has been Activated!" ) ; $ ( "#" + data [ 0 ] ) . attr ( "checked" , false ) ; } , error : function ( req , err ) { dangerNotification ( "Error!" ) ; } , } ) ; } ) ; }
toggle active status of an employee
toggle active status of an employee