Subversion Repositories SmartDukaan

Rev

Rev 36814 | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(document).on('click', ".beat-report", function () {
    doGetAjaxRequestHandler(context + "/beat-report",
        function (response) {
            $('#main-content').html(response);
        });
});

$(document).on('click', ".company-office-list", function () {
    doGetAjaxRequestHandler(context + "/company-office-list",
        function (response) {
            $('#main-content').html(response);
        });
});

$(document).on('click', ".beat-report-approval", function () {
    doGetAjaxRequestHandler(context + "/beat-report/approval",
        function (response) {
            $('#main-content').html(response);
        });
});

$(document).on('click', '.beat-report-fetch', function () {
    var selectedDate = $("#beat-report-date").val();
    if (!selectedDate) {
        alert("Please select a date!");
        return;
    }
    var categoryId = $('#beat-report-category').val();
    var level = $('#beat-report-level').val();
    var url = context + "/beat-report/data?date=" + encodeURIComponent(selectedDate);
    if (categoryId) url += '&categoryId=' + encodeURIComponent(categoryId);
    if (level) url += '&escalationType=' + encodeURIComponent(level);
    doGetAjaxRequestHandler(url,
        function (response) {
            $('.beat-report-container').html(response);
        });
});

$(document).on('click', '.user-detail-refresh', function () {
    var userId = $('#user-detail-user').val() || $(this).data('userid');
    var selectedDate = $("#user-detail-date").val();
    if (!selectedDate) {
        alert("Please select a date!");
        return;
    }
    doGetAjaxRequestHandler(context + "/beat-report/user-detail?userId=" + userId + "&date=" + selectedDate,
        function (response) {
            $('#main-content').html(response);
        });
});

$(document).on('change', '#user-detail-level', function () {
    var level = $(this).val();
    var userSelect = $('#user-detail-user');
    userSelect.html('<option value="">Select User</option>');
    if (!level) return;

    $.ajax({
        url: context + "/beatPlan/getAuthUsers", type: "GET", dataType: "json",
        data: { categoryId: 4, escalationType: level },
        success: function (r) {
            var data = r.response || r;
            var html = '<option value="">Select User</option>';
            data.forEach(function (u) {
                html += '<option value="' + u.id + '">' + u.name + '</option>';
            });
            userSelect.html(html);
        }
    });
});

$(document).on('change', '#user-detail-user', function () {
    var authUserId = $(this).val();
    if (!authUserId) return;
    var selectedDate = $("#user-detail-date").val();
    if (!selectedDate) {
        selectedDate = new Date().toISOString().split('T')[0];
    }
    doGetAjaxRequestHandler(context + "/beat-report/user-detail?authUserId=" + authUserId + "&date=" + selectedDate,
        function (response) {
            $('#main-content').html(response);
        });
});

$(document).on('click', '.beat-user-detail-link', function () {
    var userId = $(this).data('userid');
    var selectedDate = $("#beat-report-date").val();
    if (!selectedDate) {
        selectedDate = new Date().toISOString().split('T')[0];
    }
    doGetAjaxRequestHandler(context + "/beat-report/user-detail?userId=" + userId + "&date=" + selectedDate,
        function (response) {
            $('#main-content').html(response);
        });
});