Skip to content

Instantly share code, notes, and snippets.

@chaorace
Created January 31, 2020 20:00
Show Gist options
  • Save chaorace/42dbfa08c6a522bed8aa781a2ec2cdb1 to your computer and use it in GitHub Desktop.
Save chaorace/42dbfa08c6a522bed8aa781a2ec2cdb1 to your computer and use it in GitHub Desktop.
ATT Express Ticketing Javascript dump
var outage = 0,
ticketStatus = 0,
ticketTypeID = 3,
counter = 0,
ticketInfo = {},
ticketData = {},
currentDate = new Date(),
copyYear = currentDate.getFullYear(),
chatAvail = 1,
attESHr,
unit = 'ABS-CAB',
tcChatEnabled = 0,
browserInfo = navigator.userAgent,
userObject = {},
callSamplesArray = [],
callSamplesLength = 0,
callSamplesLog = '',
callSampleIndex = 0,
callSampleProvided = 0,
ticketStatusCount = 0,
mobileAd = 0,
ie, sessSource,timezoneSetOffset,countrySelected,daylightSavings, startSess, sID, uID;
window.onbeforeunload = function(e) {
if (ticketStatus == 0) {
window.opener.reloadVar = 1;
window.opener.ticketInput = undefined;
if (startSess == 1) {
window.opener.startSess = 1;
}
}
};
$(document).on('ready', function(e) {
if(window.pageTrigger == 'viewStatus'){
handleTicketData();
prepVariableValidation();
getValidationType(ticketInput.t);
} else {
getTicketStatus();
}
attachEventHandlers();
if ($(window).width() <= 480) {
mobileAd = 1;
}
});
function getTicketStatus(){
ajaxLoadingMessage('Loading Ticket...');
handleTicketData();
requestTicket();
getMaintenance();
window.onresize = function() { setColumnHeights() };
createSessionID();
$('#copyYear').html(copyYear);
if (ie != 'ie7'){
if(! localStorage.uID){
createUID('0');
} else{
uID = localStorage.uID;
}
} else{
if(! $.cookie('uID')){
createUID('1');
} else{
uID = $.cookie('uID');
}
}
setInterval(setColumnHeights,500);
}
function attachEventHandlers(){
$('.statusButtons').on('click', function(e) {
var buttonID = $(this).attr('id'),
titleID = buttonID.replace('Button', 'Title'),
action = $(this).attr('action');
if (buttonID.indexOf('refresh') != -1) {
ajaxLoadingMessage('Refreshing Ticket...');
$('#logsLoading').show();
$('#logNotesTable').hide();
var params = {
t: ticketInfo.t,
sid: sID,
uid: uID
};
if (sessSource == 4) {
params.id = ticketInfo.id;
} else {
params.st = ticketInfo.st;
params.cc = ticketInfo.cc;
params.pin = ticketInfo.pin;
}
if(ticketInfo.ban) params.ban = ticketInfo.ban;
if(ticketInfo.cn) params.cn = ticketInfo.cn;
if(ticketInfo.source_sid) params.source_sid = ticketInfo.source_sid;
setTimeout(function(){
sendExpressRequest('../cgi-bin/status.pl','getIncidentStatus',params,null,getIncidentStatus,sendRequestFailure);
}, 2000);
} else if (titleID.indexOf('Chat') == -1) {
$('#' + titleID).show();
$('.logNotes').attr('formtitle', titleID);
$('.logNotes').attr('action', action);
if (ie != 'ie7') {
if(localStorage.primaryContactFirstName) {
$('#logFirstName').val(localStorage.primaryContactFirstName);
}
if(localStorage.primaryContactLastName) {
$('#logLastName').val(localStorage.primaryContactLastName);
}
if(localStorage.primaryContactPhone) {
var phone = localStorage.primaryContactPhone;
//var priPhone = getPhoneParts(phone);
$('#logPhoneNumber').val(phone);
}
if(localStorage.primaryContactEmail) {
$('#logEmail').val(localStorage.primaryContactEmail);
}
}
if (action.indexOf('escalate') != -1) {
getEscalationLevel(ticketData, 0);
} else {
if (action.indexOf('ActiveDispatch') == -1 && action.indexOf('generatePIN') == -1){
$('#incidentContainer').hide('fadeOut');
$('#formContainer').show('slide');
}
if(action.indexOf('CallSamples') != -1 && callSampleProvided != 1){
$('#callSamplesForm').show();
$('.status-log-note').hide();
} else if (action.indexOf('CallSamples') != -1 && callSampleProvided == 1){
$('#logForm').hide();
$('#callSamplesProvided').show();
} else if (action.indexOf('CallSamples') == -1 && callSampleProvided == 1){
$('#logForm').show();
$('.status-log-note').show();
$('#callSamplesProvided').hide();
} else if (action.indexOf('ActiveDispatch') == -1){
$('#callSamplesForm').hide();
$('.status-log-note').show();
}
if(action.indexOf('generatePIN') != -1){
$('#reqOrEnterPinModel').modal('show');
}
}
} else if (buttonID.indexOf('Chat') != -1) {
if ($(this).attr('livechat') == 0) {
ajaxLoadingMessage('Checking Chat Availability');
sendExpressRequest('../cgi-bin/status.pl','checkChatTimer',{t: ticketData.t, st: ticketData.st, cc: ticketData.cc, sid: sID, uid: uID},null,checkTimer,
function(req,status,err){
warningSubmissionAlert('<p>Chat Failed for' + ticketInfo.t + '</p>');
});
} else {
inqFrame.Inq.C2CM.agrty(0);
sendExpressRequest('../cgi-bin/express.pl','endSessionStartLivePerson',{uid:uID,sid:sID,skill:unit},null,function(data) {},function(req,status,err) {});
return false;
}
}
$('#logFormGate').html(ticketData.gate);
$('#logFormGateText').html(ticketData.gateText);
if ($('#ettxMilestone').is(':visible')) {
$('#ettxLogStatement').html($('#ettxStatement').text());
setTimeout(setFormColumnHeights,500);
} else {
$('#ettxLogForm').hide();
$('#mainGateInfo').removeClass('col-xs-6').addClass('col-xs-12');
}
//Mask call samples phone number
$('#callingNumber').mask('(999) 999-9999');
$('#calledNumber').mask('(999) 999-9999');
//Initialize the date/time picker input field
$('.call-sample-datetime[type="datetime"]').datetimepicker({
format: 'Y-m-d H:i:s',
scrollInput: false,
onSelectTime: function (currentTime, input) {
var dateString = $(input).val();
var zeroedString = dateString.replace(/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:)\d{2}/, '$100');
$(input).val(zeroedString);
}
});
$('#addCallNumber').unbind();
$('#addCallNumber').on('click', function (e) {
var callingNum, calledNum, callDateTime, callType,
valid = 0, can_add = 0;
var errorMsg = '';
if($('#callingNumber').val() == ''){
$('#callingNumber').parent().addClass('has-error').removeClass('has-success');
}else{
$('#callingNumber').parent().addClass('has-success').removeClass('has-error');
}
if($('#calledNumber').val() == ''){
$('#calledNumber').parent().addClass('has-error').removeClass('has-success');
}else{
$('#calledNumber').parent().addClass('has-success').removeClass('has-error');
}
if($('#callDateTime').val() == ''){
$('#callDateTime').parent().addClass('has-error').removeClass('has-success');
}else{
$('#callDateTime').parent().addClass('has-success').removeClass('has-error');
}
if($('#callType').val() == ''){
$('#callType').parent().addClass('has-error').removeClass('has-success');
}else{
$('#callType').parent().addClass('has-success').removeClass('has-error');
}
if ($('#callSamplesForm').find('.has-error').length == 1) {
valid = 0;
} else{
callingNum = $('#callingNumber').val();
calledNum = $('#calledNumber').val();
callDateTime = $('#callDateTime').val();
callType = $('#callType').val();
if(callingNum == calledNum){
errorMsg = 'Please correct the \'Calling from\' or \'Calling to\' entry, the numbers cannot be the same or empty.';
valid = 0;
}else{
valid = 1;
}
}
if (callSamplesArray.length < 2){
can_add = 1;
clearCallSamplesForm();
} else { //max 2 call samples
can_add = 0;
}
//Form validation ok and the user still can add the call sample
if (valid == 1 && can_add == 1){
var callingNumCleaned = callingNum.replace(/\D+/g, ''),
calledNumCleaned = calledNum.replace(/\D+/g, ''),
validate = 0;
textMsg = 'Validating Call Sample...';
ajaxLoadingMessage(textMsg);
sendExpressRequest('../cgi-bin/search.pl', 'gcpGetDialPlanByTn', {
callingNum: callingNumCleaned,
calledNum: calledNumCleaned,
bvoipTime: callDateTime,
}, null, function(data){
$.unblockUI();
if (data.STATUS == 'FAIL'){
alert('Invalid Call Sample. Please Correct');
validate = 1;
}
if (validate == 0){
var callSample = {
callingNum: callingNum,
calledNum: calledNum,
bvoipDate: callDateTime,
bvoipCallTypeInput: callType
};
callSamplesArray.push(callSample);
callSamplesLength = callSamplesArray.length;
clearCallSamplesForm();
//add the validated call samples in their own field.
var html = addBVOIPDiv(callingNum, calledNum, callDateTime, callType);
$('#callSampleContainer').append(html);
$('#requiredCallSamples').empty();
$('#requiredCallSamples').text(callSamplesArray.length);
callSampleIndex++;
}
}, function(request, status, err){
$.unblockUI();
});
} else if(valid == 0 && can_add == 0){
//Clear the call samples form, we got the data we need
clearCallSamplesForm();
}
});
});
$(document).on('keyup', function(e) {
if ($('#formContainer').is(':visible') && e.keyCode == 27) {
$('.logNotes').trigger('click');
}
});
$('.logNotes').on('click', function(e) {
var titleID = $(this).attr('formtitle'),
action = $(this).attr('action');
if ($(this).attr('stype') == 'cancel') {
if (action.indexOf('escalate') != -1) {
$('#escContainer').hide();
}
$('#incidentContainer').show('slide');
$('#formContainer').hide('fadeIn');
$('#' + titleID).hide();
setTimeout(setColumnHeights,500);
} else if ($(this).attr('stype') == 'submit' && action != 'addCallSamples') {
var valid = 0,
submission = {
action: action,
t: ticketInfo.t,
cc: ticketInfo.cc,
st: ticketInfo.st,
wc: ticketData.wc,
at: ticketData.at,
pin: ticketData.pin,
ticketType: ticketData.ticketType,
firstName: $('#logFirstName').val(),
lastName: $('#logLastName').val(),
phone: $('#logPhoneNumber').val(),
ext: $('#logExtension').val(),
email: $('#logEmail').val(),
notes: $('#logNote').val(),
lvl: ticketData.escalationLevel ? ticketData.escalationLevel : 0,
createdDate: ticketData.created
};
if (ticketTypeID == 3) {
submission.rstd = ticketData.rstd;
}
if (submission['firstName'].match(/[a-zA-z]/g) == null) {
$('#logFirstName').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logFirstName').parent().removeClass('has-error').addClass('has-success');
}
if (submission['lastName'].match(/[a-zA-z]/g) == null) {
$('#logLastName').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logLastName').parent().removeClass('has-error').addClass('has-success');
}
if (validateEmail(submission.email) == false) {
$('#logEmail').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logEmail').parent().removeClass('has-error').addClass('has-success');
}
if (validatePhone(submission.phone) == false) {
$('#logPhoneNumber').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logPhoneNumber').parent().removeClass('has-error').addClass('has-success');
}
if (submission['notes'].match(/[a-zA-z]/g) == null) {
$('#logNote').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logNote').parent().removeClass('has-error').addClass('has-success');
}
if ($('#logForm').find('.has-error').length == 0) {
valid = 1;
}
if(ticketInput.ban) submission.ban = ticketInput.ban;
if(ticketInput.cn) submission.cn = ticketInput.cn;
if (valid == 1) {
updateTicket(submission);
$('#incidentContainer').show('slide');
$('#formContainer').hide('fadeIn');
$('#logNote').val('');
$('#' + titleID).hide();
}
setTimeout(setColumnHeights,500);
} else if($(this).attr('stype') == 'submit' && action == 'addCallSamples'){
//If the user submit the call sample log
var valid = 0,
submission = {
action: action,
t: ticketInfo.t,
cc: ticketInfo.cc,
st: ticketInfo.st,
wc: ticketData.wc,
at: ticketData.at,
pin: ticketData.pin,
ticketType: ticketData.ticketType,
firstName: $('#logFirstName').val(),
lastName: $('#logLastName').val(),
phone: $('#logPhoneNumber').val(),
ext: $('#logExtension').val(),
email: $('#logEmail').val(),
notes: callSamplesLog,
lvl: ticketData.escalationLevel ? ticketData.escalationLevel : 0,
createdDate: ticketData.created
};
if (ticketTypeID == 3) {
submission.rstd = ticketData.rstd;
}
if (submission['firstName'].match(/[a-zA-z]/g) == null) {
$('#logFirstName').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logFirstName').parent().removeClass('has-error').addClass('has-success');
}
if (submission['lastName'].match(/[a-zA-z]/g) == null) {
$('#logLastName').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logLastName').parent().removeClass('has-error').addClass('has-success');
}
if (validateEmail(submission.email) == false) {
$('#logEmail').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logEmail').parent().removeClass('has-error').addClass('has-success');
}
if (validatePhone(submission.phone) == false) {
$('#logPhoneNumber').parent().addClass('has-error').removeClass('has-success');
} else {
$('#logPhoneNumber').parent().removeClass('has-error').addClass('has-success');
}
if ($('#logForm').find('.has-error').length == 0) {
valid = 1;
}
if(callSamplesArray.length == 2){
callSamplesLog += constructCallSamples(callSamplesArray);
}
if (valid == 1) {
updateTicket(submission);
$('#incidentContainer').show('slide');
$('#formContainer').hide('fadeIn');
$('#logNote').val('');
$('#' + titleID).hide();
callSamplesArray = {};
callSamplesLog = '';
$('#callSampleContainer').empty;
$('#requiredCallSamples').text(0);
}
setTimeout(setColumnHeights,500);
} else if ($(this).attr('stype') == 'back' && action == 'addCallSamples') {
$('#incidentContainer').show('slide');
$('#formContainer').hide('fadeIn');
$('#' + titleID).hide();
setTimeout(setColumnHeights,500);
}
});
//Assign a click event to each call sample panel that removes the panel and adjusts the number
//of samples in the array if user hits x.
$('#callSampleContainer').unbind();
$('#callSampleContainer').on('click', '.deleteCallSample', function (e) {
var csampleID = $(this).closest('.panel').index();
$(this).closest('div.panel').remove();
callSamplesArray.splice(csampleID, 1);
$('#reqSamples').empty();
$('#reqSamples').append(callSamplesArray.length);
if (callSamplesArray.length < 2) {
$('#bvoipContinue').hide();
$('#callingNumberDiv, #calledNumberDiv, #bvoipDateTimeDiv, #bvoipCallTypeDiv').addClass('ticket-form-required');
}
});
$('#logNote').on('keyup', function(e) {
var maxChars = $(this).attr('maxlength');
textCounter(e.target.id, "logCharsTyped", maxChars);
});
$('#feedbackLink').on('click', function(e) {
e.preventDefault();
loadFeedbackModal('loadedModals', 'feedbackLink');
});
/* Status Lookup Form Inputs */
$('#statusT').on('blur', function(e) {
var valid = validateTicketNumber($(this).val());
if (valid == 0) {
$(this).parent().addClass('has-error').removeClass('has-success');
} else if (valid == 1) {
$(this).parent().addClass('has-success').removeClass('has-error');
ticketInfo.t = $(this).val();
}
});
$('#statusT').on('keyup', function(e) {
var ticketNumber = $(this).val().toUpperCase(),
valid = validateTicketNumber($(this).val());
$(this).val(ticketNumber);
if (valid == 0) {
$(this).parent().addClass('has-error').removeClass('has-success');
} else if (valid == 1) {
$(this).parent().addClass('has-success').removeClass('has-error');
ticketInfo.t = $(this).val();
}
});
$('#statusCountry').on('blur', function(e) {
var country = $(this).val();
if (country == '') {
$(this).parent().addClass('has-error').removeClass('has-success');
} else if (country != '') {
$(this).parent().addClass('has-success').removeClass('has-error');
ticketInfo.cc = $(this).val();
}
});
$('#statusCountry').on('change', function(e) {
var country = $(this).val();
if (country == '') {
$(this).parent().addClass('has-error').removeClass('has-success');
} else if (country != 'USA') {
$(this).parent().addClass('has-success').removeClass('has-error');
$('#headerState, #statusState').val('').attr('disabled', true);
ticketInfo.cc = $(this).val();
ticketInfo.st = '';
} else if (country == 'USA') {
$(this).parent().addClass('has-success').removeClass('has-error');
$('#headerState, #statusState').val('').attr('disabled', false);
ticketInfo.cc = $(this).val();
}
});
$('#statusState').on('blur', function(e) {
var state = $(this).val();
if (state == '' && ticketInfo.cc == 'USA') {
$(this).parent().addClass('has-error').removeClass('has-success');
} else if (state != '' && ticketInfo.cc == 'USA') {
$(this).parent().addClass('has-success').removeClass('has-error');
ticketInfo.st = $(this).val();
}
});
$('#statusState').on('change', function(e) {
var state = $(this).val();
if (state == '' && ticketInfo.cc == 'USA') {
$(this).parent().addClass('has-error').removeClass('has-success');
} else if (state != '' && ticketInfo.cc == 'USA') {
$(this).parent().addClass('has-success').removeClass('has-error');
ticketInfo.st = $(this).val();
}
});
$('#ban_field').on('blur input', function(e){
var ban = $(this).val();
$(this).val(ban.toUpperCase());
var ban_regex = /\w+/;
ban.match(ban_regex) ? $(this).parent().addClass('has-success').removeClass('has-error') : $(this).parent().addClass('has-error').removeClass('has-success');
});
$('#cn_field').on('blur input', function(e){
var cn = $(this).val();
var cn_regex = /\d+/;
cn.match(cn_regex) ? $(this).parent().addClass('has-success').removeClass('has-error') : $(this).parent().addClass('has-error').removeClass('has-success');
});
$('#ban_field, #cn_field').on('keyup paste', function(e) {
if (e.keyCode == 13) {
$('#getStatus').trigger('click');
}
});
$('#getStatus').on('click', function(e) {
e.preventDefault();
if (ticketInfo.cc == undefined || ticketInfo.cc == '') {
ticketInfo.cc = $('#statusCountry').val();
}
if (ticketInfo.st == undefined || ticketInfo.st == '') {
ticketInfo.st = $('#statusState').val();
}
ticketInfo.ban = $('#ban_field').val();
ticketInfo.cn = $('#cn_field').val();
if($('#chkYes').is(':checked')){
ticketInfo.pin = $('#pinNumber').val();
}else{
ticketInfo.pin = undefined;
ticketData.pin = undefined;
}
var valid = validateStatusSubmission(ticketInfo);
ticketInfo.sid = sID;
ticketInfo.uid = uID;
if (valid == 1) {
$('#statusT').parent().removeClass('has-success');
$('#statusCountry').val('USA').parent().removeClass('has-success');
$('#statusState').val('').removeAttr('disabled').parent().removeClass('has-success');
ajaxLoadingMessage('Loading Ticket...');
var params = {
t: ticketInfo.t,
sid: sID,
uid: uID
};
if (sessSource == 4) {
params.id = ticketInfo.id;
} else {
params.st = ticketInfo.st;
params.cc = ticketInfo.cc;
params.pin = ticketInfo.pin;
}
if(ticketInfo.ban) params.ban = ticketInfo.ban;
if(ticketInfo.cn) params.cn = ticketInfo.cn;
if(ticketInfo.pin) params.pin = ticketInfo.pin;
setTimeout(function(){
sendExpressRequest('../cgi-bin/status.pl','getIncidentStatus',params,null,getIncidentStatus,sendRequestFailure);
}, 2000);
}
});
$('#warning').on('closed.bs.alert', function () {
closeAlert('warningMessage');
});
$('#successful').on('closed.bs.alert', function() {
closeAlert('successMessage');
});
$('#saasPleaseRefresh').on('closed.bs.alert', function() {
closeAlert('saasRefresh');
});
$('#eo_click').on('click', function(e) {
e.preventDefault();
window.open('https://expressordering.att.com/','_blank');
sendExpressRequest('../cgi-bin/express.pl','eoClick', {sid:sID,uid:uID}, null,function(data){});
});
$('#bc_click').on('click', function(e) {
e.preventDefault();
window.open('https://businesscenter.att.com/ebiz/registration','_blank');
sendExpressRequest('../cgi-bin/express.pl','bcClick', {sid:sID,uid:uID}, null,function(data){});
});
$('#bd_click').on('click', function(e) {
e.preventDefault();
window.open('https://www.businessdirect.att.com','_blank');
sendExpressRequest('../cgi-bin/express.pl','bdClick', {sid:sID,uid:uID}, null,function(data){});
});
}
function handleTicketData() {
var qs = location.search.replace('?', '').split('&'),
oqs = {};
if (typeof window.ticketInput != 'undefined') {
ticketInfo = window.ticketInput;
ticketInfo.id = (window.ticketInput.id) ? window.ticketInput.id : '';
sID = (window.ticketInput.sid) ? window.ticketInput.sid : '';
uID = (window.ticketInput.uid) ? window.ticketInput.uid : '';
sessSource = window.ticketInput.ss;
if (window.ticketInput.fromCreate) {
ticketInfo.fromCreate = window
.ticketInput.fromCreate;
}
ticketStatus = 0;
} else if (window.opener && typeof window.opener.ticketInput != 'undefined') {
ticketInfo = window.opener.ticketInput;
ticketInfo.id = (window.opener.ticketInput.id) ? window.opener.ticketInput.id : '';
sID = (window.opener.ticketInput.sid) ? window.opener.ticketInput.sid : '';
uID = (window.opener.ticketInput.uid) ? window.opener.ticketInput.uid : '';
sessSource = window.opener.ticketInput.ss;
if (window.opener.startSess == 1) {
startSess = 1;
}
if (window.opener.ticketInput.fromCreate) {
ticketInfo.fromCreate = window.opener.ticketInput.fromCreate;
}
ticketStatus = 0;
} else {
ticketStatus = 1;
if (window.opener && window.opener.startSess == 1) {
startSess = 1;
}
}
}
function requestTicket(refresh){
if (ticketStatus == 0) {
var params = {
t: ticketInfo.t,
sid: sID,
uid: uID
};
if (sessSource == 4) {
params.id = ticketInfo.id;
} else {
params.st = ticketInfo.st;
params.cc = ticketInfo.cc;
params.pin = ticketInfo.pin;
}
if(ticketInfo.ban) params.ban = ticketInfo.ban;
if(ticketInfo.cn) params.cn = ticketInfo.cn;
if(ticketInfo.source_sid) params.source_sid = ticketInfo.source_sid;
if (refresh == 1) {
ajaxLoadingMessage('Refreshing Ticket...');
}
setTimeout(function(){
sendExpressRequest('../cgi-bin/status.pl','getIncidentStatus',params,null,getIncidentStatus,sendRequestFailure);
}, 2000);
} else if (ticketStatus == 1) {
setTimeout(function() {
systemMaintenance();
$.unblockUI();
if (!window.opener) {
ajaxLoadingMessage('Loading Express Ticketing...');
document.location = '/expressticketing/index.html';
} else {
sID = window.opener.sID;
uID = window.opener.uID;
}
}, 2000);
}
}
function getIncidentStatus(data) {
timezoneLocalStorage('getTZInfo');
if (userObject.tzSettings) {
var tzSettings = userObject.tzSettings;
timezoneSetOffset = tzSettings.timezone;
countrySelected = tzSettings.tzCountry;
} else {
timezoneSetOffset = setTimezone(currentDate.getTimezoneOffset());
getCountryFromTZ(timezoneSetOffset);
}
$.unblockUI();
if (data.STATUS == 0) {
counter++;
ticketStatus = (counter == 3) ? 2 : 1;
if (data.LOCKED === 1){
ticketStatusCount = 1;
}
$('#not_found_alert_div').show();
systemMaintenance();
} else {
var returnData = data.RESPONSE;
// console.log(returnData);
ticketData = {
t: ticketInfo.t,
cc: ticketInfo.cc,
st: ticketInfo.st,
pin: ticketInfo.pin,
gate: returnData['gate'],
gateText: returnData['gateText'],
created: returnData['wto'],
ctn: '',
ct: '',
ce: returnData['ce'],
cch: returnData['cc'],
cw: returnData['cw'],
lpq: returnData['lpq'],
at: returnData['at'],
ticketType: returnData['ts'],
ah: returnData['ah'],
mi: returnData['mi'],
miDesc: returnData['miDesc'],
bat: '',
eb: returnData['eb'],
ao: returnData['ao'],
cs: returnData['cs'],
rtta: returnData['rtta'],
durl : returnData['durl'],
eta: returnData['eta']
};
if (sessSource == 4) {
ticketData.id = ticketInfo.id;
if (ticketData.gate != 'Closed' || ticketData.gate != 'Ticket Closed') {
setInterval(function() {
$('#saasRefreshContainer').slideDown();
}, 300000);
}
}
if (ticketData.gate == 'Incident Lookup Failed') {
ticketStatus = 1;
systemMaintenance();
} else {
ticketStatus = 0;
systemMaintenance();
if (!ticketInfo.fromCreate && startSess != 1) {
startSession();
}
if (ie != 'ie7') {
localStorage.lastStatusTicket = ticketInfo.t;
localStorage.lastStatusState = ticketInfo.st;
localStorage.lastStatusCountry = ticketInfo.cc;
localStorage.lastStatusTicketType = returnData['ts'];
} else {
createCookiesIfDNE();
$.cookie('lastStatusTicket', ticketInfo.t, {expires: 1500});
$.cookie('lastStatusState', ticketInfo.st, {expires: 1500});
$.cookie('lastStatusCountry', ticketInfo.cc, {expires: 1500});
$.cookie('lastStatusTicketType', returnData['ts'], {expires: 1500});
}
ticketTypeID = returnData['ts'];
if(ticketData.ticketType == 3) {
ticketData.rstd = returnData['rstd'];
}
$('#gate').text(ticketData.gate);
$('#gateText').html(ticketData.gateText);
if (ticketTypeID == 1 || ticketTypeID == 2) {
ticketData.ctn = returnData['ctn'];
if(returnData['bat']) {
ticketData.bat = returnData['bat'];
t = returnData['bat'];
ticketData.t = t;
ticketTypeID = 2;
ticketData.ticketType = 2;
}
}
lpq = returnData['lpq'];
ticketData.t = ticketData['t'].replace(/^0{6}/, '');
if (returnData['md']) {
if (returnData['md']['wc']) {
ticketData.wc = returnData['md']['wc'];
}
}
if (returnData['ct']) {
var ctDate = new Date(returnData['ct']);
ctDate = ctDate.toISOString();
ticketData.ct = moment.tz(ctDate, timezoneSetOffset).format('MM/DD/YYYY h:mm A z');
}
var date = new Date(returnData['wto']);
date = date.toISOString();
ticketData.created = moment.tz(date, timezoneSetOffset).format('MM/DD/YYYY h:mm A z');
$('#createdDate').text(ticketData.created);
if (ticketData.gate == 'Closed' || ticketData.gate == 'Ticket Closed') {
ticketData.closeCode = returnData['closeCode'];
$('#buttonContainer').hide();
$('#incident').removeClass('col-xs-8').addClass('col-xs-12');
$('#incident').css('padding-left', '5px').css('padding-right', '5px');
$('#closureInfoRow').show();
$('#closeCode').html(ticketData.closeCode);
} else {
if (ticketData.ce == 0) {
$('#escalateTicketButton').hide();
} else if (ticketData.ce == 1) {
$('#escalateTicketButton').show();
getEscalationLevel(ticketData, 1);
}
//Pin is checked and pin is locked for 3 wrong attempts show generatePINButton
//on status un-authenticated view.
if(($('#chkYes').is(':checked') && data.pinLocked != '1') || (sessSource == '0' && ticketInfo.fromCreate)){
$('#generatePINButton').hide();
}else if($('#chkYes').is(':checked') && data.pinLocked == '1'){
ticketData.pin = 0;
}
if(($('#chkROEPYes').is(':checked') && data.pinLocked != '1') || (sessSource == '0' && ticketInfo.fromCreate)){
$('#generatePINButton').hide();
}else if($('#chkROEPYes').is(':checked') && data.pinLocked == '1'){
ticketData.pin = 0;
}
if(ticketData.lpq != null) {
if (ticketData.cch == 0) {
if (ticketData.cw != null && chatAvail == 1) {
$('#requestChatButton').show();
$('#requestChatButton').attr('livechat', 0);
if (tcChatEnabled == 1) {
tcChatEnabled = 0;
inqCustData.tcChatEnabled = tcChatEnabled;
//Inq.reinitChat();
Inq.fireCustomEvent('reloadFrmwk');
}
} else {
$('#requestChatButton').hide();
}
} else if (ticketData.cch == 1 && chatAvail == 1) {
$('#requestChatButton').show();
tcChatEnabled = 1;
unit = ticketData.lpq;
inqCustData.tcChatEnabled = tcChatEnabled;
inqCustData.Unit = unit;
//Inq.reinitChat();
if (typeof (Inq) != 'undefined') {
Inq.fireCustomEvent('reloadFrmwk');
}
$('#requestChatButton').attr('livechat', 1);
setTimeout(function() {
$('#inqTestDiv').hide();
}, 1000);
} else {
$('#requestChatButton').hide();
}
} else {
$('#requestChatButton').hide();
}
$('#buttonContainer').show();
if (returnData['ettx'] == 1) {
var ettxDate = (returnData['ettxTime'] != null) ? returnData['ettxTime'] : '',
ettxTZ = (ettxDate != '') ? ettxDate.substr(20,3) : '',
ettxTZName = (ettxDate != '') ? usAbbreviations[ettxTZ]['tz'] : '';
if (ettxDate != '') {
ettxDate = ettxDate.substr(0,19) + usAbbreviations[ettxTZ]['offset'];
ettxDate = new Date(ettxDate);
var ettxTime = moment.tz(ettxDate, ettxTZName).format('MM/DD/YYYY h:mm A z');
ettxTime = new Date(ettxTime);
ettxTime = ettxTime.toISOString();
var ettxTimeSet = moment.tz(ettxTime, timezoneSetOffset).format('MM/DD/YYYY h:mm A z');
}
$('#ettxStatusCurrentStep').html(returnData['ettxStatusCurrentStep']);
$('#ettxTime').html(ettxTimeSet);
$('#ettxMilestone').show();
}
}
if (ticketTypeID == 3) {
$('#logNote').attr('maxlength', 650);
$('#logCharsAvailable').html('650');
if (mobileAd == 1) {
$('#eoMobile').show();
$('#eoDesktop').hide();
}
//$('#eoBannerAd').show();
} else if (ticketTypeID == 2) {
$('#logNote').attr('maxlength', 1800);
$('#logCharsAvailable').html('1800');
if (mobileAd == 1) {
$('#bdMobile').show();
$('#bdDesktop').hide();
}
$('#bdBannerAd').show();
} else if (ticketTypeID == 1) {
$('#logNote').attr('maxlength', 32000);
$('#logCharsAvailable').html('32000');
if (mobileAd == 1) {
$('#bcMobile').show();
$('#bcDesktop').hide();
}
$('#bcBannerAd').show();
}
if (ticketData.ct != '') {
$('#serviceRestoralRow').show();
$('#restoralGoal').text(ticketData.ct);
}
if (ticketData.rtta == 1) {
if (ticketData.eta != '') {
var timeString = (ticketData.eta == '1') ? 'Minute' : 'Minutes';
$('#ETARow').show();
$('#eta').text(ticketData.eta + ' ' + timeString);
} else {
$('#ETARow').show();
$('#eta').text('Truck Data Currently Unavailable');
}
if (ticketData.durl != '') {
$('#dispatchURL').show();
}
}
$('#ActiveDispatchButton').on('click', function(e) {
$('#iframeContainer').show();
$('#ActiveDispatchButton').hide();
$('#HideActiveDispatch').show();
document.getElementById("iframeContainer").innerHTML = '<iframe src="'+ticketData.durl + '" height="480" width="640" style="border-radius: 6px;"></iframe>';
});
$('#HideActiveDispatch').on('click', function(e) {
$('#iframeContainer').hide();
$('#ActiveDispatchButton').show();
$('#HideActiveDispatch').hide();
});
if (ticketData.ctn != '' && ticketData.ctn != null) {
$('#custTickNumRow').show();
$('#custTicketNum').text(ticketData.ctn);
}
if(ticketData.bat && ticketData.bat != '') {
$('#assocBMPRow').show();
$('#associatedBMPTicket').text(ticketData.bat);
}
if (ticketData.gate == 'Restored' || ticketData.gate == 'Service Restored' || ticketData.gate == 'Resolved') {
if (ticketData.eb == 0) {
$('#contestClosureButton').show();
}
else {
$('#contestClosureButton').hide();
}
$('#requestClosureButton').hide();
$('#escalateTicketButton').hide();
} else {
$('#requestClosureButton').show();
$('#contestClosureButton').hide();
}
if(ticketData.ao != '' && (ticketData.ao == 'US-IPCC-LCT1' || ticketData.ao == 'US-IPCC-LCT2')){
$('#escalateTicketButton').hide();
$('#requestChatButton').hide();
}
if(ticketData.cs && ticketData.cs == 1){
$('#addCallSamplesButton').show();
} else{
$('#addCallSamplesButton').hide();
}
document.title = 'Ticket Status for ' + ticketInfo.t;
$('#ticketNumber').text(ticketInfo.t);
getLogNotes(ticketData);
}
}
}
function refreshTicket(ticket, type) {
// Type variable - 0 = Full Refresh, 1 = Logs Refresh
if (type == 0) {
ajaxLoadingMessage('Refreshing Ticket...');
$('#logNotesTable').hide();
$('#logsLoading').show();
handleTicketData();
requestTicket(1);
} else if (type == 1) {
$('#logNotesTable').hide();
$('#logsLoading').show();
getLogNotes(ticket);
}
}
function getLogNotes (ticket) {
var t = ticket.t,
cc = ticket.cc,
st = ticket.st,
wc = ticket.wc,
pin = ticket.pin,
number = ticket.number,
htmlArray = [],
html = '',
params = {
ajaxAction: 'getLogs',
t: t,
st: st,
cc: cc,
sid: sID,
uid: uID,
wc: wc,
pin: pin,
};
if(typeof ticketInput != 'undefined'){
if(ticketInput.ban) params.ban = ticketInput.ban;
if(ticketInput.cn) params.cn = ticketInput.cn;
if(ticketInput.source_sid) params.source_sid = ticketInput.source_sid;
}
if (typeof ticket.at != 'undefined') {
if (ticket.t != ticket.at) {
t = ticket.at
}
}
if (sessSource == 4) {
params.id = ticketData.id;
}
$.unblockUI();
setTimeout(function() {
sendExpressRequest('../cgi-bin/status.pl','getLogs',params,null,displayLogNotes,sendRequestFailure);
}, 1000);
}
function displayLogNotes(data) {
var responseData = data.RESPONSE;
if (data.STATUS == 0) {
warningSubmissionAlert(responseData.ERROR);
} else {
if(responseData['gate'] == 'Incident Lookup Failed') {
warningSubmissionAlert('<p>Log Notes Lookup Failed</p><p>There was an issue related to log notes for this ticket. Close this alert and you can try your request again.</p>');
} else {
var html = '';
for (var i = 0; i < responseData['ld'].length; i++) {
var date = responseData['ld'][i]['LOG_DATETIME'],
type = responseData['ld'][i]['LOG_TYPE'] || '',
remark = responseData['ld'][i]['LOG_REMARK'],
utcTime = new Date(date);
utcTime = utcTime.toISOString();
date = moment.tz(utcTime, timezoneSetOffset).format('MM/DD/YYYY h:mm A z');
html += '<tr><td class="logDate">' + date + '</td><td>' + remark + '</td></tr>';
}
html = decodeString(html);
$("#logsLoading").hide();
$('#logNotesTable').show();
$('#logNotes').html(html);
lpq = responseData['lpq'];
setTimeout(setColumnHeights,500);
}
}
}
function decodeString(str) {
var string = "",
entities = {
nbsp : ' ',
amp : '&',
quot : '"',
lt : '<',
gt : '>'
};
$.each(entities, function(k,v) {
var re = new RegExp('&' + k + ';', 'g');
string = str.replace(re, v);
str = string;
});
return string;
}
function getEscalationLevel(ticket, silent) {
var t,
prefix,
text = 'Getting Current Escalation Level',
title = 'Escalation Error for ' + ticket.t,
levelHtml = '',
html = '',
params = {
t: ticketInfo.t,
st: ticketInfo.st,
cc: ticketInfo.cc,
sid: sID,
uid: uID
};
if (sessSource == 4) {
params.id = ticketData.id;
}
if(ticketInfo.ban) params.ban = ticketInfo.ban;
if(ticketInfo.cn) params.cn = ticketInfo.cn;
if(ticketInfo.source_sid) params.source_sid = ticketInfo.source_sid;
if(ticket.ticketType == 3){
t = ticket.wc + '' + ticket.t;
} else {
if (ticket.t != ticket.at) {
t = ticket.at;
} else {
t = ticket.t;
}
}
if (silent == 0) {
ajaxLoadingMessage(text);
} else {
$.unblockUI();
}
setTimeout(function() {
sendExpressRequest('../cgi-bin/status.pl','getEscalationLevel',params,silent,displayEscalationLevel,function (req,status,err) {
if (silent == 0) {
html = '<p>Unfortunately, we cannot escalate this ticket at this time.</p><p>For help escalating this ticket, contact your local maintenance center, the number can be found on your billing statement.</p>';
warningSubmissionAlert(html);
}
});
}, 1000);
}
function displayEscalationLevel(data, silent) {
$.unblockUI();
var responseData = data.RESPONSE;
var html = '',
levelHtml = '';
if (responseData.ESC_LEVEL == 0) {
levelHtml = 'No escalation level';
} else {
if (responseData.ESC_LEVEL == 1) {
levelHtml = '1st Level';
} else if (responseData.ESC_LEVEL == 2) {
levelHtml = '2nd Level';
} else if (responseData.ESC_LEVEL == 3) {
levelHtml = '3rd Level';
} else if (responseData.ESC_LEVEL == 4) {
levelHtml = '4th Level';
} else if (responseData.ESC_LEVEL == 5) {
levelHtml = '5th Level';
} else if (responseData.ESC_LEVEL == 6) {
levelHtml = '6th Level';
}
}
if (responseData.CAN_ESC == 0) {
if (silent == 1) {
if (responseData.ESC_LEVEL == 0) {
$('#escalationRow').hide();
} else if (responseData.ESC_LEVEL > 0) {
$('#escalationRow').show();
$('#escalationLevel').text(levelHtml);
}
} else if (silent == 0 && responseData.MINUTES > 0) {
var escMsg = (responseData.ESC_LEVEL) ? 'Current escalation level is: Level '+ responseData.ESC_LEVEL : '';
if(responseData.ESC_LEVEL > 0){
html = '<p>You can submit a ticket escalation request once an hour.</p><p>You may escalate in '+responseData.MINUTES+' minutes.</p><p>' + escMsg + '</p>';
} else if(responseData.ESC_LEVEL == 0){
html = '<p>A first level escalation may not occur until 1 hour after ticket creation.</p><p>You may escalate in '+ responseData.MINUTES + ' minutes.</p><p>' + escMsg + '</p>';
} else if(responseData.ESC_LEVEL == 6){
html = '<p>'+ escMsg + '. Escalation has reached the highest level that can be obtained (Level 6), no further escalation is necessary.</p>';
} else {
var minutes = responseData.MINUTES;
if(minutes > 60){
var hours = parseInt(minutes/60);
var remainingMinutes = minutes - (hours*60);
var message = hours + " hours and "+ remainingMinutes + " minutes.";
} else{
var message = minutes + " minutes.";
}
html = '<p>Unfortunately, we cannot escalate this ticket at this time.</p><p>You may submit a ticket escalation request in '+ message + '</p>';
}
$('#escalateTicketTitle').hide();
warningSubmissionAlert(html);
} else {
html = '<p>Unfortunately, we cannot escalate this ticket at this time.</p><p>' + escMsg + 'For help escalating this ticket, contact your local maintenance center, the number can be found on your billing statement.</p>';
warningSubmissionAlert(html);
}
setTimeout(setColumnHeights,500);
} else if (responseData.CAN_ESC == 1) {
if (silent == 1) {
if (responseData.ESC_LEVEL == 0) {
$('#escalationRow').hide();
} else if (responseData.ESC_LEVEL > 0) {
$('#escalationRow').show();
$('#escalationLevel').text(levelHtml);
}
} else {
$('#escalateTicketTitle').show();
ticketData.escalationLevel = responseData.ESC_LEVEL;
$('#escContainer').show();
$('#escLevel').text(responseData.ESC_LEVEL);
$('#incidentContainer').hide('fadeOut');
$('#formContainer').show('slide');
setTimeout(setFormColumnHeights, 500);
}
} else {
if (silent == 0) {
html = '<p>Unfortunately, we cannot escalate this ticket at this time.</p><p>For help escalating this ticket, contact your local maintenance center, the number can be found on your billing statement.</p>';
warningSubmissionAlert(html);
}
}
}
function updateTicket(submission) {
var valid = true,
btnAction = submission.action,
action = '',
params = {},
text = '',
html = '',
updateSuccess = '',
updateFailure = '',
updateType = '',
t = submission.t;
if (ticketInput.emmsTicketLink != 1) {
var c2,
c3 = valST(submission.st),
c4 = valSID(sID),
c5 = valUID(uID),
c6 = valL(submission.notes),
c7 = valWC(submission.wc ? submission.wc : ''),
c8 = valCC(submission.cc);
}
if (btnAction == 'escalateTicket') {
//escalateTicket(submission);
action = 'escalateTicket';
params = {
t: t,
st: submission.st,
cc: submission.cc,
sid: sID,
uid: uID,
name: submission.firstName + ' ' + submission.lastName,
phone: submission.phone,
ext: submission.ext,
email: submission.email,
l: submission.notes,
wc: submission.wc
};
text = 'Escalating Ticket';
updateSuccess = '<p>Escalated Ticket Successfully</p>';
updateFailure = '<p>Escalate Ticket Failure</p>';
updateType = 'escalating ticket.'
} else if (btnAction == 'addLogNote') {
action = 'sendLogs';
params = {
t: t,
st: submission.st,
cc: submission.cc,
sid: sID,
uid: uID,
name: submission.firstName + ' ' + submission.lastName,
phone: submission.phone,
ext: submission.ext,
email: submission.email,
l: submission.notes,
wc: submission.wc
};
text = 'Sending Log Notes';
updateSuccess = '<p>Updated Log Notes Successfully</p>';
updateFailure = '<p>Add Log Notes Failure</p>';
updateType = 'adding log notes.'
} else if (btnAction == 'addCallSamples') {
action = 'sendCallSamples';
params = {
t: t,
st: submission.st,
cc: submission.cc,
sid: sID,
uid: uID,
name: submission.firstName + ' ' + submission.lastName,
phone: submission.phone,
ext: submission.ext,
email: submission.email,
l: submission.notes,
wc: submission.wc
};
if(params.l == ''){
//Make sure to construct call samples log before submitting
params.l = constructCallSamples(callSamplesArray);
}
text = 'Adding Call Samples';
updateSuccess = '<p>Updated Call Samples Successfully</p>';
updateFailure = '<p>Add Call Samples Failure</p>';
updateType = 'adding call samples.'
} else if (btnAction == 'requestClosure') {
action = 'requestClosure';
params = {
t: t,
st: submission.st,
cc: submission.cc,
sid: sID,
uid: uID,
name: submission.firstName + ' ' + submission.lastName,
phone: submission.phone,
ext: submission.ext,
email: submission.email,
l: submission.notes,
wc: submission.wc
};
text = 'Submitting Closure Request';
updateSuccess = '<p>Closure Request Successful</p>';
updateFailure = '<p>Closure Request Failed</p>';
updateType = 'requesting closure.';
} else if (btnAction == 'contestClosure') {
action = 'contestClosure';
params = {
t: t,
st: submission.st,
cc: submission.cc,
sid: sID,
uid: uID,
name: submission.firstName + ' ' + submission.lastName,
phone: submission.phone,
ext: submission.ext,
email: submission.email,
l: submission.notes,
wc: submission.wc,
createdDate: submission.createdDate
};
if (submission.rstd) {
params.rstd = submission.rstd;
}
text = '<p>Submitting Contest Closure Request</p>';
updateSuccess = '<p>Contest Closure Successful</p>';
updateFailure = '<p>Contest Closure Failed</p>';
updateType = 'contesting closure.';
} else if(btnAction == 'generatePIN'){
action = 'generatePIN';
params = {
t: submission.at,
st: submission.st,
cc: submission.cc,
sid: sID,
uid: uID,
name: submission.firstName + ' ' + submission.lastName,
phone: submission.phone,
ext: submission.ext,
email: submission.email,
l: submission.notes,
wc: submission.wc,
createdDate: submission.createdDate,
ot: submission.t,
};
text = '<p>Submitting Generate PIN Request</p>';
updateSuccess = '<p>PIN Generated Successful</p>';
updateFailure = '<p>PIN Generatiom Failed</p>';
updateType = 'generate PIN.';
}
if (submission.t != submission.at) {
t = submission.at;
c2 = valT(t);
params.t = t;
} else {
t = submission.t;
c2 = valT(t);
params.t = t;
}
if (submission.cc == "USA" && (!submission.ban && !submission.cn && ticketInput.emmsTicketLink == 0)) {
if (!c3) {
warningSubmissionAlert('<p>Data Validation Failure</p><p>There was an issue validating the data submitted. Please check the input and try again.</p>');
valid = false;
}
}
if(submission.ban) params.ban = submission.ban;
if(submission.cn) params.cn = submission.cn;
if (params.ext != '') {
params.phone = params.phone + ' x' + params.ext;
}
if (sessSource == 4) {
params.id = ticketData.id;
}
if(typeof ticketInfo.pin !== 'undefined' || typeof ticketData.pin !== 'undefined'){
var validatePinParams;
validatePinParams = {
ticketNumber: ticketInfo.t,
ticketInfoPin: ticketInfo.pin,
ticketDataPin: ticketData.pin,
}
// the submit button is not picking up the ajax loader, its hanging for few seconds and then start loading - will fix this after release.
//valid = validatePin(validatePinParams);
}
if (valid && (btnAction == 'addLogNote' || btnAction == 'requestClosure' || btnAction == 'contestClosure' || btnAction == 'escalateTicket' || btnAction == "addCallSamples" || btnAction == "generatePIN")) {
ajaxLoadingMessage(text);
if (ticketInput.emmsTicketLink == 1) {
params.emmsTicketLink = 1;
}
sendExpressRequest('../cgi-bin/status.pl', action, params, null, function (data) {
$.unblockUI();
if (btnAction == 'escalateTicket') {
if (data.STATUS == 0) {
if (data.ERR) {
var minutes = data.MINUTES;
if (minutes > 60) {
var hours = parseInt(minutes / 60);
var remainingMinutes = minutes - (hours * 60);
var message = hours + " hours and " + remainingMinutes + " minutes.";
} else {
var message = minutes + " minutes.";
}
html = '<p>Unfortunately, we cannot escalate this ticket at this time.</p><p>You may submit a ticket escalation request in ' + message + '</p>';
} else {
html = '<p>Unfortunately, we cannot escalate this ticket at this time.</p><p>For help escalating this ticket, contact your local maintenance center, the number can be found on your billing statement.</p>';
}
warningSubmissionAlert(html);
closeAlert('successMessage');
} else {
level = parseInt(submission.lvl);
ticketRefresh = {
t: submission.t,
cc: submission.cc,
st: submission.st
};
level = level + 1;
html = '<p>Successful Escalation to level ' + level + '</p>';
successfulSubmissionAlert(html);
refreshTicket(submission, 1);
closeAlert('warningMessage');
}
} else if (btnAction == 'addLogNote') {
if (data.STATUS == 1) {
successfulSubmissionAlert(updateSuccess);
refreshTicket(submission, 1);
closeAlert('warningMessage');
} else {
warningSubmissionAlert(updateFailure + '<p>There was an issue related to log notes for this ticket. Close this window and you can try your request again.</p>');
closeAlert('successMessage');
}
} else if (btnAction == 'addCallSamples'){
if (data.STATUS == 1) {
successfulSubmissionAlert(updateSuccess);
refreshTicket(submission, 1);
$('#callSampleContainer').empty();
callSampleIndex = 0;
callSampleProvided = 1;
$('#callSamplesForm').hide();
$('#callSamplesProvided').show();
} else {
warningSubmissionAlert(updateFailure + '<p>There was an issue related to add call samples for this ticket. Close this window and you can try your request again.</p>');
$('#callSampleContainer').empty();
callSampleIndex = 0;
}
} else if(btnAction == "generatePIN"){
if (data.STATUS == 1) {
successfulSubmissionAlert(updateSuccess);
refreshTicket(submission, 1);
closeAlert('warningMessage');
$('#generatePINButton').hide();
} else {
warningSubmissionAlert(updateFailure + '<p>There was an issue related to generate PIN for this ticket. Close this window and you can try your request again.</p>');
closeAlert('successMessage');
}
} else {
if (data.STATUS == 1) {
successfulSubmissionAlert(updateSuccess);
refreshTicket(submission, 0);
closeAlert('warningMessage');
} else {
if (btnAction == 'requestClosure') {
warningSubmissionAlert(updateFailure + '<p>There was an issue with the Request Ticket Closure Request. Close this window and you can try your request again.</p>');
} else {
warningSubmissionAlert(updateFailure + '<p>There was an issue with the Contest Ticket Closure Request. Close this window and you can try your request again.</p>');
}
closeAlert('successMessage');
}
}
}, function (req, err, status) {
$.unblockUI();
warningSubmissionAlert('<p>Ticket Update Failure</p><p>Ticket update failed for ' + updateType, '</p>');
closeAlert('successMessage');
});
}
}
/* Status Functions for Express Ticketing Application */
function getMaintenance() {
sendExpressRequest('../cgi-bin/express.pl','getMaintenance',{},null,function(data) {
var response = data.DATA;
if (response.active == 1 && response.isFullDown == 1) {
outage = 2;
//systemMaintenance();
} else if (response.active == 1 && response.isFullDown == 0) {
outage = 1;
var startDate = moment(response.startday).format("MMMM D, YYYY"),
startTime = moment.tz(response.startday,timezoneSetOffset).format('hh:mm A'),
endDate = moment(response.endday).format('MMMM D, YYYY'),
endTime = moment.tz(response.endday,timezoneSetOffset).format('hh:mm A');
$('#startDate').html(startDate);
$('#startTime').html(startTime);
$('#endDate').html(endDate);
$('#endTime').html(endTime);
//systemMaintenance();
}
systemMaintenance();
},function(req,status,err) {});
}
function systemMaintenance() {
if (outage == 0 && ticketStatus == 0) {
$('.appText').html('Ticket Status for <span id="ticketNumber"></span>');
if (ticketInfo.t) {
$('#ticketNumber').text(ticketInfo.t);
}
$('#standardOutages').hide();
$('#fullOutage').hide();
$('#statusErrorContainer').hide();
if (!$('#formContainer').is(':visible')) {
$('#incidentContainer').show();
}
$('#logsStatusForm').show();
} else if (outage == 0 && ticketStatus == 1) {
if (!window.opener) {
document.location = '/expressticketing/index.html';
$('#ticketStatusForm').hide();
//$('#browserWindow').show();
//$('#reloadPageMessage').hide();
//$('#lookupFailure').hide();
//$('.appText').text('AT&T Express Ticketing Status Application');
} else if (window.opener.reloadVar && window.opener.reloadVar == 1) {
$('#reloadPageMessage').show();
$('.appText').text('AT&T Express Ticketing Status Application');
$('#lookupFailure').hide();
$('#browserWindow').hide();
} else {
$('#lookupFailure').show();
$('#reloadPageMessage').hide();
$('#browserWindow').hide();
$('.appText').text('Ticket Lookup Failed');
document.title = 'Ticket Lookup Failed';
}
if (!window.opener) {
ajaxLoadingMessage('Loading Express Ticketing....');
$('#ticketStatusForm').hide();
} else {
$('#standardOutages').hide();
$('#fullOutage').hide();
$('#incidentContainer').hide();
$('#formContainer').hide();
$('#logsStatusForm').hide();
if (ticketStatusCount === 1){
$('#ticketLockedFailed').show();
$('#statusErrorContainer').hide();
}else{
$('#statusErrorContainer').show();
}
}
} else if (outage ==0 && ticketStatus == 2) {
$('#standardOutages').hide();
$('#fullOutage').hide();
$('#incidentContainer').hide();
$('#formContainer').hide();
$('#logsStatusForm').hide();
$('#statusErrorContainer').hide();
$('#statusMaxFailures').show();
} else if (outage == 1 && ticketStatus == 0) {
$('.appText').html('Ticket Status for <span id="ticketNumber"></span>');
if (ticketInfo.t) {
$('#ticketNumber').text(ticketInfo.t);
}
$('#standardOutages').show();
$('#fullOutage').hide();
$('#statusErrorContainer').hide();
if (!$('#formContainer').is(':visible')) {
$('#incidentContainer').show();
}
$('#logsStatusForm').show();
} else if (outage == 1 && ticketStatus == 1) {
$('#standardOutages').show();
$('#fullOutage').hide();
$('#incidentContainer').hide();
$('#formContainer').hide();
$('#logsStatusForm').hide();
$('#statusErrorContainer').show();
} else if (outage == 2) {
$('#standardOutages').hide();
$('#fullOutage').show();
$('#incidentContainer').hide();
$('#formContainer').hide();
$('#logsStatusForm').hide();
$('#statusErrorContainer').hide();
}
setTimeout(setColumnHeights,500);
}
function sendExpressRequest(sURL, sActionToTake, criteriaData,booleanVar,onSuccessCallback, onErrorCallback) {
//Set the action to be the passed in sActionToTake value
var requestData = new Object();
requestData['action'] = sActionToTake;
if (criteriaData) {
//If there was criteriaData present, extend it into the requestData object
$.extend(requestData, criteriaData);
}
$.ajax({
url: sURL,
data: (requestData),
dataType: 'json',
type: 'POST',
async: true,
timeout: 180000,
success: function (data) {
if (typeof (onSuccessCallback) === typeof (Function)) {
if (booleanVar != null) {
onSuccessCallback(data,booleanVar);
} else {
onSuccessCallback(data);
}
}
},
error: function (request, status, err) {
if (typeof (onErrorCallback) === typeof (Function)) {
onErrorCallback(request, status, err);
}
$.unblockUI();
}
});
}
function sendRequestFailure(request, status, err) {
$.unblockUI();
ticketStatus = 1;
systemMaintenance();
}
function setColumnHeights() {
var leftColHeight = $('#incident').height();
$('#buttons').css('min-height', leftColHeight + 'px');
if ($('#saasRefreshContainer').is(':visible')) {
var tHeight = $('#saasRefreshContainer').height() + $('#ticketStatusForm').height();
$('#logsStatusForm').css('top', tHeight + 5);
} else {
$('#logsStatusForm').css('top', $('#ticketStatusForm').height() + 5);
}
}
function setFormColumnHeights() {
var leftColHeight = $('#mainGateInfo').height(),
rightColHeight = $('#ettxLogForm').height();
if (leftColHeight > rightColHeight) {
$('#ettxLogForm').height(leftColHeight).children().height(leftColHeight);
} else {
$('#mainGateInfo').height(rightColHeight).children().height(rightColHeight);
}
}
function closeAlert (alert) {
if (alert == 'warningMessage') {
var html = '<div id="warning" class="alert alert-danger alert-dismissible alertStyle" role="alert"></div>';
$('#warningContainer').hide();
$('#warningContainer > div').html(html);
setColumnHeights();
$('#warning').on('closed.bs.alert', function () {
closeAlert('warningMessage');
});
} else if (alert == 'successMessage') {
var html = '<div id="successful" class="alert alert-success alert-dismissible alertStyle" role="alert"></div>';
$('#successfulContainer').hide();
$('#successfulContainer > div').html(html);
setColumnHeights();
$('#successful').on('closed.bs.alert', function() {
closeAlert('successMessage');
});
} else if (alert == 'saasRefresh') {
var html = '<div id="saasPleaseRefresh" class="alert alert-info alertStyleInfo alert-dismissible" role="alert"><p>Please click the "Refresh Ticket" button periodically for the latest status updates.<button type="button" class="close" data-dismiss="alert" aria-label="Close" style="top: -14px;"><span aria-hidden="true">&times;</span></button></p></div>';
$('#saasRefreshContainer').hide();
$('#saasRefreshContainer > div > div').html(html);
$('#saasPleaseRefresh').on('closed.bs.alert', function() {
closeAlert('saasRefresh');
});
}
}
function successfulSubmissionAlert(html) {
var baseHTML = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><img src="images/green-success.png" width="50" alt="AT&T Express Ticketing Warning" class="pull-left" />';
baseHTML += html;
$('#successful').html(baseHTML);
$('#successfulContainer').show();
}
function warningSubmissionAlert(html) {
var baseHTML = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><img src="images/warning.png" width="50" alt="AT&T Express Ticketing Warning" class="pull-left" />';
baseHTML += html;
$('#warning').html(baseHTML);
$('#warningContainer').show();
}
function checkTimer(data) {
$.unblockUI();
if (data.STATUS == 0) {
warningSubmissionAlert('<p>Chat Failed for' + ticketInfo.t + '</p>');
} else if (data.RESPONSE['cc'] == 1) {
isilchat = 1;
if (chatAvail == 1) {
tcChatEnabled = 1;
unit = ticketData.lpq;
inqCustData.tcChatEnabled = tcChatEnabled;
inqCustData.Unit = unit;
//Inq.reinitChat();
Inq.fireCustomEvent('reloadFrmwk');
$('#chatNow_' + number).attr('livechat', 1);
setTimeout(function () {
$('#inqTestDiv').hide();
inqFrame.Inq.C2CM.agrty(0);
sendExpressRequest('../cgi-bin/express.pl','endSessionStartLivePerson',{uid:uID,sid:sID,skill:unit},null,function(data) {},function(req,status,err) {});
return false;
}, 750);
}
} else {
var arrTime = data.RESPONSE['cw'].split(":"),
hrsPart = (arrTime[0] == 0) ? "" : arrTime[0] + ' hour and ',
html = '<p>We\'re working to diagnose the issue reported. This process can take up to 2 hours to complete.</p>' + '<p>You have ' + hrsPart + arrTime[1] + ' minutes until you can chat with a live AT&amp;T Express Ticketing agent.</p>';
warningSubmissionAlert(html);
}
}
/* Utility Functions for Express Ticketing Application */
if ( !Date.prototype.toISOString ) {
( function() {
function pad(number) {
if ( number < 10 ) {
return '0' + number;
}
return number;
}
Date.prototype.toISOString = function() {
return this.getUTCFullYear() +
'-' + pad( this.getUTCMonth() + 1 ) +
'-' + pad( this.getUTCDate() ) +
'T' + pad( this.getUTCHours() ) +
':' + pad( this.getUTCMinutes() ) +
':' + pad( this.getUTCSeconds() ) +
'.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
'Z';
};
}() );
}
function createSessionID() {
// http://www.ietf.org/rfc/rfc4122.txt
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
sID = s.join("");
var cookie = $.cookie('attESHr');
if(cookie != null){
var cookieArr = cookie.split('|');
attESHr = cookieArr[0]+"|"+cookieArr[1]+"|"+cookieArr[2];
}
}
function createUID(browser) {
// http://www.ietf.org/rfc/rfc4122.txt
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
uID = s.join("");
if(browser == 1){
$.cookie('uID', uID, {expires: 1500});
} else{
localStorage.uID = uID;
}
}
function startSession() {
sendExpressRequest('../cgi-bin/express.pl','startSession',{uid: uID, sid: sID, sS: sessSource, attESHr: attESHr, device: browserInfo},null,
function(data){
if (data.STATUS == 1) {
startSess = 1;
}
},
function(req,status,err) {});
}
function endSession(flowType) {
sendExpressRequest('../cgi-bin/express.pl','endSession',{uid: uID, sid: sID, flow_type: flowType},null,function(data){},function(req,status,err) {});
}
function valSID(sid) {
if(sid.length == 36) {
return true;
}
return false;
}
function valUID(uid) {
if(uid.length == 36) {
return true;
}
return false;
}
function valST(st) {
if(st.length == 0 || st.length > 2) {
return false;
}
return true;
}
function valCC(cc) {
if(cc.length == 0 ) {
return false;
}
return true;
}
function valT(t) {
if(t.length == 0 || t.length > 15) {
return false;
}
return true;
}
function valP(p) {
if(p.length > 0) {
if(p.length != 6) {
return false;
}
return true;
}
return false;
}
function valL(l) {
if(l.length > 0) {
if(l.length > 300) {
return false;
}
return true;
}
return false;
}
function valWC(wc) {
if(wc.length > 3)
return false;
return true;
}
function cleanString(str){
str = str.replace('&','&amp;'); // &
str = str.replace('<','&lt;'); // <
str = str.replace('>','&gt;'); // >
str = str.replace('^','&#94;'); // ^
return(str);
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validatePhone(phone) {
if (phone.match(/\d/g) == null) {
return false;
} else if (phone.match(/\d/g).length >= 10) {
return true;
} else {
return false;
}
}
function validateTicketNumber(ticketNumber) {
var ticketLength = ticketNumber.length,
valid = 0;
if (ticketLength == 8) {
var regex = /[A-Za-z]{2}/;
valid = (ticketNumber.match(regex)) ? 1 : 0;
} else if (ticketLength == 9) {
var regex = /[1-9]{1}/;
valid = (ticketNumber.match(regex)) ? 1 : 0;
} else if (ticketLength == 15) {
var regex = /^0{6}[1-9]{1}/m;
valid = (ticketNumber.match(regex)) ? 1 : 0;
}
return valid;
}
function validateStatusSubmission(ticketInput) {
var ticketNumber = ticketInput.t,
ticketLength = ticketNumber.length,
ticketCountry = ticketInput.cc,
ticketState = ticketInput.st,
ban = ticketInput.ban,
cn = ticketInput.cn,
valid = 0;
if ((ticketCountry == 'USA' && ticketState != '') || (ticketCountry != 'USA' && ticketState == '')) {
if (ticketLength == 8) {
var regex = /[A-Za-z]{2}/;
valid = (ticketNumber.match(regex)) ? 1 : 0;
} else if (ticketLength == 9) {
var regex = /[1-9]{1}/;
valid = (ticketNumber.match(regex)) ? 1 : 0;
} else if (ticketLength == 15) {
var regex = /^0{6}[1-9]{1}/m;
valid = (ticketNumber.match(regex)) ? 1 : 0;
}
} else if(ban != undefined && ban != '' && cn != undefined && cn != ''){
var tn_regex = /^(?:\d{9}|\d{15})$/;
var ban_regex = /\w+/;
var cn_regex = /^\d+$/;
valid = (
ticketNumber.match(tn_regex) &&
ban.match(ban_regex) &&
cn.match(cn_regex)
) ? 1 : 0;
}
//If pin number is checked as yes and empty value provided OR Not input provided.
if (($('#chkYes').is(':checked') && ticketInput.pin == '') || (!$('#chkYes').is(':checked') && !$('#chkNo').is(':checked'))){
valid = 0;
}
return valid;
}
function textCounter(field,cntfield,maxlimit) {
if ($('#'+field).html().length > maxlimit){
$('#'+field).html($('#'+field).html().substring(0, maxlimit));
}
else {
$('#'+cntfield).html($('#'+field).val().length);
}
}
function modalPixelWidth(html) {
var strLength = html.length,
totalPX = strLength * 12,
width;
if (totalPX < 600) {
width = totalPX + 4;
} else {
width = 600;
}
return width;
}
function ajaxLoadingMessage(text) {
var width = modalPixelWidth(text),
screen = $(document).width();
if (width < 300) {
width = 300
}
$.blockUI({
message: '<p style="font-size: 16px;">' + text + '</p><p style="font-size: 12px;">Please Wait <img src="images/ajax_loader.gif" alt="Please Wait" width="20" style="vertical-align: middle;" /></p>',
css: {
padding: '15px',
width: width + 'px',
top: '40%',
left: (screen/2) - (width/2),
textAlign: 'center',
color: '#888',
border: '1px solid #aaa',
borderRadius: '6px',
boxShadow: '5px 5px 5px #555',
backgroundColor:'#fff',
cursor: 'wait'
}
});
}
function setTimezone(offset) {
var determineTimezone = jstz.determine(),
timezoneName = determineTimezone.name(),
tempTimezoneObject = {},
tzOffset = Number(offset);
if (daylightSavings == true) {
if (offset < 0) {
tempTimezoneObject.offset = tzOffset + 60;
} else {
tempTimezoneObject.offset = tzOffset - 60
}
tempTimezoneObject.name = timezoneName;
} else {
tempTimezoneObject.offset = tzOffset;
tempTimezoneObject.name = timezoneName;
}
return tempTimezoneObject.name;
}
function getCountryFromTZ(tz) {
$.each(countries, function (country, val) {
if (val.multipleTZs == true) {
$.each(val.timezones, function(zone, v) {
if (v.tz == tz) {
countrySelected = country;
}
});
} else {
if (val.tz == tz) {
countrySelected = country;
}
}
});
}
function setTimezoneList(country) {
var c = countries[country],
html = '',
htmlArray = ['<option id="selectTZ" style="display: none;">Select Timezone</option>'];
if (c.multipleTZs == false) {
html = '<option value="' + c.offsetMinutes + '" offset="' + c.offsetHours + '" tz="' + c.tz + '">' + c.tzFriendly + '</option>';
} else {
$.each(c.timezones, function(tz, val) {
html = '';
html = '<option value="' + val.offsetMinutes + '" offset="' + val.offsetHours + '" tz="' + val.tz + '">' + val.tzFriendly + '</option>';
htmlArray.push(html);
});
html = htmlArray.join('');
}
return html;
}
function timezoneLocalStorage(setting) {
if (setting == 'setTZInfo') {
if (window.localStorage && document.documentMode != 7) {
localStorage.tzCountry = countrySelected;
localStorage.timezone = timezoneSetOffset;
} else {
$.cookie('tzCountry', countrySelected, {expires : 1500});
$.cookie('timezone', timezoneSetOffset, {expires : 1500});
}
} else if (setting == 'getTZInfo') {
if (window.localStorage && document.documentMode != 7) {
if (localStorage.getItem('timezone') != null || localStorage.getItem('tzCountry') != null) {
userObject.tzSettings = {};
userObject['tzSettings']['tzCountry'] = localStorage.tzCountry;
userObject['tzSettings']['timezone'] = localStorage.timezone;
}
} else {
if ($.cookie('timezone') != null || $.cookie('tzCountry') != null) {
userObject.tzSettings = {};
userObject['tzSettings']['tzCountry'] = $.cookie('tzCountry');
userObject['tzSettings']['timezone'] = $.cookie('timezone');
}
}
}
}
function createCookiesIfDNE(){
//if cookie doesnt exist create it
if(! $.cookie('lconFirstName')){$.cookie('lconFirstName', '', {expires: 1500});}
if(! $.cookie('lconLastName')){$.cookie('lconLastName', '', {expires: 1500});}
if(! $.cookie('lconPhone')){$.cookie('lconPhone', '', {expires: 1500});}
if(! $.cookie('lconEmail')){$.cookie('lconEmail', '', {expires: 1500});}
if(! $.cookie('lconExt')){$.cookie('lconExt', '', {expires: 1500});}
if(! $.cookie('primaryContactFirstName')){$.cookie('primaryContactFirstName', '', {expires: 1500});}
if(! $.cookie('primaryContactLastName')){$.cookie('primaryContactLastName', '', {expires: 1500});}
if(! $.cookie('primaryContactPhone')){$.cookie('primaryContactPhone', '', {expires: 1500});}
if(! $.cookie('primaryContactEmail')){$.cookie('primaryContactEmail', '', {expires: 1500});}
if(! $.cookie('primaryContactExt')){$.cookie('primaryContactExt', '', {expires: 1500});}
}
function changeText(inputElem,outputElem,button) {
$('#' + inputElem).unbind('keyup');
$('#' + outputElem).html($('#' + inputElem).val());
$('#' + inputElem).on('keyup', function(e) {
if (e.keyCode == 13) {
$('.' + button).trigger('click');
}
var textVal = $('#' + inputElem).val();
$('#' + inputElem).val(textVal.toUpperCase());
$('#' + outputElem).html(textVal.toUpperCase());
});
}
function prepVariableValidation(){
$('.statusField').hide();
$('.statusField').children('input, select').prop('disabled', true);
}
function getValidationType(ticketNumber){
var criteria = {'t': ticketNumber};
ajaxLoadingMessage('Loading Validation...');
sendExpressRequest('../cgi-bin/status.pl','getValidationType', criteria, null, validationFormSetup,null);
}
function validationFormSetup(data){
$('#not_found_alert_div').hide();
$('.statusField').hide();
if(window.ticketInput['t']){
$('#statusT').val(window.ticketInput['t']);
$('#statusT').prop('disabled', true);
$('#statusT').closest('.statusField').show();
}
var inputs;
switch (data.VALIDATION_TYPE) {
case 'cn':
inputs = '#ban_field, #cn_field';
break;
default:
inputs = '#statusState, #statusCountry';
break;
}
$(inputs).prop('disabled', false);
$(inputs).closest('.statusField').show();
$('#statusErrorContainer').show();
$.unblockUI();
}
function addBVOIPDiv(callingNum, calledNum, bvoiptime, bvoipCallType) {
var html = '';
html = '<div id="" class="panel panel-default">';
html += '<div class="panel-heading clearfix">';
html += '<h4 class="panel-title pull-left" style="padding-top: 5px;">';
html += '<a data-toggle="collapse" href="#callAccordion_' + callSampleIndex + '">';
html += 'Call Sample ';
html += '</a>';
html += '</h4>';
html += '<button class="deleteCallSample btn btn-default btn-sm btn-danger pull-right" callsampleid="' + callSampleIndex + '">Delete</button>';
html += '</div>';
html += '<div id="callAccordion_' + callSampleIndex + '" class="panel-collapse collapse">';
html += '<div class="panel-body">';
html += '<p><b>Calling From: </b>' + callingNum + '<br />';
html += '<b>Calling To: </b>' + calledNum + '<br />';
html += '<b>Date/Time: </b>' + bvoiptime + '<br />';
html += '<b>Call Type: </b>' + bvoipCallType + '<br />';
html += '</div>';
html += '</div>';
html += '</div>';
return html;
}
//Construct the call samples log before submit
function constructCallSamples(callSamples) {
var cs_log = '';
$.each(callSamples, function (index, value) {
cs_log += 'SAMPLE ' + parseInt(index+1) + '\n\tCalling From: ' + callSamples[index]['callingNum'] + '\n\tCalling To: ' + callSamples[index]['calledNum'] +
'\n\tDate/Time: ' + callSamplesArray[index]['bvoipDate'] + '\n\tCall Type: ' + callSamplesArray[index]['bvoipCallTypeInput'] + '\n';
});
return cs_log;
}
function clearCallSamplesForm() {
$('#callingNumber').val('').parent().removeClass('has-error').removeClass('has-success');
$('#calledNumber').val('').parent().removeClass('has-error').removeClass('has-success');
$('#callDateTime').val('').parent().removeClass('has-error').removeClass('has-success');
$('#callType').parent().removeClass('has-error').removeClass('has-success');
}
function ShowHideDiv() {
var chkYes = document.getElementById("chkYes");
var dvtext = document.getElementById("dvtext");
dvtext.style.display = chkYes.checked ? "block" : "none";
}
function ShowHideDivForROEP() {
var chkYes = document.getElementById("chkROEPYes");
var dvtext = document.getElementById("dvtextForROEP");
dvtext.style.display = chkYes.checked ? "block" : "none";
if($('#chkROEPNo').is(':checked')){
$('#ROEPlogForm').show();
document.getElementById("ROEPlogForm").style.display = 'table';
}else{
$('#ROEPlogForm').hide();
}
$('#ROEP-submit').on('click', function(e) {
if($('#chkROEPYes').is(':checked')){
if($('#pinROEPNumber').val().match(/\d/g).length != 6){
return false;
}
ticketData.pin = $('#pinROEPNumber').val();
ticketInfo.pin = $('#pinROEPNumber').val();
var ticket = {
t: ticketData.t,
cc: ticketData.cc,
st: ticketData.st,
wc: ticketData.wc,
pin: ticketData.pin,
at: ticketData.at,
ot: ticketInfo.pin //original ticket number
};
$('#reqOrEnterPinModel').modal('hide');
$('#generatePINButton').hide();
refreshTicket(ticket,0);
}else{
ticketData.pin = undefined;
var valid = 0,
fisrtName = $('#ROEPlogFirstName').val();
lastName = $('#ROEPlogLastName').val();
email = $('#ROEPlogEmail').val();
phone = $('#ROEPlogPhoneNumber').val();
extension = $('#ROEPlogExtension').val();
submission = {
action: 'generatePIN',
t: ticketInfo.t,
cc: ticketInfo.cc,
st: ticketInfo.st,
wc: ticketData.wc,
at: ticketData.at,
pin: ticketData.pin,
ticketType: ticketData.ticketType,
firstName: $('#ROEPlogFirstName').val(),
lastName: $('#ROEPlogLastName').val(),
phone: $('#ROEPlogPhoneNumber').val(),
ext: $('#ROEPlogExtension').val(),
email: $('#ROEPlogEmail').val(),
notes: '',
lvl: ticketData.escalationLevel ? ticketData.escalationLevel : 0,
createdDate: ticketData.created
};
if (ticketTypeID == 3) {
submission.rstd = ticketData.rstd;
}
if (fisrtName.match(/[a-zA-z]/g) == null) {
$('#ROEPlogFirstName').parent().addClass('has-error').removeClass('has-success');
} else {
$('#ROEPlogFirstName').parent().removeClass('has-error').addClass('has-success');
}
if (lastName.match(/[a-zA-z]/g) == null) {
$('#ROEPlogLastName').parent().addClass('has-error').removeClass('has-success');
} else {
$('#ROEPlogLastName').parent().removeClass('has-error').addClass('has-success');
}
if (validateEmail(email) == false) {
$('#ROEPlogEmail').parent().addClass('has-error').removeClass('has-success');
} else {
$('#ROEPlogEmail').parent().removeClass('has-error').addClass('has-success');
}
if (validatePhone(phone) == false) {
$('#ROEPlogPhoneNumber').parent().addClass('has-error').removeClass('has-success');
} else {
$('#ROEPlogPhoneNumber').parent().removeClass('has-error').addClass('has-success');
}
if ($('#ROEPlogForm').find('.has-error').length == 0) {
valid = 1;
}
if(ticketInput.ban) submission.ban = ticketInput.ban;
if(ticketInput.cn) submission.cn = ticketInput.cn;
if (valid == 1) {
$('#reqOrEnterPinModel').modal('hide');
updateTicket(submission);
}
setTimeout(setColumnHeights,500);
}
});
}
function validatePin(validatePinParams){
var flag=true;
$.ajax({
type: 'POST',
url: '../cgi-bin/search.pl',
data: ({
action: 'validatePIN',
ticketNumberForValidation: validatePinParams.ticketNumber,
ticketInfoPin: validatePinParams.ticketInfoPin,
ticketDataPin: validatePinParams.ticketDataPin,
}),
dataType: 'json',
async: false,
success: function(data) {
if(data.STATUS == 0){
// console.log(data);
warningSubmissionAlert('<p>There were security issues related to this ticket. Close this window and you can try your request again.</p>');
flag = false;
}
},
error: function(err, data) {
warningSubmissionAlert('<p>There were security issues related to this ticket. Close this window and you can try your request again.</p>');
flag = false;
}
});
return flag;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment