NS: Deal Tracker Plus (Tampermonkey script)
// ==UserScript==
// @name Deal Tracker Plus
// @namespace https://rymo.io/
// @version 0.1
// @description Add some cool enhancements to Deal Tracker Search
// @author rymo
// @match https://system.netsuite.com/app/common/search/searchresults.nl?searchid=236661*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function () {
function objStore(tot, prj, com, ups) {
this.tot = tot;
this.prj = prj;
this.com = com;
this.ups = ups;
}
var scope = this;
scope.sum = new objStore(0, 0, 0, 0);
scope.pat = new objStore(0, 0, 0, 0);
scope.wes = new objStore(0, 0, 0, 0);
// iterate through all rows in the forecast
$('.uir-list-row-tr').each(function() {
var forecast = $(this).find('td:eq(3)').text()
,projected = Number($(this).find('td:eq(4)').text().replace(/[^0-9\.]+/g,""))
,vlcommit = Number($(this).find('td:eq(5)').text().replace(/[^0-9\.]+/g,""))
;
scope.manager = ($(this).find('td:eq(8)').text() == 'Yates, Patricia') ? 'pat' : 'wes';
if (forecast == 'Commit') {
scope.sum.com += vlcommit;
scope[scope.manager].com += vlcommit;
} else if (forecast == 'Upside') {
scope.sum.ups += vlcommit;
scope[scope.manager].ups += vlcommit;
}
scope[scope.manager].prj += projected;
scope[scope.manager].tot += vlcommit;
scope.sum.prj += projected;
scope.sum.tot += vlcommit;
});
/**
* *******************************************************************************************
* Begin HTML content for header info
* *******************************************************************************************
*/
var content = ''
+ '<div id="uir-summary-section" class="uir_filters collapsed">'
+ '<div class="uir_filters_header">'
+ '<span>'
+ '<span class="ns-icon ns-filters-onoff-button" tabindex="0" role="button" aria-expanded="true" aria-controls="uir_summary_body"></span>'
+ '<span>Forecast Summary</span>'
+ '</span>'
+ '</div>'
+ '<div class="uir_filters_body uir_summary_body">'
+ '<table style="width:100%">'
+ '<tbody>'
// Header summary row
+ '<tr>'
+ '<td style="text-align:left"><h2 style="color:#34495e;font-style:bold">Vertical Summary'
+ '<td style="text-align:right"><h2 style="color:#34495e;font-style:bold">Projected ASA: $'
+ scope.sum.prj.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h2></td>'
+ '<td style="text-align:right"><h2 style="color:#2ecc71;font-style:bold">Commit: $'
+ scope.sum.com.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h2></td>'
+ '<td style="text-align:right"><h2 style="color:#e67e22;font-style:bold">Upside: $'
+ scope.sum.ups.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h1></td>'
+ '<td style="text-align:right"><h2 style="color:#3498db;font-style:bold">Total: $'
+ scope.sum.tot.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h2></td>'
+ '</tr>'
// Manager rows - Pat
+ '<tr>'
+ '<td style="text-align:left"><h4 style="color:#34495e;font-size:0.9em">Pat Yates</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#34495e;font-size:0.9em">$'
+ scope.pat.prj.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#2ecc71;font-size:0.9em">$'
+ scope.pat.com.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#e67e22;font-size:0.9em">$'
+ scope.pat.ups.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#3498db;font-size:0.9em">$'
+ scope.pat.tot.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '</tr>'
// Manager rows - Wes
+ '<tr>'
+ '<td style="text-align:left"><h4 style="color:#34495e;font-size:0.9em">Wes Kapsa</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#34495e;font-size:0.9em">$'
+ scope.wes.prj.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#2ecc71;font-size:0.9em">$'
+ scope.wes.com.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '<td style="text-align:right"><h4 style="color:#e67e22;font-size:0.9em">$'
+ scope.wes.ups.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h1></td>'
+ '<td style="text-align:right"><h4 style="color:#3498db;font-size:0.9em">$'
+ scope.wes.tot.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
+ '</h4></td>'
+ '</tr>'
+ '</tbody>'
+ '</table>'
+ '</div>'
+ '</div>'
;
$('#div__footer').prepend(content);
$('#div__body').css('height', $( window ).height() / 2);
$('#uir-summary-section').click(function() {
$(this).toggleClass('collapsed');
$('#div__body').css('height', $( window ).height() / 2);
});
}).call({});