231 lines
7.5 KiB
JavaScript
231 lines
7.5 KiB
JavaScript
|
|
/*================================================================================================================\
|
|
+
|
|
+ Project : GoData-Eicher
|
|
+ Filename : reportTicketKamOpen.js
|
|
+ Module Name : Report
|
|
+ Purpose : For reporting
|
|
+ Coded By : Parul Gupta
|
|
+
|
|
+================================================================================================================*/
|
|
|
|
|
|
/**
|
|
* For reporting
|
|
* @module ReportModule
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* This class contains functionality of Ticket report(Open)
|
|
* @class KamOpenTicketReport
|
|
* @constructor
|
|
*/
|
|
|
|
|
|
|
|
//Global variables
|
|
var slaMetImagePath = "../../Content/css/images/icons/green_circle.png";
|
|
var slaNotMetImagePath = "../../Content/css/images/icons/red_circle.png";
|
|
var xhr_exportExport;
|
|
var temp_dataItemId, temp_dataItemRowIndex;
|
|
|
|
|
|
/**
|
|
* Function to display open ticket details
|
|
* @method showKamOpenTicketDetails
|
|
* @for KamOpenTicketReport
|
|
*/
|
|
function showKamOpenTicketDetails(e) {
|
|
temp_dataItemId = "";
|
|
temp_dataItemRowIndex = '';
|
|
//console.log($(e.currentTarget).closest("tr"), $(e.currentTarget).closest("tr").index());
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
//console.log(dataItem);
|
|
|
|
|
|
temp_dataItemId = dataItem.Id;
|
|
temp_dataItemRowIndex = parseInt($(e.currentTarget).closest("tr").index(), 10);
|
|
|
|
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/Report/Ticket_GetOpencloseTicketFullDetails/",
|
|
data: { ticketId: dataItem.Id, ticketStatus: "open" },
|
|
success: function (data) {
|
|
$("#divTicketDetails").html(data);
|
|
//open window in new dialog box
|
|
$("#divTicketDetails").data("kendoWindow").open();
|
|
openKendoWindowInCenter("#divTicketDetails");
|
|
},
|
|
error: function (data) {
|
|
console.log(data);
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Function to get open tickets history
|
|
* @method getKamOpenTicketHistory
|
|
* @for KamOpenTicketReport
|
|
*/
|
|
function getKamOpenTicketHistory() {
|
|
var startDate = null, endDate = null;
|
|
var userID = userId;
|
|
//send ajax request
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/Report/Report_KamTickets_Open_Grid/",
|
|
data: { userId: userID, startDate: startDate, endDate: endDate, ticketStatus: "open" },
|
|
success: function (data) {
|
|
$("#divGrid").html(data);
|
|
if (document.getElementById('KamOpenTicket') !== null) {
|
|
//applyFiltersBasedOnParametersToKendoGrid();
|
|
setTimeout(function () {
|
|
if ($("#KamOpenTicket .k-grid-content table tbody tr").length > 0) {
|
|
$('.excelIcon').show();
|
|
} else {
|
|
$('.excelIcon').hide();
|
|
}
|
|
}, 1000);
|
|
} else {
|
|
$('.excelIcon').hide();
|
|
}
|
|
},
|
|
complete: function () {
|
|
startDateParam = "";
|
|
endDateParam = "";
|
|
},
|
|
error: function (data) {
|
|
console.log(data);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
* Function call on row bound of close tickets table
|
|
* @method onRowBound
|
|
* @for KamOpenTicketReport
|
|
*/
|
|
function onRowBound(e) {
|
|
console.log(_userRole.toLowerCase().trim());
|
|
if (_userRole.toLowerCase().trim() == 'cce' || _userRole.toLowerCase().trim() == 'cce_admin') {
|
|
$('.k-grid-EditTicketActivity').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-edit'></span>").show();
|
|
$('.k-grid-TicketDetails').hide();
|
|
} else {
|
|
$('.k-grid-TicketDetails').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-justifyFull'></span>").show();
|
|
$('.k-grid-EditTicketActivity').hide();
|
|
}
|
|
//$('.k-grid-Performance').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-performance'></span>");
|
|
// called common file function to show title on mouse hover.
|
|
addTitleAttribute();
|
|
// sla met or not met functionality
|
|
var data = this.dataSource.view();
|
|
//console.log(data);
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
//get uid of row
|
|
var uid = data[i].uid;
|
|
// get default sla time of row
|
|
var defaultSla = data[i].DefaultSlaTime;
|
|
// get total ticket life cycle sla value
|
|
var totalLifeCycleSla = data[i].TotalTicketLifeCycleTimeSlab;
|
|
//get gps status of van
|
|
var gps_status = data[i].gps_status;
|
|
var row = this.table.find("tr[data-uid='" + uid + "']");
|
|
|
|
//console.log(defaultSla, totalLifeCycleSla);
|
|
|
|
if (defaultSla > totalLifeCycleSla) {
|
|
row.find('.k-grid-resolutionSla').text("").removeClass("k-button k-button-icontext").html("<img src='" + slaMetImagePath + "' title='SLA met'>");
|
|
} else {
|
|
row.find('.k-grid-resolutionSla').text("").removeClass("k-button k-button-icontext").html("<img src='" + slaNotMetImagePath + "' title='SLA not met'>");
|
|
}
|
|
|
|
if (gps_status != null) {
|
|
if (gps_status.toLowerCase().trim() == "true")
|
|
row.find('.k-grid-gps_status').text("").removeClass("k-button k-button-icontext").html("<img src='" + slaMetImagePath + "' title='Online'>");
|
|
else
|
|
row.find('.k-grid-gps_status').text("").removeClass("k-button k-button-icontext").html("<img src='" + slaNotMetImagePath + "' title='Offline'>");
|
|
} else {
|
|
row.find('.k-grid-gps_status').text("").removeClass("k-button k-button-icontext").html("");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* To get filter parameters and export report.
|
|
* @method exportReport
|
|
* @for KamOpenTicketReport
|
|
*/
|
|
function exportReport() {
|
|
var userID = userId;
|
|
|
|
// 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/Ticket_Close_Open_ExportToExcel/",
|
|
data: { UserId: userID, startDate: "", endDate: "", ticketStatus: "open" },
|
|
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");
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* To get refresh reports on close of ticket details.
|
|
* @method getRefresh
|
|
* @for KamOpenTicketReport
|
|
*/
|
|
function getRefresh() {
|
|
$(".k-i-close").click(function () {
|
|
//console.log(temp_dataItemId, temp_dataItemRowIndex);
|
|
var openTicketId = temp_dataItemId;
|
|
var openTicketRowIndex = temp_dataItemRowIndex;
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/Report/CheckIfTicketExistInOpen/",
|
|
data: { ticketId: openTicketId, ticketStatus: "open" },
|
|
success: function (data) {
|
|
if (data.success == true) {
|
|
|
|
} else {
|
|
$('#KamOpenTicket').data('kendoGrid').removeRow($('#KamOpenTicket').data('kendoGrid').tbody.find("tr")[parseInt(openTicketRowIndex, 10)]);
|
|
}
|
|
},
|
|
error: function (data) {
|
|
console.log(data);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
//============================= document ready function ===============================//
|
|
|
|
$(document).ready(function () {
|
|
$('.excelIcon').hide();
|
|
|
|
getKamOpenTicketHistory();
|
|
|
|
addKendoWindow("#divTicketDetails", "Ticket Details", "1000px", 150, 120);
|
|
$("#divTicketDetails").parent().addClass("TicketReportDetails_Window");
|
|
});
|