
$(document).ready(function () {
    abba_get_dashboard_content();
});

$('body').on('change', '.abba_display_campus', function () {

    abba_get_dashboard_content();
});

function abba_get_dashboard_content() {
    
    var abba_instituion_id = $('.abba_display_campus option:selected').data('id');
    
    var abba_campus_id = $('.abba_display_campus option:selected').val();
    
    var user_id = $('#user_id_admin').val();

    $('#get_total_students').html('<i class="fa fa-spinner fa-spin"></i>');

    $('#get_total_staff').html('<i class="fa fa-spinner fa-spin"></i>');

    $('#get_total_students_male').html('<i class="fa fa-spinner fa-spin"></i>');

    $('#get_total_staff_male').html('<i class="fa fa-spinner fa-spin"></i>');

    $('#get_total_students_female').html('<i class="fa fa-spinner fa-spin"></i>');

    $('#get_total_staff_female').html('<i class="fa fa-spinner fa-spin"></i>');

    $('#best_student').html('<i class="fa fa-spinner fa-spin"></i>');
    
    $('#avg_score').html('<i class="fa fa-spinner fa-spin"></i>');
    
    $('#upcoming_bday').html('<i class="fa fa-spinner fa-spin"></i>');

    $.ajax({
        type: "POST",
        url: "../../controller/scripts/schoolhead/dashboard_data/abba_dashboard_data.php",
        data: { abba_instituion_id: abba_instituion_id, user_id: user_id, abba_campus_id:abba_campus_id },
        //cache: false,
        success: function (output) {

            console.log(output);

            var jsonData = JSON.parse(output);

            $('#get_total_students').html(jsonData.total_students);

            $('#get_total_staff').html(jsonData.total_staff);

            $('#get_total_students_male').html(jsonData.total_students_male);

            $('#get_total_staff_male').html(jsonData.total_staff_male);

            $('#get_total_students_female').html(jsonData.total_students_female);

            $('#get_total_staff_female').html(jsonData.total_staff_female);

            $('#best_student').html(jsonData.best_student);
            
            $('#avg_score').html(jsonData.avg_score);
            
            $('#upcoming_bday').html(jsonData.upcoming_bday);

        }
    });
}