$(window).bind('beforeunload', function () {
setTimeZoneCookie();
return;
});
function setTimeZoneCookie() {
var localTime = new Date();
var year = localTime.getFullYear();
var month = localTime.getMonth() + 1;
var date = localTime.getDate();
var hours = localTime.getHours();
var minutes = localTime.getMinutes();
var seconds = localTime.getSeconds();
var h = localTime.getHours();
var m = localTime.getMinutes();
var _time = (h >= 12) ? ('PM') : ('AM');
var CalculateDateTimeZone = month + "/" + date + "/" + year + " " + hours + ":" + minutes + ":" + seconds + " " + _time;
$.cookie("LocalTimeZone", CalculateDateTimeZone, { path: '/' });
document.cookie = 'LocalTimeZone=' + CalculateDateTimeZone + ';path=/';
return CalculateDateTimeZone;
}
//function ConvertUTCTimeToLocalTime(UTCDateString, IsDisplayYear) {
// var offsetms = ((new Date()).getTimezoneOffset() * 60 * 1000);
// var convertdLocalTime = new Date(UTCDateString);
// var newDate = new Date(convertdLocalTime.valueOf() - offsetms);
// // var newDate = new Date(convertdLocalTime.getTime() + (convertdLocalTime.getTimezoneOffset() * 60 * 1000));
// // newDate.setHours((convertdLocalTime.getHours()) - (convertdLocalTime.getTimezoneOffset() / 60));
// var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// var date_format = '12'; /* FORMAT CAN BE 12 hour (12) OR 24 hour (24)*/
// var d = newDate;
// var hour = d.getHours();
// var minutes = d.getMinutes();
// var result = hour;
// var ext = '';
// if (date_format == '12') {
// if (hour > 12) {
// ext = 'PM';
// hour = (hour - 12);
// if (hour < 10) {
// result = "0" + hour;
// } else if (hour == 12) {
// hour = "00";
// ext = 'AM';
// }
// }
// else if (hour < 12) {
// result = ((hour < 10) ? "0" + hour : hour);
// ext = 'AM';
// } else if (hour == 12) {
// ext = 'PM';
// }
// }
// if (minutes < 10) {
// minutes = "0" + minutes;
// }
// if (IsDisplayYear)
// return monthNames[newDate.getMonth()] + " " + newDate.getDate() + ", " + newDate.getFullYear() + " " + result + ":" + minutes + ' ' + ext;
// else
// return monthNames[newDate.getMonth()] + " " + newDate.getDate() + ", " + result + ":" + minutes + ' ' + ext;
//}
function ConvertUTCTimeToLocalTimeWithMonthNumber(UTCDateString) {
var offsetms = ((new Date()).getTimezoneOffset() * 60 * 1000);
var convertdLocalTime = new Date(UTCDateString);
var newDate = new Date(convertdLocalTime.valueOf() - offsetms);
var monthNames = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
var date_format = '24'; /* FORMAT CAN BE 12 hour (12) OR 24 hour (24)*/
var d = newDate;
var hours = d.getHours();
var minutes = d.getMinutes();
hours = ((hours < 10) ? "0" + hours : hours);
if (minutes < 10) {
minutes = "0" + minutes;
}
return monthNames[newDate.getMonth()] + "/" + newDate.getDate() + "/" + newDate.getFullYear() + ", " + hours + ":" + minutes;
}
function ConvertUTCTimeToLocalTime(UTCDateString, IsDisplayYear) {
var offsetms = ((new Date()).getTimezoneOffset() * 60 * 1000);
var convertdLocalTime = new Date(UTCDateString);
var newDate = new Date(convertdLocalTime.valueOf() - offsetms);
var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var date_format = '12'; /* FORMAT CAN BE 12 hour (12) OR 24 hour (24)*/
var d = newDate;
var hours = d.getHours();
var minutes = d.getMinutes();
var suffix = '';
if (hours > 11) {
suffix += "PM";
} else {
suffix += "AM";
}
if (hours > 12) {
hours -= 12;
} else if (hours === 0) {
hours = 12;
}
hours = ((hours < 10) ? "0" + hours : hours);
if (minutes < 10) {
minutes = "0" + minutes;
}
if (IsDisplayYear)
return monthNames[newDate.getMonth()] + " " + newDate.getDate() + ", " + newDate.getFullYear() + " " + hours + ":" + minutes + ' ' + suffix;
else
return monthNames[newDate.getMonth()] + " " + newDate.getDate() + ", " + hours + ":" + minutes + ' ' + suffix;
}
function convertLocalDateToUTCDate(date) {
date = new Date(date);
//Local time converted to UTC
var localOffset = date.getTimezoneOffset() * 60000;
var localTime = date.getTime();
date = localTime + localOffset;
date = new Date(date);
return date;
}
function CheckSoonDate(UTCDateString) {
var offsetms = ((new Date()).getTimezoneOffset() * 60 * 1000);
var convertdLocalTime = new Date(UTCDateString);
var newDate = new Date(convertdLocalTime.valueOf() - offsetms);
var nowDate = new Date();
nowDate.setDate(nowDate.getDate() + 1);
if (newDate <= nowDate || newDate <= new Date()) {
return true;
} else {
return false;
}
}
function showflags(COntrolID) {
$('#' + COntrolID).flagStrap({
countries: {
"ar": "Arabic",
"us": "English",
"de": "German",
"es": "Spanish",
"th": "Thai",
"vi": "Vietnamese"
},
buttonSize: "",
buttonType: "btn-info",
labelMargin: "10px",
scrollable: false,
scrollableHeight: "350px"
});
$('#' + COntrolID + ' ul li').on("click", function () {
$("#loadingWithBG").show();
try {
var DropDown = $('#' + COntrolID).find('select');
var lang = DropDown.val();
var hdnUrl = "";
$.ajax({
url: '/Common/SetLanguage',
data: { langid: 0, lang: lang, returnUrl: hdnUrl },
success: function (data) {
location.reload();
$("#loadingWithBG").hide();
},
error: function (e) {
$("#loadingWithBG").hide();
}
});
}
catch (error) { $("#loadingWithBG").hide(); }
});
}
function OpenNewTab(url) {
location.href = url;
$('#PatientHistory').modal('toggle');
}
$(document).ready(function () {
$(".wysihtml5 - toolbar").hide();
//$('input[type="radio"], input[type="checkbox"]').uniform();
//For Decimal
$(document).off('keypress', ".allowDouble");
$(document).on('keypress', ".allowDouble", function (e) {
if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
return false;
}
});
//For int
$(document).off('keypress', ".allowint");
$(document).on('keypress', ".allowint", function (e) {
//console.log(e.which);
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
//For Minus/int
$(document).off('keypress', ".allowmint");
$(document).on('keypress', ".allowmint", function (e) {
if (e.which != 8 && e.which != 0 && e.which != 45 && (e.which < 48 || e.which > 57)) {
return false;
}
});
$(document).on('change', '.btn-file :file', function () {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [numFiles, label]);
});
$('#i_file').change(function (event) {
var html = "";
$("#file_count").text(event.target.files.length + " file(s) selected");
});
$('.plusbtn').click(function (e) {
e.preventDefault();
var acid = $(this).attr('href');
$(this).children('i').addClass('fa');
$(this).children('i').toggleClass('fa-plus fa-minus');
$('#' + acid).slideToggle('slow');
});
$(document).off('click', '.comentlink');
$(document).on('click', '.comentlink', function (e) {
e.preventDefault();
$(this).closest('.commentdiv').attr('data-top', $('#divBlogList').scrollTop());
var cclass = $(this).closest('.commentdiv').children('.comments');
if ($(this).hasClass('active')) {
$(cclass).slideUp('slow');
$(this).removeClass('active');
} else {
$(cclass).slideToggle('slow');
$(this).addClass('active');
}
});
$('.blcont .blincont').each(function () {
var blheight = $(this).height();
var contentfull = $(this).find('.inner-blog-content-full').html();
var contentless;
var showChar = 125;
if (contentfull.length > showChar) {
var contentless = contentfull.substr(0, showChar);
$(this).find('.inner-blog-content-full').hide();
$(this).find('.inner-blog-content-less').show().html(contentless + "...");
$(this).parent().next('.blbtndiv').slideDown('slow');
}
else {
$(this).find('.inner-blog-content-full').show();
$(this).find('.inner-blog-content-less').hide();
}
});
$('.bllink').click(function () {
$(this).closest('.blcontmain').children('.blcont').toggleClass('expand');
var blliktext = $(this).text();
if (blliktext == 'View More') {
$(this).text('View Less');
$(this).closest('.blcontmain').children('.blcont').children('.blincont').find('.inner-blog-content-less').hide();
$(this).closest('.blcontmain').children('.blcont').children('.blincont').find('.inner-blog-content-full').fadeIn('slow');
} else {
$(this).text('View More');
$(this).closest('.blcontmain').children('.blcont').children('.blincont').find('.inner-blog-content-full').hide();
$(this).closest('.blcontmain').children('.blcont').children('.blincont').find('.inner-blog-content-less').fadeIn('slow');
}
});
$('.msgtd label').click(function () {
var minput = $(this).find('input');
if ($(minput).is(':checked')) {
$(this).next('.msgsend').fadeOut('slow');
} else {
$(this).next('.msgsend').fadeIn('slow');
}
});
$(document).off('keyup', '.commentBase textarea');
$(document).on('keyup', '.commentBase textarea', function () {
$(this).next('.form-group').removeClass('fgError').children('p').remove();
if ($(this).val() == '') {
$('
').insertAfter($(this));
}
});
});
function postBlog() {
if ($("#txtContent").val() != '') {
$("#frmBlog").submit();
} else {
$("#txtContent").css('border', '2px solid red');
return false;
}
}
$("#txtContent").keydown(function () {
$("#txtContent").css('border', '2px solid grey');
});
function LoadColleaguesForCurrentCustomer(Search_Name, officeid, IsStudent) {
$('#hidepatent').hide();
$.ajax({
url: "/Colleague/" + (IsStudent ? "GetStudentCaseForSendOffice" : "GetColleagesPatients"),
type: 'POST',
dataType: 'json',
data: { Search_Name: Search_Name, officeid: officeid },
async: false,
success: function (data) {
$("#Search_PatientClickColleague").fadeIn('slow');
if (data !== false) {
if (data.length != 0) {
$(".loadingWithBG").hide();
$("#Search_PatientClick").hide();
$("#Search_PatientClickConsult").hide();
$('.colleaguepatient').fadeIn("slowly");
$(".colleaguepatient .colleaguerow").empty();
$("#sp_displaymsgnotfoundColleague").addClass('hide');
$.each(data, function (i, val) {
var index = i + 1;
var content = '';
content += '' + '';
content += ' ' + index + ' ';
content += ' ' + ' | ';
content += '' + '' + val.FirstName + '' + ' | ';
content += '' + '' + val.LastName + '' + ' | ';
content += '' + '' + (val.IsCaseReturned == false ? val.SendDate == null ? "-" : ConvertUTCTimeToLocalTime(val.SendDate, false) : "RETURNED") + '' + ' | ';
content += '' + '' + (val.SenderName != null ? val.SenderName : '-') + '' + ' | ';
content += '' + '' + (val.ReceiverName != null ? val.ReceiverName : '-') + '' + ' | ';
if (!_isOffline && val.MailTo != null) {
content += '' + ' | ';
} else {
content += ' | ';
}
if (val.Comment != undefined && val.Comment != "" && val.Comment != null) {
content += '' + ' | ';
}
else {
content += ' | ';
}
if (val.IsValidReturn) {
content += '' + '' + ' | ';
}
else {
content += ' | ';
}
if (val.IsValidTransfer) {
content += '' + '' + ' | ';
}
else {
content += ' | ';
}
content += ' | ';
content += '
';
$(".colleaguepatient tbody").append(content);
});
$('.pformico').tooltip({
tooltipClass: "blue_tooltip",
position: {
my: "left bottom",
at: "left-5 top-10"
}
});
$('[data-toggle="popover"]').popover({
placement: 'left',
container: 'body',
html: true,
content: function () {
return $(this).parent().children('.popData').html();
}
});
$('.dmpop').popover({
placement: 'left',
container: 'body',
html: true,
content: function () {
var ilength_mailfrom = $(this).parent().children('.popData').find('.mailfrom').val().length * 6.5;
var ilength_mailto = $(this).parent().children('.popData').find('.mailto').val().length * 6.5;
var maxLength = ilength_mailfrom > ilength_mailto ? ilength_mailfrom : ilength_mailto;
$(this).parent().children('.popData').find('input').width(maxLength);
return $(this).parent().children('.popData').html();
}
});
$(document).on('click', '.dmpop', function () {
if (!$(this).hasClass('active')) {
var ilength_mailfrom = $(this).parent().children('.popData').find('.mailfrom').val().length * 6.5;
var ilength_mailto = $(this).parent().children('.popData').find('.mailto').val().length * 6.5;
var maxLength = ilength_mailfrom > ilength_mailto ? ilength_mailfrom : ilength_mailto;
if (maxLength > 276) {
var ilength2 = maxLength - 248;
var ileftpos = $(this).offset().left - 288;
var popleft = ileftpos - ilength2;
$('.popover').css({ 'left': popleft });
}
}
$(this).addClass('active');
$('.popover').css({ 'max-width': 'inherit' });
$(".mailsentmsg").hide();
});
$('.pop-function-rate').popover({
placement: 'left',
container: 'body',
html: true,
content: function () {
var ilength = $(this).parent().children('.popData').find('input').val().length * 6.5;
$(this).parent().children('.popData').find('input').width(ilength);
return $(this).parent().children('.popData').html();
}
});
$(document).on('click', '.pop-function-rate', function () {
if (!$(this).hasClass('active')) {
var ilength = $(this).next('.popData').find('input').val().length * 6.5;
if (ilength > 276) {
var ilength2 = ilength - 248;
var ileftpos = $(this).offset().left - 288;
var popleft = ileftpos - ilength2;
$('.popover').css({ 'left': popleft });
}
}
$(this).addClass('active');
$('.popover').css({ 'max-width': 'inherit' });
});
$(document).on('click', function (e) {
$('[data-toggle="popover"],[data-original-title]').each(function () {
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
(($(this).popover('hide').data('bs.popover') || {}).inState || {}).click = false // fix for BS 3.3.6
}
});
});
$(document).on('click', '.sendmessage', function () {
var Message = $(this).closest('.popover-content').find('.messagetext').val();
var MailFrom = $(this).closest('.popover-content').find('.mailfrom').val();
var MailTo = $(this).closest('.popover-content').find('.mailto').val();
if (Message == "") {
$('.messagetext').focus();
return false;
}
else {
$.ajax({
url: "/Dashboard/DirectMail",
type: 'POST',
dataType: 'json',
data: { MailFrom: MailFrom, MailTo: MailTo, Message: Message },
async: false,
success: function (data) {
if (data == true) {
$(".mailsentmsg").show();
}
}
});
}
});
}
else {
$(".loadingWithBG").hide();
$("#Search_PatientClick").hide();
$("#Search_PatientClickConsult").hide();
$(".colleaguepatient .colleaguerow").empty();
$("#sp_displaymsgnotfoundColleague").removeClass('hide');
}
}
else {
$(".loadingWithBG").hide();
$("#Search_PatientClick").hide();
$("#Search_PatientClickConsult").hide();
$(".colleaguepatient .colleaguerow").empty();
$("#sp_displaymsgnotfoundColleague").removeClass('hide');
}
},
error: function () {
alert('Your latest changes were not saved because of server connection error. You will be redirected to the home page!');
window.location.href = "/Home/Index";
}
});
}
$(function () {
$('#sp_tablesearch2, .ReturnDetailColleague').on('click', 'a', function (e) {
var patientId = $(this).attr("id");
var officeid = $('input[name=office_radio]:checked', '.search_patient').val();
if ($(this).attr('data-profile') != undefined && $(this).attr('data-profile') != null && $(this).attr('data-profile')) {
var customerID = $(this).attr('data-customerid');
$.ajax({
url: "/Common/GetConsultantInfo",
type: 'POST',
dataType: 'json',
data: { customerID: customerID },
async: false,
success: function (data) {
if (data != undefined && data != null && data != "") {
$("#consultant_FullName").empty();
$("#consultant_CityInfo").empty();
$("#consultant_StateInfo").empty();
$("#consultant_CountryInfo").empty();
$("#consultant_LanguageInfo").empty();
var FullName = data.FirstName + ' ' + data.LastName;
var Cityname = data.City;
var Statename = data.State;
var CountryName = data.Country;
var Language = data.Laguage;
$('#consultant_pinfo_name').text('Profile Information');
$("#consultant_FullName").append(FullName);
$("#consultant_CityInfo").append(Cityname);
$("#consultant_StateInfo").append(Statename);
$("#consultant_CountryInfo").append(CountryName);
$("#consultant_LanguageInfo").append((Language != undefined && Language != "" && Language != null ? Language : "English"));
$('#consulting_service_profile_information').modal('show');
}
}
});
} else {
$("#loadingWithBG").show();
$.ajax({
url: "/Dashboard/addpatientID",
type: 'post',
dataType: 'json',
data: { patientId: patientId, officeid: officeid },
async: true,
success: function (data) {
if (data.patientId != null) {
$("#loadingWithBG").hide();
$("#_hiddenPatientID").val(data.patientId);
if (window.location.href.indexOf("Dashboard/Social") > -1) {
window.location.href = "/clinic/ortho-classification";
}
$("#_ClinicalPatientHistory").attr("href", "/clinic/clinical-dental");
$("#_Modules").attr("href", "/clinic/ortho-classification");
$("#_MedicalForms").attr("href", "/clinic/clinical-history");
$("#_CaseDiagnostics").attr("href", "/clinic/clinical-perio");
$("#Classification1").attr("href", "/clinic/ortho-classification");
$("#Classification2").attr("href", "/clinic/ortho-classification2");
$("#PatientExpectations").attr("href", "/clinic/ortho-patient-expections");
$("#GoalsLimitations").attr("href", "/clinic/ortho-goals");
$("#Pictures").attr("href", "/clinic/ortho-pictures");
$("#DentalCAD").attr("href", "/clinic/ortho-dentalcad");
$("#Calculations").attr("href", "/clinic/ortho-calculations");
$("#Cephalometric").attr("href", "/clinic/ortho-cephalometrics");
$("#TreatmentPlan").attr("href", "/clinic/ortho-treatment");
$("#_PatientHistory").attr("href", "/Clinic/PatientHistory");
$("#Appliance").attr("href", "/clinic/ortho-appliance-master/");
$("#Search_PatientClick").fadeOut('slow');
//Reloading page
var location = window.location.href;
if (location.indexOf("clinic") != -1) {
if (location.indexOf('#') != -1) {
window.location.href = location.split('#')[0];
} else {
window.location.href = location;
}
}
$('.fade').css("display", "none");
}
}
});
}
});
$("#sp_tablesearch2, .ReturnDetailColleague").on('click', '.return', function () {
var PatientId = $(this).attr('id');
var DoctorId = $(this).attr('name');
$.ajax({
url: "/Colleague/BindReturnColleague",
type: 'POST',
dataType: 'html',
data: { patientId: PatientId, senderID: DoctorId },
async: false,
success: function (data) {
if (data != "") {
$("#ReturnConsultCase").empty();
$("#ReturnConsultCase").append(data);
$("#return_case1").modal("show");
$("#open_patientforsearchadd").modal("hide");
}
else {
alert("Something went wrong. Please try after sometime.");
}
},
error: function () {
alert("Something went wrong. Please try after sometime.");
}
});
});
$("#sp_tablesearch2, .ReturnDetailColleague").on('click', '.transfer', function () {
var officeid = $('input[name=office_radio]:checked', '.search_patient').val();
var id = $(this).attr('id');
$.ajax({
url: "/Dashboard/GetTransferPatient",
type: 'POST',
dataType: 'html',
data: { PatientId: id, officeid: officeid, colleagueID: $(this).attr('data-colleagueid') },
async: true,
success: function (data) {
if (data != null) {
selectedPatientID = id;
$("#Pateitntranferdata").empty();
$("#Pateitntranferdata").append(data);
$(".close").trigger('click');
$('#PatientTransfer').modal('show');
$('#opt_transfer_file').hide();
$('#opt_referral_file').hide();
$('#PatientTransfer').on('shown.bs.modal', function () {
$('.pTtable .crbite .form-group').each(function () {
$(this).children('label').find('em').remove();
var spantext = $(this).children('label').text();
if ($(this).children('label').find('span').children('em').length == 0) {
$(this).children('label').find('span').append('' + spantext + '');
}
});
});
}
}
});
});
//$(".ReturnDetailColleague").on('click', '.return', function () {
// var PatientId = $(this).attr('id');
// var DoctorId = $(this).attr('name');
// $.ajax({
// url: "/Dashboard/BindReturnConsulting",
// type: 'POST',
// dataType: 'html',
// data: { PatientId: PatientId, DoctorId: DoctorId },
// async: false,
// success: function (data) {
// if (data != "") {
// $("#PatientsDataConsulting").modal("hide");
// $("#ReturnConsultCase").empty();
// $("#ReturnConsultCase").append(data);
// $("#return_case1").modal("show");
// $("#open_patientforsearchadd").modal("hide");
// } else {
// alert("Something went wrong. Please try after sometime.");
// }
// },
// error: function () {
// alert("Something went wrong. Please try after sometime.");
// }
// });
//});
});
$(document).on('click', '.colleaguePatient_Delete', function () {
var colleagueId = $(this).attr("id")
$("#open_patientforsearchadd").modal('hide');
var deleteMessages;
if ($(this).attr('data-colleague') != "undefined" && $(this).attr('data-colleague') != "" && $(this).attr('data-colleague') != null) {
deleteMessages = "Are you sure you want to delete " + $(this).attr('data-patient') + " (Colleague copy) of " + $(this).attr('data-colleague') + "?";
$.confirm({
title: "Delete Colleague Copy",
text: deleteMessages,
confirm: function () {
$("#loadingWithBG").show();
$.ajax({
url: "/Colleague/DeleteColleagueCase",
type: 'POST',
dataType: 'json',
data: { colleagueID: colleagueId },
async: true,
success: function (data) {
$("#loadingWithBG").hide();
if (data == true) {
$(".successconsult3").css("display", "block");
$(".successconsult5").css("display", "none");
$(".successconsult2").css('display', 'none');
$(".successconsult1").css('display', 'none');
$(".successconsult4").css('display', 'none');
$(".successconsult6").css('display', 'none');
$('#SuccessModelConsulting').modal('show');
$('#PatientTransfer').modal('hide');
location.reload();
}
location.reload();
}
});
return false;
},
confirmButton: "Ok"
});
}
});
function CommonResponseDialog(title, message, callback) {
$.confirm({
title: title,
text: message,
confirm: function (button) {
callback();
},
cancel: function (button) {
},
confirmButton: "Ok",
cancelButton: "Cancel",
confirmButtonClass: "btn-theme",
cancelButtonClass: "hide",
dialogClass: "modal-dialog"
});
}
function IsValidEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
function hasScrollbar(elemet, isUsingId) {
if (isUsingId) {
return document.getElementById(elemet).scrollHeight > document.getElementById(elemet).clientHeight;
}
else {
return document.getElementsByClassName(elemet).scrollHeight > document.getElementsByClassName(elemet).clientHeight;
}
}