"use strict";
$('.mCustomScrollbar').mCustomScrollbar({
scrollButtons:{
enable:true
}
});
/**
* This object sets default values for popup modal
*/
var toastrOptions = {
timeOut: 15000,
closeButton: false,
positionClass: "toast-bottom-right"
};
/**
* This function shows the success (green) popup message on the screen
* @params {string} message - Success Message
*/
var successToastr = function successToastr(message) {
toastr.remove();
toastr.success(message, '', toastrOptions);
};
/**
* This function shows the information (blue) popup message on the screen
* @params {string} message - Information Message
*/
var infoToastr = function infoToastr(message) {
toastr.remove();
toastr.info(message, '', toastrOptions);
};
/**
* This function shows the error (red) popup message on the screen
* @params {string} message - Error Message
*/
var errorToastr = function errorToastr(message) {
toastr.remove();
toastr.error(message, '', toastrOptions);
};
/**
* This is an object that consists of various functions to handle the staff's responses to be displayed in offender's dashboard.
Forms and Activities gets filtered out and gets displayed on its respective view section. Status of forms are also displayed
*/
var StaffAction = {
show: "all",
// number_format : function(number, decimals, dec_point, thousands_point) {
// if (number == null || !isFinite(number)) {
// throw new TypeError("number is not valid");
// }
// if (!decimals) {
// var len = number.toString().split('.').length;
// decimals = len > 1 ? len : 0;
// }
// if (!dec_point) {
// dec_point = '.';
// }
// if (!thousands_point) {
// thousands_point = ',';
// }
// number = parseFloat(number).toFixed(decimals);
// number = number.replace(".", dec_point);
// var splitNum = number.split(dec_point);
// splitNum[0] = splitNum[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands_point);
// number = splitNum.join(dec_point);
// return number;
// },
addFine: function (type, data) {
var template;
console.log('fine data', data); // var amount = this.number_format(data.payment_amount, '2', '.', ',');
var commonTemplate = `
<div class="staff-response-box-wrap ${data.title}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Payment Acknowlegement
</h6>
`;
if (data.payment_status === 'due') {
template = `${commonTemplate}
<p class="text-black-50">
The ${data.title} has sent you payment request.
</p>
`;
if (data.action === 'deleted') {
template = `${template}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${template}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button title="View Details" type="button" class="btn btn-primary btn-sm js-fine-new-window" data-fine="${data.id}">
View Details
</button>
</div>
</div>
</div>
`;
} else {
template = `
${template}
<div class="text-right">
<button title="View Details" type="button" class="btn btn-primary btn-sm js-fine-new-window" data-fine="${data.id}">
View Details
</button>
</div>
</div>
</div>
`;
}
} else if (data.payment_status === 'disagree') {
template = `${commonTemplate}
<p class="text-black-50">
The ${data.title} has sent you payment request.
</p>
`;
if (data.action === 'deleted') {
template = `${template}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${template}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Disagreed to pay
</p>
</div>
</div>
</div>
`;
} else {
template = `
${template}
<div class="text-right">
<button title="View Details" type="button" class="btn btn-primary btn-sm js-fine-new-window" data-fine="${data.id}">
View Details
</button>
</div>
</div>
</div>
`;
}
} else {
template = `${commonTemplate}
<p class="text-black-50">
You have agree to pay fine on ${this.parseTime(data.updated_date)}
</p>
`;
if (data.action === 'deleted') {
template = `
${template}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${data.updated_date}
</p>
</div>
</div>
</div>
`;
} else {
template = `${template}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-success sm-font new-alert-box">
Agreed to pay
</p>
<button title="View Details" type="button" class="btn btn-primary btn-sm js-fine-new-window" data-fine="${data.id}">
View Details
</button>
</div>
</div>
</div>
`;
}
}
this.showUI(template, data.action, '#' + type + data.id);
},
addCompliance: function (type, data) {
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.title}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Compliance Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the compliance form.
<br>
<b>Note : </b>${data.note}
</p>
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info mr-2 sm-font new-alert-box">Deadline :${this.parseTime(data.deadline)} </p>
`;
if (data.status === 'signed') {
if (data.action === 'deleted') {
template = `${commonTemplate}
</div>
<div class="mt-3">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success sm-font new-alert-box">Signed</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
</div>
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success sm-font new-alert-box">Signed</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-compliance-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
;
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
</div>
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
</div>
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-compliance-window" data-id="${data.id}" title="Sign Compliance Form">
Sign Now
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<button type="button" class="btn btn-primary btn-sm my-0 js-compliance-window" data-id="${data.id}" title="Sign Compliance Form">
Sign Now
</button>
</div>
</div>
</div>
`;
}
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $('#offender-action-message').prepend(template)
// } else {
// $('#add_compliance' + data.id).removeAttr('class').empty().append(template)
// }
},
addProbation: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Probation Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the probation form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-probation-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-probation-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-probation-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addFBProbation: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Probation Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the probation form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-fb-probation-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-fb-probation-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-fb-probation-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addProIntake: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Intake Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the intake form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-pro-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-pro-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-pro-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id);
},
addFairIntake: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Intake Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the intake form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-fair-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-fair-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-fair-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id);
},
addEIntake: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
First Appointment Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the First Appointment form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-e-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-e-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-e-intake-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id);
},
addRecommendation: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
DUI Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the DUI form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-recommendation-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-recommendation-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-recommendation-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addRecklessDriving: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Reckless Driving Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the Reckless Driving form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-reckless-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-reckless-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-reckless-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addCriminalCase: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Criminal Case Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the Criminal Case form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-criminal-case-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-criminal-case-window" data-id="${data.id}" title="Sign Now">
Sign Now
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-criminal-case-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addCaseBindover: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Case Bindover Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the Case Bindover form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-bindover-case-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-bindover-case-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-bindover-case-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addPreTrail: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Pre Trial Form Received
</h6>
<p class="text-black-50">
The ${data.title} has sent you the Pre Trial form.
</p>
`;
if (data.status === 'incomplete') {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-pre-trial-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-pre-trial-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex mt-3" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">${data.status}</p>
<button type="button" class="btn btn-primary btn-sm my-0 js-pre-trial-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// $(template).prependTo('#offender-action-message').hide().slideDown(5000,'easeInQuad');
// //$('#offender-action-message').prepend(template);
// } else {
// $('#add_probation' + data.id).removeAttr('class').empty().append(template)
// }
},
addPlea: function (type, data) {
console.log(data.id);
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Plea Received
</h6>
<p class="text-black-50 text-capitalize">
${data.slug}'s decision: ${this.parsePleaAction(data.pd_choose)}.
</p>
</div>
</div>
`;
this.showUI(template, data.action, '#' + type + data.id); // if (update === '') {
// //$('#offender-action-message').prepend(template);
// $(template).prependTo('#offender-action-message').slideDown(5000,'easeInQuad');
// alert('');
// } else {
// $('#add_fine' + data.id).removeAttr('class').empty().append(template)
// }
},
addTransfer: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Transferred to the ${data.title}
</h6>
</div>
</div>
`;
$('#join_stop_video').hide();
localStorage.removeItem('LS_offender_staff_sessions_id');
localStorage.removeItem('LS_registration_info');
localStorage.removeItem('LS_staff_id');
$('#current-video-session').html("<div class='js-video-icon-toggle'><i class='fa fa-video-camera mr-2'></i> " + data.title + "</div>");
var isForm = false;
this.showUI(template, "new", '#' + type + data.id, isForm);
},
addPickup: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
Picked up by ${data.title}
</h6>
</div>
</div>
`;
$('#current-video-session').html("<div class='js-video-icon-toggle'><i class='fa fa-video-camera mr-2'></i> " + data.title + "</div>");
var isForm = false;
this.showUI(template, "new", '#' + type + data.id, isForm);
},
addVideoStarted: function (type, data) {
console.log(data);
console.log('vide ' + data.id);
console.log(type);
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
$('#join_stop_video').show(); //$('#join_stop_video').trigger('click')
///alert(session_info.video_started);
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
addVideoStop: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
$('#join_stop_video').hide();
localStorage.removeItem('LS_offender_staff_sessions_id');
localStorage.removeItem('LS_registration_info');
localStorage.removeItem('LS_staff_id');
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
addcloseCase: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
$("#offender_content").remove();
$('#join_stop_video').remove();
$('.nd-session-time').remove();
$('#current-video-session').remove();
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
addSessionStart: function (type, data) {
console.log(data.id);
console.log(type);
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
addCallStart: function (type, data) {
console.log(data.id);
console.log(type);
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="">
${data.message}
</h6>
</div>
</div>
`;
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
// addNoActivities: function () {
// var template = `
// <div class="staff-response-box-wrap " id="no-activity" >
// <div>
// </div>
// <div class="card new-card w-100 h-auto top-left-corner ml-2">
// <h6 class="">
// There are no activities at the moment.
// </h6>
// </div>
// </div>
// `;
// this.showUI(template, "added", '#');
// },
addCaseOnHold: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
this.showUI(template, "added", '#' + type + data.id);
},
addCaseOffHold: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
••••••••••••
</div>
</div>
`;
this.showUI(template, "added", '#' + type + data.id);
},
addNewSession: function (type, data) {
console.log(data);
var template;
var commonTemplate = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
`;
if (data.offender_auth === null) {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
</div>
</div>
`;
} else if (data.action === 'updated') {
template = `
${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-info sm-font new-alert-box">
Edited
</p>
<button type="button" class="btn btn-primary btn-sm js-new-session-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
} else {
template = `
${commonTemplate}
<div class="text-right">
<button type="button" class="btn btn-primary btn-sm js-new-session-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
} else {
if (data.action === 'deleted') {
template = `${commonTemplate}
<div class="">
<p class="alert alert-danger sm-font new-alert-box">
Deleted by the ${data.title} on ${this.parseTime(data.updated_date)}
</p>
</div>
<div class="mt-3">
<p class="alert alert-success new-alert-box sm-font text-capitalize">Complete</p>
</div>
</div>
</div>
`;
} else {
template = `${commonTemplate}
<div class="my-d-flex" style="justify-content: space-between;">
<p class="alert alert-success new-alert-box sm-font text-capitalize">Acknowledged</p>
<button type="button" class="btn btn-primary btn-sm js-new-session-window" data-id="${data.id}" title="View Document">
View Document
</button>
</div>
</div>
</div>
`;
}
;
}
this.showUI(template, data.action, '#' + type + data.id);
},
addEndSession: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
this.showUI(template, "added", '#' + type + data.id);
},
addJoinSession: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
$('#join_stop_video').show();
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
addLeftSession: function (type, data) {
var template = `
<div class="staff-response-box-wrap ${data.slug}" id="${type}${data.id}">
<div>
<div class="staff-response-box-time">
<i class="fa fa-clock-o fa-2x"></i>
</div>
<p class="sm-font text-center">
${this.parseTime(data.updated_date)}
</p>
</div>
<div class="card new-card w-100 h-auto top-left-corner ml-2">
<h6 class="text-capitalize">
${data.message}
</h6>
</div>
</div>
`;
$('#join_stop_video').show();
var isForm = false;
this.showUI(template, "added", '#' + type + data.id, isForm);
},
parseTime: function (datetime) {
console.log("data parsetime" + datetime);
var date = new Date(datetime + " UTC"); // var old_formatted_date= date.toLocaleTimeString(navigator.language, {
// timeZone: "America/New_York"
// },{hour: '2-digit', minute:'2-digit'}).replace(/:\d{2}\s/,' ');
// var formatted_date = moment.utc(datetime).tz('America/New_York').format('hh:mm A');
var formatted_date = datetime;
console.log("result formatted_date" + formatted_date); // console.log("old formatted_date"+old_formatted_date);
return formatted_date;
},
parsePleaAction: function (slug) {
switch (slug) {
case "plea_not_guilty":
return "plea not guilty";
break;
case "plea_guilty":
return "plea guilty";
break;
case "plea_nolo":
return "plea no-lo";
break;
case "reset_for_compliance":
return "reset for compliance";
break;
case "reset_for_trial":
return "reset for trial";
break;
default:
return "unknown";
break;
}
},
updateDOM: function (activities, display) {
// value of show = all or new
this.show = display;
$('.card').css("border", "1px solid #efefef");
console.log(activities); // $('#no-activity').remove()
var count = Object.keys(activities).length;
console.log("******************* length" + count);
// if (count > 0) {
// this.addNoActivities()
// $('#no-activity').remove();
// }
var counter = 0;
for (var key in activities) {
counter++;
console.log("key........................." + key);
var elem = activities[key];
console.log("action:" + elem.type);
switch (elem.type) {
case 'fine':
//this.addFine(elem.type, elem.activity, update = true)
this.addFine(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'compliance':
this.addCompliance(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'probation':
this.addProbation(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'fb_probation':
this.addFBProbation(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'pro_intake':
this.addProIntake(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'fairburn_intake':
this.addFairIntake(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'e_intake':
this.addEIntake(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'recommendation':
this.addRecommendation(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'reckless_driving':
this.addRecklessDriving(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'criminal_case':
this.addCriminalCase(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'case_bindover':
this.addCaseBindover(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'preTrial':
this.addPreTrail(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'plea':
console.log(elem.activity);
this.addPlea(elem.type, elem.activity); //alert('');
$('#no-form').remove();
break;
case 'transfer':
this.addTransfer(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'pickup':
this.addPickup(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'videoStart':
this.addVideoStarted(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'videoStop':
// this.addVideoStarted(elem.type, elem.activity)
this.addVideoStop(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'closeCase':
// $('.nd-queue-msg').hide()
// $('.video-preview').hide()
// $('#first-queue-position').hide()
var template = `<div class="centered-video-img" style="width: 75%;">
<h2 class="mb-3 text-center">
Thank you for using iCourt
</h2>
<h5 class="text-center">
${elem.activity.message}
</h5>
<div class="text-center">
<button class="btn btn-primary js-case-summary" data-id="${elem.activity.case_id}" title="View Case Summary">
View Case Summary
</button>
</div>
</div>`;
$('#first-queue-position').hide();
$('#video-preview').hide();
$('.js-centered-img-wrap').show().html(template);
if (windowWidth < 991) {
var windowHt = $(window).height();
var headerHt = $('.navbar.navbar-expand-lg').height();
var footerHt = $('.mbl-foot').outerHeight();
var headHt = headerHt + footerHt;
$('#test').css('height', windowHt - headHt);
$('.nd-video-wrap').css('height', windowHt - headHt);
}
$(window).unbind('beforeunload');
this.addcloseCase(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'sessionStart':
$('.nd-queue-msg').remove();
$('#no-activity').remove();
this.addSessionStart(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'conferenceCall':
this.addCallStart(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'caseHold':
this.addCaseOnHold(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'caseOffHold':
this.addCaseOffHold(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'newSession':
this.addNewSession(elem.type, elem.activity);
$('#no-form').remove();
break;
case 'caseEndSession':
this.addEndSession(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'joinSession':
this.addJoinSession(elem.type, elem.activity);
$('#no-activity').remove();
break;
case 'leftSession':
this.addLeftSession(elem.type, elem.activity);
$('#no-activity').remove();
break;
default:
alert('caught by default' + elem.type);
break;
}
}
},
showUI: function (template, action, container, isForm = true) {
//alert(this.show);
if (this.show === "all") {
if(isForm === true) {
$(template).prependTo('#offender-action-message');
}
else {
$(template).prependTo('#offender-activity-msg');
}
} else if (this.show === "new") {
switch (action) {
case "updated":
$(container).removeAttr('class').empty().append(template); // $(container).removeAttr('class').empty().append(template).hide().slideDown(500,'easeInQuad');
$(container + ' .card').css("border", "2px solid green"); //ashesh needs to work on this
break;
case "added":
//new-card
console.log('container ' + container);
if(isForm === true) {
$(template).prependTo('#offender-action-message').hide().slideDown(1000, 'easeInQuad');
}
else {
$(template).prependTo('#offender-activity-msg').hide().slideDown(1000, 'easeInQuad');
// $(template).prependTo('#offender-activity-msg');
}
$(container + ' .card').css("border", "2px solid green"); //alert('asdfadsf');
break;
case "deleted":
$(container).removeAttr('class').empty().append(template); // $(container).removeAttr('class').empty().append(template).hide().slideDown(500,'easeInQuad');
$(container + ' .card').css("border", "2px solid red");
break;
default:
if(isForm === true) {
$(template).prependTo('#offender-action-message').hide().slideDown(1000, 'easeInQuad');
}
else {
$(template).prependTo('#offender-activity-msg').hide().slideDown(1000, 'easeInQuad');
// $(template).prependTo('#offender-activity-msg');
}
// $(template).prependTo('#offender-action-message').hide().slideDown(1000, 'easeInQuad');
$(container + ' .card').css("border", "2px solid green");
break;
}
} // if (update === '') {
// //$('#offender-action-message').prepend(template)
// $(template).prependTo('#offender-action-message').css("border", "1px solid green").hide().slideDown(1000,'easeInQuad');
// } else {
// $(container).removeAttr('class').empty().append(template);
// //'#add_fine' + data.id
// }
}
}; //updateDOM();
var windowWidth = $(window).width();
window.addEventListener("resize", function(){
windowWidth = $(window).width();
});
/**
* This function handles the css of iframe
*/
var iframeControls = function iframeControls() {
var windowHt = $(window).height();
// var roadmapHt = $('.nd-body-right').height();
var headerHt = $('.nd-header-wrap').outerHeight()
if(windowWidth > 991) {
var bodyHt = $('.nd-body-wrap').outerHeight()
$('.js-iframe').css('height', bodyHt)
$('.js-iframe-wrap').css('height', bodyHt)
$('.js-iframe-wrap').css('top', headerHt)
$('#iframe_mbl_link').trigger('click')
}
else {
$('.js-iframe').css('height', windowHt - 37);
}
}; // Add smooth scrolling to all links
/**
* handle click event to scroll on specific section
*/
$("a#iframe_mbl_link").on('click', function (event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault(); // Store hash
var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 500, function () {// Add hash (#) to URL when done scrolling (default click behavior)
// window.location.hash = hash;
});
} // End if
});
/**
* open new window for fine payment
*/
$(document).on('click', '.js-fine-window', function () {
var _this = $(this);
var fineId = _this.data('fine');
$.get(base_url + "offender/get-fine/" + fineId, function (resp) {
var data = JSON.parse(resp);
var fineData = data.fine;
var formURL = base_url + '/offender/submit-fine/' + fineData.id;
var externalURL = data.court.payment_url;
var template = `
<div>
<h5>I agree to pay : USD ${fineData.payment_amount} fine as per your preference.</h5>
<div class="form-group">
<h5 class="text-black-50">CITATION</h5>
<h5>
${fineData.citation}
</h5>
</div>
<div class="form-group">
<h5 class="text-black-50">PAYMENT TERMS / NOTE</h5>
<h5>
${fineData.note}
</h5>
</div>
<h5>I agree that I will make the payment by clicking the 'PAY NOW' button.</h5>
<form action="${formURL}" class="offender_fine_sign" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<input type="hidden" name="id" value="${fineData.payment_amount}">
<div class="text-right">
<button type="button" title="Acknowlege" class="btn btn-success offender_fine_sign_submit"
data-url="${externalURL}" data-id="${fineData.id}">Acknowlege</button>
</div>
</form>
</div>
`;
$('#pay_now_block').empty().append(template);
$('#finePayModal').modal('show');
}); // var pageURL = base_url+"offender/get-fine/"+fineId
// var pageTitle = "iCourtApp::Fine";
// var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 850, 300);
// var myWindow = window.open(base_url+"offender/get-fine/"+fineId, "", "width=600,height=500,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* handle fine form submit
*/
$(document).on('click', '.offender_fine_sign_submit', function (e) {
// console.log('fine sign called')
var _this = $(this);
var fineId = _this.data('id');
var fineUrl = _this.data('url');
e.preventDefault();
var form = _this.parents('.offender_fine_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents(".offender_fine_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
_this.attr("disabled", "disabled"); // $('#clerk_compliance_form').css("opacity",".5");
},
success: function (response) {
//console.log(response);
switch (response.status) {
case "success":
// window.close()
// window.opener.getAttorneyStaffSessionActivitiesUpdate()
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate(); // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// // window.close();
// // window.opener.openFineUrl(fineUrl)
// window.opener.newOpenFineUrl(fineId);
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
window.parent.newOpenFineUrl(fineId);
// }
break;
case "validation_failed":
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Validation error occured');
break;
case "error":
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Error occured');
console.log(atob(response.message));
} // getStaffResonse(session_info.current_staff_id);
// getStaffSession();
}
});
return false;
});
/**
* handle fine disagree form submit
*/
$(document).on('click', '.offender_fine_disagree_submit', function (e) {
// console.log('fine sign called')
var _this = $(this);
var fineId = _this.data('id');
var base_url = _this.data('url');
e.preventDefault();
var form = _this.parents('.offender_fine_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: base_url + "offender/submit-fine-disagree/" + fineId,
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
_this.attr("disabled", "disabled"); // $('#clerk_compliance_form').css("opacity",".5");
},
success: function (response) {
//console.log(response);
switch (response.status) {
case "success":
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate();
// window.close(); // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// // window.close()
// // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Validation error occured');
break;
case "error":
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
// _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Error occured');
console.log(atob(response.message));
} // getStaffResonse(session_info.current_staff_id);
// getStaffSession();
}
});
return false;
});
/**
* compliance form submit
*/
$(document).on('click', '.offender_compliance_sign_submit', function (e) {
var _this = $(this);
var complianceId = _this.data('id'); // var sign = _this.parents('.new-compliance-form').find('.comp-sign').val();
// if(sign ===""){
// _this.parents('.new-compliance-form').find(".comp-sign-error").html("Please Sign");
// return false;
// }
var auth = $('#offender_auth_co').val();
if (auth === "") {
$("#offender_auth_co").addClass("makeRed");
var input = document.getElementById("offender_auth_co");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-compliance-form').find('.offender_compliance_sign' + complianceId)[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-compliance-form').find(".offender_compliance_sign" + complianceId).attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {// $('.submitBtn').attr("disabled","disabled");
// $('#clerk_compliance_form').css("opacity",".5");
},
success: function (response) {
//console.log(response);
switch (response.status) {
case "success":
// $("#offender_content").html(atob(response.message));
// infoToastr(atob(response.message))
// getLegalDocuments();
// window.opener.getStaffSessionActivitiesUpdate(); // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
break;
case "failed":
console.log('failed', response); // _this.parents('.modal').modal('hide');
// $('.modal-backdrop').remove();
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
} // getStaffResonse(session_info.current_staff_id);
// getStaffSession();
}
}); // html2canvas($("#canvas-signature"), {
// onrendered: function(canvas) {
// var imgsrc = canvas.toDataURL("image/png");
// var dataURL = canvas.toDataURL();
// $.ajax({
// type: "POST",
// url: base_url+"offender/create_offender_sign",
// data: {
// imgBase64: dataURL,
// filename : imgsrc
// }
// }).done(function(responses) {
// var fileData = JSON.parse(responses)
// if(fileData.offsign !=""){
// _this.parents('.new-compliance-form').find(".file-path").val(fileData.offsign);
// var form = _this.parents('.new-compliance-form').find('.offender_compliance_sign'+complianceId)[0];
// // Create an FormData object
// var formData = new FormData(form);
// $.ajax({
// type: 'POST',
// url: _this.parents('.new-compliance-form').find(".offender_compliance_sign"+complianceId).attr('action'),
// data: formData,
// dataType: 'json',
// contentType: false,
// cache: false,
// processData:false,
// beforeSend: function(){
// // $('.submitBtn').attr("disabled","disabled");
// // $('#clerk_compliance_form').css("opacity",".5");
// },
// success: function(response){ //console.log(response);
// switch(response.status){
// case "success":
// // $("#offender_content").html(atob(response.message));
// // infoToastr(atob(response.message))
// // getLegalDocuments();
// window.opener.getStaffSessionActivitiesUpdate()
// // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
// break;
// case "failed":
// console.log('failed',response)
// // _this.parents('.modal').modal('hide');
// // $('.modal-backdrop').remove();
// errorToastr('Validation error occured')
// break;
// case "error":
// errorToastr('Error occured')
// console.log(atob(response.message))
// break;
// default:
// errorToastr('Error occured')
// console.log(atob(response.message))
// }
// // getStaffResonse(session_info.current_staff_id);
// // getStaffSession();
// }
// });
// }
// });
// }
// });
return false;
});
/**
* open new window for probation form
*/
$(document).on('click', '.js-probation-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-probation/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for probation form
*/
$(document).on('click', '.js-fb-probation-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-fb-probation/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for pro intake form
*/
$(document).on('click', '.js-pro-intake-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-pro-intake/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for fair intake form
*/
$(document).on('click', '.js-fair-intake-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-fair-intake/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for e-intake form
*/
$(document).on('click', '.js-e-intake-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-e-intake/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for recommendation form
*/
$(document).on('click', '.js-recommendation-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-recommendation/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for reckless driving form
*/
$(document).on('click', '.js-reckless-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-reckless-driving/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for criminal case form
*/
$(document).on('click', '.js-criminal-case-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-criminal-case/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for bindover form
*/
$(document).on('click', '.js-bindover-case-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-bindover-case/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
}); // open new window for probation form
/**
* open new window for pre-trial form
*/
$(document).on('click', '.js-pre-trial-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-pre-trial/" + Id;
var pageTitle = "iCourtApp::PreTrial";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-probation/"+Id, "", "width='100%',height='100%',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for fine form
*/
$(document).on('click', '.js-fine-new-window', function () {
var Id = $(this).data('fine');
var pageURL = base_url + "offender/get-fine/" + Id;
var pageTitle = "iCourtApp::Fine";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-compliance/"+Id, "", "width=600,height=500,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for pro compliance form
*/
$(document).on('click', '.js-compliance-window', function () {
var Id = $(this).data('id');
var pageURL = base_url + "offender/get-compliance/" + Id;
var pageTitle = "iCourtApp::Fine";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto'); // var myWindow = window.open(base_url+"offender/get-compliance/"+Id, "", "width=600,height=500,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* open new window for new-schedule date
*/
$(document).on('click', '.js-new-session-window', function () {
var _this = $(this);
var fineId = _this.data('id');
var pageURL = base_url + "offender/get-new-date/" + fineId;
var pageTitle = "iCourtApp::New Date";
popUpHandler.open(pageURL, pageTitle); // var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// var myWindow = window.open(base_url+"offender/get-fine/"+fineId, "", "width=600,height=500,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
});
/**
* handle probation form submit
*/
$(document).on('click', '.offender_probation_sign_submit', function (e) {
var _this = $(this);
var probationID = _this.data('id');
console.log('probationID', probationID);
var sign = _this.parents('.new-probation-form').find(".prob-sign").val(); // if(sign ===""){
// _this.parents('.new-probation-form').find(".pr-sign-error").html("Please Sign");
// return false;
// }
var auth = $('#offender_auth').val();
if (auth === "") {
$("#offender_auth").addClass("makeRed");
var input = document.getElementById("offender_auth");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-probation-form').find('.offender_probation_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-probation-form').find(".offender_probation_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
_this.addClass('disabled');
},
success: function (response) {
switch (response.status) {
case "success":
// getStaffSession();
// getLegalDocuments();
// infoToastr(atob(response.message));
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate(); // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
} // $('#clerk_compliance_form').css("opacity","");
// $('.modal').remove();
// getStaffResonse(session_info.current_staff_id);
// getStaffSession();
_this.removeClass('disabled');
}
}); // html2canvas($("#canvas-signature"), {
// onrendered: function(canvas) {
// var imgsrc = canvas.toDataURL("image/png");
// // $("#newimg").attr('value', imgsrc);
// // $("#img").show();
// var id=null;
// var dataURL = canvas.toDataURL();
// $.ajax({
// type: "POST",
// url: base_url + "offender/create_offender_sign",
// data: {
// imgBase64: dataURL,
// filename : imgsrc
// }
// }).done(function(responses) {
// var fileData = JSON.parse(responses)
// if(fileData.offsign !=""){
// _this.parents('.new-probation-form').find(".files-path").val(fileData.offsign);
// // var _this = $(this)
// var form = _this.parents('.new-probation-form').find('.offender_probation_sign')[0];
// // Create an FormData object
// var formData = new FormData(form);
// console.log('ajax responses', fileData);
// $.ajax({
// type: 'POST',
// url: _this.parents('.new-probation-form').find(".offender_probation_sign").attr('action'),
// data: formData,
// dataType: 'json',
// contentType: false,
// cache: false,
// processData:false,
// beforeSend: function(){
// },
// success: function(response){
// switch(response.status){
// case "success":
// // getStaffSession();
// // getLegalDocuments();
// // infoToastr(atob(response.message));
// window.opener.getStaffSessionActivitiesUpdate()
// // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
// break;
// case "validation_failed":
// errorToastr('Validation error occured');
// break;
// case "error":
// errorToastr('Error occured');
// console.log(atob(response.message))
// break;
// default:
// errorToastr('Error occured');
// console.log(atob(response.message))
// }
// // $('#clerk_compliance_form').css("opacity","");
// // $('.modal').remove();
// // getStaffResonse(session_info.current_staff_id);
// // getStaffSession();
// }
// });
// }
// });
// }
// });
return false;
});
/**
* handle probation form submit
*/
$(document).on('click', '.offender_fb_probation_sign_submit', function (e) {
var _this = $(this);
var probationID = _this.data('id');
console.log('probationID', probationID);
var sign = _this.parents('.new-fb-probation-form').find(".prob-sign").val();
var auth = $('#offender_auth').val();
if (auth === "") {
$("#offender_auth").addClass("makeRed");
var input = document.getElementById("offender_auth");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-probation-form').find('.offender_probation_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-probation-form').find(".offender_probation_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {},
success: function (response) {
switch (response.status) {
case "success":
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate();
// window.close();
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
}
}
});
return false;
});
/**
* handle pre trial form submit
*/
$(document).on('click', '.offender_pre_trial_sign_submit', function (e) {
var _this = $(this);
var preTrialID = _this.data('id');
console.log('preTrialID', preTrialID); // var sign = _this.parents('.new-pre-trial-form').find(".prob-sign").val();
var auth = $('#offender_auth_pre').val();
if (auth === "") {
$("#offender_auth_pre").addClass("makeRed");
var input = document.getElementById("offender_auth_pre");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-pre-trial-form').find('.offender_pre_trial_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-pre-trial-form').find(".offender_pre_trial_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {},
success: function (response) {
switch (response.status) {
case "success":
// getStaffSession();
// getLegalDocuments();
// infoToastr(atob(response.message));
window.opener.getStaffSessionActivitiesUpdate(); // window.opener.getAttorneyStaffSessionActivitiesUpdate()
window.close();
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
} // $('#clerk_compliance_form').css("opacity","");
// $('.modal').remove();
// getStaffResonse(session_info.current_staff_id);
// getStaffSession();
}
}); // html2canvas($("#canvas-signature"), {
// onrendered: function(canvas) {
// var imgsrc = canvas.toDataURL("image/png");
// // $("#newimg").attr('value', imgsrc);
// // $("#img").show();
// var id=null;
// var dataURL = canvas.toDataURL();
// $.ajax({
// type: "POST",
// url: base_url + "offender/create_offender_sign",
// data: {
// imgBase64: dataURL,
// filename : imgsrc
// }
// }).done(function(responses) {
// var fileData = JSON.parse(responses)
// if(fileData.offsign !=""){
// _this.parents('.new-pre-trial-form').find(".files-path").val(fileData.offsign);
// // var _this = $(this)
// }
// });
// }
// });
return false;
});
/**
* handle recommendation form submit
*/
$(document).on('click', '.offender_recommendation_sign_submit', function (e) {
var _this = $(this);
var probationID = _this.data('id');
console.log('probationID', probationID);
var sign = _this.parents('.new-recmmondation-form').find(".prob-sign").val(); // if(sign ===""){
// _this.parents('.new-recmmondation-form').find(".pr-sign-error").html("Please Sign");
// return false;
// }
var auth = $('#offender_auth_rec').val();
if (auth === "") {
$("#offender_auth_rec").addClass("makeRed");
var input = document.getElementById("offender_auth_rec");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-recmmondation-form').find('.offender_rec_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-recmmondation-form').find(".offender_rec_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
_this.addClass('disabled');
},
success: function (response) {
switch (response.status) {
case "success":
// getStaffSession();
// getLegalDocuments();
// infoToastr(atob(response.message));
// window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.opener.getStaffSessionActivitiesUpdate()
// window.close();
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate();
// window.close();
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
}
_this.removeClass('disabled');
}
}); // html2canvas($("#canvas-signature"), {
// onrendered: function(canvas) {
// var imgsrc = canvas.toDataURL("image/png");
// // $("#newimg").attr('value', imgsrc);
// // $("#img").show();
// var id=null;
// var dataURL = canvas.toDataURL();
// $.ajax({
// type: "POST",
// url: base_url + "offender/create_offender_sign",
// data: {
// imgBase64: dataURL,
// filename : imgsrc
// }
// }).done(function(responses) {
// var fileData = JSON.parse(responses)
// // if(fileData.offsign !=""){
// // _this.parents('.new-recmmondation-form').find(".files-path").val(fileData.offsign);
// var form = _this.parents('.new-recmmondation-form').find('.offender_rec_sign')[0];
// // Create an FormData object
// var formData = new FormData(form);
// console.log('ajax responses', fileData);
// $.ajax({
// type: 'POST',
// url: _this.parents('.new-recmmondation-form').find(".offender_rec_sign").attr('action'),
// data: formData,
// dataType: 'json',
// contentType: false,
// cache: false,
// processData:false,
// beforeSend: function(){
// },
// success: function(response){
// switch(response.status){
// case "success":
// // getStaffSession();
// // getLegalDocuments();
// // infoToastr(atob(response.message));
// window.opener.getStaffSessionActivitiesUpdate()
// // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
// break;
// case "validation_failed":
// errorToastr('Validation error occured');
// break;
// case "error":
// errorToastr('Error occured');
// console.log(atob(response.message))
// break;
// default:
// errorToastr('Error occured');
// console.log(atob(response.message))
// }
// // $('#clerk_compliance_form').css("opacity","");
// // $('.modal').remove();
// // getStaffResonse(session_info.current_staff_id);
// // getStaffSession();
// }
// });
// // }
// });
// }
// });
return false;
});
/**
* handle reckless form submit
*/
$(document).on('click', '.offender_reckless_sign_submit', function (e) {
var _this = $(this);
var probationID = _this.data('id');
console.log('probationID', probationID);
var sign = _this.parents('.new-reckless-driving-form').find(".prob-sign").val(); // if(sign ===""){
// _this.parents('.new-recmmondation-form').find(".pr-sign-error").html("Please Sign");
// return false;
// }
var auth = $('#offender_auth_reckless').val();
if (auth === "") {
$("#offender_auth_reckless").addClass("makeRed");
var input = document.getElementById("offender_auth_reckless");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-reckless-driving-form').find('.offender_reckless_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-reckless-driving-form').find(".offender_reckless_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
_this.addClass('disabled');
},
success: function (response) {
switch (response.status) {
case "success":
// window.opener.getStaffSessionActivitiesUpdate()
// window.close();
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate();
// window.close();
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
}
_this.removeClass('disabled');
}
});
return false;
});
/**
* handle probation form submit
*/
$(document).on('click', '.offender_cc_sign_submit', function (e) {
var _this = $(this);
var probationID = _this.data('id');
console.log('cc ', probationID); // var sign = _this.parents('.new-cc-form').find(".prob-sign").val();
// if(sign ===""){
// _this.parents('.new-cc-form').find(".pr-sign-error").html("Please Sign");
// return false;
// }
var auth = $('#offender_auth_cc').val();
if (auth === "") {
$("#offender_auth_cc").addClass("makeRed");
var input = document.getElementById("offender_auth_cc");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-cc-form').find('.offender_cc_sign')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-cc-form').find(".offender_cc_sign").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {
_this.addClass('disabled');
},
success: function (response) {
switch (response.status) {
case "success":
// window.opener.getStaffSessionActivitiesUpdate()
// window.close();
// if (windowWidth > 991) {
// window.opener.getStaffSessionActivitiesUpdate();
// window.close();
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
}
_this.removeClass('disabled');
}
}); // html2canvas($("#canvas-signature"), {
// onrendered: function(canvas) {
// var imgsrc = canvas.toDataURL("image/png");
// // $("#newimg").attr('value', imgsrc);
// // $("#img").show();
// var id=null;
// var dataURL = canvas.toDataURL();
// $.ajax({
// type: "POST",
// url: base_url + "offender/create_offender_sign",
// data: {
// imgBase64: dataURL,
// filename : imgsrc
// }
// }).done(function(responses) {
// var fileData = JSON.parse(responses)
// if(fileData.offsign !=""){
// _this.parents('.new-cc-form').find(".files-path").val(fileData.offsign);
// // var _this = $(this)
// var form = _this.parents('.new-cc-form').find('.offender_cc_sign')[0];
// // Create an FormData object
// var formData = new FormData(form);
// $.ajax({
// type: 'POST',
// url: _this.parents('.new-cc-form').find(".offender_cc_sign").attr('action'),
// data: formData,
// dataType: 'json',
// contentType: false,
// cache: false,
// processData:false,
// beforeSend: function(){
// },
// success: function(response){
// switch(response.status){
// case "success":
// window.opener.getStaffSessionActivitiesUpdate()
// window.close();
// break;
// case "validation_failed":
// errorToastr('Validation error occured');
// break;
// case "error":
// errorToastr('Error occured');
// console.log(atob(response.message))
// break;
// default:
// errorToastr('Error occured');
// console.log(atob(response.message))
// }
// // $('#clerk_compliance_form').css("opacity","");
// // $('.modal').remove();
// // getStaffResonse(session_info.current_staff_id);
// // getStaffSession();
// }
// });
// }
// });
// }
// });
return false;
}); // // new date sign submit to be implemented
// $(document).on('click', '.offender_new_date_sign_submit', function(e) {
// var _this = $(this)
// var newDateId = _this.data('id')
// console.log('newDateId',newDateId)
// var sign = _this.parents('.new-date-form').find(".prob-sign").val();
// if(sign ===""){
// _this.parents('.new-date-form').find(".comp-sign-error").html("Please Sign");
// return false;
// }
// html2canvas($("#canvas-signature"), {
// onrendered: function(canvas) {
// var imgsrc = canvas.toDataURL("image/png");
// // $("#newimg").attr('value', imgsrc);
// // $("#img").show();
// var dataURL = canvas.toDataURL();
// var id=null;
// $.ajax({
// type: "POST",
// url: base_url + "offender/create_offender_sign",
// data: {
// imgBase64: dataURL,
// filename : imgsrc
// }
// }).done(function(responses) {
// var fileData = JSON.parse(responses)
// if(fileData.offsign !=""){
// _this.parents('.new-date-form').find(".files-path").val(fileData.offsign);
// // var _this = $(this)
// var form = _this.parents('.new-date-form').find('.new_date_form')[0];
// // Create an FormData object
// var formData = new FormData(form);
// console.log('ajax responses', fileData);
// $.ajax({
// type: 'POST',
// url: _this.parents('.new-date-form').find(".new_date_form").attr('action'),
// data: formData,
// dataType: 'json',
// contentType: false,
// cache: false,
// processData:false,
// beforeSend: function(){
// },
// success: function(response){
// switch(response.status){
// case "success":
// // getStaffSession();
// // getLegalDocuments();
// // infoToastr(atob(response.message));
// window.opener.getStaffSessionActivitiesUpdate()
// // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
// break;
// case "validation_failed":
// errorToastr('Validation error occured');
// break;
// case "error":
// errorToastr('Error occured');
// console.log(atob(response.message))
// break;
// default:
// errorToastr('Error occured');
// console.log(atob(response.message))
// }
// // $('#clerk_compliance_form').css("opacity","");
// // $('.modal').remove();
// // getStaffResonse(session_info.current_staff_id);
// // getStaffSession();
// }
// });
// }
// });
// }
// });
// return false;
// });
// new date sign submit to be implemented
/**
* handle new date sign submit
*/
$(document).on('click', '.offender_new_date_sign_submit', function (e) {
var _this = $(this);
var newDateId = _this.data('id');
console.log('newDateId', newDateId);
var auth = $('#offender_auth_newdate').val();
if (auth === "") {
$("#offender_auth_newdate").addClass("makeRed");
var input = document.getElementById("offender_auth_newdate");
input.placeholder = "Required";
return false;
}
var form = _this.parents('.new-date-form').find('.new_date_form')[0]; // Create an FormData object
var formData = new FormData(form);
$.ajax({
type: 'POST',
url: _this.parents('.new-date-form').find(".new_date_form").attr('action'),
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function () {},
success: function (response) {
switch (response.status) {
case "success":
// if (windowWidth > 991) {
// // getStaffSession();
// // getLegalDocuments();
// // infoToastr(atob(response.message));
// window.opener.getStaffSessionActivitiesUpdate(); // window.opener.getAttorneyStaffSessionActivitiesUpdate()
// window.close();
// } else {
popUpHandler.closeIframe();
window.parent.getStaffSessionActivitiesUpdate();
// }
break;
case "validation_failed":
errorToastr('Validation error occured');
break;
case "error":
errorToastr('Error occured');
console.log(atob(response.message));
break;
default:
errorToastr('Error occured');
console.log(atob(response.message));
} // $('#clerk_compliance_form').css("opacity","");
// $('.modal').remove();
// getStaffResonse(session_info.current_staff_id);
// getStaffSession();
}
});
return false;
});
/**
* This is an object which consists of two functions namely closeIframe and open.
* closeIframe is a function that closes the form view in offender's dashboard
* open is a function that opens the forms in iframe in offender's dashboard
*/
var popUpHandler = {
closeIframe: function () {
$('#mbl_iframe', window.parent.document).hide().removeClass('active');
$('#new_iframe', window.parent.document).attr('src', '').empty();
},
open: function (pageURL, pageTitle = '') {
// if (windowWidth > 991) {
// var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// }
// else {
$('.js-iframe-wrap').show().addClass('active'); // $('.js-iframe-wrap.active').css('bottom', $('.nd-body-right').height())
$('.js-iframe').attr('src', pageURL);
iframeControls();
// }
}
};