266 lines
7.6 KiB
JavaScript
266 lines
7.6 KiB
JavaScript
|
function onChangeState() {
|
|||
|
|
|||
|
var stateCode = $('#state').val();
|
|||
|
var method = "";
|
|||
|
var inputUrl = "";
|
|||
|
|
|||
|
portalUtil.showMainLoading(true);
|
|||
|
method = "GET";
|
|||
|
inputUrl = contextPath +'/ref/cityByState?stateCode=' + stateCode;
|
|||
|
|
|||
|
$.ajax({
|
|||
|
headers: { 'X-CSRF-Token': csrf_token },
|
|||
|
type: method,
|
|||
|
url: inputUrl
|
|||
|
|
|||
|
}).done(function(data) {
|
|||
|
console.log(data);
|
|||
|
|
|||
|
var cityList = data;
|
|||
|
|
|||
|
$select = $("#city");
|
|||
|
$select.empty();
|
|||
|
$select.append("<option value ='' selected='selected'>- Please Select -</option>");
|
|||
|
|
|||
|
if (cityList != null && cityList.length != 0) {
|
|||
|
for (var s = 0; s < cityList.length; s++) {
|
|||
|
$select.append("<option value ='" + cityList[s].cityCode + "'>" + cityList[s].cityDesc + "</option>");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
portalUtil.showMainLoading(false);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
var captchaWidgetId;
|
|||
|
var onloadCallback = function() {
|
|||
|
var recaptchaId = $("#recaptchaId").val();
|
|||
|
|
|||
|
if ($('#captcha').length) {
|
|||
|
captchaWidgetId = grecaptcha.render('captcha', {
|
|||
|
'sitekey': recaptchaId,
|
|||
|
'callback': captchaVerifyCallback,
|
|||
|
'expired-callback': function() { },
|
|||
|
'theme': 'light'
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
var captchaVerifyCallback = function(response) {
|
|||
|
$('.captchaError').remove();
|
|||
|
};
|
|||
|
|
|||
|
$(document).ready(function() {
|
|||
|
component.initFile();
|
|||
|
|
|||
|
//setFormValidation('#mcRegisterValidation');
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
var formsubmit = 0; // sca start
|
|||
|
$("form").submit(function() {
|
|||
|
$('.captchaError').remove();
|
|||
|
/*if (grecaptcha.getResponse(captchaWidgetId) == "") {
|
|||
|
$("#captcha").append('<label class="captchaError">Please verify that you are not a robot.</label>');
|
|||
|
return false;
|
|||
|
}*/
|
|||
|
|
|||
|
if($('form').attr('id') == "saRegisterValidation"){
|
|||
|
console.log("sca form submitting");
|
|||
|
var nullContact = 0;
|
|||
|
var contact = document.getElementById("contactNoOwner").value;
|
|||
|
console.log("contact value : " + contact);
|
|||
|
if(contact == "" || contact == null){
|
|||
|
console.log("contact is null");
|
|||
|
var label = "This field is required";
|
|||
|
document.getElementById("lblOwnerError").style.display = null;
|
|||
|
document.getElementById("lblOwnerError").innerHTML = label;
|
|||
|
$("#contactNoOwner").closest(".form-group").addClass("has-danger");
|
|||
|
nullContact = 1;
|
|||
|
}
|
|||
|
else{
|
|||
|
document.getElementById("lblOwnerError").style.display = "none";
|
|||
|
}
|
|||
|
if(!($('#sameAsOwner').is(":checked"))){
|
|||
|
var contact2 = document.getElementById("contactNoPIC").value;
|
|||
|
if(contact2 == "" || contact2 == null){
|
|||
|
console.log("PIC contact is null");
|
|||
|
var label = "This field is required";
|
|||
|
document.getElementById("lblPicError").style.display = null;
|
|||
|
document.getElementById("lblPicError").innerHTML = label;
|
|||
|
$("#contactNoPIC").closest(".form-group").addClass("has-danger");
|
|||
|
nullContact = 1;
|
|||
|
}
|
|||
|
else{
|
|||
|
document.getElementById("lblPicError").style.display = "none";
|
|||
|
}
|
|||
|
}
|
|||
|
if(nullContact == 1){
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$('.captchaError').remove();
|
|||
|
if (grecaptcha.getResponse(captchaWidgetId) == "") {
|
|||
|
$("#captcha").append('<label class="captchaError">Please verify that you are not a robot.</label>');
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
if($("form").valid())
|
|||
|
{
|
|||
|
if( formsubmit == 1 ){
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
swal({
|
|||
|
title: "Are you sure you want to submit the form ?",
|
|||
|
text: "",
|
|||
|
type: "warning",
|
|||
|
showCancelButton: true,
|
|||
|
confirmButtonColor: "#DD6B55",
|
|||
|
confirmButtonText: "Submit",
|
|||
|
}).then(result => {
|
|||
|
//swal("Deleted!", "Your file has been deleted.", "success");
|
|||
|
//alert(result.value)
|
|||
|
if (result.value == true ) {
|
|||
|
//alert(result.value)
|
|||
|
//alert("form submit");
|
|||
|
formsubmit = 1;
|
|||
|
$("form").submit();
|
|||
|
} {
|
|||
|
//swal("Cancelled", "Your imaginary file is safe :)", "error");
|
|||
|
return false;
|
|||
|
swal.closeModal();
|
|||
|
}
|
|||
|
swal.closeModal();
|
|||
|
});
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
// sca start end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
function hidePic(e) {
|
|||
|
var checkbox = e.target;
|
|||
|
if (checkbox.checked) {
|
|||
|
document.getElementById('picOwner').hidden = true;
|
|||
|
} else {
|
|||
|
$('#sameAsOwner').val("false");
|
|||
|
document.getElementById('picOwner').hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function initFileUpload(fileHiddenClass, fileVisibleClass) {
|
|||
|
|
|||
|
$('.form-file-multiple .' + fileVisibleClass + ', .form-file-simple .' + fileVisibleClass + ' .input-group-btn').click(function() {
|
|||
|
//console.log("click2");
|
|||
|
$(this).parent().parent().find('.inputFileHidden').trigger('click');
|
|||
|
$(this).parent().parent().addClass('is-focused');
|
|||
|
});
|
|||
|
|
|||
|
$('.form-file-multiple .inputFileVisible, .form-file-multiple .input-group-btn').blur(function() {
|
|||
|
console.log("blur");
|
|||
|
if ($(this).val()) {
|
|||
|
$(this).parent().parent().removeClass('has-danger');
|
|||
|
$(this).parent().parent().addClass('fileupload-exists has-success is-filled').removeClass('fileupload-new');
|
|||
|
}
|
|||
|
else $(this).parent().parent().removeClass('has-success is-filled');
|
|||
|
})
|
|||
|
$('.form-file-multiple .' + fileHiddenClass).change(function() {
|
|||
|
console.log("change2");
|
|||
|
var names = '';
|
|||
|
for (var i = 0; i < $(this).get(0).files.length; ++i) {
|
|||
|
if (i < $(this).get(0).files.length - 1) {
|
|||
|
names += $(this).get(0).files.item(i).name + ',';
|
|||
|
} else {
|
|||
|
names += $(this).get(0).files.item(i).name;
|
|||
|
}
|
|||
|
}
|
|||
|
$(this).siblings('.input-group').find('.inputFileVisible').val(names);
|
|||
|
});
|
|||
|
|
|||
|
$('.form-file-multiple .btn').on('focus', function() {
|
|||
|
$(this).parent().siblings().trigger('focus');
|
|||
|
});
|
|||
|
|
|||
|
$('.form-file-multiple .btn').on('focusout', function() {
|
|||
|
$(this).parent().siblings().trigger('focusout');
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
var tabID = 0;
|
|||
|
var activeTab = true;
|
|||
|
addDoctorTab(activeTab);
|
|||
|
$('.btn-add-tab').click(function() {
|
|||
|
activeTab = false;
|
|||
|
addDoctorTab(activeTab);
|
|||
|
});
|
|||
|
|
|||
|
function addDoctorTab(activeTab){
|
|||
|
var tabActive = "";
|
|||
|
var tabPaneActive = "fade";
|
|||
|
var buttonClose = '<button class="close" type="button" title="Remove this Tab">×</button>';
|
|||
|
if(activeTab){
|
|||
|
tabActive="active";
|
|||
|
tabPaneActive="active";
|
|||
|
buttonClose = "";
|
|||
|
}
|
|||
|
|
|||
|
tabID++;
|
|||
|
$('#tab-list').append($('<li class="nav-item"><a class="nav-link ' + tabActive + '" href="#tab' + tabID + '" role="tab" data-toggle="tab">Doctor ' + tabID + buttonClose+ '</a></li>'));
|
|||
|
//$('#tab-content').append($('<div class="tab-pane fade" id="tab' + tabID + '">Tab ' + tabID + ' content</div>'));
|
|||
|
var tabId = "tab" + tabID;
|
|||
|
var content = jQuery('#addtothisdiv');
|
|||
|
var element = content.clone();
|
|||
|
var doctorHiddenId = "doctorHiddenId" + (tabID - 1);
|
|||
|
var doctorVisibleId = "doctorVisibleId" + (tabID - 1);
|
|||
|
|
|||
|
element.attr('id', tabId).addClass('tab-pane '+tabPaneActive);
|
|||
|
|
|||
|
element.find('.doctornameCls').attr('name', "mcProfile.doctorProfiles[" + (tabID - 1) + "].doctorNm");
|
|||
|
element.find('.doctorprofCls').attr('name', "mcProfile.doctorProfiles[" + (tabID - 1) + "].doctorId");
|
|||
|
element.find('.doctorqualiCls').attr('name', "mcProfile.doctorProfiles[" + (tabID - 1) + "].doctorQualif");
|
|||
|
element.find('.inputFileHidden').addClass(doctorHiddenId);
|
|||
|
element.find('.inputFileVisible').addClass(doctorVisibleId);
|
|||
|
element.find('.input-group-btn').addClass(doctorVisibleId);
|
|||
|
var elements = element.find("*[id^=\"mcProfile.doctorProfilesObj.docList\"]");
|
|||
|
var name = "";
|
|||
|
for(var i=0; i<elements.length; i++) {
|
|||
|
var s = elements[i].name;
|
|||
|
name = s.replace("doctorProfilesObj", "doctorProfiles["+ (tabID - 1)+ "]");
|
|||
|
$(elements[i]).attr('name', name);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
element.appendTo('#tab-content');
|
|||
|
if(!activeTab){
|
|||
|
initFileUpload(doctorHiddenId, doctorVisibleId);
|
|||
|
//component.initFile();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$('#tab-list').on('click', '.close', function() {
|
|||
|
var tabID = $(this).parents('a').attr('href');
|
|||
|
$(this).parents('li').remove();
|
|||
|
$(tabID).remove();
|
|||
|
//display first tab
|
|||
|
var tabFirst = $('#tab-list a:first');
|
|||
|
tabFirst.tab('show');
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
var list = document.getElementById("tab-list");
|
|||
|
|
|||
|
|
|||
|
|