/**
** @package: SoOLEAGL calendar
** @Author: Jaeeme
** @Author Email: jaeeme.khan@sitanet.in
** @Author URI: http://soolegal.com
** @File Name : tlc.js
** @Description: SoOLEAGL calendar
*/
function pad(num, size) {
var s = num + "";
while (s.length < size)
s = "0" + s;
return s;
}
// default render calendar
if (jQuery('div#render-tlc').length > 0) {
jQuery.ajax({
url: url + 'tlc/getCalendar',
dataType: 'html',
beforeSend: function () {
$('#custom-calendar').html('
');
},
complete: function () {
jQuery('[data-caltoggle="tooltip"]').tooltip();
jQuery(".holiday").prev().css("color", "red");
},
success: function (html) {
jQuery('#custom-calendar').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
// render calendar with navigation
jQuery(document).on("click", "a.calnav", function (e) {
e.preventDefault();
var page = jQuery(this).data("calvalue");
jQuery.ajax({
url: url + 'tlc/getCalendar',
type: 'post',
data: {page: page},
dataType: 'html',
beforeSend: function () {
$('#custom-calendar').html('
');
},
complete: function () {
jQuery('[data-caltoggle="tooltip"]').tooltip();
jQuery(".holiday").prev().css("color", "red");
},
success: function (html) {
jQuery('#custom-calendar').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// render calendar change month
jQuery(document).on("change", "#setMonthVal", function (e) {
e.preventDefault();
var month = this.value;
var year = jQuery('#setYearVal > option:selected').val();
jQuery.ajax({
url: url + 'tlc/getCalendar',
type: 'post',
data: {year: year, month: month},
dataType: 'html',
beforeSend: function () {
$('#custom-calendar').html('
');
},
complete: function () {
jQuery('[data-caltoggle="tooltip"]').tooltip();
jQuery(".holiday").prev().css("color", "red");
},
success: function (html) {
jQuery('#custom-calendar').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// render calendar change year
jQuery(document).on("change", "#setYearVal", function (e) {
e.preventDefault();
var year = this.value;
var month = jQuery('#setMonthVal > option:selected').val();
jQuery.ajax({
url: url + 'tlc/getCalendar',
type: 'post',
data: {year: year, month: month},
dataType: 'html',
beforeSend: function () {
$('#custom-calendar').html('
');
},
complete: function () {
jQuery('[data-caltoggle="tooltip"]').tooltip();
jQuery(".holiday").prev().css("color", "red");
},
success: function (html) {
jQuery('#custom-calendar').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
jQuery(document).on("click", ".addhearinglog", function () {
var hearing_id = jQuery(this).data('hid');
var alog = jQuery(this).data('log');
var filename = jQuery(this).data('filename');
var prevfile = jQuery(this).data('prevfile');
jQuery('#create-hearing-id').val(hearing_id);
jQuery('#hearing_log').summernote('code', alog);
jQuery('#fileattach').html(filename);
jQuery('#prev_filename').val(prevfile);
});
jQuery(document).on('click', '#hearinglogadd', function () {
var checkbtn = this;
if (jQuery('form#add-hearing-log').valid() === false) {
return false;
} else {
var share = jQuery(this).data('share');
var hearing_id = jQuery('#create-hearing-id').val();
var hearing_log = jQuery('#hearing_log').val();
var prev_filename = jQuery('#prev_filename').val();
var formData = new FormData();
formData.append('hearing_log', hearing_log);
formData.append('hearing_id', hearing_id);
formData.append('share', share);
formData.append('prev_filename', prev_filename);
jQuery.each(jQuery('.filestyle')[0].files, function (i, file) {
formData.append('file', file);
});
jQuery.ajax({
url: url + 'clients/updateHearingLog',
type: 'post',
data: formData,
processData: false,
contentType: false,
dataType: 'json',
beforeSend: function () {
jQuery(checkbtn).button('loading');
},
complete: function () {
jQuery(checkbtn).button('reset');
jQuery('#addHearingLog').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#addHearingLog').modal('hide');
},
success: function (json) {
$('#errormsg').html(json.error);
if (share == 2) {
window.location.replace(json.path);
} else {
location.reload();
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
jQuery(document).on('click', '.delete-log', function () {
var type = jQuery(this).data('type');
if (type == 'aid') {
var checktype = 'MOM';
} else {
var checktype = 'comment';
}
if (confirm("Are you sure want to delete this " + checktype + "?")) {
var id = jQuery(this).data('aid');
jQuery.ajax({
url: url + 'c2rm/deleteLog',
type: 'post',
data: {type: type, id: id},
dataType: 'json',
beforeSend: function () {
//jQuery('#hearinglogadd').button('loading');
},
complete: function () {
//
},
success: function (json) {
location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
return false;
});
jQuery(document).on("click", ".addappointmentlog", function () {
var appointment_id = jQuery(this).data('aid');
var alog = jQuery(this).data('log');
jQuery('#create-appointment-id').val(appointment_id);
jQuery('#appointment_log').summernote('code', alog);
var prevfilemom = jQuery(this).data('prevfilemom');
jQuery('#prev_filenamemom').val(prevfilemom);
var filenamemom = jQuery(this).data('filenamemom');
jQuery('#fileattachmom').html(filenamemom);
});
jQuery(document).on('click', '#appointmentlogadd', function () {
var checkbtnmom = this;
if (jQuery('form#add-appointment-log').valid() === false) {
return false;
} else {
var share = jQuery(this).data('share');
var appointment_id = jQuery('#create-appointment-id').val();
var appointment_log = jQuery('#appointment_log').val();
var prev_filenamemom = jQuery('#prev_filenamemom').val();
var formData = new FormData();
formData.append('appointment_log', appointment_log);
formData.append('appointment_id', appointment_id);
formData.append('share', share);
formData.append('prev_filenamemom', prev_filenamemom);
jQuery.each(jQuery('.filestylemom')[0].files, function (i, file) {
formData.append('file', file);
});
jQuery.ajax({
url: url + 'clients/updateAppointmentLog',
type: 'post',
data: formData,
processData: false,
contentType: false,
dataType: 'html',
beforeSend: function () {
jQuery(checkbtnmom).button('loading');
},
complete: function () {
jQuery(checkbtnmom).button('reset');
jQuery('#addAppointmentLog').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#addAppointmentLog').modal('hide');
},
success: function (html) {
$option = '';
$option += 'Log Added!
';
$option += html;
$('#appointmentid-' + appointment_id).html($option);
$('#appointmentid-' + appointment_id + ' .log-ff').delay(3000).fadeOut();
location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
jQuery(document).on("click", ".addndoh", function () {
var hearing_id = jQuery(this).data('hid');
jQuery('#current-hearing-id').val(hearing_id);
});
jQuery(document).on('click', '#ndohadd', function () {
if (jQuery('form#add-next-date-of-hearing').valid() === false) {
return false;
} else {
var share = jQuery(this).data('share');
var hearing_id = jQuery('#current-hearing-id').val();
var ndoh_court_no = jQuery('#ndoh_court_no').val();
var ndoh_court_name = jQuery('#ndoh_court_name').val();
var ndoh_hearing_prosecutor = jQuery('#ndoh_hearing_prosecutor').val();
var ndoh_hearing_date = jQuery('#ndoh_hearing_date').val();
var ndoh_judge_name = jQuery('#ndoh_judge_name').val();
var ndoh_hearing_description = jQuery('#ndoh_hearing_description').val();
jQuery.ajax({
url: url + 'clients/saveNDOH',
type: 'post',
data: {ndoh: ndoh_hearing_date, court_no: ndoh_court_no, court_name: ndoh_court_name, judge: ndoh_judge_name, prosecutor: ndoh_hearing_prosecutor, description: ndoh_hearing_description, hearing_id: hearing_id, share: share},
dataType: 'html',
beforeSend: function () {
jQuery('#ndohadd').button('loading');
},
complete: function () {
jQuery('#ndohadd').button('reset');
jQuery('#addNDOH').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#addNDOH').modal('hide');
},
success: function (html) {
//location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
/* for calendar change month */
jQuery(document).on("click", "#search_hearing_filter", function () {
var search_hearing_client_name = jQuery("#search_hearing_client_name").val();
var search_hearing_year = jQuery("#search_hearing_year").val();
var search_hearing_month = pad(jQuery("#search_hearing_month").val(), 2);
var search_hearing_date = '';
if (jQuery("#search_hearing_date").val() != '') {
search_hearing_date = pad(jQuery("#search_hearing_date").val(), 2);
}
jQuery.post(url + "tlc/filterHearingLog", {client: search_hearing_client_name, year: search_hearing_year, month: search_hearing_month, date: search_hearing_date},
function (data, status) {
if (status == 'success') {
jQuery("#custom-hearing-log").html(data);
} else {
console.log('failed');
}
});
});
/* for calendar change month */
jQuery(document).on("click", "#search_appointment_filter", function () {
var search_appointment_client_name = jQuery("#search_appointment_client_name").val();
var search_appointment_year = jQuery("#search_appointment_year").val();
var search_appointment_month = pad(jQuery("#search_appointment_month").val(), 2);
var search_appointment_date = '';
if (jQuery("#search_appointment_date").val() != '') {
search_appointment_date = pad(jQuery("#search_appointment_date").val(), 2);
}
jQuery.post(url + "tlc/filterAppointmentLog", {client: search_appointment_client_name, year: search_appointment_year, month: search_appointment_month, date: search_appointment_date},
function (data, status) {
if (status == 'success') {
jQuery("#custom-appointment-log").html(data);
} else {
console.log('failed');
}
});
});
/* add calendar event */
jQuery(function () {
jQuery(document).on("click", ".addHearing", function () {
jQuery('textarea#add_log').attr('readonly', 'readonly');
$.getJSON(url + "clients/getclientListCalendarModal", {ajax: 'true'}, function (data) {
var options = '';
jQuery("select#event_client_name").find("option:eq(0)").html("Please wait..");
options += '*Select Client ';
for (var i = 0; i < data.length; i++) {
options += '' + data[i].client_name + ' ';
}
jQuery("select#event_client_name").html(options);
});
});
//
jQuery(document).on("click", ".hearing-event", function () {
var completeDate = jQuery(this).data('hearingdata');
jQuery(".modal-body #current-date-task").val(completeDate);
jQuery(".modal-body #create-task-date").html(completeDate);
var currentdate = jQuery(this).data('currentdate');
jQuery.ajax({
url: url + 'clients/renderDateWiseData',
type: 'post',
data: {hearingDate: completeDate},
dataType: 'html',
beforeSend: function () {
$('#render-datewise-data').html('
');
},
success: function (html) {
jQuery("div#render-datewise-data").html(html);
$('.c2rm-cal-ul > li').removeClass("active");
$('.c2rm-cal-ul #li-hearing').addClass("active");
$('.c2rm-tab-pan').removeClass("active");
$('#hearing').addClass("active");
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//
jQuery(document).on("click", ".appointment-event", function () {
var completeDate = jQuery(this).data('appointmentdata');
jQuery(".modal-body #current-date-task").val(completeDate);
jQuery(".modal-body #create-task-date").html(completeDate);
var currentdate = jQuery(this).data('currentdate');
jQuery.ajax({
url: url + 'clients/renderDateWiseData',
type: 'post',
data: {hearingDate: completeDate},
dataType: 'html',
beforeSend: function () {
$('#render-datewise-data').html('
');
},
success: function (html) {
jQuery("div#render-datewise-data").html(html);
$('.c2rm-cal-ul > li').removeClass("active");
$('.c2rm-cal-ul #li-appointmentanonymous').addClass("active");
$('.c2rm-tab-pan').removeClass("active");
$('#appointmentanonymous').addClass("active");
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// get need a lawyer details
jQuery(document).on("click", ".need-lawyer", function () {
var completeDate = jQuery(this).data('needalawyerdata');
jQuery(".modal-body #current-date-task").val(completeDate);
jQuery(".modal-body #create-task-date").html(completeDate);
var currentdate = jQuery(this).data('currentdate');
jQuery.ajax({
url: url + 'clients/renderDateWiseData',
type: 'post',
data: {hearingDate: completeDate},
dataType: 'html',
beforeSend: function () {
$('#render-datewise-data').html('
');
},
success: function (html) {
jQuery("div#render-datewise-data").html(html);
$('.c2rm-cal-ul > li').removeClass("active");
$('.c2rm-cal-ul #li-need-lawyer').addClass("active");
$('.c2rm-tab-pan').removeClass("active");
$('#need-lawyer').addClass("active");
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// get public event details
jQuery(document).on("click", ".public-event", function () {
var completeDate = jQuery(this).data('publiceventdata');
jQuery(".modal-body #current-date-task").val(completeDate);
jQuery(".modal-body #create-task-date").html(completeDate);
var currentdate = jQuery(this).data('currentdate');
jQuery.ajax({
url: url + 'clients/renderDateWiseData',
type: 'post',
data: {hearingDate: completeDate},
dataType: 'html',
beforeSend: function () {
jQuery('#render-current-date-time').html('');
$('#render-datewise-data').html('
');
},
success: function (html) {
jQuery('#render-current-date-time').html('( ' + completeDate + ' )');
jQuery("div#render-datewise-data").html(html);
$('.c2rm-cal-ul > li').removeClass("active");
$('.c2rm-cal-ul #li-public-event').addClass("active");
$('.c2rm-tab-pan').removeClass("active");
$('#public-event').addClass("active");
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// get public event details
jQuery(document).on("click", ".google-cal", function () {
var completeDate = jQuery(this).data('googlecaldata');
jQuery(".modal-body #current-date-task").val(completeDate);
jQuery(".modal-body #create-task-date").html(completeDate);
var currentdate = jQuery(this).data('currentdate');
jQuery.ajax({
url: url + 'clients/renderDateWiseData',
type: 'post',
data: {hearingDate: completeDate},
dataType: 'html',
beforeSend: function () {
jQuery('#render-current-date-time').html('');
$('#render-datewise-data').html('
');
},
success: function (html) {
jQuery('#render-current-date-time').html('( ' + completeDate + ' )');
jQuery("div#render-datewise-data").html(html);
$('.c2rm-cal-ul > li').removeClass("active");
$('.c2rm-cal-ul #li-gcal').addClass("active");
$('.c2rm-tab-pan').removeClass("active");
$('#gcal').addClass("active");
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//
jQuery(document).on("click", ".addEvent_popup", function () {
var myYear = jQuery(this).data('year');
var myMonth = jQuery(this).data('month');
var myDays = pad(jQuery(this).data('days'), 2);
var completeDate = myYear + '-' + myMonth + '-' + myDays;
//jQuery('#render-current-date-time').html('( '+completeDate+' )');
jQuery(".modal-body #current-date-task").val(completeDate);
jQuery(".modal-body #create-task-date").html(completeDate);
alert(completeDate);
var currentdate = jQuery(this).data('currentdate');
jQuery.ajax({
url: url + 'clients/renderDateWiseData',
type: 'post',
data: {hearingDate: completeDate},
dataType: 'html',
beforeSend: function () {
jQuery('#render-current-date-time').html('');
$('#render-datewise-data').html('
');
},
success: function (html) {
jQuery('#render-current-date-time').html('( ' + completeDate + ' )');
jQuery("div#render-datewise-data").html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
jQuery(document).on("click", ".modifyNewHearing", function () {
jQuery('textarea#edit_add_log').attr('readonly', 'readonly');
var hearingID = jQuery(this).data('hearingid');
var hearingDate = jQuery(this).data('hearingdate');
$.getJSON(url + "clients/getHearingDetailsSingle/", {hearingID: hearingID, hearingDate: hearingDate, ajax: 'true'}, function (rs) {
// list member client
var data = rs.client_list;
var options_data = '';
var selected = '';
jQuery('form#edit-event-form').find("select#edit_event_client_name").find("option:eq(0)").html("Please wait..");
for (var i = 0; i < data.length; i++) {
if (data[i].id == rs.member_clients_id) {
selected = 'selected="selected"';
options_data += '' + data[i].client_name + ' ';
} else {
selected = '';
options_data += '' + data[i].client_name + ' ';
}
}
jQuery('form#edit-event-form').find("select#edit_event_client_name").html(options_data);
// list client case
var case_count = rs.client_case_list;
var options_result = '';
jQuery("select#edit_case-num").find("option:eq(0)").html("Please wait..");
var selected = '';
for (var i = 0; i < case_count.length; i++) {
if (case_count[i].id == rs.case_id) {
var selected = 'selected="selected"';
options_result += '' + case_count[i].case_num + ' ';
} else {
var selected = '';
options_result += '' + case_count[i].case_num + ' ';
}
}
jQuery("select#edit_case-num").html(options_result);
jQuery('input[name="modifycreateTaskDate"]').val(hearingDate);
jQuery('#edit_hearingid').val(rs.hearing_id);
jQuery('#edit_event_client_name').val(rs.member_clients_id);
jQuery('#edit_case-name').val(rs.case_name);
jQuery('#edit_versus-name').val(rs.versus);
jQuery('#edit_date-time-task-date').val(rs.hearing_date);
jQuery('#edit_hearing-next-date').val(rs.hearing_next_date);
jQuery('#edit_court-no').val(rs.court_no);
jQuery('#edit_court-name').val(rs.court_name);
jQuery('#edit_judge-name').val(rs.judge_name);
jQuery('#edit_prosecutor-name').val(rs.prosecutor);
jQuery('#edit_add-description').val(rs.description);
jQuery('#edit_add_log').val(rs.hearing_log);
});
});
jQuery(document).on("click", "#myeventupdate", function () {
if (jQuery('form#edit-event-form').valid() === false) {
return false;
} else {
var modifyHearingID = jQuery('input[name="modifyHearingID"]').val();
var modifyclientName = jQuery('select[name="modifyclientName"]').val();
var modifycaseNo = jQuery('select[name="modifycaseNo"]').val();
var modifycaseName = jQuery('input[name="modifycaseName"]').val();
var edit_court_no = jQuery('input#edit_court-no').val();
var edit_court_name = jQuery('input#edit_court-name').val();
var modifyversus = jQuery('input[name="modifyversus"]').val();
var modifyhearingNextDate = jQuery('input[name="modifyhearingNextDate"]').val();
var modifyjudgeName = jQuery('input[name="modifyjudgeName"]').val();
var modifyprosecutorName = jQuery('input[name="modifyprosecutorName"]').val();
var modifyadd_dscription = jQuery('textarea[name="modifyadd_dscription"]').val();
var modifyaddlog = jQuery('textarea[name="modifyaddlog"]').val();
var modifycreateTaskDate = jQuery('input[name="modifycreateTaskDate"]').val();
var modifydateTime = jQuery('input[name="modifydateTime"]').val();
var completeDate = modifycreateTaskDate + ' ' + modifydateTime;
if (jQuery.trim(modifyHearingID) != '') {
jQuery.ajax({
url: url + 'clients/modifyClientsCaseHearing',
type: 'post',
data: {modifyHearingID: modifyHearingID, modifyclientName: modifyclientName, modifycaseNo: modifycaseNo, modifyhearingNextDate: modifyhearingNextDate, modifyjudgeName: modifyjudgeName, modifyprosecutorName: modifyprosecutorName, modifyadd_dscription: modifyadd_dscription, modifyaddlog: modifyaddlog, completeDate: completeDate, edit_court_no: edit_court_no, edit_court_name: edit_court_name},
dataType: 'html',
beforeSend: function () {
jQuery('#myeventupdate').button('loading');
},
complete: function () {
jQuery('#myeventupdate').button('reset');
jQuery('#modifyNewHearing').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#modifyNewHearing').modal('hide');
jQuery('span#hearing-notification').html('Hearing has been updated successfully');
setTimeout(function () {
jQuery('span#hearing-notification').html("");
}, 5000);
},
success: function (html) {
jQuery("#hearingid-" + modifyHearingID).html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}
});
jQuery(document).on("click", "#update-calendar-appointment", function () {
if (jQuery('form#edit-appointments-form').valid() === false) {
return false;
} else {
var modifyAppointmentID = jQuery('input[name="modifyAppointmentID"]').val();
var modifyclient_name_appoint = jQuery('select[name="modifyclient_name_appoint"]').val();
var modifydescriptionApp = jQuery('textarea[name="modifydescriptionApp"]').val();
var modifyAppointmentTaskDate = jQuery('input[name="modifyAppointmentTaskDate"]').val();
var modifydate_time_appoint = jQuery('input[name="modifydate_time_appoint"]').val();
var completeDate = modifyAppointmentTaskDate + ' ' + modifydate_time_appoint;
if (jQuery.trim(modifyAppointmentID) != '') {
jQuery.ajax({
url: url + 'clients/modifyClientsAppointment',
type: 'post',
data: {modifyAppointmentID: modifyAppointmentID, clientID: modifyclient_name_appoint, modifydescriptionApp: modifydescriptionApp, completeDate: completeDate},
dataType: 'html',
beforeSend: function () {
jQuery('#update-calendar-appointment').button('loading');
jQuery("#hearing").collapse('hide');
},
complete: function () {
jQuery('#update-calendar-appointment').button('reset');
jQuery("#appointmentanonymous").collapse('show');
jQuery('#modifycalendarAppoitnment').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#modifycalendarAppoitnment').modal('hide');
},
success: function (html) {
jQuery("#appointmentid-" + modifyAppointmentID).html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}
});
jQuery(document).on("click", ".modifycalendarAppoitnment", function () {
var appoitnmentID = jQuery(this).data('appoitnmentid');
var appointmentDate = jQuery(this).data('appointmentdate');
$.getJSON(url + "clients/getAppoitnmentDetailsSingle/", {appoitnmentID: appoitnmentID, appointmentDate: appointmentDate, ajax: 'true'}, function (rsp) {
$.getJSON(url + "clients/getclientListCalendarModal", {ajax: 'true'}, function (data) {
var options = '';
jQuery("select#edit_event_client_name_app").find("option:eq(0)").html("Please wait..");
options += '*Select Client ';
for (var i = 0; i < data.length; i++) {
if (data[i].id == rsp.member_clients_id) {
var selected = 'selected="selected"';
} else {
var selected = "";
}
options += '' + data[i].client_name + ' ';
}
jQuery("select#edit_event_client_name_app").html(options);
});
jQuery('#create-task-date_app').val(appointmentDate);
jQuery('#edit_event_appointment_id_app').val(rsp.appointment_id);
jQuery('#edit_event_client_name_app').val(rsp.member_clients_id);
jQuery('#edit_date-time-task-date_app').val(rsp.date_time);
jQuery('#edit_date-time-task-date_app').val(rsp.date_time);
jQuery('#edit_description_msg_app').val(rsp.description);
});
});
jQuery(document).on("change", "#event_client_name", function (e) {
var clientID = jQuery(this).find(':selected').data("clientid");
if (clientID) {
jQuery('a#disbale-case').hide();
jQuery('a#enable-case').show();
} else {
jQuery('a#disbale-case').show();
jQuery('a#enable-case').hide();
}
jQuery('.get-current-client').find('a#enable-case').data('scid', clientID);
$.getJSON(url + "clients/getClientCaseListCalendarModal/", {clientID: clientID, ajax: 'true'}, function (result) {
var options = '';
jQuery("select#case-num").find("option:eq(0)").html("Please wait..");
options += 'Select Case Num ';
for (var i = 0; i < result.length; i++) {
options += '' + result[i].case_num + ' ';
}
jQuery("select#case-num").html(options);
});
});
jQuery(document).on("change", "#edit_event_client_name", function (e) {
var clientID = jQuery(this).find(':selected').data("clientid");
$.getJSON(url + "clients/getClientCaseListCalendarModal/", {clientID: clientID, ajax: 'true'}, function (result) {
var options = '';
jQuery("select#edit_case-num").find("option:eq(0)").html("Please wait..");
options += 'Select Case Num ';
for (var i = 0; i < result.length; i++) {
options += '' + result[i].case_num + ' ';
}
jQuery("select#edit_case-num").html(options);
});
});
/*jQuery("#addEvent").on('hide.bs.modal', function (e) {
jQuery(this).find('form')[0].reset();
});*/
jQuery(document).on('click', '.addEvent2', function (e) {
var memberID = jQuery(this).data("ssid");
});
jQuery("#addEvent3").on('hide.bs.modal', function (e) {
jQuery(this).find('form')[0].reset();
});
jQuery(document).on('click', '.addEvent3', function (e) {
var memberID = jQuery(this).data("ssid");
if (jQuery(this).data("scid")) {
var member_client_id = jQuery(this).data("scid");
} else {
var member_client_id = '';
}
$.getJSON(url + "clients/getclientListCalendarModal", {ajax: 'true'}, function (j) {
var options = '';
var selected = '';
jQuery("select#client_name").find("option:eq(0)").html("Please wait..");
options += 'Select Client ';
for (var i = 0; i < j.length; i++) {
if (j[i].id == member_client_id) {
selected = 'selected="selected"';
} else {
selected = "";
}
options += '' + j[i].client_name + ' ';
}
jQuery("select#client_name").html(options);
});
});
});
/* for calendar load page */
jQuery(document).on("change", ".addnewevent", function (e) {
e.preventDefault();
var myTaskType = jQuery('#addnewevent').find(":selected").val();
if (myTaskType == 1) {
jQuery("span#render-task-type").load(url + "tlc/appointmenttask");
$.getJSON(url + "clients/getclientListCalendarModal", {ajax: 'true'}, function (data) {
var options = '';
jQuery("select#event_client_name").find("option:eq(0)").html("Please wait..");
options += '*Select Client ';
for (var i = 0; i < data.length; i++) {
options += '' + data[i].client_name + ' ';
}
jQuery("select#event_client_name").html(options);
});
} else if (myTaskType == 2) {
jQuery("span#render-task-type").load(url + "tlc/hearingtask");
$.getJSON(url + "clients/getclientListCalendarModal", {ajax: 'true'}, function (data) {
var options = '';
jQuery("select#event_client_name").find("option:eq(0)").html("Please wait..");
options += '*Select Client ';
for (var i = 0; i < data.length; i++) {
options += '' + data[i].client_name + ' ';
}
jQuery("select#event_client_name").html(options);
});
}
});
/* for calendar open multiple popup */
jQuery(document).on('show.bs.modal', '.modal', function (event) {
var zIndex = 1040 + (10 * $('.modal:visible').length);
$(this).css('z-index', zIndex);
setTimeout(function () {
jQuery('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
});
/* for calendar add clients */
jQuery(document).on('click', '#add-calendar-client', function () {
if (jQuery('form#add-client-oncalendar').valid() === false) {
return false;
} else {
var memberID = jQuery(this).data("ssID");
var clientName = jQuery('input[name="client_name"]').val();
var contact_person_name = jQuery('#contactperson-name').val();
var clientaddres = jQuery('#clientaddres').val();
var email = jQuery('input[name="email"]').val();
var contactNum = jQuery('input[name="contact_num"]').val();
var description = jQuery('textarea#addmceEditorID').val();
var createDate = new Date();
var modifiedDate = new Date();
jQuery.ajax({
url: url + 'clients/createNewClientModal',
type: 'post',
data: {clientName: clientName, contact_person_name: contact_person_name, email: email, contactNum: contactNum, description: description, clientaddres: clientaddres, memberID: memberID},
dataType: 'json',
beforeSend: function () {
jQuery('#add-calendar-client').button('loading');
},
complete: function () {
jQuery('#add-calendar-client').button('reset');
jQuery('#addEvent2').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#addEvent2').modal('hide');
},
success: function (json) {
var options = '';
var selected = '';
jQuery("select#event_client_name").find("option:eq(0)").html("Please wait..");
options += '*Select Client ';
var clientID = json['last_insert_client_id'].client_id;
if (clientID) {
jQuery('a#disbale-case').hide();
jQuery('a#enable-case').show();
} else {
jQuery('a#disbale-case').show();
jQuery('a#enable-case').hide();
}
jQuery('.get-current-client').find('a').data('scid', clientID);
for (var i = 0; i < json['client_details'].length; i++) {
if (json['client_details'][i].id == json['last_insert_client_id'].client_id) {
selected = 'selected="selected"';
} else {
selected = "";
}
options += '' + json['client_details'][i].client_name + ' ';
}
jQuery("select#event_client_name").html(options);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
// for calendar add cases
jQuery(document).on('click', '#add-calendar-case', function () {
if (jQuery('form#add-case-oncalendar').valid() === false) {
return false;
} else {
var singlepage = jQuery(this).data('singlepage');
var key = jQuery('input[name=caseform]').val();
var pord = jQuery('.changecasePorD').find('option:selected').val();
if (pord) {
pord = pord;
} else {
pord = jQuery('.changecasePorDc').find('option:selected').val();
}
var client_name_case = jQuery('select[name="client_name_case"]').val();
var caseNum = jQuery('input[name="case_num"]').val();
var caseName = jQuery('input[name="case_name"]').val();
var versus = jQuery('input[name="versusName"]').val();
var court_no = jQuery('input[name="court_no"]').val();
var court_name = jQuery('input[name="court_name"]').val();
var judge_name = jQuery('input[name="judge_name"]').val();
var opponent_advocate = jQuery('input[name="opponent_advocate"]').val();
var description = jQuery('textarea#case-description').val();
jQuery.ajax({
url: url + 'clients/createclientcase',
type: 'post',
data: {clientID: client_name_case, caseNum: caseNum, caseName: caseName, versus: versus, opponent_advocate: opponent_advocate, judge_name: judge_name, court_name: court_name, court_no: court_no, description: description, pord: pord},
dataType: 'json',
beforeSend: function () {
jQuery('#add-calendar-case').button('loading');
},
complete: function () {
jQuery('#add-calendar-case').button('reset');
jQuery('form#add-event-form').find('input[name="caseName"]').val(caseName);
jQuery('form#add-event-form').find('input[name="versus"]').val(versus);
jQuery('form#add-event-form').find('input[name="hcourtNo"]').val(court_no);
jQuery('form#add-event-form').find('input[name="hcourtName"]').val(court_name);
jQuery('form#add-event-form').find('input[name="judgeName"]').val(judge_name);
jQuery('form#add-event-form').find('input[name="prosecutorName"]').val(opponent_advocate);
jQuery('form#add-newhearing-form').find('input[name="caseName"]').val(caseName);
jQuery('form#add-newhearing-form').find('input[name="versus"]').val(versus);
jQuery('form#add-newhearing-form').find('input[name="hcourtNo"]').val(court_no);
jQuery('form#add-newhearing-form').find('input[name="hcourtName"]').val(court_name);
jQuery('form#add-newhearing-form').find('input[name="judgeName"]').val(judge_name);
jQuery('form#add-newhearing-form').find('input[name="prosecutorName"]').val(opponent_advocate);
jQuery('#addEvent3').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#addEvent3').modal('hide');
},
success: function (json) {
if (key != '' && key == 'caseform') {
jQuery("span#alert-message-add-client").html('Client Case Added!
');
setTimeout(function () {
window.location.replace(url + 'c2rm/ListCases');
}, 1000);
} else {
var options = '';
var selected = '';
jQuery("select#case-num").find("option:eq(0)").html("Please wait..");
options += 'Select Client ';
for (var i = 0; i < json['case_client_details'].length; i++) {
if (json['case_client_details'][i].id == json['last_client_case_id'].case_id) {
selected = 'selected="selected"';
} else {
selected = "";
}
options += '' + json['case_client_details'][i].case_num + ' ';
}
jQuery("select#case-num").html(options);
jQuery("span#alert-message-add-client").html('Client Case Added!
');
if (singlepage) {
setTimeout(function () {
window.location.replace(url + 'c2rm/ListCases');
}, 1000);
}
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
jQuery(document).on("change", "#case-num", function (e) {
var casenumID = jQuery(this).find(':selected').data("casenum");
$.getJSON(url + "clients/getCaseNameandVersus/", {casenumID: casenumID, ajax: 'true'}, function (res) {
jQuery('form#add-event-form').find('input[name="caseName"]').val(res.case_name);
jQuery('form#add-event-form').find('input[name="versus"]').val(res.versus);
jQuery('form#add-event-form').find('input[name="hcourtNo"]').val(res.court_no);
jQuery('form#add-event-form').find('input[name="hcourtName"]').val(res.court_name);
jQuery('form#add-event-form').find('input[name="judgeName"]').val(res.judge_name);
jQuery('form#add-event-form').find('input[name="prosecutorName"]').val(res.opponent_advocate);
});
});
jQuery(document).on("change", "#case-num", function (e) {
var casenumID = jQuery(this).find(':selected').data("casenum");
$.getJSON(url + "clients/getCaseNameandVersus/", {casenumID: casenumID, ajax: 'true'}, function (res) {
jQuery('form#add-newhearing-form').find('input[name="caseName"]').val(res.case_name);
jQuery('form#add-newhearing-form').find('input[name="versus"]').val(res.versus);
jQuery('form#add-newhearing-form').find('input[name="hcourtNo"]').val(res.court_no);
jQuery('form#add-newhearing-form').find('input[name="hcourtName"]').val(res.court_name);
jQuery('form#add-newhearing-form').find('input[name="judgeName"]').val(res.judge_name);
jQuery('form#add-newhearing-form').find('input[name="prosecutorName"]').val(res.opponent_advocate);
});
});
jQuery(document).on("change", "#edit_case-num", function (e) {
var casenumID = jQuery(this).find(':selected').data("casenum");
$.getJSON(url + "clients/getCaseNameandVersus/", {casenumID: casenumID, ajax: 'true'}, function (res) {
jQuery('form#edit-event-form').find('input[name="modifycaseName"]').val(res.case_name);
jQuery('form#edit-event-form').find('input[name="modifyversus"]').val(res.versus);
jQuery('form#edit-event-form').find('input[name="courtNo"]').val(res.court_no);
jQuery('form#edit-event-form').find('input[name="courtName"]').val(res.court_name);
jQuery('form#edit-event-form').find('input[name="modifyjudgeName"]').val(res.judge_name);
jQuery('form#edit-event-form').find('input[name="modifyprosecutorName"]').val(res.opponent_advocate);
});
});
// render lawyer hearing
jQuery(document).on('click', '.add-new-hearing', function () {
if (jQuery('form#add-event-form').valid() === false) {
return false;
} else {
var singlepage = jQuery(this).data('singlepage');
var share = jQuery(this).data('share');
var clientID = jQuery('select[name="clientName"]').val();
var caseNum = jQuery('select[name="caseNo"]').val();
var judgeName = jQuery('input[name="judgeName"]').val();
var courtNo = jQuery('input[name="hcourtNo"]').val();
var courtName = jQuery('input[name="hcourtName"]').val();
var prosecutorName = jQuery('input[name="prosecutorName"]').val();
var addDscription = jQuery('textarea[name="add_dscription"]').val();
var addlog = jQuery('textarea[name="addlog"]').val();
var hearingNextDate = jQuery('input[name="hearingNextDate"]').val();
var event_color = jQuery('input[name="event_color"]').val();
var hearingDate = jQuery('#create-task-date').text() + ' ' + jQuery('input[name="dateTime"]').val();
jQuery.ajax({
url: url + 'clients/saveHearingOnCalendar',
type: 'post',
data: {clientID: clientID, caseNum: caseNum, judgeName: judgeName, courtNo: courtNo, courtName: courtName, prosecutorName: prosecutorName, addDscription: addDscription, addlog: addlog, hearingNextDate: hearingNextDate, hearingDate: hearingDate, event_color: event_color, share: share},
dataType: 'html',
beforeSend: function () {
jQuery('#new-hearing-' + share).button('loading');
},
complete: function () {
jQuery('#new-hearing-' + share).button('reset');
jQuery('#addHearing').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('span#hearing-notification').html('New Hearing Added!');
jQuery('#addHearing').modal('hide');
setTimeout(function () {
jQuery('span#hearing-notification').html("");
}, 5000);
},
success: function (html) {
jQuery('.no-result-tlc').html('');
jQuery("#datewise-hearing").prepend(html);
jQuery("#case-manager-calendar").fullCalendar("refetchEvents");
if (singlepage) {
setTimeout(function () {
window.location.replace(url + 'c2rm/hearing');
}, 2000);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
// render Appointment
jQuery(document).on('click', '.new-appointment-on, #add-calendar-appointment', function () {
if (jQuery('form#add-appointments-form').valid() === false) {
return false;
} else {
var singlepage = jQuery(this).data('singlepage');
var share = jQuery(this).data('share');
var key = jQuery('input[name=appoform]').val();
if (key != '' && key == 'appoform') {
var dateTime = jQuery('input[name="date_time"]').val();
var dateTimeTo = jQuery('input[name="date_time_to"]').val();
} else {
var dateTime = jQuery('#create-task-date').text() + ' ' + jQuery('input[name="date_time"]').val();
var dateTimeTo = jQuery('#create-task-date').text() + ' ' + jQuery('input[name="date_time_to"]').val();
}
var clientID = jQuery('select[name="client_name"]').val();
var title_appointment = jQuery('#title-appointment').val();
var description = jQuery('textarea#tlc-appointment').summernote('code');
//alert(dateTime+" "+dateTimeTo);
jQuery.ajax({
url: url + 'clients/savePersonalAppoitment',
type: 'post',
data: {clientID: clientID, title_appointment: title_appointment, dateTime: dateTime, dateTimeTo: dateTimeTo, description: description, share: share},
dataType: 'html',
beforeSend: function () {
jQuery('#add-calendar-appointment-' + share).button('loading');
},
complete: function () {
jQuery('#add-calendar-appointment-' + share).button('reset');
jQuery('#calendarAppointment').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('span#appointment-notification').html('New Appointment Added!')
jQuery('#calendarAppointment').modal('hide');
},
success: function (html) {
jQuery('.no-result-tlc').html('');
if (key != '' && key == 'appoform') {
jQuery('#addappointmentsucess').html(' Appointment has been added successfully
');
} else {
jQuery("#datewise-personalAppointment").prepend(html);
}
if (singlepage) {
setTimeout(function () {
window.location.replace(url + 'c2rm/appointment');
}, 2000);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
// reset client data
jQuery(document).on('click', '.add_client', function () {
jQuery('#createNewClient').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
});
jQuery(document).on('click', '.delete-client-cldr', function () {
var delete_id = jQuery(this).data('scid');
jQuery('button#delete-client').attr('data-deletescid', delete_id);
});
// edit client
jQuery(document).on('click', '#delete-client', function () {
var clientID = jQuery(this).attr('data-deletescid');
jQuery('#client_hidden_id').val(clientID);
jQuery.ajax({
url: url + 'clients/removeclients',
type: 'post',
data: {clientID: clientID},
dataType: 'json',
complete: function () {
jQuery('#delete-calendar-client').modal('hide');
},
success: function (json) {
jQuery('.render-success-msg').html(' Client has been Deleted!
');
jQuery('tr#listofclient' + clientID).html(' Client has been Deleted!
');
setTimeout(function () {
//jQuery('tr#listofclient' + clientID).remove()
location.reload();
}, 5000);
//location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// edit client
jQuery(document).on('click', '.edit-client', function () {
var clientID = jQuery(this).data('scid');
var clientadloc = jQuery(this).data('clientadloc');
jQuery('#client_hidden_id').val(clientID);
jQuery.ajax({
url: url + 'clients/getClientInfo',
type: 'post',
data: {clientID: clientID},
dataType: 'html',
beforeSend: function () {
jQuery('span#client-info-render').html('
');
},
success: function (html) {
jQuery('span#client-info-render').html(html);
jQuery('.selectpicker').selectpicker('refresh');
jQuery("select#client-rescountry").trigger("change");
jQuery("select#client-resstate").trigger("change");
jQuery('.richtext').summernote('code');
jQuery('form#create-client').find('#add-client').data('clientloc', clientadloc);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// add New Client
jQuery(document).on('click', '#add-client', function () {
if (jQuery('form#create-client').valid() === false) {
return false;
} else {
var singlepage = jQuery(this).data('singlepage');
var key = jQuery('input[name=clientform]').val();
jQuery.ajax({
url: url + 'clients/createNewClient',
type: 'post',
data: jQuery('#create-client input, #create-client textarea, #create-client select'),
dataType: 'html',
beforeSend: function () {
jQuery('#add-client').button('loading');
},
complete: function () {
jQuery('#add-client').button('reset');
jQuery('form#create-client').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('.selectpicker').selectpicker('refresh');
jQuery('#createNewClient').modal('hide');
},
success: function (html) {
if (key != '' && key == 'clientform') {
jQuery("span#alert-message-add-client").html(' New Client Added Successfully!
');
setTimeout(function () {
window.location.href = url + 'c2rm/client';
}, 1000);
} else {
var clientloc = jQuery('form#create-client').find('#add-client').data('clientloc');
if (clientloc == 1) {
jQuery.ajax({
url: url + 'clients/makeClientDropDown',
type: 'post',
dataType: 'json',
beforeSend: function () {
jQuery("select#invoice_client_name").find("option:eq(0)").html("Please wait..");
},
success: function (json) {
var options = '';
options += 'Select Client ';
for (var i = 0; i < json['client_details'].length; i++) {
options += '' + json['client_details'][i].client_name + ' ';
}
jQuery('form#invoice_generation').find("select#invoice_client_name").html(options);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
if (jQuery('#client_hidden_id').val()) {
jQuery('tr#listofclient' + jQuery('#client_hidden_id').val()).html(html);
jQuery("span#alert-message-add-client").html(' Client details has been updated successfully!
');
if (singlepage) {
setTimeout(function () {
window.location.href = url + 'c2rm/client';
}, 1000);
} else {
location.reload();
}
} else {
jQuery('#render-client').prepend(html);
jQuery("span#alert-message-add-client").html(' New Client Added Successfully!
');
if (singlepage) {
setTimeout(function () {
window.location.href = url + 'c2rm/client';
}, 1000);
} else {
location.reload();
}
}
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
// view client details
jQuery(document).on('click', '.view-client', function () {
var client_id = jQuery(this).data('scid');
jQuery.ajax({
url: url + 'clients/getClientCaseList',
type: 'post',
data: {client_id: client_id},
dataType: 'html',
beforeSend: function () {
$('#render-client-view-data').html('
');
},
success: function (html) {
jQuery('#render-client-view-data').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// view client case details
jQuery(document).on('click', '.view-client-case', function () {
var client_case_id = jQuery(this).data('client_case_id');
jQuery.ajax({
url: url + 'clients/getClientCaseView',
type: 'post',
data: {client_case_id: client_case_id},
dataType: 'html',
beforeSend: function () {
$('#render-client-case-view-data').html('
');
},
success: function (html) {
jQuery('#render-client-case-view-data').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
jQuery(document).on('click', '.edit-client-case', function () {
var client_case_id = jQuery(this).data('client_case_id');
jQuery.ajax({
url: url + 'clients/modifyClientCaseView',
type: 'post',
data: {client_case_id: client_case_id},
dataType: 'json',
success: function (json) {
var options = '';
var selected = '';
jQuery("select#update_client_name").find("option:eq(0)").html("Please wait..");
options += 'Select Client ';
for (var i = 0; i < json['client_details'].length; i++) {
if (json['client_details'][i].id == json['clientCaseInfo'].member_clients_id) {
selected = 'selected="selected"';
} else {
selected = "";
}
options += '' + json['client_details'][i].client_name + ' ';
}
var options1 = '';
var selected1 = '';
var selected2 = '';
jQuery("select.changecasePorD").find("option:eq(0)").html("Please wait..");
options1 += 'Select ';
if (1 == json['clientCaseInfo'].pord) {
selected1 = 'selected="selected"';
} else {
selected1 = "";
}
if (2 == json['clientCaseInfo'].pord) {
selected2 = 'selected="selected"';
} else {
selected2 = "";
}
options1 += 'Plaintiff ';
options1 += 'Defendent ';
jQuery('form#update-client-case').find("select#update_client_name").html(options);
jQuery('form#update-client-case').find("select.changecasePorD").html(options1);
jQuery('form#update-client-case').find('#update_case_num').val(json['clientCaseInfo'].case_num);
jQuery('form#update-client-case').find('#update_case_name').val(json['clientCaseInfo'].case_name);
jQuery('form#update-client-case').find('#update_versus-name').val(json['clientCaseInfo'].versus);
jQuery('form#update-client-case').find('#update_opponent-advocate').val(json['clientCaseInfo'].opponent_advocate);
jQuery('form#update-client-case').find('#update_court-number').val(json['clientCaseInfo'].court_no);
jQuery('form#update-client-case').find('#update_court-name').val(json['clientCaseInfo'].court_name);
jQuery('form#update-client-case').find('#update_judge-name').val(json['clientCaseInfo'].judge_name);
jQuery('form#update-client-case').find('#updatecaseid').val(json['clientCaseInfo'].case_id);
jQuery('form#update-client-case').find('#update-case-description').val(json['clientCaseInfo'].description);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
jQuery(document).on('click', '#update-case', function () {
if (jQuery('form#update-client-case').valid() === false) {
return false;
} else {
var case_client_id = jQuery('input#updatecaseid').val();
jQuery.ajax({
url: url + 'clients/updateCase',
type: 'post',
data: jQuery('#update-client-case input, #update-client-case select, #update-client-case textarea'),
dataType: 'html',
beforeSend: function () {
jQuery('#add-case').button('loading');
},
complete: function () {
jQuery('#add-case').button('reset');
jQuery('#updateCases').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#updateCases').modal('hide');
},
success: function (html) {
jQuery('#case-update-' + case_client_id).html(html);
location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
jQuery(document).on('click', '#add-case', function () {
if (jQuery('form#create-case').valid() === false) {
return false;
} else {
var client_id = jQuery('select[name="client_name_case"] option:selected').val();
jQuery.ajax({
url: url + 'clients/addclientcase',
type: 'post',
data: jQuery('#create-case input, #create-case select, #create-case textarea'),
dataType: 'html',
beforeSend: function () {
jQuery('#add-case').button('loading');
},
complete: function () {
jQuery('#add-case').button('reset');
jQuery('#createCases').find('input[type=text],input[name=email],select,textarea').each(function () {
jQuery(this).val('');
});
jQuery('#createCases').modal('hide');
},
success: function (html) {
jQuery('#render-client-case' + client_id).prepend(html);
jQuery("span#alert-message-add-client-case").html('Client Case Added!
');
jQuery('tr#remove-tr' + client_id).remove();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
// render holiday calendar
jQuery(document).on("click", ".court_calendar", function (e) {
e.preventDefault();
var calendartype = jQuery(this).data("calendartype");
jQuery.ajax({
url: url + 'tlc/courtCalendarHoliday',
type: 'post',
data: {type_calendar: calendartype},
dataType: 'html',
beforeSend: function () {
jQuery('#render-holiday-calendar').html('
');
},
success: function (html) {
jQuery('#update_calendar').data('caltype', calendartype);
if (calendartype == 1) {
jQuery('#alert-message-calendar').html('Court Holiday Calendar ');
} else {
jQuery('#alert-message-calendar').html('Supreme Court Holiday Calendar ');
}
jQuery('#render-holiday-calendar').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
$(document).ready(function () {
jQuery('textarea#add_log').attr('readonly', 'readonly');
$.getJSON(url + "clients/getclientListCalendarModal", {ajax: 'true'}, function (data) {
var options = '';
jQuery("select#event_client_name").find("option:eq(0)").html("Please wait..");
options += '*Select Client ';
var member_clients_id = getUrlParameter('clid');
for (var i = 0; i < data.length; i++) {
/*options += '' + data[i].client_name + ' ';*/
if (data[i].id == member_clients_id) {
selected = 'selected="selected"';
options += '' + data[i].client_name + ' ';
} else {
selected = '';
options += '' + data[i].client_name + ' ';
}
}
jQuery("select#event_client_name").html(options);
});
});
$("#hearingdate").datetimepicker({
dateFormat: "dd-M-yy",
minDate: 0,
onSelect: function (date) {
var date2 = $('#hearingdate').datetimepicker('getDate');
date2.setDate(date2.getDate());
$('#end_date').datetimepicker('setDate', date2);
//sets minDate to dt1 date + 1
$('#end_date').datetimepicker('option', 'minDate', date2);
}
});
$("#apointmentdatefrom").datetimepicker({
dateFormat: "dd-M-yy",
minDate: 0,
onSelect: function (date) {
var date2 = $('#apointmentdatefrom').datetimepicker('getDate');
date2.setDate(date2.getDate());
$('#apointmentdatefrom').datetimepicker('setDate', date2);
//sets minDate to dt1 date + 1
$('#apointmentdatefrom').datetimepicker('option', 'minDate', date2);
}
});
$("#appointmentto").datetimepicker({
dateFormat: "dd-M-yy",
minDate: 0,
onSelect: function (date) {
var date2 = $('#appointmentto').datetimepicker('getDate');
date2.setDate(date2.getDate());
$('#appointmentto').datetimepicker('setDate', date2);
//sets minDate to dt1 date + 1
$('#appointmentto').datetimepicker('option', 'minDate', date2);
}
});
// render lawyer hearing
jQuery(document).on('click', '.addhearingevent', function () {
if (jQuery('form#add-newhearing-form').valid() === false) {
return false;
} else {
var share = jQuery(this).data('share');
var buttonid = jQuery(this).data('buttonid');
var clientID = jQuery('form#add-newhearing-form').find('select[name="clientName"]').val();
var caseNum = jQuery('form#add-newhearing-form').find('select[name="caseNo"]').val();
var judgeName = jQuery('input[name="judgeName"]').val();
var courtNo = jQuery('input[name="hcourtNo"]').val();
var courtName = jQuery('input[name="hcourtName"]').val();
var prosecutorName = jQuery('input[name="prosecutorName"]').val();
var addDscription = jQuery('textarea[name="add_dscription"]').val();
var addlog = jQuery('textarea[name="addlog"]').val();
var hearingNextDate = jQuery('input[name="hearingNextDate"]').val();
var hearingDate = jQuery('input[name="hearingdate"]').val();
var event_color = jQuery('input[name="event_color"]').val();
alert(hearingDate);
jQuery.ajax({
url: url + 'clients/savenewHearing',
type: 'post',
data: {clientID: clientID, caseNum: caseNum, judgeName: judgeName, courtNo: courtNo, courtName: courtName, prosecutorName: prosecutorName, addDscription: addDscription, addlog: addlog, hearingNextDate: hearingNextDate, hearingDate: hearingDate, event_color: event_color, share: share},
dataType: 'json',
beforeSend: function () {
jQuery('#' + buttonid).button('loading');
},
complete: function () {
jQuery('#' + buttonid).button('reset');
},
success: function (response) {
jQuery('#addhearingsucess').html(' Hearing has been added successfully
');
if(response.status == 'success')
{
setTimeout(function () {
window.location.href = url + 'c2rm/hearing';
}, 1000);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
jQuery(document).on('click', '.delete-case-cldr', function () {
var delete_id = jQuery(this).data('scid');
jQuery('button#delete-case').data('deletescaid', delete_id);
});
// edit client
jQuery(document).on('click', '#delete-case', function () {
var caseID = jQuery(this).data('deletescaid');
jQuery('#case_hidden_id').val(caseID);
jQuery.ajax({
url: url + 'clients/removeCase',
type: 'post',
data: {caseID: caseID},
dataType: 'json',
complete: function () {
jQuery('#delete-calendar-case').modal('hide');
},
success: function (json) {
jQuery('tr#listofcase' + caseID).html(' Case has been Deleted!
');
setTimeout(function () {
jQuery('tr#listofcase' + caseID).remove()
}, 5000);
//location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// share document on client dashboard page
// share-document-on-client-dashboard
jQuery(document).on("click", ".share-document-on-client-dashboard", function () {
var client_id = jQuery(this).data('clientid');
jQuery.ajax({
url: url + 'document-central/shareDocumentOnClientDashboard',
type: 'post',
data: {client_dashboard: 'client_dashboard', client_id: client_id},
dataType: 'html',
success: function (html) {
jQuery('#render-my-document').html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// share document
jQuery(document).on('click', '.share-file-client-dashboard', function () {
var currentdir = jQuery(this).data('fullpath');
var client_id = jQuery(this).data('sharecid');
if (client_id) {
client_id = client_id;
} else {
client_id = '';
}
share_email = '';
$.ajax({
url: baseurl + 'document-central/shareFile',
type: 'post',
dataType: 'json',
data: {share_email: share_email, currentdir: currentdir, client_id: client_id},
success: function (json) {
jQuery('#filemanager-msg').html('Document has been shared with ' + json.client_name + ' If your client does not receive the invoice on email in few minutes, please ask them to check their Junk E-mail/Spam folder just in case the invoice email got delivered there instead of their inbox. If so, select the Invoice E-mail and click Not Junk, which will allow future messages to get through.
');
setTimeout(function () {
location.reload(true);
}, 5000);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// change Plaintiff and Defendent
jQuery(document).on('change', '#client_name', function () {
var clientname = $(this).find('option:selected').val();
if (clientname != '') {
$('.changecasePorDc').prop("disabled", false);
} else {
$('.changecasePorDc').prop("disabled", true);
}
});
jQuery(document).on('change', '.changecasePorDc', function () {
var clientname = $('#client_name').find('option:selected').html();
var pord = $(this).find('option:selected').val();
if (pord == 1) {
jQuery('#add-case-oncalendar').find('#case_name').val(clientname);
jQuery('#add-case-oncalendar').find('#versus-name').val('');
} else if (pord == 2) {
jQuery('#add-case-oncalendar').find('#versus-name').val(clientname);
jQuery('#add-case-oncalendar').find('#case_name').val('');
} else {
jQuery('#add-case-oncalendar').find('#versus-name').val('');
jQuery('#add-case-oncalendar').find('#case_name').val('');
}
});
jQuery(document).on('change', '#event_client_name', function () {
var clientname = $(this).find('option:selected').val();
if (clientname != '') {
$('.changecasePorD').prop("disabled", false);
} else {
$('.changecasePorD').prop("disabled", true);
}
});
jQuery(document).on('change', '.changecasePorD', function () {
var clientname = $('#event_client_name').find('option:selected').html();
var pord = $(this).find('option:selected').val();
if (pord == 1) {
$('#case_name').val(clientname);
$('#versus-name').val('');
} else if (pord == 2) {
$('#versus-name').val(clientname);
$('#case_name').val('');
} else {
$('#versus-name').val('');
$('#case_name').val('');
}
});
jQuery(document).on('change', '#update-client-case #update_client_name', function () {
var clientname = $(this).find('option:selected').val();
if (clientname != '') {
$('#update-client-case .changecasePorD').prop("disabled", false);
} else {
$('#update-client-case .changecasePorD').prop("disabled", true);
}
});
jQuery(document).on('change', '#update-client-case .changecasePorD', function () {
var clientname = $('#update-client-case #update_client_name').find('option:selected').html();
var pord = $(this).find('option:selected').val();
if (pord == 1) {
$('#update-client-case #update_case_name').val(clientname);
$('#update-client-case #update_versus-name').val('');
} else if (pord == 2) {
$('#update-client-case #update_versus-name').val(clientname);
$('#update-client-case #update_case_name').val('');
} else {
$('#update-client-case #update_versus-name').val('');
$('#update-client-case #update_case_name').val('');
}
});
// full calendar legend funtionality
jQuery(document).on('click', 'a.cal-legend', function() {
var flag = jQuery(this).data('cflegend');
var legend_id = jQuery(this).data('cflegendid');
jQuery.ajax({
url: url + 'tlc/saveLegend',
type: 'post',
data: {flag:flag, legend_id:legend_id},
dataType: 'html',
beforeSend: function () {
//jQuery('.cal-legend').button('loading');
},
complete: function () {
//jQuery('.cal-legend').button('reset');
jQuery('#case-manager-calendar').fullCalendar('refetchEvents');
},
success: function (html) {
jQuery("span#cflegendrdr"+legend_id).html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
//alert(jQuery(this).data('cflegend'));
});
// delete log
jQuery(document).on('click', '.delete-log-permanently', function () {
if (confirm("Are you sure want to delete this log?")) {
var id = jQuery(this).data('aid');
jQuery.ajax({
url: url + 'c2rm/deleteLogPermanently',
type: 'post',
data: {id: id},
dataType: 'json',
beforeSend: function () {
//jQuery('#hearinglogadd').button('loading');
},
complete: function () {
//
},
success: function (json) {
location.reload();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
return false;
});