Still have questions? Call: ' + window.top.Firm.SupportPhone + '
',height: '50%',width:'50%',showConfirmButton:false})
}
else
{
window.top.Alert('Please call: ' + window.top.Firm.SupportPhone +' for support.');
//window.top.startChat();
}
}
else
{
window.top.Alert('Please call: ' + window.top.Firm.SupportPhone +' for support.');
//window.top.startChat();
}
}
//this is our local storage module
var lStorage = {
getEpoch: function()
{
var d = new Date();
return d.getDate();
},
getItem: function(key)
{
//see if the item is in local storage
//if it is see if it has expired
var r = { results: false};
if(window.localStorage)
{
var i
i = localStorage.getItem(key);
if( isJSON(i) == true)
{
//we are json
i = JSON.parse(i);
if(i.ttl)
{
//we have an expiration
if(i.ttl > lStorage.getEpoch())
{
//we are still valid
return {
results: true,
data: LZString.decompress(i.data)
}
}
else
{
//data has expired
return { results: false };
}
}
else
{
return { results: false };
}
}
else
{
return { results: false };
}
}
else
{
return { results: false };
}
},
addItem: function(key,item,ttl)
{
if(!ttl){var ttl = lStorage.getEpoch() + 86400000}else{ttl = ttl + lStorage.getEpoch()};
if(window.localStorage)
{
//we exists
var r = {
ttl: ttl,
data: LZString.compress(item)
};
localStorage.setItem(key, JSON.stringify(r));
return true;
}
else
{
return false;
}
}
}
function CreateLink(msg,find,type)
{
switch(type)
{
case 'ticket':
return String(msg).replace(find,'' + find + '');
break;
}
}
function dialog(title,placeholder,callback,height)
{
if(!placeholder){var placeholder = ''};
return new Promise((resolve, reject) =>
{
var d ={title: title,input: 'text', showCancelButton: true, reverseButtons: true, inputValue: placeholder, defaultValue: placeholder, inputValidator: (value) => {
if (!value) {
return 'Please enter in a value!'
}}};
if(height)
{
if(height != '3em' && height != '2em' && height != '')
{
d.input = 'textarea'
}
}
window.top.pCallback = callback;
window.top.swal.fire(d).then(function(results)
{
if(results.isConfirmed)
{
if(window.top.pCallback)
{
window.top.$('#confirm .confirmtext').val(results.value)
window.top.pCallback(results.value);
}
resolve(results.value);
}
else
{
reject(results);
}
});
});
}
//version 2.0 5.20.2021 bruce redone
var kendoGridFunctions = {
recordsInViewDS: {},
fullRecordLookup: {},
applySelectFunction: function(grid)
{
$(grid).on('click', 'td', kendoGridFunctions.selectFn);
$(grid).on("filter", kendoGridFunctions.filterFunc);
$(grid).on("sort", kendoGridFunctions.sortFunc);
$(grid).attr('data-e-uid',uuidv4());
},
// When the user either filters or sorts, clear all the caches data structures
//
filterFunc: function(e) {
kendoGridFunctions.recordsInViewDS[UID] = null;
kendoGridFunctions.fullRecordLookup[UID] = null;
e.sender.dataSource.lastActive = false;
},
sortFunc: function(e) {
kendoGridFunctions.recordsInViewDS[UID] = null;
kendoGridFunctions.fullRecordLookup[UID] = null;
e.sender.dataSource.lastActive = false;
},
selectFn: function(e)
{
let startTime = Date.now();
if($(this).closest('.k-grid').hasClass('dontListen'))
{
return false;
}
let dataSource = $(this).closest('.k-grid').data('kendoGrid').dataSource;
let curRow = dataSource.getByUid( $(this).closest('tr').attr('data-uid'));
let grid = $(this).closest('.k-grid').data('kendoGrid');
let UID = $(this).closest('.k-grid').attr('data-e-uid');
// If we are selecting and we don't have a cache for the view or full records
// then buid this structure
if (!kendoGridFunctions.recordsInViewDS[UID]) {
let allRecords = dataSource.data();
kendoGridFunctions.recordsInViewDS[UID] = new kendo.data.DataSource.create({data: allRecords, filter: dataSource.filter(), sort: dataSource.sort(), schema: dataSource.options.schema});
kendoGridFunctions.recordsInViewDS[UID].pageSize(allRecords.length)
recordsInView = kendoGridFunctions.recordsInViewDS[UID].view();
kendoGridFunctions.fullRecordLookup[UID] = {};
let rec = null;
for (let i=0; i total) {
end = total
}
grid.clearSelection();
// Loop through each record in our recordsInView
// and we are going to add the id for the record
// to our selection
for(let RecordNumber = start; RecordNumber < end; RecordNumber++) {
let curRow = recordsInView[RecordNumber];
if(curRow) {
// Add to the grids selected list
grid._selectedIds[curRow.id]=true;
// Find the record in the full list of records
let originalRecord = kendoGridFunctions.fullRecordLookup[UID][curRow.id];
if(originalRecord.uid) {
$('tr[data-uid="' + originalRecord.uid + '"]').addClass('k-state-selected');
}
}
else
{
// We are a phantom, just ignore
}
}
}
else {
// No shift key. Could be start of multi select or just a single selection
dataSource.lastActive= recordsInView.indexOf(curRow);
if (!e.originalEvent.ctrlKey && !e.originalEvent.shiftKey && $(this).find('.k-checkbox').length == 0)
{
//console.log('resetting');
grid._selectedIds = {};
grid.clearSelection();
}
grid.select( $(this).closest('tr') );
}
}
}
$.fn.autocomplete = function(param)
{
//add loader icon
//this.replaceWith('
' + $(this)[0].outerHTML + '
');
var el = $(this);
if(el.is('input')==false){el = el.find('input')};
if( param.html)
{
el.attr('data-html',true)
}
else
{
el.attr('data-html',false)
}
//
$(el).autoComplete({
resolver: 'custom',
events: {
typed: function(newValue, origJQElement)
{
if(param.search)
{
param.search(newValue.replace(/ /g,' '));
}
return newValue;
},
freevalue: function(e,qry)
{
if(param.search)
{
param.search(qry.replace(/ /g,' '));
}
},
search:
debounce(function(qry,callback)
{
var $this=$(this);
//sow loader icon
//this.closest('div').find('.loadingIcon').show();
if(param.search)
{
param.search(qry.replace(/ /g,' '));
}
//do search
var s = param.source;
if(typeof(s) == 'function'){s = s()};
$.ajax(
{
url: s + '&term=' + escape(qry),
dataType: 'json',
method: 'GET',
qry: qry,
obj: el
}).done(function (res)
{
//convert and return
//we will get a [{label,value}]
var output = [];
for(i in res)
{
if(param['html'] == true)
{
output.push({value: res[i].value, text: res[i].label ,record: res[i]});
}
else
{
output.push({value: res[i].value, text: res[i].label.replace(/ /g,' '),record: res[i]});
}
}
$(this.obj).closest('div').find('.loadingIcon').hide();
callback(output);
}).fail(function()
{
$(this.obj).closest('div').find('.loadingIcon').hide();
});
},300)
}
}).on('autocomplete.select',function(e,i)
{
i.text = i.text.replace(/ /g,' ');
$(el).val(i.text);
$(el).closest('div').find('.loadingIcon').hide();
if(param.select)
{
param.select(i)
}
}).addClass('loaded');
};
function ApplyImpersonateUserSearch(id)
{
if(!id){id='".ImpersonateUserSearch"'};
//load all the users
//and show
jQuery.ajax({
url: window.top.myEndPoint + '/Firm/ListUsers' + parent.Beta + '?Filters=advisors&OrionSessionKey=' + window.top.MainApp.OrionSessionKey,
dataType: 'json',
method: 'GET',
obj: id
}).then(function(data)
{
if(data.results)
{
//we have data
//show it
var i='';
if($(this.obj).attr('placeholder'))
{
i = i +'placeholder="' + $(this.obj).attr('placeholder') +'"'
}
if($(this.obj).attr('style'))
{
i =i + ' style="' + $(this.obj).attr('style') + '"'
}
$(this.obj).replaceWith( Mustache.render('',data))
$(this.obj).select2({placeholder:'Select an Advisor'}).on('select',function(e)
{
//console.log('selected');
//console.log(e);
});
jQuery.ajax({
url: window.top.myEndPoint.replace('v1','v2') + '/User/GetImpersonateSessionKey' + parent.Beta + '?TargetUser=' + escape(ui.item.value) + '&OrionSessionKey=' + window.top.MainApp.OrionSessionKey,
dataType: 'json',
error: function(jqXHR, textStatus, errorThrown){parent.ProcessError(jqXHR,textStatus,errorThrown);},
method: 'GET',
obj: $(this.obj),
success: function(data)
{
if(data.results)
{
//we are good
$(this.obj).attr('data-sessionkey', OrionSessionKey);
$(this.obj).trigger('keyloaded');
}
else
{
window.top.Alert(Title,'There was an error while logging in as the user, please try again. ' + data.msg);
}
window.top.HideLoading('ImpersonateUser');
}
});
return false;
}
else
{
}
}).fail(function(jqXHR, textStatus)
{
//request failed
if(jqXHR.status == 401)
{
window.top.ProcessError(jqXHR, textStatus)
}
else
{
$(this.obj).remove();
//window.top.Alert('Fusion Elements','There was a system error while saving the profile. If the problem persists please contact support.');
}
});
}
function UpdateAccount(AccountNumber,ValuesToUpdate)
{
return jQuery.ajax({
url: window.top.Firm.myEndPoint + '/PM/Sync/Account' + window.top.Firm.Beta + '?AccountNumber=' + escape(AccountNumber) + '&ValuesToUpdate=' + ValuesToUpdate +'&OrionSessionKey=' +window.top.MainApp.SessionKey,
dataType: 'json',
error: window.top.ProcessError,
method: 'GET'
});
}
function selectAnAdvisor(options)
{
if(!options){var options = {}};
if(!options.Title){options.Title = 'Create for an Advisor'};
if(!options.Title){options.Prefix = 'Creating for '};
if(!options.DefaultText ){options.DefaultText = 'Create for Advisor'};
window.top.pmSearch.showSearch({Filters:['Users'],ButtonText:'Select',Title:options.Title,autoClose:true,close: function(){ $('#CreateForAdvisor').html(options.DefaultText).removeAttr('data-sessionkey').removeAttr('data-email').trigger('cancel'); },then: function(level,display,email,record){
if(email !='')
{
//get
$('#CreateForAdvisor').html('');
$('#CreateForAdvisor').attr('data-email',email).attr('data-name',display);
jQuery.ajax({
url: window.top.myEndPoint.replace('v1','v2') + '/User/GetImpersonateSessionKey' + parent.Beta + '?TargetUser=' + escape(email) + '&OrionSessionKey=' + window.top.MainApp.OrionSessionKey,
dataType: 'json',
method: 'GET',
displayName: display,
options: options
}).done(function(data)
{
if(data.results)
{
$('#CreateForAdvisor').html(this.options.Prefix + this.displayName).attr('data-sessionkey', data.OrionSessionKey).trigger('userloaded');
}
else
{
window.top.Alert('Fusion Elements','There was a system error while logging in as the advisor, error: ' + data.msg);
}
}).fail(function(jqXHR, textStatus)
{
//request failed
if(jqXHR.status == 401)
{
window.top.ProcessError(jqXHR, textStatus)
}
else
{
window.top.Alert('Fusion Elements','There was a system error while logging in as the advisor, error: ' + textStatus);
}
});
//console.log(a,b,c,d);
}
}});
}
//see https://jsfiddle.net/ynsbiz/pw6o0unL/11/
//v1.0 1.12.2021
var dDate = {
getMonthName: function(d)
{
if(!d){var d = new Date()};
if(typeof d == 'object'){d = d.getMonth()+ 1};
var Months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
return Months[ Number(d)- 1];
},
getFirstDayOfMonthAsDate: function(d)
{
if(!d){var d = new Date()};
return new Date(d.getFullYear(), d.getMonth(), 1);
},
getLastDayOfMonthAsDate: function(d)
{
if(!d){var d = new Date()};
var lastDay = dDate.getLastDayOfMonth(d);
return new Date(d.getFullYear(), d.getMonth(), lastDay);
},
getLastDayOfMonth: function (y,m){
if(typeof(y) == 'object'){m = y.getMonth()+1;y = y.getFullYear()}
if(!y){var y = dDate.getYear()}
if(!m){var m = dDate.getMonth()}
m = m -1;
return new Date(y, m +1, 0).getDate();
},
getYear: function()
{
return new Date().getFullYear();
},
getMonth: function()
{
return new Date().getMonth()+1;
},
dateAdd: function(fn,amount,d)
{
if(!d){var d = new Date();}
switch(fn)
{
case 'MM','M','m','mm':
return new Date(d.getFullYear(), d.getMonth() + amount,d.getDate());
}
}
}
function parseForm(selector)
{
var record = {};
$(selector).find('input,select,textarea').each(function()
{
record[ $(this).attr('name')] = $(this).val();
});
return record;
}
function ListAdHocRecords(SecondaryKey,Simple)
{
if(typeof(Simple) == 'function')
{
ListAdHocRecords(SecondaryKey,false).then(function(data)
{
Simple(data)
});
return false;
}
if(Simple === undefined){Simple='true'};
return new Promise((resolve, reject) =>
{
jQuery.ajax({
url: window.top.Firm.myEndPoint.replace('v1','v2') + '/Plugins/AdHocRecord' + window.top.Firm.Beta + '?Simple=' + Simple + '&OrionSessionKey=' +window.top.MainApp.OrionSessionKey + '&SecondaryKey=' + escape(SecondaryKey),
dataType: 'json',
method: 'GET',
SecondaryKey: SecondaryKey,
resolve: resolve,
reject: reject
}).done(function(data)
{
if(data.results)
{
this.resolve(data);
}
else
{
this.reject(data.msg);
}
}).fail(function(a,b,c)
{
window.top.ProcessError(a,b,c);
this.reject(b);
});
});
}
function SaveAdHocRecord(ID,DisplayName,SecondaryKey, Record)
{
var method = 'POST';
if(ID != ''){ method = 'PUT'};
return new Promise((resolve,reject) =>
{
jQuery.ajax({
url: window.top.Firm.myEndPoint.replace('v1','v2') + '/Plugins/AdHocRecord' + window.top.Firm.Beta + '?ID=' + ID + '&DisplayName=' + escape(DisplayName) +'&OrionSessionKey=' + window.top.MainApp.OrionSessionKey + '&OrionUsername=&OrionPassword=&SecondaryKey=' + escape(SecondaryKey),
dataType: 'json',
data: JSON.stringify(Record),
contentType: 'application/json',
method: method,
SecondaryKey: SecondaryKey,
resolve: resolve,
reject: reject
}).done(function(data)
{
if(data.results)
{
this.resolve(data);
}
else
{
this.reject(data.msg);
}
}).fail(function(a,b,c)
{
window.top.ProcessError(a,b,c);
this.reject(b);
});
});
}
function GetAdHocRecord(ID,SecondaryKey)
{
return new Promise((resolve,reject) =>
{
jQuery.ajax({
url: window.top.Firm.myEndPoint.replace('v1','v2') + '/Plugins/AdHocRecord' + window.top.Firm.Beta + '?ID=' + ID + '&OrionSessionKey=' +window.top.MainApp.OrionSessionKey + '&SecondaryKey=' + escape(SecondaryKey),
dataType: 'json',
method: 'GET',
resolve: resolve,
reject: reject
}).done(function(data)
{
if(data.results)
{
if( isJson(data.Record.RAW))
{
this.resolve(JSON.parse(data.Record.RAW));
}
else
{
this.resolve({});
}
}
else
{
this.reject(data.msg);
}
}).fail(function(a,b,c)
{
window.top.ProcessError(a,b,c);
this.reject(b);
});
});
}
if(window.jQuery)
{
jQuery.fn.CloudStorageLookup = function(options)
{
//$(this).replaceWith('