API Docs for:
Show:

File: Report\consolidatedReport.js

/*================================================================================================================\
+
+ Project     : GoData-Eicher
+ Filename    : consolidatedReport.js
+ Module Name : ReportModule
+ Purpose     : For reporting              
+ Coded By    : Parul Gupta
+
+================================================================================================================*/


/**
* For reporting
* @module ReportModule
*/



/**
* This class contains functionality of Consolidated report
* @class ConsolidatedReport
* @constructor
*/

var xhr_exportExport;


/**
* Function to get consolidated data
* @method getConsolidatedReport
* @for ConsolidatedReport
*/
function getConsolidatedReport() {
    var startDate, endDate;
    var userID = userId;
    startDate = $("#startDate").val();
    endDate = $("#endtDate").val();

    //send ajax request
    $.ajax({
        type: "POST",
        url: "/Report/ConsolidatedReport_Grid/",
        data: { userId: userID, startDate: startDate, endDate: endDate },
        success: function (data) {
            $("#divGrid").html(data);
            if (document.getElementById('Consolidated') !== null) {
                setTimeout(function () {

                    if ($("#Consolidated .k-grid-content table tbody tr").length > 0) {
                        $('.excelIcon').show();
                    } else {
                        $('.excelIcon').hide();
                    }
                }, 1000);
            } else {
                $('.excelIcon').hide();
            }
        },
        complete: function () {

        },
        error: function (data) {
            console.log(data);
        }
    });

}

/**
* Function call on row bound of close tickets table
* @method onRowBound
* @for ConsolidatedReport
*/
function onRowBound(e) {
    $('.k-grid-TimeSlot').text("").removeClass("k-button k-button-icontext");

    // called common file function to show title on mouse hover.
    addTitleAttribute();

    // time slot functionality
    var data = this.dataSource.view();
    console.log(this.dataSource.view());
    for (var i = 0; i < data.length; i++) {

        //get uid of row
        var uid = data[i].uid;
        //get creation time of ticket
        var ticketCreationDateTime = data[i].creation_time;
        var split_ticketCreationDateTime = ticketCreationDateTime.split(" ");
        var ticketCreationTime = split_ticketCreationDateTime[3];

        var row = this.table.find("tr[data-uid='" + uid + "']");

        for (var count = 0; count < 12; count++) {
            if ((Date.parse('01/01/0001 ' + ticketCreationTime) > Date.parse('01/01/0001 ' + (2 * count) + ':00:00')) && (Date.parse('01/01/0001 ' + ticketCreationTime) < Date.parse('01/01/0001 ' + ((2 * count) + 1) + ':59:59'))) {
                row.find('.k-grid-TimeSlot').text("").removeClass("k-button k-button-icontext").html("<span>" + (2 * count) + ":00 - " + ((2 * count) + 1) + ":59</span>");
                break;
            }
            console.log(count);
        }
    }

    // Date.parse('01/01/0001 10:20:45') < Date.parse('01/01/0001 5:10:10')
}

/**
* To get filter parameters and export report. 
* @method exportReport
* @for ConsolidatedReport
*/
function exportReport() {
    var userID = userId;
    var startDate = $("#startDate").val();
    var endDate = $("#endtDate").val();

    // sending ajax request to export ICR Unique Users and Data Usage to Excel, and hadling its completion
    if (xhr_exportExport && xhr_exportExport.readystate != 4) {
        xhr_exportExport.abort();
    }
    xhr_exportExport = $.ajax({
        type: "POST",
        url: "/Report/ConsolidatedReport_ExportToExcel/",
        data: { UserId: userID, startDate: startDate, endDate: endDate },
        success: function (data) {
            // making the generated Excel available for downloading.
            window.location.href = data;
        },
        complete: function () {
        },
        error: function (data) {
            console.log("Error in Export to Excel");
        }
    });
}

//============================= document ready function ===============================//

$(document).ready(function () {
    $('.excelIcon').hide();
    getConsolidatedReport();
});