public/js/env-employee.js
// Fetches data and places it into update-employee-modal form
Fetches data and places it into update-employee-modal form
Fetches data and places it into update - employee - modal form
function employeeUpdateModal() {
    $(".editBtn").on("click", function (e) {
        $("#update-employee-modal").modal("show");
        $tr = $(this).closest("tr");
        let data = $tr
            .children("td")
            .map(function () {
                return $(this).text();
            })
            .get();
        $("#id").val(data[0]);
        $("#last_name_up").val(data[1]);
        $("#first_name_up").val(data[2]);
        $("#position_up").val(data[3]);
        $("#gender_up").val(data[4]);
        $("#contact_number_up").val(data[6]);
        $("#active_status_up").val(data[8]);
        const status = data[8];
        console.log(status);
        if (status == 1) {
            $(".employeeStatus").html(
                '<div class="form-check form-switch"><input class="form-check-input" id="active_status_up" name="active_status" type="checkbox" value="0"><label for="active_status_up" class="pl-3">Deactivate Account</label></div>'
            );
        }
    });
}
function employeeUpdateModal ( ) { $ ( ".editBtn" ) . on ( "click" , function ( e ) { $ ( "#update-employee-modal" ) . modal ( "show" ) ; $tr = $ ( this ) . closest ( "tr" ) ; let data = $tr . children ( "td" ) . map ( function ( ) { return $ ( this ) . text ( ) ; } ) . get ( ) ; $ ( "#id" ) . val ( data [ 0 ] ) ; $ ( "#last_name_up" ) . val ( data [ 1 ] ) ; $ ( "#first_name_up" ) . val ( data [ 2 ] ) ; $ ( "#position_up" ) . val ( data [ 3 ] ) ; $ ( "#gender_up" ) . val ( data [ 4 ] ) ; $ ( "#contact_number_up" ) . val ( data [ 6 ] ) ; $ ( "#active_status_up" ) . val ( data [ 8 ] ) ; const status = data [ 8 ] ; console . log ( status ) ; if ( status == 1 ) { $ ( ".employeeStatus" ) . html ( '<div class="form-check form-switch"><input class="form-check-input" id="active_status_up" name="active_status" type="checkbox" value="0"><label for="active_status_up" class="pl-3">Deactivate Account</label></div>' ) ; } } ) ; }
Fetches data and places it into update-employee-modal form
Fetches data and places it into update - employee - modal form