var toastrOptions = {
timeOut: 15000,
closeButton: false,
positionClass: "toast-bottom-right",
preventDuplicates: true,
preventOpenDuplicates: true,
}
var select_queue;
/**
* This function shows the success (green) popup message on the screen
* @params {string} message - Success message
*/
var successToastr = function (message) {
return;
toastr.remove()
toastr.success(message, '', toastrOptions)
}
/**
* This function shows the information (blue) popup message on the screen
* @params {string} message - Info message
*/
var infoToastr = function (message) {
return;
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 (message) {
return;
toastr.remove()
toastr.error(message, '', toastrOptions)
}
var isOffenderQueueClick = false;
$(document).ready(function () {
$('.mCustomScrollbar').mCustomScrollbar({
scrollButtons:{
enable:true
}
});
/**
* This function expands or collapses the Court Staff's list box. Similarly the video session block also gets expanded as per the available space
* @params {string} dock - HTML element
*/
var toggle = function($dock) {
if($dock.hasClass('collapsed')) {
$dock.removeClass('collapsed')
// $dock.find('.staff-sm-img').addClass('mr-2')
$dock.find('.js-online-status').hide()
$dock.find('.js-invite-arrow').hide()
// $dock.find('#list_staff .offender-queue .main-info').removeClass('js-call-court-staff')
}
else {
$dock.addClass('collapsed')
$dock.find('.js-online-status').show()
$dock.find('.js-invite-arrow').show()
// $dock.find('.staff-sm-img').removeClass('mr-0')
// $dock.find('#list_staff .offender-queue .main-info').addClass('js-call-court-staff')
}
};
$(document).on('click', '.js-collapse-staff', function() {
toggle($('.container-dock'));
});
var initDatepicker = function () {
$('.datepicker').datepicker({
todayHighlight: true,
autoclose: true,
format: 'yyyy-mm-dd',
});
}
// refresh the current page
$(document).on('click', '.js-refresh', function () {
// window.onbeforeunload = ConfirmLeave;
location.reload();
})
// swiper initilizatin for small screen size
var swiper = new Swiper('.js-btn-swiper', {
slidesPerView: 3,
spaceBetween: 20,
loop: false,
navigation: {
nextEl: '.js-banner-next',
prevEl: '.js-banner-prev',
},
breakpoints: {
576: {
slidesPerView: 1,
spaceBetween: 10,
},
768: {
slidesPerView: 2,
spaceBetween: 20,
},
},
})
// renaming user role for valid ajax url
var renameUserRole = function (role) {
switch (role) {
case 'Public Defender':
return user_role = 'public-defender';
break;
case 'Probation Officer':
return user_role = 'probation-officer';
break;
case 'Clerk':
return user_role = 'clerk';
break;
default:
return user_role;
}
}
renameUserRole(user_role);
/**
* This function handles the offender click on Queue list block. It also blocks the another offender click until the previous offender's data
are completely loaded.
*/
$(document).on('click', '.js-offender-queue', function () {
if(!isOffenderQueueClick) {
isOffenderQueueClick = true;
setTimeout(function(){
if(isOffenderQueueClick) {
$.confirm({
title: 'A server is taking too long to reply. Do you want to continue? ',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
text: "No",
btnClass: 'btn btn-danger mr-3',
action: function(){
location.reload()
}
},
ok: {
text: "Yes",
btnClass: 'btn btn-success',
}
}
})
}
}, 1200000);
// wasVideoStarted(session_info.offender_staff_session_id)
var _this = $(this);
// _this.addClass('disabled')
$('#main-section').empty();
var position = $(this).data("position");
var userid = $(this).data("user_id");
var user_name = $(this).data("user_name");
var status = $(this).data("status");
if (status == "taken_to_staff") {
return;
}
console.log('userid', userid)
$('#myQueue').find('.active').removeClass('active');
$('#mySupportQueue').find('.active').removeClass('active');
$(this).addClass('active')
// unsubscribe_offender(session_info.offender_staff_session_id);
successToastr('connecting to '+ user_name);
currntUserBeingServed(userid,session_info.offender_staff_session_id );
}
// });
// $.get(base_url + "staff/user-detail/" + userid, function (data) {
// $("#info-box").html(data);
// });
//subscribe(userid);
//subscribe_offender(userid);
// document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
});
// added for plea
// $(document).on('click', '#plea', function () {
// var userid = $(this).data("usertype");
// // ajax call to get plea form
// $.get(base_url + "staff/plea/show-form", function (data) {
// $('#myTab').find('.active').removeClass('active')
// $('#myTabContent').find('.show.active').removeClass('show active')
// $('#new-plea-tab').parent('li').show()
// $('#new-plea-tab').text('Plea')
// $('#new-plea-tab').addClass('active')
// $('#new-plea').addClass('show active')
// $("#plea_section").empty();
// $("#plea_section").append(data);
// $('#plea-form').hide();
// });
// // $.confirm({
// // title: 'Are you sure you want to plea?',
// // columnClass: 'col-md-6 col-md-offset-2',
// // content: '',
// // buttons: {
// // cancel: {
// // btnClass: 'btn btn-danger mr-3',
// // },
// // ok: {
// // text: "Ok",
// // btnClass: 'btn btn-success',
// // keys: ['enter'],
// // action: function(){
// // // $.get(base_url+"staff/plea/current-user-being-served/"+userid, function (data) {
// // // // debugger;
// // // if(data.code==200){
// // // $(".message").html(data.message);
// // // }else{
// // // $(".message").html(data.message);
// // // }
// // // });
// // // document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
// // }
// // }
// // }
// // })
// });
// ajax call to get header information
$.get(base_url + "staff/" + user_role + "/get-header-info", function (data) {
$("#header_info").empty();
$("#header_info").append(data);
});
// // ajax call to get list of staffs
// $.get(base_url + "staff/" + user_role + "/get-staff-list", function (data) {
// $("#list_staff").empty();
// $("#list_staff").append(data);
// });
updateStaffList();
loadQueue();
// // queue list will be updated every 30 seconds
// setInterval(function() {
// loadQueue();
// },30000);
function flag_user_in_queue_being_served(user_id) {
$('.user_id').val(user_id);
$.ajax({
method: "GET",
url: "<?php echo base_url()?>" + "staff/current-user-being-served/" + user_id,
})
.done(function (response) {
if (response.code == 200) {
$(".message").html(response.message);
} else {
$(".message").html(response.message);
}
});
}
/**
* This function handles button click to open transfer form
*/
$(document).on('click', '#transfer', function () {
var pageURL = base_url + "staff/transfer/show-form" ;
var pageTitle = "iCourtApp::Transfer";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 800, 530);
});
/**
* This function handles button click to open phone call form
*/
$(document).on('click', '#conferenceCall', function () {
var pageURL = base_url + "staff/conference-call/show-form" ;
var pageTitle = "iCourtApp::Transfer";
// var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 800, 530);
$('.js-conference').show().attr('src', pageURL);
var ht = $('#conf-block').outerHeight()
$('.js-conference').css('height', ht)
document.querySelector('.js-conference').scrollIntoView({ behavior: 'smooth' });
});
/**
* This function handles button click to open invitation form
*/
$(document).on('click', '#inviteStaff', function () {
var pageURL = base_url + "staff/invite/show-form" ;
var pageTitle = "iCourtApp::Transfer";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 650, 500);
//var myWindow = window.open(base_url + "staff/transfer/show-form", "", "width=600,height=500,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
// var userid = $(this).data("usertype");
// // ajax call to get transfer form
// $.get(base_url + "staff/transfer/show-form", function (data) {
// $('#myTab').find('.active').removeClass('active')
// $('#myTabContent').find('.show.active').removeClass('show active')
// $('#new-transfer-tab').parent('li').show()
// $('#new-transfer-tab').text('Transfer')
// $('#new-transfer-tab').addClass('active')
// $('#new-transfer').addClass('show active')
// $("#transfer_section").append(data);
// });
// $.confirm({
// title: 'Are you sure you want to transfer?',
// columnClass: 'col-md-6 col-md-offset-2',
// content: '',
// buttons: {
// cancel: {
// btnClass: 'btn btn-danger mr-3',
// },
// ok: {
// text: "Ok",
// btnClass: 'btn btn-success',
// keys: ['enter'],
// action: function(){
// // document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
// }
// }
// }
// })
});
/**
* This function handles button click to open external people invitation form
*/
$(document).on('click', '#inviteExternal', function () {
var pageURL = base_url + "staff/inviteExternal/show-form" ;
var pageTitle = "iCourtApp::Invite External People";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 800, 440);
});
/**
* This function handles button click to open probation form
*/
$(document).on('click', '#new-probation-tab', function () {
var userid = $(this).data("usertype");
// showProbationForm();
$.get(base_url + "staff/probation/probation-control", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-probation-tab').parent('li').show()
$('#new-probation-tab').text('Probation')
$('#new-probation-tab').addClass('active')
$('#new-probation').addClass('show active')
$("#probation_section").empty();
$("#probation_section").append(data);
$('#probation-form').hide();
// initDatepicker();
});
});
// var loadCompliance = function () {
// // var answer = confirm('Are you sure you want to send a compliance form?')
// var userid = $(this).data("usertype");
// // ajax call to get compliance form
// $.get(base_url + "staff/compliance/show-form", function (data) {
// $("#action_section").empty()
// $("#action_section").append(data);
// $('#profile-tab').text('Compliance')
// $('#home-tab').removeClass('active')
// $('#profile-tab').addClass('active')
// $('#home').removeClass('show active')
// $('#profile').addClass('show active')
// $('#compliance-form').hide()
// initDatepicker();
// });
// // document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
// }
$(document).on('click', '#new-participants-tab', function () {
loadParticpants();
});
$(document).on('click', '#new-compliance-tab', function () {
loadCompliances();
});
$(document).on('click', '#new-fine-tab', function () {
loadFine();
});
$(document).on('click', '#new-trial-tab', function () {
loadNewDate();
});
$(document).on('click', '#new-pre-trial-tab', function () {
loadPreTrial();
});
/**
* This function handles button click to open close case form
*/
$(document).on('click', '#closeCase', function () {
$.confirm({
title: 'Are you sure you want to close the case?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
$.post(base_url + "staff/closeCase/close-action", function (data) {
if (data.status.localeCompare("success") == 0) {
// var message = atob(data.message);
$("#home_section").html(atob(data.message));
// location.reload(true);
}
}, 'json');
jist_stop();
}
}
}
})
});
/**
* This function handles button click to end session form
*/
$(document).on('click', '#closeSession', function () {
var userid = $(this).data("usertype");
$.confirm({
title: 'Are you sure you want to close the session?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
// $.get( base_url+ "staff/caseHandler/show-tab-section", function( data ) {
// $('#main-section').empty()
// $('#main-section').append(data)
// });
// ajax call to get main content
$.get(base_url + "staff/caseHandler/show-form", function (data) {
// $('#home_section').append(data)
$("#action_section").empty()
$("#action_section").append(data);
$('#profile-tab').text('Close Session')
$('#home-tab').removeClass('active')
$('#profile-tab').addClass('active')
$('#home').removeClass('show active')
$('#profile').addClass('show active')
});
// document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
}
}
}
})
});
/**
* This function handles button click to open case dismiss form
*/
$(document).on('click', '#caseDismiss', function () {
$.confirm({
title: 'Are you sure you want to dismiss the case?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
$.post(base_url + "staff/closeCase/dismiss-action", function (data) {
if (data.status.localeCompare("success") == 0) {
var message = atob(data.message);
$("#home_section").html(atob(data.message));
location.reload(true);
}
}, 'json');
}
}
}
})
});
// $(document).on('click', '#transferToJudge', function () {
// var pageURL = base_url + "staff/transferToJudge/show-form" ;
// var pageTitle = "iCourtApp::Reset For Trial";
// var myWindow = createPopupWin(pageURL, pageTitle, 'auto', 'auto');
// initDatepicker();
// });
/**
* This function handles button click to open plea form
*/
$(document).on('click', '#plea', function () {
var pageURL = base_url + "staff/plea/show-form" ;
var pageTitle = "iCourtApp::Plea";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 600, 450);
//var myWindow = window.open(base_url + "staff/plea/show-form", "", "width=600,height=500,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
// var userid = $(this).data("usertype");
// // ajax call to get main content
// $.get(base_url + "staff/transferToJudge/show-form", function (data) {
// $('#myTab').find('.active').removeClass('active')
// $('#myTabContent').find('.show.active').removeClass('show active')
// $('#new-schedule-tab').parent('li').show()
// $('#new-schedule-tab').text('New Date')
// $('#new-schedule-tab').addClass('active')
// $('#new-schedule').addClass('show active')
// $("#schedule_section").empty();
// $("#schedule_section").append(data);
// });
});
/**
* This function handles button click to open hold form
*/
$(document).on('click', '#hold', function () {
$.confirm({
title: 'Are you sure you want to put an offender on hold?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
$.post(base_url + "staff/hold/hold-action", function (data) {
if (data.status.localeCompare("success") == 0) {
var message = atob(data.message);
$("#home_section").html(atob(data.message));
loadQueue();
// location.reload(true);
}
}, 'json');
}
}
}
})
});
/**
* This function handles button click to open 'End the session' form
*/
$(document).on('click', '#endSession', function () {
$.confirm({
title: 'Are you sure you want to end the session?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
$.post(base_url + "staff/closeCase/close-action", function (data) {
if (data.status.localeCompare("success") == 0) {
// var message = atob(data.message);
// $("#home_section").html(atob(data.message));
// location.reload(true);
}
}, 'json');
}
}
}
})
});
var isSupportOffenderClick = false;
/**
* This function handles the offender click on Support Queue list block. It also blocks the another offender click until the previous offender's data
are completely loaded.
*/
$(document).on('click', '.js-support-queue', function() {
if(!isSupportOffenderClick) {
isSupportOffenderClick = true;
setTimeout(function(){
if(isOffenderQueueClick) {
$.confirm({
title: 'A server is taking too long to reply. Do you want to continue? ',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
text: "No",
btnClass: 'btn btn-danger mr-3',
action: function(){
location.reload()
}
},
ok: {
text: "Yes",
btnClass: 'btn btn-success',
}
}
})
}
}, 1200000);
$('#mySupportQueue').find('.active').removeClass('active');
$('#myQueue').find('.active').removeClass('active');
$(this).addClass('active')
var position = $(this).data("position");
var support_queue_id = $(this).data("user_id");
var staff_id = $(this).data('staff_id')
var registration_info = session_info.registration_info
if (position > 0) {
// console.log('Not allowed to attend a user...');
errorToastr('Not allowed to attend a user...')
return;
}
$('#main-section').empty();
$('#test').empty();
$('#loading-icon').show();
var video_music = document.getElementById('staff_video_start_music');
video_music.play();
var container = document.querySelector('#test');
var jisti_room = "ROOM"+registration_info.court_id+"00000"+ support_queue_id;
var options = {
"roomName": jisti_room,
"parentNode": container,
"jwt": registration_info.jwt,
userInfo: {
canmute: false,
canmutevideo: false,
// displayName: staff_info.user_name
},
interfaceConfigOverwrite: {
filmStripOnly: false,
DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
},
configOverwrite: {
disableRemoteMute: true,
remoteVideoMenu: {
disableKick: true
},
},
onload: function(){
$('#loading-icon').hide();
isSupportOffenderClick = false;
},
"width": "100%",
"height": "100%"
};
//alert(registration_info.jitsi_url);
api = new JitsiMeetExternalAPI(registration_info.jitsi_url, options);
api.executeCommand('toggleTileView');
$("#start").hide();
var template = `
<div class="card new-card w-100 p-4">
<div class="mdc-card-wrap">
<button class="mdc-card mb-0" id="endSupportSession" data-support_queue_id="${support_queue_id}" data-staff_id="${staff_id}">End the session</button>
</div>
</div>
`;
$('#main-section').empty();
$('#main-section').html(template)
$.get(base_url + "staff/support-queue-served/" + support_queue_id, function (data) {
$('#info-box').html(atob(data.message));
});
}
})
/**
* This function ends the support session
*/
$(document).on('click', '#endSupportSession', function() {
var support_queue_id = $(this).data("support_queue_id");
$.confirm({
title: 'Are you sure you want to end the session?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
$.get(base_url + "staff/end-support-session/" + support_queue_id, function (data) {
jist_stop();
//location.reload(true);
showSupportQueue();
$('#main-section').html('');
isSupportOffenderClick = false;
});
}
}
}
})
})
// $(document).on('click', '#inviteStaff', function () {
// // alert('inviteStaff');
// $.get(base_url + "staff/invite/show-form", function (data) {
// $('#myTab').find('.active').removeClass('active')
// $('#myTabContent').find('.show.active').removeClass('show active')
// $('#new-invite-staff-tab').parent('li').show()
// $('#new-invite-staff-tab').text('Invite Staff')
// $('#new-invite-staff-tab').addClass('active')
// $('#new-invite-staff').addClass('show active')
// $("#invite_staff_section").html(data);
// });
// });
});
/**
* This function loads the compliance form's data, activates the compliance tab, and shows the list of compliance form if this form was
previously sent or just shows the compliance button
*/
var loadCompliances = function () {
// var answer = confirm('Are you sure you want to send a compliance form?')
var userid = $(this).data("usertype");
// ajax call to get compliance form
$.get(base_url + "staff/compliance/show-form", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-compliance-tab').parent('li').show()
$('#new-compliance-tab').text('Reset')
$('#new-compliance-tab').addClass('active')
$('#new-compliance').addClass('show active')
$("#compliance_section").empty();
$("#compliance_section").append(data);
$('#compliance-form').hide()
// $('.datepicker').datepicker({
// todayHighlight: true,
// autoclose: true,
// format: 'yyyy-mm-dd',
// });
});
// document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
}
/**
* This function loads the payment acknowledgement form's data, activates the payment acknowledgement tab, and shows the list of payment
acknowledgement form if this form was previously sent or just shows the payment acknowledgement button
*/
var loadFine = function () {
// var answer = confirm('Are you sure you want to fine?')
// if(answer == true) {
// }
var userid = $(this).data("usertype");
// ajax call to get fine form
$.get(base_url + "staff/fine/show-form", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-fine-tab').parent('li').show()
$('#new-fine-tab').text('Payment')
$('#new-fine-tab').addClass('active')
$('#new-fine').addClass('show active')
$("#fine_section").empty();
$("#fine_section").append(data);
$('#payment-form').hide()
});
// document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
}
/**
* This function loads the pre-trial form's data, activates the pre-trial tab, and shows the list of pre-trial form if this form was
previously sent or just shows the pre-trial button
*/
var loadPreTrial = function () {
// var answer = confirm('Are you sure you want to fine?')
// if(answer == true) {
// }
var userid = $(this).data("usertype");
// ajax call to get fine form
$.get(base_url + "staff/preTrial/show-control", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
// document.querySelector('.queue-page').scrollIntoView({ behavior: 'smooth' });
}
/**
* This function loads the pre-trial form's data, activates the pre-trial tab, and shows the list of pre-trial form if this form was
previously sent or just shows the pre-trial button
*/
var loadPreTrialList = function () {
$.get(base_url + "staff/preTrial/pre-trial-list", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
}
/**
* This function activates the participants tab, and shows the list of currently active/online participants
*/
var loadParticpants = function (){
var userid = $(this).data("usertype");
// showProbationForm();
$.get(base_url + "staff/get-participants", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-participants-tab').parent('li').show()
$('#new-participants-tab').text('Participants')
$('#new-participants-tab').addClass('active')
$('#new-participants').addClass('show active')
$("#participants_section").empty();
$("#participants_section").append(data);
// initDatepicker();
});
}
/**
* This function loads the recommendation form's data, activates the recommendation tab, and shows the list of recommendation form if this form was
previously sent or just shows the recommendation button
*/
var loadRecommendList = function () {
$.get(base_url + "staff/preTrial/recommedation-list", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
}
/**
* This function loads the reckless driving form's data, activates the reckless driving tab, and shows the list of reckless driving form if this form was
previously sent or just shows the reckless driving button
*/
var loadRecklessList = function () {
$.get(base_url + "staff/preTrial/reckless-driving-list", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
}
/**
* This function loads the criminal case form's data, activates the criminal case tab, and shows the list of criminal case form if this form was
previously sent or just shows the criminal case button
*/
var loadCriminalCaseList = function () {
$.get(base_url + "staff/preTrial/criminal-case-list", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
}
/**
* This function loads the bindover form's data, activates the bindover tab, and shows the list of bindover form if this form was
previously sent or just shows the bindover button
*/
var loadBindoverList = function () {
$.get(base_url + "staff/preTrial/bindover-list", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
}
/**
* This function loads the new-date form's data, activates the new-date tab, and shows the list of new-date form if this form was
previously sent or just shows the new-date button
*/
var loadNewDate = function(){
$.get(base_url + "staff/reset/show-form", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-trial-tab').parent('li').show()
$('#new-trial-tab').text('Reset')
$('#new-trial-tab').addClass('active')
$('#new-trial').addClass('show active')
$("#trial_section").empty();
$("#trial_section").append(data);
// $('#payment-form').hide()
});
}
var timer;
/**
* This function starts the video session
*/
var jist_start = function (offender_staff_sessions_id, staff_info) {
console.log('jisti session being started' + staff_id + "::" + registration_info.user_id);
// infoToastr('success', 'Jisti session being started ')
//infoToastr('initiating video')
$('#test').empty();
$('#loading-icon').show();
var video_music = document.getElementById('staff_video_start_music');
video_music.volume = 0.2;
video_music.play();
var container = document.querySelector('#test');
console.log(registration_info.jwt);
//var domain = "jitsi1.outlines-rnd.com/";
//var domain = "3.235.252.250:8443";
//if(caseno ==""){alert("invalid case no"); return;}
console.log(staff_info.user_id);
var jisti_room = "ROOM" + offender_staff_sessions_id;
console.log(jisti_room + "room");
var options = {
"roomName": jisti_room,
"parentNode": container,
"jwt": registration_info.jwt,
userInfo: {
canmute: false,
canmutevideo: false,
displayName: staff_info.user_name
},
interfaceConfigOverwrite: {
filmStripOnly: false,
DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
},
configOverwrite: {
disableRemoteMute: true,
remoteVideoMenu: {
disableKick: true
},
},
onload: function(){
$('#loading-icon').hide();
},
"width": "100%",
"height": "100%"
};
session_info.jitsi_started = 1;
//alert(registration_info.jitsi_url);
api = new JitsiMeetExternalAPI(registration_info.jitsi_url, options);
if(typeof localStorage.videoSourceText != "undefined"){
api.setVideoInputDevice(localStorage.videoSourceText, localStorage.videoSourceValue)
}
if(typeof localStorage.inputSourceText != "undefined"){
api.setAudioInputDevice(localStorage.inputSourceText, localStorage.inputSourceValue)
}
if(typeof localStorage.outputSourceText != "undefined"){
api.setAudioOutputDevice(localStorage.outputSourceText, localStorage.outputSourceValue)
}
api.executeCommand('subject', ' ');
// api.executeCommand('toggleTileView');
$("#start").hide();
};
/**
* This function stops the video session
*/
var jist_stop = function () {
session_info.jitsi_started = 0;
console.log('closing');
$('#test').html("");
$("#start").html("");
$('#loading-icon').hide();
$('#staff_video').html("")
$('#staff-loading-icon').hide()
}
/**
* This function starts the internal staff's video session
*/
var staff_jist_start = function (offender_staff_sessions_id, staff_info) {
console.log('jisti session being started' + staff_id + "::" + registration_info.user_id);
// infoToastr('success', 'Jisti session being started ')
//infoToastr('initiating video')
$('#staff_video').empty();
$('#staff-loading-icon').show();
var video_music = document.getElementById('staff_video_start_music');
video_music.volume = 0.2;
video_music.play();
var container = document.querySelector('#staff_video');
console.log(registration_info.jwt);
//var domain = "jitsi1.outlines-rnd.com/";
//var domain = "3.235.252.250:8443";
//if(caseno ==""){alert("invalid case no"); return;}
console.log(staff_info.user_id);
var jisti_room = "INTERNAL STAFF ROOM" + offender_staff_sessions_id;
console.log(jisti_room + "room");
var options = {
"roomName": jisti_room,
"parentNode": container,
"jwt": registration_info.jwt,
userInfo: {
canmute: false,
canmutevideo: false,
displayName: staff_info.user_name
},
interfaceConfigOverwrite: {
filmStripOnly: false,
DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
},
configOverwrite: {
disableRemoteMute: true,
remoteVideoMenu: {
disableKick: true
},
},
onload: function(){
$('#staff-loading-icon').hide();
},
"width": "100%",
"height": "100%"
};
session_info.jitsi_started = 1;
//alert(registration_info.jitsi_url);
api = new JitsiMeetExternalAPI(registration_info.jitsi_url, options);
if(typeof localStorage.videoSourceText != "undefined"){
api.setVideoInputDevice(localStorage.videoSourceText, localStorage.videoSourceValue)
}
if(typeof localStorage.inputSourceText != "undefined"){
api.setAudioInputDevice(localStorage.inputSourceText, localStorage.inputSourceValue)
}
if(typeof localStorage.outputSourceText != "undefined"){
api.setAudioOutputDevice(localStorage.outputSourceText, localStorage.outputSourceValue)
}
api.executeCommand('subject', ' ');
// api.executeCommand('toggleTileView');
$("#start").hide();
};
/**
* This function loads the list of offenders on the Queue list block. It checks if the offender is previously clicked and loads the main
content accordingly.
*/
var loadQueue = function () {
// infoToastr('success', 'Pulling data about queue')
// infoToastr('Connecting to server...')
console.log('pulling data about queue');
$.get(base_url + "staff/" + user_role + "/get-my-queue", function (data) {
$("#list_queue").empty();
$("#list_queue").append(data);
console.log("queue_id"+localStorage.LS_selected_queue_id);
console.log("length: "+$("#queue_"+localStorage.LS_selected_queue_id).length);
if(typeof localStorage.LS_selected_queue_id != "undefined"){
if($("#queue_"+localStorage.LS_selected_queue_id).length == 0){
jist_stop();
var msg = `<div class="card new-card w-100 p-4">
<h4>Please select user in the queue</h4>
</div>`;
$('#main-section').html(msg);
}else{
$("#queue_"+localStorage.LS_selected_queue_id).addClass('active');
}
}
});
}
/**
* This function loads the plea form's data sent from offender
*/
var loadoffenderchoice = function (id) {
$.get(base_url + "staff/get-offender-choice/"+id, function (data) {
$("#info-plea").empty();
var mess ='<div class="info-box-bottom" id="info-plea">'+data+ '</div>';
$("#info-plea").append(data);
});
}
/**
* This function loads the probation form's data, activates the probation tab, and shows the list of probation form if this form was
previously sent or just shows the probation button
*/
var showProbationForm = function () {
$.get(base_url + "staff/probation/show-form", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-probation-tab').parent('li').show()
$('#new-probation-tab').text('Probation')
$('#new-probation-tab').addClass('active')
$('#new-probation').addClass('show active')
$("#probation_section").empty();
$("#probation_section").append(data);
$('#probation-form').hide();
// initDatepicker();
});
}
/**
* This function loads the recommendation form's data, activates the recommendation tab, and shows the list of recommendation form if this form was
previously sent or just shows the recommendation button
*/
var loadRecommendation = function () {
$.get(base_url + "staff/recommendation/show-control", function(data) {
$('.new-tab-wrap').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-recommendation-tab').parent('li').show()
$('#new-recommendation-tab').addClass('active')
$('#new-recommendation').addClass('show active')
$("#recommendation_section").empty();
$("#recommendation_section").append(data);
});
}
/**
* This function loads the reckless driving form's data, activates the reckless driving tab, and shows the list of reckless driving form if this form was
previously sent or just shows the reckless driving button
*/
var loadRecklessDriving = function () {
$.get(base_url + "staff/recommendation/reckless-show-control", function(data) {
$('.new-tab-wrap').find('.active').removeClass('active')
$('#new-pre-trial-tab').parent('li').show()
$('#new-pre-trial-tab').text('Pre Trial')
$('#new-pre-trial-tab').addClass('active')
$('#new-pre-trial').addClass('show active')
$("#pre_trial_section").empty();
$("#pre_trial_section").append(data);
$('#pre_trial_form').hide()
});
}
/**
* This function loads the criminal case form's data, activates the criminal case tab, and shows the list of criminal case form if this form was
previously sent or just shows the criminal case button
*/
var loadCriminalCase = function () {
$.get(base_url + "staff/criminal_case/show-control", function(data) {
$('.new-tab-wrap').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-criminal-case-tab').parent('li').show()
$('#new-criminal-case-tab').addClass('active')
$('#new-criminal-case').addClass('show active')
$("#criminal_case_section").empty();
$("#criminal_case_section").append(data);
});
}
/**
* This function loads the bindover form's data, activates the bindover tab, and shows the list of bindover form if this form was
previously sent or just shows the bindover button
*/
var loadBindOver = function () {
$.get(base_url + "staff/case_bindover/show-control", function(data) {
$('.new-tab-wrap').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-case-bindover-tab').parent('li').show()
$('#new-case-bindover-tab').addClass('active')
$('#new-case-bindover').addClass('show active')
$("#case_bindover_section").empty();
$("#case_bindover_section").append(data);
});
}
/**
* This function loads the probation intake form's data, activates the probation intake tab, and shows the list of probation intake form if this form was
previously sent or just shows the probation intake button
*/
var loadProIntake = function () {
$.get(base_url + "staff/probation/intake-control", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-probation-tab').parent('li').show()
$('#new-probation-tab').text('Probation')
$('#new-probation-tab').addClass('active')
$('#new-probation').addClass('show active')
$("#probation_section").empty();
$("#probation_section").append(data);
$('#probation-form').hide();
// initDatepicker();
});
}
/**
* This function loads the fair intake form's data, activates the fair intake tab, and shows the list of fair intake form if this form was
previously sent or just shows the fair intake button
*/
var loadFairIntake = function () {
$.get(base_url + "staff/probation/fair-control", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-probation-tab').parent('li').show()
$('#new-probation-tab').text('Probation')
$('#new-probation-tab').addClass('active')
$('#new-probation').addClass('show active')
$("#probation_section").empty();
$("#probation_section").append(data);
$('#probation-form').hide();
// initDatepicker();
});
}
/**
* This function loads the e-intake form's data, activates the e-intake tab, and shows the list of e-intake form if this form was
previously sent or just shows the e-intake button
*/
var loadEintake = function () {
$.get(base_url + "staff/probation/e-control", function (data) {
$('#myTab').find('.active').removeClass('active')
$('#myTabContent').find('.show.active').removeClass('show active')
$('#new-probation-tab').parent('li').show()
$('#new-probation-tab').text('Probation')
$('#new-probation-tab').addClass('active')
$('#new-probation').addClass('show active')
$("#probation_section").empty();
$("#probation_section").append(data);
$('#probation-form').hide();
// initDatepicker();
});
}
/**
* This function handles the button click whether to put offender off from hold
*/
$(document).on('click', '#offHold', function () {
$.confirm({
title: 'Are you sure you want to put offender off from hold?',
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
},
ok: {
text: "Ok",
btnClass: 'btn btn-success',
keys: ['enter'],
action: function () {
$.post(base_url + "staff/hold/off-hold-action", function (data) {
if (data.status.localeCompare("success") == 0) {
var message = atob(data.message);
$("#home_section").html(atob(data.message));
loadQueue();
// location.reload(true);
}
}, 'json');
}
}
}
})
});
/**
* This function handles the button click to open case details window
*/
$(document).on('click', '#caseDetails', function () {
$.get(base_url + "staff/caseDetials", function (data) {
// var link = base_url + 'welcome/case_summary/'+ data.caseId+'/no';
// var url = window.open(link, '_blank');
// if (url) {
// url.focus();
// } else {
// //alert('Please allow popups for this website');
// }
var pageURL = base_url + 'welcome/case_summary/'+ data.caseId+'/no';
var pageTitle = "iCourtApp::Case";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 'auto', 'auto');
}, 'json')
});
/**
* This function handles the button click whether to start or stop own video
*/
// function to control own video session
$(document).on('click', "#toggleMyVideo", function () {
// if ($(this).is(':checked')) {
if (session_info.jitsi_started ==1) {
jist_stop()
localStorage.setItem('LS_is_video_start', 'false')
}
else {
jist_start(session_info.offender_staff_session_id, registration_info);
localStorage.setItem('LS_is_video_start', 'true')
}
// }
})
/**
* This function handles the button click whether to start or stop own video
*/
var startMyVideo = function () {
console.log('init--------', localStorage.LS_is_video_start)
// if(typeof localStorage.LS_is_video_start != "undefined"){
if(localStorage.LS_is_video_start !== 'false') {
jist_start(session_info.offender_staff_session_id, registration_info);
}
else {
jist_stop()
}
// }
}
/**
* This function handles the button click whether to start or stop video session with the offender
*/
$(document).on('click', "#toggleOffenderVideo", function () {
if ($(this).is(':checked')) {
$.post(base_url + "staff/start-session", function (data) {
if (data.status.localeCompare("success") == 0) {
session_info.offender_staff_session_id = data.offender_staff_session_id;
infoToastr('Connecting to offender')
//jist_stop();
// localStorage.setItem('LS_offender_video_start', 'true')
}
}, 'json');
} else {
$.post(base_url + "staff/stop-session", function (data) {
if (data.status.localeCompare("success") == 0) {
session_info.offender_staff_session_id = data.offender_staff_session_id;
infoToastr('Disconnecting with offender')
// localStorage.removeItem('LS_offender_video_start')
}
}, 'json');
}
})
var callingPopup;
var calling_music;
/**
* This function calls the staff from Court Staff list. It checks whether staff is on a call or not.
*/
$(document).on('click', '.js-call-court-staff', function(e) {
console.log('asdf', $(e.target))
if(!$(e.target).hasClass('js-open-pickup-queue-i')) {
if($(this).hasClass('in-call')) {
$.confirm({
title: `You are on a call. Please end the previous call before making a new call.`,
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
ok: {
text: 'OK',
btnClass: 'btn btn-success mr-3',
action: function() {
}
},
}
});
}
else {
var name = $(this).data('name')
var title = $(this).data('title')
var id =$(this).data('id')
var _this = $(this)
// _this.hide()
_this.find('.fa.fa-phone.js-phone-icon').hide()
_this.find('.phonering-alo-phone.js-phone-ringing').show()
$.get(
base_url + "staff/call/"+id,
function (data) {
//alert(data.call_id);
calling_music = document.getElementById('calling_music');
calling_music.volume = 0.8;
calling_music.play();
switch(data.status){
case "success":
// change to vibrating phone icon
callingPopup = $.confirm({
title: `Calling ${name} (${title})`,
columnClass: 'col-md-6 col-md-offset-2',
content: '',
buttons: {
cancel: {
btnClass: 'btn btn-danger mr-3',
action: function() {
calling_music.pause();
var id =
$.get(
base_url + "staff/cancel-call/"+data.call_id,
function (data) {
console.log(data);
switch(data.status){
case "success":
// close the popup
break;
case "warning":
break;
default :
break;
}
},
'json');
// _this.show()
// _this.parent('.btn-dot').find('.js-phone-ringing').hide()
_this.find('.fa.fa-phone.js-phone-icon').show()
_this.find('.phonering-alo-phone.js-phone-ringing').hide()
}
},
}
});
break;
case "warning":
break;
default :
break;
}
},
'json');
}
}
})
$(document).on('click', '.js-staff-queue', function() {
var template = `
<div class="mdc-card-wrap">
<div class="tg-list-item mdc-card p-0">
<input class="tgl tgl-skewed" id="toggleMyVideo" type="checkbox"/>
<label class="tgl-btn" data-tg-off="Start My Video" data-tg-on="Stop My Video" for="toggleMyVideo"></label>
</div>
</div>
`;
$('#main-section').find('.card').empty();
$('#main-section .card').html(template)
})
var invitation_data = null;
function animateRing(id) {
var a= document.getElementById(id);
}
/**
* This function ends the phone calls with the staff
*/
$(document).on('click', '#endCallSession', function(){
var call_id = $(this).data('call_id');
$.get(
base_url + "staff/end-call/"+call_id,
function (data) {
console.log(data);
jist_stop();
// location.reload();
$('#videoCallDoModal').modal('hide');
$('.modal-backdrop').remove();
$('.js-call-court-staff').removeClass('in-call')
$('#phone_icon_'+call_id).parent('.btn-dot').find('.js-phone-ringing').hide();
if(localStorage.LS_selected_queue_id !== undefined) {
if(localStorage.LS_is_video_start === 'false' || localStorage.LS_is_video_start === '') {
$('#toggleMyVideo').prop("checked", true)
console.log('localStorage-----------',localStorage.length)
}
console.log('localStorage-----------',localStorage.length)
startMyVideo();
}
// unsubscribe_offender(session_info.offender_staff_session_id);
// $.get(base_url + "staff/common/current-user-being-served/"+ localStorage.LS_selected_queue_id, function (data) {
// // localStorage.setItem('LS_selected_queue_id', userid);
// session_info.offender_staff_session_id = data.offender_staff_session_id;
// startMyVideo();
// $('#loading-icon').show();
// $("#info-box").html('');
// $("#info-box").html(data.offender_detail);
// $('#queue_'+localStorage.LS_selected_queue_id).addClass('active');
// $('#main-section').empty();
// $.get(base_url + "staff/common/show-control", function (data) {
// $('#main-section').empty();
// $('#main-section').html(data);
// // subscribe_offender(session_info.offender_staff_session_id);
// if (data.code == 200) {
// $(".message").html(data.message);
// } else {
// $(".message").html(data.message);
// }
// });
// });
},
'json');
})
/**
* This function handles the button click to open the 'Take Offender' form
*/
$(document).on('click', '#take_offender', function () {
var pageURL = base_url + "staff/take-offender/show-form" ;
var pageTitle = "iCourtApp::Transfer";
var myWindow = newWindow.createPopupWin(pageURL, pageTitle, 600, 400);
});
var show_control = function(inviteId){
console.log('inviteid '+inviteId);
$.get(base_url + "staff/get-invitation-controls/"+inviteId, function (data) {
$('#main-section').empty();
$('#main-section').append(data);
});
}
/**
* This function gets the invitee details and render it on the staff's dashboard
* @params {string} inviteId - ID of the invitee staff
*/
var invitee_detial = function(inviteId){
$.get(base_url + "staff/invite-detail/" + inviteId, function (data) {
$("#info-box").html(data);
});
}
/**
* This function gets the staff list and render it on the staff's dashboard
*/
var updateStaffList = function(){
$.get(base_url + "staff/" + user_role + "/get-staff-list", function (data) {
$("#list_staff").empty();
$("#list_staff").append(data);
});
}
// var updateInviteList = function(){
// $.post(base_url+ "staff/update-invite", function(data){
// },"json");
// }
/**
* This function loads the html template which contains the Leave button (to leave the session) and Document button (to view offender's)
documents
*/
var show_invitee_control = function(){
var template = `<div class="mt-3 mt-xl-4 position-relative">
<ul class="nav nav-tabs new-tab-wrap" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link" id="invite-legalDoc-tab" data-toggle="tab" href="#invite-legalDoc" role="tab" aria-controls="invite-legalDoc" aria-selected="true">Video</a>
</li>
</ul>
<div class="tab-content" id="inviteTabContent">
<div class="tab-pane fade active show" id="invite-video" role="tabpanel" aria-labelledby="invite-video-tab">
<div class="mdc-card-wrap">
<button class="mdc-card mb-0 js-refresh" id="invite_leave" data-user_id="" >Leave</button>
</div>
</div>
<div class="tab-pane fade" id="invite-legalDoc" role="tabpanel" aria-labelledby="invite-legalDoc-tab">
<div class="mdc-card-wrap">
+data.doc+
</div>
</div>
</div>
</div>`;
$('#main-section').empty();
$('#main-section').html(template)
}
var pingBack = function(){
$.ajax({
type: "POST",
url: base_url + "ping-back",
dataType:'JSON',
success: function(data){
if(data.status =='success'){
console.log(data.login_id)
console.log('success')
// $.get(base_url + "staff/Staff/get-staff-list", function (data) {
// $("#list_staff").empty();
// $("#list_staff").append(data);
// });
updateStaffList();
$.get(base_url + "staff/Staff/get-my-queue", function (data) {
//var queue_id = $('#queue_'+select_queue).val();
//alert(select_queue);
$("#list_queue").empty();
$("#list_queue").append(data);
$('#queue_'+localStorage.LS_selected_queue_id).addClass('active');
});
}else{
console.log('error')
}
}
});
}
/**
* This function handles the button click to open case summary window
*/
$(document).on('click', '.js-case-summary', function(e) {
e.preventDefault();
var caseId = $(this).data('id')
var myWindow = window.open(base_url+"welcome/case_summary/"+caseId+"/no", "", "width='auto',height='auto',directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0");
})
/**
* This function handles the button click to open recommendation form
*/
$(document).on('click', '#new-recommendation-tab', function () {
// ajax call to get recommendation form
$.get(base_url + "staff/recommendation/show-control", function (data) {
$("#recommendation_section").empty();
$("#recommendation_section").append(data);
});
});
// $(document).on('click', '#new-recommendation-tab', function () {
// // ajax call to get recommendation form
// $.get(base_url + "staff/recommendation/reckless-show-control", function (data) {
// $("#recommendation_section").empty();
// $("#recommendation_section").append(data);
// });
// });
/**
* This function handles the button click to open criminal case form
*/
$(document).on('click', '#new-criminal-case-tab', function () {
// ajax call to get criminal case control
$.get(base_url + "staff/criminal_case/show-control", function (data) {
$("#criminal_case_section").empty();
$("#criminal_case_section").append(data);
});
});
/**
* This function handles the button click to open case bindover form
*/
$(document).on('click', '#new-case-bindover-tab', function () {
// ajax call to get case bindover control
$.get(base_url + "staff/case_bindover/show-control", function (data) {
$("#case_bindover_section").empty();
$("#case_bindover_section").append(data);
});
});
var loadInfoBox = function(){
$.get(base_url+"staff/common/loadInfoBox", function(data){
console.log(data);
$("#info-box").empty();
$("#info-box").append(data);
});
}
/**
* This function handles the select options of bindover forms
*/
$(document).on('change', '.js-new-pretrial-select', function () {
var value = $(this).val()
if(value == 'criminalCase') {
loadCriminalCaseList();
}
else if (value == 'bindover') {
loadBindoverList();
}
else if (value == 'pretrial') {
loadPreTrialList();
}
else if (value == 'recommendation') {
loadRecommendList();
}
else if (value == 'reckless') {
loadRecklessDriving();
}
});
/**
* This function handles the select options of probation forms
*/
$(document).on('change', '.js-new-probation-select', function () {
var value = $(this).val()
if(value == 'pro-intake') {
loadProIntake();
}
else if (value == 'probation') {
showProbationForm();
}
else if (value == 'fair-intake') {
loadFairIntake();
}
else if (value == 'e-intake') {
loadEintake();
}
});
/**
* This function checks whether video session was started or not
* @params {string} offender_staff_session_id - ID of offender staff session
*/
var wasOffenderVideoStarted = function(offender_staff_session_id){
$.get(base_url + "offender/was-video-started/"+ offender_staff_session_id, function (data) {
if(data.videoStated > 0){
$('#toggleOffenderVideo').prop("checked", true)
}
},"json");
}
// to be deleted
async function wasVideoStarted (offender_staff_session_id){
$.post(base_url + "staff/vidoe-stop/"+ offender_staff_session_id, function (data) {
console.log('aaa');
return;
}, 'json');
}
/**
* This function subscribes the currently clicked offender and unsubscribes the old offender. Staffs own video gets started.
Contents in the tab section are loaded according to the privilidges.
* @params {string} offender_staff_session_id - ID of the currently clicked offender staff session
* @params {string} userInfo - ID of the previous offender staff session
*/
async function currntUserBeingServed (userid,old_offender_staff_session_id){
// await wasVideoStarted(old_offender_staff_session_id);
$.post(base_url + "staff/vidoe-stop/"+ old_offender_staff_session_id, function (elem) {
console.log('aaa');
if(elem.status === "success"){
console.log('eee');
unsubscribe_offender(old_offender_staff_session_id);
$.get(base_url + "staff/common/current-user-being-served/"+ userid, function (data) {
select_queue = userid;
localStorage.setItem('LS_selected_queue_id', userid);
console.log(data);
console.log("ossid ",session_info.offender_staff_session_id);
session_info.offender_staff_session_id = data.offender_staff_session_id;
startMyVideo();
$("#info-box").html(data.offender_detail);
$('#main-section').empty();
$.get(base_url + "staff/common/show-control", function (data) {
$('#main-section').empty();
$('#main-section').append(data);
subscribe_offender(session_info.offender_staff_session_id);
if (data.code == 200) {
$(".message").html(data.message);
} else {
$(".message").html(data.message);
}
$('.session-time').show()
$('#basicUsage2').html('00:00:00')
timer = new Timer();
timer.start();
timer.addEventListener('secondsUpdated', function (e) {
$('#basicUsage2').html(timer.getTimeValues().toString());
});
if(localStorage.LS_is_video_start === 'false' || localStorage.LS_is_video_start === '') {
$('#toggleMyVideo').prop("checked", true)
}
wasOffenderVideoStarted(session_info.offender_staff_session_id)
isOffenderQueueClick = false;
});
});
}
}, 'json');
}