- Updated README.md to include "Project Structure" section. - Removed WeatherForecastController.cs and WeatherForecast.cs. - Simplified Surge365.MassEmailReact.Server.csproj. - Updated solution file to reflect new project references. - Refactored jquery.ss.dbmanager-1.0.js and jquery.usahaulers.global.js. - Modified logging functionalities in jquery.usahaulers.logging-1.0.js. - Set up constants from environment variables in constants.js and constants.ts. - Introduced new classes in Surge365.MassEmailReact.Application, Domain, and Infrastructure. - Added UnitTest1.cs for basic unit testing structure. - Enhanced Surge365.MassEmailReact.Web.esproj with new configurations. - Expanded utility functions in ytb-massemail-.global.ts and ytb-massemail-utilities-1.0.ts.
611 lines
16 KiB
TypeScript
611 lines
16 KiB
TypeScript
|
|
|
|
//global variables
|
|
var table;
|
|
var allUsers = [];
|
|
var user = null;
|
|
|
|
//login stuff
|
|
function logout() {
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods',
|
|
'methodName': 'LogOut',
|
|
'parameters': {},
|
|
success: function (json) {
|
|
|
|
document.location.href = '/login.aspx';
|
|
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
function checkLoggedInStatus() {
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods',
|
|
'methodName': 'CheckAuthToken',
|
|
'parameters': {},
|
|
success: function (json) {
|
|
if ($.getBoolean(json.success)) {
|
|
$.localStorage("session_currentUser", json.data);
|
|
|
|
|
|
//set user info
|
|
user = $.localStorage("session_currentUser");
|
|
|
|
//set franchise if it isn't set yet.
|
|
//franchiseDeferred = $.Deferred();
|
|
|
|
//call back to page that called this method.
|
|
// $.when(franchiseDeferred).done(function () {
|
|
/*
|
|
if ($.sessionStorage("Auth-Impersonate-Guid") != null) {
|
|
//session is being impersonated, override name and signout
|
|
$("#spanProfileName").html("Signed in as " + user.FirstName + ' ' + user.LastName);
|
|
$("#spanProfileNameTitle").html("Signed in as " + user.FirstName + ' ' + user.LastName);
|
|
}
|
|
else {
|
|
$("#spanProfileName").html(user.FirstName + ' ' + user.LastName);
|
|
$("#spanProfileNameTitle").html(user.FirstName + ' ' + user.LastName);
|
|
} */
|
|
|
|
// $("#spanMenuName").html(user.FirstName + ' ' + user.LastName);
|
|
|
|
// var userid = $.localStorage("session_currentUser").UserID;
|
|
// var imgid = userid + "&t=" + new Date().getTime();
|
|
/*
|
|
if (user.HasProfileImage) {
|
|
$("#imgRightProfile").attr("src", "/webservices/getprofileimage.ashx?id=" + imgid);
|
|
$("#imgRightProfile").on('error', function () {
|
|
$("#imgRightProfile").attr("src", "/img/generic_avatar.jpg");
|
|
});
|
|
|
|
$("#imgLeftProfile").attr("src", "/webservices/getprofileimage.ashx?id=" + imgid);
|
|
$("#imgLeftProfile").on('error', function () {
|
|
$("#imgLeftProfile").attr("src", "/img/generic_avatar.jpg");
|
|
});
|
|
|
|
$("#imgMainProfile").attr("src", "/webservices/getprofileimage.ashx?id=" + imgid);
|
|
$("#imgMainProfile").on('error', function () {
|
|
$("#imgMainProfile").attr("src", "/img/generic_avatar.jpg");
|
|
});
|
|
}
|
|
else {
|
|
$("#imgRightProfile").attr("src", "/img/generic_avatar.jpg");
|
|
$("#imgLeftProfile").attr("src", "/img/generic_avatar.jpg");
|
|
$("#imgMainProfile").attr("src", "/img/generic_avatar.jpg");
|
|
} */
|
|
|
|
loadPage();
|
|
|
|
}
|
|
else {
|
|
$.sessionStorage("redirect_url", document.location.href);
|
|
document.location.href = '/login';
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function setCurrentFranchise(d) {
|
|
$.usaHaulersDB.getFranchises().then((data) => {
|
|
$.sessionStorage("currentFranchise", data);
|
|
if (d != null) {
|
|
d.resolve();
|
|
}
|
|
});
|
|
|
|
/*
|
|
search = {};
|
|
search.FranchiseCode = $.sessionStorage("franchiseCode");
|
|
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods/',
|
|
'methodName': 'GetReport_Franchise',
|
|
'parameters': { "search": search },
|
|
success: function (json) {
|
|
|
|
if ($.getBoolean(json.success)) {
|
|
$.sessionStorage("currentFranchise", json.data[0]);
|
|
if (d != null) {
|
|
d.resolve();
|
|
}
|
|
}
|
|
}
|
|
}); */
|
|
|
|
}
|
|
|
|
function createSetting(obj, settingTypeCode, value) {
|
|
|
|
//see if setting exists
|
|
var bFound = false;
|
|
for (var x = 0; x < obj.Settings.length; x++) {
|
|
if (obj.Settings[x].SettingTypeCode == settingTypeCode) {
|
|
bFound = true;
|
|
break;
|
|
}
|
|
}
|
|
if (bFound) {
|
|
//existing setting
|
|
obj.Settings[x].Value = value;
|
|
}
|
|
else {
|
|
|
|
|
|
setting = {}
|
|
setting.SettingTypeCode = settingTypeCode;
|
|
setting.Value = value;
|
|
|
|
if (obj.Settings == null) {
|
|
obj.Settings = [];
|
|
}
|
|
obj.Settings.push(setting);
|
|
}
|
|
}
|
|
|
|
function createCaseSetting(obj, settingTypeCode, value) {
|
|
|
|
//see if setting exists
|
|
var bFound = false;
|
|
for (var x = 0; x < obj.settings.length; x++) {
|
|
if (obj.settings[x].case_setting_type_code == settingTypeCode) {
|
|
bFound = true;
|
|
break;
|
|
}
|
|
}
|
|
if (bFound) {
|
|
//existing setting
|
|
obj.settings[x].value = value;
|
|
}
|
|
else {
|
|
|
|
|
|
setting = {}
|
|
setting.case_setting_type_code = settingTypeCode;
|
|
setting.value = value;
|
|
|
|
if (obj.settings == null) {
|
|
obj.settings = [];
|
|
}
|
|
obj.settings.push(setting);
|
|
}
|
|
}
|
|
|
|
function getReportSetting(settings, setting_field, setting_code) {
|
|
var value = "";
|
|
if (settings != null) {
|
|
for (var x = 0; x < settings.length; x++) {
|
|
setting = settings[x];
|
|
if (setting[setting_field] == setting_code) {
|
|
value = setting["value"];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
|
|
function getSetting(settings, settingTypeCode) {
|
|
var value = "";
|
|
for (var x = 0; x < settings.length; x++) {
|
|
setting = settings[x];
|
|
if (setting.SettingTypeCode == settingTypeCode) {
|
|
value = setting.Value;
|
|
break;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
|
|
|
|
|
|
|
|
//web calls
|
|
function callMethod(methodname, callback, sessionName, deferred, search) {
|
|
|
|
var params = {};
|
|
|
|
if (search == null) {
|
|
search = {};
|
|
}
|
|
|
|
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods/',
|
|
'methodName': methodname,
|
|
'parameters': { "search": search },
|
|
success: function (json) {
|
|
|
|
$.sessionStorage(sessionName, json.data);
|
|
|
|
if ($.getBoolean(json.success)) {
|
|
if (deferred != null) {
|
|
deferred.resolve(true);
|
|
}
|
|
if (callback != null) {
|
|
callback();
|
|
}
|
|
}
|
|
else {
|
|
notify("Error", "There was an error performing this action. Please try again.")
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function callSearchTransactions(methodname, callback, sessionName, deferred, search) {
|
|
//REPEAT OF CALL METHOD,, JSON.DATA DOESN'T WORK HERE..
|
|
//TODO MAKE DYNAMIC LATER.
|
|
|
|
var params = {};
|
|
|
|
if (search == null) {
|
|
search = {};
|
|
}
|
|
|
|
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods/',
|
|
'methodName': methodname,
|
|
'parameters': { "search": search },
|
|
success: function (json) {
|
|
|
|
$.sessionStorage(sessionName, json);
|
|
|
|
if ($.getBoolean(json.success)) {
|
|
if (deferred != null) {
|
|
deferred.resolve(true);
|
|
}
|
|
if (callback != null) {
|
|
callback();
|
|
}
|
|
}
|
|
else {
|
|
notify("Error", "There was an error performing this action. Please try again.")
|
|
}
|
|
}
|
|
});
|
|
}
|
|
//overlay
|
|
function showwait(item) {
|
|
$("#waitOverlay").show();
|
|
if (item) {
|
|
item.show();
|
|
|
|
}
|
|
else {
|
|
$("#loading").show();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
function hidewait(item) {
|
|
$("#waitOverlay").hide();
|
|
if (item) {
|
|
item.hide();
|
|
}
|
|
else {
|
|
$("#loading").hide();
|
|
|
|
}
|
|
}
|
|
|
|
//helper function
|
|
function getParameterByName(name) {
|
|
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
|
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
|
results = regex.exec(location.search);
|
|
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
}
|
|
function getCurrency(val) {
|
|
return '$' + parseFloat(val, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString()
|
|
}
|
|
function getDate(val) {
|
|
var newDate = new Date(Date.parse(val)).toLocaleDateString()
|
|
return newDate;
|
|
}
|
|
function changeDateFormat(inputDate) { // expects Y-m-d
|
|
var splitDate = inputDate.split('-');
|
|
if (splitDate.count == 0) {
|
|
return null;
|
|
}
|
|
|
|
var year = splitDate[0];
|
|
var month = splitDate[1];
|
|
var day = splitDate[2];
|
|
|
|
return month + '/' + day + '/' + year;
|
|
}
|
|
|
|
function getTime(val) {
|
|
var newDate = new Date(Date.parse(val)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
return newDate;
|
|
}
|
|
function getDateAndTime(val) {
|
|
var newDate = new Date(Date.parse(val)).toLocaleDateString() + ' ' + new Date(Date.parse(val)).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true })
|
|
return newDate;
|
|
}
|
|
function getDateAndTimeAndSeconds(val) {
|
|
var newDate = new Date(Date.parse(val)).toLocaleDateString() + ' ' + new Date(Date.parse(val)).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true, second: '2-digit' })
|
|
return newDate;
|
|
}
|
|
function notify(title, message) {
|
|
$.gritter.add({
|
|
title: title,
|
|
text: message,
|
|
sticky: false,
|
|
time: '2000',
|
|
|
|
});
|
|
}
|
|
function getObjectByKey(key, value, objectArray) {
|
|
for (var x = 0; x < objectArray.length; x++) {
|
|
if (objectArray[x][key] == value) {
|
|
return objectArray[x];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function formatSelect2Data(id, name, data) {
|
|
var newdata = [];
|
|
//var blank = { };
|
|
// blank.id = "";
|
|
//blank.text = "";
|
|
//data.push(blank);
|
|
for (var x = 0; x < data.length; x++) {
|
|
var obj = {};
|
|
obj.id = data[x][id];
|
|
obj.text = data[x][name]
|
|
newdata.push(obj);
|
|
|
|
}
|
|
return newdata;
|
|
}
|
|
|
|
function formatSelect2DataForReturnedBatched(id, name, data) {
|
|
var newdata = [];
|
|
//var blank = { };
|
|
// blank.id = "";
|
|
//blank.text = "";
|
|
//data.push(blank);
|
|
for (var x = 0; x < data.length; x++) {
|
|
if (data[x].Type != "ShiftCharges") {
|
|
var obj = {};
|
|
obj.id = data[x][id];
|
|
obj.text = data[x][name]
|
|
newdata.push(obj);
|
|
}
|
|
|
|
}
|
|
return newdata;
|
|
}
|
|
|
|
function formatSelect2DataForUser(id, data) {
|
|
var newdata = [];
|
|
//var blank = { };
|
|
// blank.id = "";
|
|
//blank.text = "";
|
|
//data.push(blank);
|
|
for (var x = 0; x < data.length; x++) {
|
|
var obj = {};
|
|
obj.id = data[x][id];
|
|
obj.text = data[x]["FirstName"] + ' ' + data[x]["LastName"] + ' - ' + data[x]["UserID"];
|
|
newdata.push(obj);
|
|
|
|
}
|
|
return newdata;
|
|
}
|
|
|
|
//batches
|
|
function fillDropDown(dropdown, method, session, deferred, fieldname, fieldvalue, placeholder) {
|
|
if ($.sessionStorage(session) == null) {
|
|
callMethod(method, fillDropDown, session, deferred, null);
|
|
}
|
|
else {
|
|
var data = formatSelect2Data(fieldname, fieldvalue, $.sessionStorage(session));
|
|
$(control).select2({
|
|
placeholder: placeholder,
|
|
allowClear: true,
|
|
selectOnClose: false,
|
|
//closeOnSelect: false,
|
|
data: data,
|
|
width: "200px"
|
|
});
|
|
batchDeferred.resolve(true);
|
|
}
|
|
}
|
|
|
|
|
|
var currentDropdown;
|
|
//location
|
|
function fillLocationsDropDown(deferred) {
|
|
|
|
|
|
|
|
var search = {};
|
|
if (!$.userHasRole("Administrators")) {
|
|
search.UserID = $.localStorage("session_currentUser").UserID;
|
|
}
|
|
else {
|
|
search = null;
|
|
}
|
|
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods/',
|
|
'methodName': 'SearchLocations',
|
|
'parameters': { "search": search },
|
|
success: function (json) {
|
|
|
|
$.sessionStorage("session_locations", json.data);
|
|
|
|
if ($.getBoolean(json.success)) {
|
|
var data = formatSelect2Data("ID", "Name", $.sessionStorage("session_locations"));
|
|
|
|
if ($.userHasRole("Administrators")) {
|
|
$("#selLocation").select2({
|
|
placeholder: "Select a location...",
|
|
allowClear: true,
|
|
selectOnClose: false,
|
|
//closeOnSelect: false,
|
|
data: data
|
|
});
|
|
$("#selLocation").enable(true);
|
|
}
|
|
else {
|
|
$("#selLocation").select2({
|
|
|
|
data: data
|
|
});
|
|
$("#selLocation").select2('val', data[0].id);
|
|
$("#selLocation").enable(false);
|
|
}
|
|
|
|
if (deferred != null) {
|
|
deferred.resolve(true);
|
|
}
|
|
}
|
|
else {
|
|
notify("Error", "There was an error performing this action. Please try again.")
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
var currentSpinner = null
|
|
function spin2(spin) {
|
|
//spinner = $("#spanSpinner");
|
|
currentSpinner.show();
|
|
|
|
if (spin) {
|
|
rotation = function () {
|
|
currentSpinner.rotate({
|
|
angle: 0,
|
|
animateTo: 360,
|
|
callback: rotation
|
|
});
|
|
}
|
|
rotation();
|
|
}
|
|
else {
|
|
currentSpinner.stopRotate();
|
|
currentSpinner.hide();
|
|
}
|
|
}
|
|
|
|
function spin(spin, spinner) {
|
|
//spinner = $("#spanSpinner");
|
|
spinner.show();
|
|
|
|
if (spin) {
|
|
rotation = function () {
|
|
spinner.rotate({
|
|
angle: 0,
|
|
animateTo: 360,
|
|
callback: rotation
|
|
});
|
|
}
|
|
rotation();
|
|
}
|
|
else {
|
|
spinner.stopRotate();
|
|
spinner.hide();
|
|
}
|
|
}
|
|
|
|
//employee
|
|
function fillEmployeesDropDown(deferred, dropdown) {
|
|
|
|
if (dropdown == null) {
|
|
dropdown = $("#selEmployee");
|
|
}
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods/',
|
|
'methodName': 'GetUsers',
|
|
'parameters': { "activeOnly": false },
|
|
success: function (json) {
|
|
|
|
$.sessionStorage("session_users", json.data);
|
|
|
|
if ($.getBoolean(json.success)) {
|
|
var data = formatSelect2DataForUser("UserID", $.sessionStorage("session_users"));
|
|
dropdown.select2({
|
|
placeholder: "Select an employee...",
|
|
allowClear: true,
|
|
selectOnClose: false,
|
|
//closeOnSelect: false,
|
|
data: data
|
|
});
|
|
|
|
if (deferred != null) {
|
|
deferred.resolve(true);
|
|
}
|
|
}
|
|
else {
|
|
notify("Error", "There was an error performing this action. Please try again.")
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//new imove global functions
|
|
|
|
|
|
function stripCharacters(str) {
|
|
return str.replace(/[-' ]/g, '').toUpperCase();
|
|
}
|
|
|
|
function searchUsers(d) {
|
|
search = {};
|
|
|
|
$.webMethod({
|
|
'methodPage': 'UserMethods/',
|
|
'methodName': 'SearchUsers',
|
|
'parameters': { "search": search },
|
|
success: function (json) {
|
|
|
|
|
|
if ($.getBoolean(json.success)) {
|
|
|
|
allUsers = json.data;
|
|
d.resolve();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function growlWarn(msg) {
|
|
$.bootstrapGrowl("<strong>" + msg + "</strong>", {
|
|
type: 'warning',
|
|
align: 'center',
|
|
width: 'auto',
|
|
allow_dismiss: true,
|
|
offset: { from: 'top', amount: 60 }
|
|
});
|
|
}
|
|
function growlSuccess(msg) {
|
|
$.bootstrapGrowl("<strong>" + msg + "</strong>", {
|
|
type: 'success',
|
|
align: 'center',
|
|
width: 'auto',
|
|
allow_dismiss: true,
|
|
offset: { from: 'top', amount: 60 }
|
|
});
|
|
}
|
|
|
|
function getUser(users, id) {
|
|
for (var x = 0; x < users.length; x++) {
|
|
if (users[x].UserID == id) {
|
|
return users[x];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|