/*================================================================================================================\ + + Project : GODATA-EICHER + Filename : Dashboard.js + Module Name : Tile Dashboard Module + Purpose : To show Tile Dashboard KPIs between 2 dates. + Coded By : Pankaj Khandal + +================================================================================================================*/ /** * To show Tile Dashboard KPIs between 2 dates. * @module Dashboard */ /** * To show Tile Dashboard KPIs between 2 dates. * @class TileDashboard * @constructor */ /** * Global References: To store Ajax Request's XHR object. * @for TileDashboard */ var xhr_refreshDashboard = null; // /** * Global References: Setting countUp options (To change the gradient of tiles and slowly incresing the numbers on tiles) * @for TileDashboard */ var options = { useEasing: true, // toggle easing useGrouping: true, // 1,000,000 vs 1000000 separator: '', // character to use as a separator decimal: '.', // character to use as a decimal }; var demo; /** * Global References: To store color-combinations to show gradient effect on tiles. * @for TileDashboard */ var startingColor11 = 'rgb(47,128,227)', // dark blue color code startingColor12 = 'rgb(109,192,254)', // light blue color code endColor11 = 'rgb(200,36,27)', // red color code endColor12 = 'rgb(254,112,69)', // red startingColor21 = 'rgb(125,188,29)', // light green startingColor22 = 'rgb(42,169,28)', // green warningColor11 = 'rgb(249, 140, 29)',// yellow warningColor21 = 'rgb(254, 180, 44)';// yellow lightOcean = 'rgb(0, 171, 169)'; // light ocean darkOcean = 'rgb(46, 98, 98)'; // dark ocean lightBlue = 'rgb(66, 146, 234)'; // light blue darkBlue = 'rgb(24, 57, 134)'; // dark blue /** * Convert HH:mm format to Minutes. * @method convertToMin * @param {String} time input timei in HH:mm format * @for TileDashboard */ function convertToMin(time) { var timeArray = time.split(":"); return parseInt(timeArray[0], 10) * 60 + parseInt(timeArray[1], 10); } var presentDate = new Date(); var regionVal = []; var dealerVal = []; var verticleVal = []; var emissionVal = []; var customerVal = []; var strDealerVal = ""; /** * To bind values on infra tile dashboard for selected circles. * @method refreshDashboard * @for TileDashboard */ function refreshDashboard() { var date = new Date(); var firstDay = new Date(date.getFullYear(), date.getMonth(), 1); var twoDaysAgo = date.getDate() - 1; var date = new Date(); var yesterday = date - 1000 * 60 * 60 * 24 * 1; // current date's milliseconds - 1,000 ms * 60 s * 60 mins * 24 hrs * (# of days beyond one to go back) //yesterday = yesterday + 530; yesterday = new Date(yesterday); var x = new Date(); x.setDate(1); x.setMonth(x.getMonth() - 1); var y = new Date(); //var y = new Date(); //y.setDate(1); //y.setMonth(x.getMonth()); // alert(y); var date = new Date(); var firstDay = x;//new Date(date.getFullYear(), date.getMonth(), 1); var lastDay = new Date(yesterday); // alert(firstDay); /// alert(lastDay); $("#monthpickerTo").kendoDatePicker({ min: x, max: y, format: "dd MMM yyyy" }); $("#monthpickerFrom").kendoDatePicker({ min: x, max: y, format: "dd MMM yyyy" }); var date = new Date(); var day = date.getDate(); var month = date.getMonth() + 1; var year = date.getFullYear(); if (month < 10) month = "0" + month; if (day < 10) day = "0" + day; // var today = day + "/" + month + "/" + year; // var today = mm + '/' + dd + '/' + yyyy; // alert(UtcMinutes); // $("#monthpickerFrom").val(today); // loadEmissonList(); // loadVerticleList(); // loadRegionList(); // loadDealerList(); DashboardType = dashboardType; var verticle = ""; var emissionnorms = ""; var region = ""; var customertype = ""; var dealers = ""; if (DashboardType == "all") { UserId = userId; } else { UserId = $("#DealerId").data("kendoComboBox").value();; } SecurityToken = securityToken; utcMinutes = parseInt(UtcMinutes, 10); console.log(WCFRESTURL.GetNewGlobalDashboard); // Getting first and last date from a month var startDate = $("#monthpickerFrom").val(); var endDate = $("#monthpickerTo").val(); debugger; // var startDate = $("#startDate").val(); // var endDate = $("#endtDate").val(); // alert(startDate); // Sending the Ajax Request for showing the dashboard values and handling its completion. if (xhr_refreshDashboard && xhr_refreshDashboard.readystate != 4) { xhr_refreshDashboard.abort(); } xhr_refreshDashboard = $.ajax({ type: "POST", url: WCFRESTURL.GetNewGlobalDashboard, data: { Token: SecurityToken, StartDate: startDate, EndDate: endDate, UtcMinute: UtcMinutes, UserId: UserId, FromDate: startDate, ToDate: endDate, regionVal: regionVal, dealerVal: dealerVal, verticleVal: verticleVal, emissionVal: emissionVal, customerVal: customerVal, strDealerVal: strDealerVal }, dataType: "json", success: function (model) { debugger; $('#tdOpenTickets').html(model.OpenTicket); $('#tdOpenTicket24hours').html(model.OpenTicket24hours); $('#tdAverageResolutionTime').html(model.AverageResolutionTime); $('#tdAverageVanReachTime').html(model.AverageVanReachTime); var SLA1hrs = ""; if (model.SLA1hrs == null) { SLA1hrs = "0"; } else { if (SLA1hrs == "100") { SLA1hrs = model.SLA1hrs; } else { SLA1hrs = model.SLA1hrs.slice(0, (model.SLA1hrs.indexOf(".")) + 3); } } var SLA2hrs = ""; if (model.SLA2hrs == null) { SLA2hrs = "0"; } else { if (model.SLA2hrs == "100") { SLA2hrs = model.SLA2hrs; } else { SLA2hrs = model.SLA2hrs.slice(0, (model.SLA2hrs.indexOf(".")) + 3); } } var SLA3hrs = ""; if (model.SLA3hrs == null) { SLA3hrs = "0"; } else { if (model.SLA3hrs == "100") { SLA3hrs = model.SLA3hrs; } else { SLA3hrs = model.SLA3hrs.slice(0, (model.SLA3hrs.indexOf(".")) + 3); } } var SLAMoreThan3hrs = ""; if (model.SLAMoreThan3hrs == null) { SLAMoreThan3hrs = "0"; } else { if (model.SLAMoreThan3hrs == "100") { SLAMoreThan3hrs = model.SLAMoreThan3hrs; } else { SLAMoreThan3hrs = model.SLAMoreThan3hrs.slice(0, (model.SLAMoreThan3hrs.indexOf(".")) + 3); } } var SLA12hrs = ""; if (model.SLA12hrs == null) { SLA12hrs = "0"; } else { if (model.SLA12hrs == "100") { SLA12hrs = model.SLA12hrs; } else { SLA12hrs = model.SLA12hrs.slice(0, (model.SLA12hrs.indexOf(".")) + 3); } } var SLA16hrs = ""; if (model.SLA16hrs == null) { SLA16hrs = "0"; } else { if (model.SLA16hrs == "100") { SLA16hrs = model.SLA16hrs; } else { SLA16hrs = model.SLA16hrs.slice(0, (model.SLA16hrs.indexOf(".")) + 3); } } var SLA18hrs = ""; var SLARes1hrs = ""; var SLARes3hrs = ""; var SLA5hrs = ""; var SLA7hrs = ""; var SLA10hrs = ""; if (model.SLA18hrs == null) { SLA18hrs = "0"; } else { if (model.SLA18hrs == "100") { SLA18hrs = model.SLA18hrs; } else { SLA18hrs = model.SLA18hrs.slice(0, (model.SLA18hrs.indexOf(".")) + 3); } } if (model.SLARes1hrs == null) { SLARes1hrs = "0"; } else { if (model.SLARes1hrs == "100") { SLARes1hrs = model.SLARes1hrs; } else { SLARes1hrs = model.SLARes1hrs.slice(0, (model.SLARes1hrs.indexOf(".")) + 3); } } if (model.SLARes3hrs == null) { SLARes3hrs = "0"; } else { if (model.SLARes3hrs == "100") { SLARes3hrs = model.SLARes3hrs; } else { SLARes3hrs = model.SLARes3hrs.slice(0, (model.SLARes3hrs.indexOf(".")) + 3); } } if (model.SLA5hrs == null) { SLA5hrs = "0"; } else { if (model.SLA5hrs == "100") { SLA5hrs = model.SLA5hrs; } else { SLA5hrs = model.SLA5hrs.slice(0, (model.SLA5hrs.indexOf(".")) + 3); } } console.log(model.SLA7hrs); if (model.SLA7hrs == null) { SLA7hrs = "0"; } else { if (model.SLA7hrs == "100") { SLA7hrs = model.SLA7hrs; } else { SLA7hrs = model.SLA7hrs.slice(0, (model.SLA7hrs.indexOf(".")) + 3); } } if (model.SLA10hrs == null) { SLA10hrs = "0"; } else { if (model.SLA10hrs == "100") { SLA10hrs = model.SLA10hrs; } else { SLA10hrs = model.SLA10hrs.slice(0, (model.SLA10hrs.indexOf(".")) + 3); } } var SLAMoreThan18hrs = ""; if (model.SLAMoreThan18hrs == null) { SLAMoreThan18hrs = "0"; } else { if (model.SLAMoreThan18hrs == "100") { SLAMoreThan18hrs = model.SLAMoreThan18hrs; } else { SLAMoreThan18hrs = model.SLAMoreThan18hrs.slice(0, (model.SLAMoreThan18hrs.indexOf(".")) + 3); } } var CSat = ""; if (model.CSat == null) { CSat = "0"; } else { if (model.CSat == "100") { CSat = model.CSat; } else { CSat = model.CSat.slice(0, (model.CSat.indexOf(".")) + 3); } } // var SLA1hrs = model.SLA1hrs; // var SLA2hrs = model.SLA2hrs; //var SLA3hrs = model.SLA3hrs; //var SLAMoreThan3hrs = model.SLAMoreThan3hrs; //var SLA12hrs = model.SLA12hrs; //var SLA16hrs = model.SLA16hrs; //var SLA18hrs = model.SLA18hrs; //var SLAMoreThan18hrs = model.SLAMoreThan18hrs; //var CSat = model.CSat; $('#tdSLA1hrs').html(SLA1hrs + '%'); $('#tdSLA2hrs').html(SLA2hrs + '%'); $('#tdSLA3hrs').html(SLA3hrs + '%'); $('#tdSLAMoreThan3hrs').html(SLAMoreThan3hrs + '%'); $('#tdSLARes1hrs').html(SLARes1hrs + '%'); $('#tdSLARes3hrs').html(SLARes3hrs + '%'); $('#tdSLA5hrs').html(SLA5hrs + '%'); $('#tdSLA7hrs').html(SLA7hrs + '%'); $('#tdSLA10hrs').html(SLA10hrs + '%'); $('#tdSLA12hrs').html(SLA12hrs + '%'); $('#tdSLA16hrs').html(SLA16hrs + '%'); $('#tdSLA18hrs').html(SLA18hrs + '%'); $('#tdSLAMoreThan18hrs').html(SLAMoreThan18hrs + '%'); $('#tdTABsBusyCount').html(model.TABsBusyCount); $('#tdTABsOfflineMorethan7Days').html(model.TABsOfflineMorethan7Days); $('#tdTABFreeCount').html(model.TABsFreeCount); $('#tdopplostTicketCount').html(model.OppLostCount); $('#tdAssignedTicketCount').html(model.AssignedTicketCount); $('#tdTripStartCount').html(model.TripStartCount); $('#tdInprogressTicketCount').html(model.InprogressTicketCount); $('#tdClosedTicketCount').html(model.ClosedTicketCount); $('#tdDeclinedTicketCount').html(model.DeclinedTicketCount); $('#tdActiveCount').html(model.ActiveCount); $('#tdBreakDownTickets').html(model.BreakDownTickets); $('#tdCSat').html(CSat + '%'); $('#spntotalbreakdown').html(model.BreakDownTicketsBystatus); $('#tdPreclosureCount').html(model.PreclosureCount); }, complete: function () { debugger; loadTopDealers(); }, error: function (data) { debugger; console.log("Error"); } }); } function loadTopDealers() { DashboardType = dashboardType; // alert(WCFRESTURL.GetTopDealer); if (DashboardType == "all") { UserId = userId; } else { UserId = $("#DealerId").data("kendoComboBox").value();; } SecurityToken = securityToken; utcMinutes = parseInt(UtcMinutes, 10); // Getting first and last date from a month var startDate = $("#monthpickerFrom").val(); var endDate = $("#monthpickerTo").val(); console.log(startDate + 'startDate' + endDate + 'endDate' + regionVal + 'regionVal' + dealerVal + 'dealerVal' + verticleVal + 'verticleVal' + emissionVal + 'emissionVal' + customerVal + 'customer') // Sending the Ajax Request for showing the dashboard values and handling its completion. if (xhr_refreshDashboard && xhr_refreshDashboard.readystate != 4) { xhr_refreshDashboard.abort(); } xhr_refreshDashboard = $.ajax({ type: "POST", url: WCFRESTURL.GetTopDealer, data: { Token: SecurityToken, UtcMinute: utcMinutes, UserId: UserId, FromDate: startDate + ' 00:00:00', ToDate: endDate + ' 23:59:59', regionVal: regionVal, dealerVal: dealerVal, verticleVal: verticleVal, emissionVal: emissionVal, customerVal: customerVal }, dataType: "json", success: function (data) { html = ""; var keyVar; for (keyVar in data) { if (data.hasOwnProperty(keyVar)) { var title = data[keyVar].DealerName; var encoded = data[keyVar].DealerName;//encodeURI(title); var dealertxt = data[keyVar].DealerName.slice(0, 40) + '...'; html += '