`;
dynamicCard.innerHTML += tempHtml;
}
}
}
} else {
dynamicCard.innerHTML = 'No results found for the specified keyword';
}
}
else {
window.location.href = window.location.protocol + "//" + window.location.host + "/error.html";
}
}
};
xmlhttp1.send();
}
}
// this is for list of properties page-- edit button
function updateProperty() {
var type = $("#type").val();
var bedrooms = $("#bedrooms").val();
var zip = $("#zip").val();
var furnishing = $("#furnishing").val();
var squareFeet = $("#squareFeet").val();
var rentAmount = $("#rentAmount").val();
var houseNo = $("#houseNo").val();
var streetAddress = $("#streetAddress").val();
var city = $("#city").val();
var state = $("#state").val();
var country = $("#country").val();
var carParking = $("#carParking").val();
var bathrooms = $("#bathrooms").val();
var carParkingType = $("#carParkingType").val();
var rentalRate = $("#rentalRate").val();
var termsAndConditions = $('#termsAndConditions').val();
var propertyDesc = $('#propertyDesc').val();
var landlordEmail = $('#landlord_email').val();
var number = $('#number').val();
var otherBookingPlatform = $("#otherBookingPlatform").val();
var endDate = $("#endDate").val();
var startDate = $("#startDate").val();
$(".add_properties strong").html("");
if (otherBookingPlatform) {
if (!startDate) { // Check if startDate is empty
$("#startDate_error").html('This field is required');
document.getElementById("startDate").focus();
return; // Stop the function if validation fails
}
}
if (otherBookingPlatform) {
$("endDate_error").html('This field is required');
document.getElementById("endDate").focus();
}
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp1.open("POST", baseurl + "/rentaladmin/updateproperty?propertyID=" + propertyID + "&landlordEmail=" + landlordEmail, true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
var res = JSON.parse(this.responseText);
var loginRes = res.response;
// console.log(loginRes);
var s = res.rspnsMsg;
// console.log(s);
var s = s.replace(/[{}]/g, "");
let pairs = s.split(', ')
let obj = pairs.reduce((obj, data) => {
let [k, v] = data.split('=')
obj[k] = v
return obj
}, {})
// console.log(obj)
// this is to clear error after user puts fills valid values
$(".add_properties strong").html("");
// this is to populate error below each field in add properties form
if (obj.zip == "Invalid Zip!!") {
var error = document.getElementById("zip_error");
error.innerHTML = obj.zip;
}
if (obj.city == "Invalid City!!") {
var error = document.getElementById("city_error");
error.innerHTML = obj.city;
}
if (obj.squareFeet == "Invalid Square Feet!!") {
var error = document.getElementById("squareFeet_error");
error.innerHTML = obj.squareFeet;
}
if (obj.rentAmount == "Invalid Amount!!") {
var error = document.getElementById("rentAmount_error");
error.innerHTML = obj.rentAmount;
}
if (obj.houseNo == "Invalid House Number!!") {
var error = document.getElementById("houseNo_error");
error.innerHTML = obj.houseNo;
}
if (obj.streetAddress == "Invalid Street Address!!") {
var error = document.getElementById("streetAddress_error");
error.innerHTML = obj.streetAddress;
}
if (obj.state == "Invalid State!!") {
var error = document.getElementById("state_error");
error.innerHTML = obj.state;
}
if (obj.country == "Invalid Country!!") {
var error = document.getElementById("country_error");
error.innerHTML = obj.country;
}
if (obj.type == "Please select an item") {
var error = document.getElementById("type_error");
error.innerHTML = obj.type;
}
if (obj.bedrooms == "Please select an item") {
var error = document.getElementById("bedrooms_error");
error.innerHTML = obj.bedrooms;
}
if (obj.bathrooms == "Please select an item") {
var error = document.getElementById("bathrooms_error");
error.innerHTML = obj.bathrooms;
}
if (obj.furnishing == "Please select an item") {
var error = document.getElementById("furnishing_error");
error.innerHTML = obj.furnishing;
}
if (obj.carParking == "Please select an item") {
var error = document.getElementById("carParking_error");
error.innerHTML = obj.carParking;
}
if (obj.carParkingType == "Please select an item") {
var error = document.getElementById("carParkingType_error");
error.innerHTML = obj.carParkingType;
}
if (obj.rentalRate == "Please select an item") {
var error = document.getElementById("rentalRate_error");
error.innerHTML = obj.rentalRate;
}
if (res.rspnsMsg == "GOOD") {
location.reload();
// window.location.href = window.location.protocol + "//" + window.location.host + "/admin/list-of-properties.html"
}
} else {
var res = JSON.parse(this.responseText);
console.log(res.response);
if (res.response === "401 UNAUTHORIZED") {
$('#employee_modal_message').modal("show");
$("#modal_message_content").html("
You are not authorised for this action
");
$("#employee_modal_title").html("OOPS!!");
}
}
};
xmlhttp1.send(JSON.stringify({
"type": type,
"bedrooms": bedrooms,
"zip": zip,
"furnishing": furnishing,
"squareFeet": squareFeet,
"carParking": carParking,
"rentAmount": rentAmount,
"houseNo": houseNo,
"streetAddress": streetAddress,
"city": city,
"state": state,
"country": country,
"bathrooms": bathrooms,
"rentalRate": rentalRate,
"carParkingType": carParkingType,
"termsAndConditions": termsAndConditions,
"propertyDesc": propertyDesc,
"number": number,
"otherBookingPlatform": otherBookingPlatform,
"startDate": startDate,
"endDate": endDate
}));
console.log("waiting for server response....");
}
//this is for invite applicant page-- property dropdown
function loadAllProperties() {
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp1.open("GET", baseurl + "/rentaladmin/getproperties", true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "") {
var res = JSON.parse(this.responseText);
if (res.rspnsCode === 1000) {
var response = JSON.parse(res['response']);
var dropdown = '';
for (var i = 0; i < response.length; i++) {
if (response[i].deleteFlag == '0') {
dropdown += '';
}
}
$("#propertyDropdown").html(dropdown);
}
}
};
xmlhttp1.send();
}
// this sends mail for inviting application
function initInviteApplication() {
var email = $("#customer_email").val();
var webBaseURL = window.location.protocol + "//" + window.location.host;
var propertyID = $('#propertyDropdown').val();
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp1.open("POST", baseurl + "/rentaladmin/inviteapplication?email=" + email + "&propertyID=" + propertyID + "&webBaseURL=" + webBaseURL, true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
var res = JSON.parse(this.responseText);
var loginRes = res.response;
var s = res.rspnsMsg;
// console.log(s);
var s = s.replace(/[{}]/g, "");
const obj = Object.fromEntries([s.split("=")])
// console.log(obj)
// console.log(obj.error);
document.getElementById("error_nullMail").innerHTML = "";
document.getElementById("invite_email").innerHTML = "";
document.getElementById("error_propertyId").innerHTML = "";
if (propertyID == -1) {
$("#error_propertyId").html("Please Select Required Property");
}
if (email == "") {
$("#error_nullMail").html("Please fill Mail Id");
return false;
}
if (obj.error == "Invalid Mail Id!!") {
var error = document.getElementById("invite_email");
error.innerHTML = obj.error;
}
if (res.response == "SUCCESS") {
$('#basicModal').modal("show");
$("#modal_message").html("
");
$("#modal_title").html("OOPS!!");
}
}
};
xmlhttp1.send(JSON.stringify({
"table_email": emailID,
"table_appID": appID,
"webBaseURL": webBaseURL
}));
console.log("waiting for server response....");
}
// this is for delete button on unsubmitted application table(invite-applicant.html)
function deleteApplication(appID) {
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp1.open("POST", baseurl + "/rentaladmin/deleteapplication?appID=" + appID, true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
if (confirm('Are you sure you want to delete this application')) {
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
var res = JSON.parse(this.responseText);
var loginRes = res.response;
location.reload();
} else {
var res = JSON.parse(this.responseText);
// console.log(res.response);
if (res.response === "401 UNAUTHORIZED") {
$('#employee_modal_message').modal("show");
$("#modal_message_content").html("
You are not authorised for this action
");
$("#employee_modal_title").html("OOPS!!");
}
}
};
xmlhttp1.send();
}
console.log("waiting for server response....");
}
// this is for inviting new lease-- this will send mail with lease form
function inviteNewLease(appID, propertyID, type) {
var webBaseURL = window.location.protocol + "//" + window.location.host;
// rental address
var houseNo = $("#houseNo").val();
var streetAddress = $("#streetAddress").val();
var zip = $("#zip").val();
var city = $("#city").val();
var state = $("#state").val();
var country = $("#country").val();
//applicant details
var fullName = $('#fullName').val();
var mail = $('#mail').val();
var phoneNo = $('#phone_no').val();
// console.log(phoneNo);
var principalOwner = $("#principalOwner").val();
var tenant = $("#tenant").val();
//terms
var leaseStartDate = $("#leaseStartDate").val();
var leaseEndDate = $("#leaseEndDate").val();
// rent
var rentAmount = $("#rentAmount").val();
var rentPayDate = $("#rentPayDate").val();
var rentTo = $("#rentTo").val();
var percentElectricityBill = $("#percentElectricityBill").val();
var electricityBillAmount = $("#electricityBillAmount").val();
var percentWaterBill = $("#percentWaterBill").val();
var waterBillAmount = $("#waterBillAmount").val();
var percentPhoneBill = $("#percentPhoneBill").val();
var phoneBillAmount = $("#phoneBillAmount").val();
var percentOtherBill = $("#percentOtherBill").val();
var otherBillAmount = $("#otherBillAmount").val();
//house hold rules
var cleaning = $("#cleaning").val();
var kitchenUse = $("#kitchenUse").val();
var overnightGuests = $("#overnightGuests").val();
var useOfAppliances = $("#useOfAppliances").val();
var smoking = $("#smoking").val();
var useOfCommonAreas = $("#useOfCommonAreas").val();
var alcoholUse = $("#alcoholUse").val();
var telephoneUse = $("#telephoneUse").val();
var studyingHours = $("#studyingHours").val();
var personalItemsShared = $("#personalItemsShared").val();
var music = $("#music").val();
var bedroomAssignment = $("#bedroomAssignment").val();
var pets = $("#pets").val();
var other = $("#other").val();
//deposits
var lastPaidDate = formatDate($("#lastPaidDate").val());
var lastPaidAmount = $("#lastPaidAmount").val();
var securityDeposit = formatDate($("#securityDeposit").val());
var securityAmount = $("#securityAmount").val();
var refundDeposit = $("#refundDeposit").val();
var refundPaidDate = formatDate($("#refundPaidDate").val());
var refundDuration = $("#refundDuration").val();
// conflict resolution
var conflictionDecision = $("input:radio[name=conflicResolution]:checked").val();
//lead based paint discloser
var agreementDay = $("#agreementDay").val();
var agreementMonth = $("#agreementMonth").val();
var agreementYear = $("#agreementYear").val();
var other_programs1 = $("#other_programs1").val();
var other_programs2 = $("#other_programs2").val();
var other_programs3 = $("#other_programs3").val();
var other_programs4 = $("#other_programs4").val();
var other_programs5 = $("#other_programs5").val();
var other_programs6 = $("#other_programs6").val();
var other_programs7 = $("#other_programs7").val();
var other_programs8 = $("#other_programs8").val();
var other_programs9 = $("#other_programs9").val();
var other_programs10 = $("#other_programs10").val();
var other_programs11 = $("#other_programs11").val();
var copy = $("input:radio[name=other_radio]:checked").val();
var leadBasedInput1 = $("#leadBasedInput1").val();
var leadBasedInput2 = $("#leadBasedInput2").val();
var leaseTermType = $("#leaseTermType").val();
var permanentAddress = $("#permanentAddress").val();
var paymentMethod = $("#paymentMethod").val();
var minimumObligationPeriod = $("#minimumObligationPeriod").val();
var minimumObligationNoticePeriod = $("#minimumObligationNoticePeriod").val();
var monthtoMonthNoticePeriod = $("#monthtoMonthNoticePeriod").val();
var utilityExpenses = $("input:radio[name=utilityExpenses]:checked").val();
var fixedTermDuration = $("#fixedTermDuration").val();
// this is to clear error after user puts fills valid values
$("fieldset span").html("");
if (type == "RESIDENTIAL") {
var isHouseHoldRuleChecked = document.getElementById("check_1").checked;
var isConflictResolutionChecked = document.getElementById("check_2").checked;
var isPrivacyChecked = document.getElementById("check_3").checked;
var isDepositsChecked = document.getElementById("check_4").checked;
var isOtherAgreementChecked = document.getElementById("check_5").checked;
var isMegansLawChecked = document.getElementById("check_6").checked;
var isPaintDisclosureChecked = document.getElementById("check_7").checked;
// this is to populate error below fields if user fills wrong input
if (houseNo == "" || houseNo == null) {
document.getElementById("house").innerHTML = "This field is mandatory";
document.getElementById("houseNo").focus();
return false;
}
if (streetAddress == "" || streetAddress == null) {
document.getElementById("").innerHTML = "This field is mandatory";
document.getElementById("streetAddress").focus();
return false;
}
if (zip == "" || zip == null) {
document.getElementById("rentalzip").innerHTML = "This field is mandatory";
document.getElementById("zip").focus();
return false;
}
if (city == "" || city == null) {
document.getElementById("rentalcity").innerHTML = "This field is mandatory";
document.getElementById("city").focus();
return false;
}
if (state == "" || state == null) {
document.getElementById("rentalstate").innerHTML = "This field is mandatory";
document.getElementById("state").focus();
return false;
}
if (country == "" || country == null) {
document.getElementById("rentalcountry").innerHTML = "This field is mandatory";
document.getElementById("country").focus();
return false;
}
if (fullName == "" || fullName == null) {
document.getElementById("applicantname").innerHTML = "This field is mandatory";
document.getElementById("fullName").focus();
return false;
}
if (mail == null || mail == "") {
document.getElementById("applicantmail").innerHTML = "This field is mandatory";
document.getElementById("mail").focus();
return false;
}
if (principalOwner == "" || principalOwner == null) {
document.getElementById("principal_owner").innerHTML = "This field is mandatory";
document.getElementById("principalOwner").focus();
return false;
}
if (tenant == "" || tenant == null) {
document.getElementById("tenant_name").innerHTML = "This field is mandatory";
document.getElementById("tenant").focus();
return false;
}
if (leaseTermType == "" || leaseTermType == null) {
document.getElementById("error_leaseTerm").innerHTML = "This field is mandatory";
document.getElementById("leaseTermType").focus();
return false;
}
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("applicantleaseStartDate").innerHTML = "This field is mandatory";
document.getElementById("leaseStartDate").focus();
return false;
}
var today = new Date();
today.setHours(0, 0, 0, 0);
var oneDayBeforeToday = new Date(today);
oneDayBeforeToday.setDate(today.getDate() - 1);
var selectedDate = new Date(leaseStartDate);
selectedDate.setHours(0, 0, 0, 0);
if (selectedDate.getTime() < oneDayBeforeToday.getTime()) {
document.getElementById("applicantleaseStartDate").innerHTML = "Lease start date should not be earlier than one day before today's date";
document.getElementById("leaseStartDate").focus();
return false;
}
if (leaseTermType != "Month-By-Month") {
if (leaseEndDate == null || leaseEndDate == "") {
document.getElementById("applicantleaseEndDate").innerHTML = "This field is mandatory";
document.getElementById("leaseEndDate").focus();
return false;
}
} else {
// Clear the leaseEndDate value when "Month-By-Month" is selected
leaseEndDate = "";
}
// lease Start Date should be previous than End Date
if (leaseEndDate != null && leaseEndDate != "" && leaseStartDate >= leaseEndDate) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date";
document.getElementById("leaseEndDate").focus();
return false;
}
if (leaseTermType == "Weekly") {
var weekDifference = Math.floor((new Date(leaseEndDate) - selectedDate) / (1000 * 60 * 60 * 24 * 7));
// Check if there is at least a week difference
if (weekDifference < 1) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a week between lease start and end dates for weekly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (leaseTermType == "Bi-Weekly") {
var biWeekDifference = Math.floor((new Date(leaseEndDate) - selectedDate) / (1000 * 60 * 60 * 24 * 7 * 2));
// Check if there is at least a two-week difference
if (biWeekDifference < 1) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a two-week difference between lease start and end dates for bi-weekly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
// if(leaseTermType == "Monthly")
// {
// var oneMonthLater = new Date(selectedDate);
// oneMonthLater.setMonth(oneMonthLater.getMonth() + 1);
// // Check if there is at least a 28-day difference
// if (oneMonthLater > new Date(leaseEndDate)) {
// document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a 28-day difference between lease start and end dates for monthly leases.";
// document.getElementById("leaseEndDate").focus();
// return false;
// }
// }
if (leaseTermType == "Yearly") {
var oneYearLater = new Date(selectedDate);
oneYearLater.setFullYear(oneYearLater.getFullYear() + 1);
// Check if there is at least a 365-day difference
if (oneYearLater.getTime() > new Date(leaseEndDate).getTime()) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a 365-day difference between lease start and end dates for yearly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (rentAmount == "" || rentAmount == null) {
document.getElementById("rentOfAmount").innerHTML = "This field is mandatory";
document.getElementById("rentAmount").focus();
return false;
}
if (rentPayDate == "" || rentPayDate == null) {
document.getElementById("rentOfPayDate").innerHTML = "This field is mandatory";
document.getElementById("rentPayDate").focus();
return false;
}
if (rentTo == "" || rentTo == null) {
document.getElementById("rentTo_error").innerHTML = "This field is mandatory";
document.getElementById("rentTo").focus();
return false;
}
if (document.getElementById('check_4').checked) {
if (securityDeposit == "" || securityDeposit == null) {
document.getElementById("conflictsecurityDeposit").innerHTML = "This field is mandatory";
document.getElementById("securityDeposit").focus();
return false;
}
if (securityAmount == "" || securityAmount == null) {
document.getElementById("conflictsecurityAmount").innerHTML = "This field is mandatory";
document.getElementById("securityAmount").focus();
return false;
}
}
if (document.getElementById('check_7').checked && $("#leadBasedInput1").val() == "") {
document.getElementById("errorLeadBased1").innerHTML = "This field is mandatory";
document.getElementById("leadBasedInput1").focus();
return false;
}
if (document.getElementById('check_7').checked && $("#leadBasedInput2").val() == "") {
document.getElementById("errorLeadBased2").innerHTML = "This field is mandatory";
document.getElementById("leadBasedInput2").focus();
return false;
}
} else if (type === "PAYING-GUEST") {
leaseStartDate = ($("#monthtoMonthStartDate").val() || $("#fixedTermStartDate").val() || $("#minObligationStartDate").val());
leaseEndDate = $("#fixedTermEndDate").val();
leaseTermType = $("input:radio[name=leaseTermType]:checked").val();
tenant = $("#fullName").val();
utilityExpenses = $("input:radio[name=utilityExpenses]:checked").val();
var includedRadio = document.getElementById("includedRadio");
var notIncludedRadio = document.getElementById("notIncludedRadio");
// phoneNo = document.getElementById("phone_no");
if (houseNo == "" || houseNo == null) {
document.getElementById("house").innerHTML = "This field is mandatory";
document.getElementById("houseNo").focus();
return false;
}
if (streetAddress == "" || streetAddress == null) {
document.getElementById("streetAddress").innerHTML = "This field is mandatory";
document.getElementById("street").focus();
return false;
}
if (zip == "" || zip == null) {
document.getElementById("rentalzip").innerHTML = "This field is mandatory";
document.getElementById("zip").focus();
return false;
}
if (city == "" || city == null) {
document.getElementById("rentalcity").innerHTML = "This field is mandatory";
document.getElementById("city").focus();
return false;
}
if (state == "" || state == null) {
document.getElementById("rentalstate").innerHTML = "This field is mandatory";
document.getElementById("state").focus();
return false;
}
if (country == "" || country == null) {
document.getElementById("rentalcountry").innerHTML = "This field is mandatory";
document.getElementById("country").focus();
return false;
}
if (principalOwner == "" || principalOwner == null) {
document.getElementById("principal_owner").innerHTML = "This field is mandatory";
document.getElementById("principalOwner").focus();
return false;
}
if (fullName == "" || fullName == null) {
document.getElementById("applicantname").innerHTML = "This field is mandatory";
document.getElementById("fullName").focus();
return false;
}
if (mail == null || mail == "") {
document.getElementById("applicantmail").innerHTML = "This field is mandatory";
document.getElementById("mail").focus();
return false;
}
if (leaseTermType == "" || leaseTermType == null) {
document.getElementById("error_leaseTermType").innerHTML = "Lease term is mandatory";
document.getElementById("durationType1").focus(); // Issue
return false;
}
if (leaseTermType === "Month-to-Month") {
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("conflictMonthtoMonthDate").innerHTML = "This field is Mandatory";
document.getElementById("monthtoMonthStartDate").focus();
return false;
}
var today = new Date();
today.setHours(0, 0, 0, 0);
var oneDayBeforeToday = new Date(today);
oneDayBeforeToday.setDate(today.getDate() - 1);
var selectedDate = new Date(leaseStartDate);
selectedDate.setHours(0, 0, 0, 0);
if (selectedDate.getTime() < oneDayBeforeToday.getTime()) {
document.getElementById("conflictMonthtoMonthDate").innerHTML = "Lease start date should not be earlier than one day before today's date";
document.getElementById("monthtoMonthStartDate").focus();
return false;
}
if (monthtoMonthNoticePeriod == "" || monthtoMonthNoticePeriod == null) {
document.getElementById("conflictMonthytoMonthNotice").innerHTML = "This field is mandatory";
document.getElementById("monthtoMonthNoticePeriod").focus();
return false;
}
if (monthtoMonthNoticePeriod < 0) {
document.getElementById("conflictMonthytoMonthNotice").innerHTML = "Invalid Value";
document.getElementById("monthtoMonthNoticePeriod").focus();
return false
}
}
if (leaseTermType === "Fixed-Term") {
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("conflictfixedTermStartDate").innerHTML = "This field is mandatory";
document.getElementById("fixedTermStartDate").focus();
return false;
}
var today = new Date();
today.setHours(0, 0, 0, 0);
var oneDayBeforeToday = new Date(today);
oneDayBeforeToday.setDate(today.getDate() - 1);
var selectedDate = new Date(leaseStartDate);
selectedDate.setHours(0, 0, 0, 0);
if (selectedDate.getTime() < oneDayBeforeToday.getTime()) {
document.getElementById("conflictfixedTermStartDate").innerHTML = "Lease start date should not be earlier than one day before today's date";
document.getElementById("fixedTermStartDate").focus();
return false;
}
if (leaseEndDate == "" || leaseEndDate == null) {
document.getElementById("conflictfixedTermEndDate").innerHTML = "This field is mandatory";
document.getElementById("fixedTermEndDate").focus();
return false;
}
if (fixedTermDuration == "" || fixedTermDuration == null) {
document.getElementById("conflictfixedDuration").innerHTML = "This field is mandatory";
document.getElementById("fixedTermDuration").focus();
return false;
}
if (fixedTermDuration < 0) {
document.getElementById("conflictfixedDuration").innerHTML = "Invalid Value";
document.getElementById("fixedTermDuration").focus();
return false;
}
if (leaseEndDate != null && leaseEndDate != "" && leaseStartDate >= leaseEndDate) {
document.getElementById("conflictfixedTermEndDate").innerHTML = "Invalid Date";
document.getElementById("fixedTermEndDate").focus();
return false;
}
}
if (leaseTermType === "Minimum-Term-Obligation") {
var today = new Date();
today.setHours(0, 0, 0, 0);
var oneDayBeforeToday = new Date(today);
oneDayBeforeToday.setDate(today.getDate() - 1);
var selectedDate = new Date(leaseStartDate);
selectedDate.setHours(0, 0, 0, 0);
if (selectedDate.getTime() < oneDayBeforeToday.getTime()) {
document.getElementById("conflictminObligationDate").innerHTML = "Lease start date should not be earlier than one day before today's date";
document.getElementById("minObligationStartDate").focus();
return false;
}
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("conflictminObligationDate").innerHTML = "This field is Mandatory";
document.getElementById("minObligationStartDate").focus();
return false;
}
if (minimumObligationPeriod == "" || minimumObligationPeriod == null) {
document.getElementById("conflictMinimumObligationPeriod").innerHTML = "This field is mandatory";
document.getElementById("minimumObligationPeriod").focus();
return false;
}
if (minimumObligationNoticePeriod == "" || minimumObligationNoticePeriod == null) {
document.getElementById("conflictminimumObligationNoticePeriod").innerHTML = "This field is mandatory";
document.getElementById("minimumObligationNoticePeriod").focus();
return false;
}
if (minimumObligationNoticePeriod < 0) {
document.getElementById("conflictminimumObligationNoticePeriod").innerHTML = "Invalid Value";
document.getElementById("minimumObligationNoticePeriod").focus();
return false;
}
}
if (rentAmount == "" || rentAmount == null) {
document.getElementById("errorMonthlyRent").innerHTML = "This field is mandatory";
document.getElementById("rentAmount").focus();
return false;
}
if (rentPayDate == "" || rentPayDate == null) {
document.getElementById("conflictDate").innerHTML = "This field is mandatory";
document.getElementById("rentPayDate").focus();
return false;
}
if (paymentMethod == "" || paymentMethod == null) {
document.getElementById("errorPaymentMethod").innerHTML = "This field is mandatory";
document.getElementById("paymentMethod").focus();
return false;
}
if (!includedRadio.checked && !notIncludedRadio.checked) {
document.getElementById("utilityExpensesError").innerHTML = "Please choose one of the options for utility expenses.";
document.getElementById("includedRadio").focus();
// document.getElementById("notIncludedRadio").focus();
return false;
}
} else if (type == "RESIDENTIAL LEASE 1") {
// this is to populate error below fields if user fills wrong input
if (houseNo == "" || houseNo == null) {
document.getElementById("house").innerHTML = "This field is mandatory";
document.getElementById("houseNo").focus();
return false;
}
if (streetAddress == "" || streetAddress == null) {
document.getElementById("").innerHTML = "This field is mandatory";
document.getElementById("streetAddress").focus();
return false;
}
if (zip == "" || zip == null) {
document.getElementById("rentalzip").innerHTML = "This field is mandatory";
document.getElementById("zip").focus();
return false;
}
if (city == "" || city == null) {
document.getElementById("rentalcity").innerHTML = "This field is mandatory";
document.getElementById("city").focus();
return false;
}
if (state == "" || state == null) {
document.getElementById("rentalstate").innerHTML = "This field is mandatory";
document.getElementById("state").focus();
return false;
}
if (country == "" || country == null) {
document.getElementById("rentalcountry").innerHTML = "This field is mandatory";
document.getElementById("country").focus();
return false;
}
if (fullName == "" || fullName == null) {
document.getElementById("applicantname").innerHTML = "This field is mandatory";
document.getElementById("fullName").focus();
return false;
}
if (mail == null || mail == "") {
document.getElementById("applicantmail").innerHTML = "This field is mandatory";
document.getElementById("mail").focus();
return false;
}
if (principalOwner == "" || principalOwner == null) {
document.getElementById("principal_owner").innerHTML = "This field is mandatory";
document.getElementById("principalOwner").focus();
return false;
}
if (tenant == "" || tenant == null) {
document.getElementById("tenant_name").innerHTML = "This field is mandatory";
document.getElementById("tenant").focus();
return false;
}
if (leaseTermType == "" || leaseTermType == null) {
document.getElementById("error_leaseTerm").innerHTML = "This field is mandatory";
document.getElementById("leaseTermType").focus();
return false;
}
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("applicantleaseStartDate").innerHTML = "This field is mandatory";
document.getElementById("leaseStartDate").focus();
return false;
}
var today = new Date();
today.setHours(0, 0, 0, 0);
var oneDayBeforeToday = new Date(today);
oneDayBeforeToday.setDate(today.getDate() - 1);
var selectedDate = new Date(leaseStartDate);
selectedDate.setHours(0, 0, 0, 0);
if (selectedDate.getTime() < oneDayBeforeToday.getTime()) {
document.getElementById("applicantleaseStartDate").innerHTML = "Lease start date should not be earlier than one day before today's date";
document.getElementById("leaseStartDate").focus();
return false;
}
if (leaseTermType != "Month-By-Month") {
if (leaseEndDate == null || leaseEndDate == "") {
document.getElementById("applicantleaseEndDate").innerHTML = "This field is mandatory";
document.getElementById("leaseEndDate").focus();
return false;
}
} else {
// Clear the leaseEndDate value when "Month-By-Month" is selected
leaseEndDate = "";
}
// lease Start Date should be previous than End Date
if (leaseEndDate != null && leaseEndDate != "" && leaseStartDate >= leaseEndDate) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date";
document.getElementById("leaseEndDate").focus();
return false;
}
if (leaseTermType == "Weekly") {
var weekDifference = Math.floor((new Date(leaseEndDate) - selectedDate) / (1000 * 60 * 60 * 24 * 7));
// Check if there is at least a week difference
if (weekDifference < 1) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a week between lease start and end dates for weekly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (leaseTermType == "Bi-Weekly") {
var biWeekDifference = Math.floor((new Date(leaseEndDate) - selectedDate) / (1000 * 60 * 60 * 24 * 7 * 2));
// Check if there is at least a two-week difference
if (biWeekDifference < 1) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a two-week difference between lease start and end dates for bi-weekly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (leaseTermType == "Yearly") {
var oneYearLater = new Date(selectedDate);
oneYearLater.setFullYear(oneYearLater.getFullYear() + 1);
// Check if there is at least a 365-day difference
if (oneYearLater.getTime() > new Date(leaseEndDate).getTime()) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a 365-day difference between lease start and end dates for yearly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (rentAmount == "" || rentAmount == null) {
document.getElementById("rentOfAmount").innerHTML = "This field is mandatory";
document.getElementById("rentAmount").focus();
return false;
}
if (rentPayDate == "" || rentPayDate == null) {
document.getElementById("rentOfPayDate").innerHTML = "This field is mandatory";
document.getElementById("rentPayDate").focus();
return false;
}
if (rentTo == "" || rentTo == null) {
document.getElementById("rentTo_error").innerHTML = "This field is mandatory";
document.getElementById("rentTo").focus();
return false;
}
} else if (type == "RESIDENTIAL-LEASE-May-15") {
if (leaseTermType === "Month-By-Month") {
leaseEndDate = "";
}
}
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
let objec = " ";
xmlhttp1.open("POST", baseurl + "/rentaladmin/inviteforlease?propertyID=" + propertyID + "&email=" + mail + "&webBaseURL=" + webBaseURL +
"&appID=" + appID + "&type=" + type, true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp1.onreadystatechange = function () {
if ((this.status == 403 || this.status == 401) && this.readyState == 4) {
window.location.href = window.location.protocol + "//" + window.location.host + "/admin/pages-error-404.html"
} else if (this.status == 500) {
var res = JSON.parse(this.responseText);
if (res.response === "401 UNAUTHORIZED") {
$('#employee_modal_message').modal("show");
$("#modal_message_content").html("
"
}
}
document.getElementById('approvedLease').innerHTML = tableData;
}
};
xmlhttp1.send();
}
}
function openEditModal(leaseID, emergencyContactInfo) {
var contactInfo = JSON.parse(decodeURIComponent(emergencyContactInfo));
if (contactInfo.contactNumber || contactInfo.contactName || contactInfo.contactPersonRelationship) {
$('#emergencyContact_modal').modal("show");
$('#modal_message1').empty();
var dynamicCard = document.getElementById('modal_contact_form');
dynamicCard.innerHTML =
`
Contact Number:
Name:
Relationship:
`+
'Save' +
`
`
}
}
function editContactInfo(leaseID) {
var contactNumber = $("#contact_number").val();
var contactName = $("#contact_name").val();
var contactPersonRelationship = $("#contact_relationship").val();
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp.open("POST", baseurl + "/rentaladmin/editemergencycontact?leaseID=" + leaseID);
xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
// var response = JSON.parse(res['response']);
var res = JSON.parse(this.responseText);
var s = res.rspnsMsg;
// console.log(s);
var s = s.replace(/[{}]/g, "");
let pairs = s.split(', ')
obj = pairs.reduce((obj, data) => {
let [k, v] = data.split('=')
obj[k] = v
return obj
}, {})
if (obj.contactNumber == "Invalid Phone Number!!") {
document.getElementById("contact_number_error").innerHTML = obj.contactNumber;
document.getElementById("contact_number").focus();
return false;
}
if (obj.contactName == "Invalid Name!!") {
document.getElementById("contact_name_error").innerHTML = obj.contactName;
document.getElementById("contact_name").focus();
return false;
}
if (obj.contactPersonRelationship == "Invalid!!") {
document.getElementById("contact_relationship_error").innerHTML = obj.contactPersonRelationship;
document.getElementById("contact_relationship").focus();
return false;
}
if (res.rspnsMsg == "GOOD") {
window.location.reload();
}
}
}
xmlhttp.send(JSON.stringify({
"contactNumber": contactNumber,
"contactName": contactName,
"contactPersonRelationship": contactPersonRelationship
}));
}
function showContactInfo(leaseID, emergencyContactInfo) {
var contactInfo = JSON.parse(decodeURIComponent(emergencyContactInfo));
if (contactInfo.contactNumber || contactInfo.contactName || contactInfo.contactPersonRelationship) {
$('#emergencyContact_modal').modal("show");
$('#modal_message1').empty();
var dynamicCard = document.getElementById('modal_contact_form');
dynamicCard.innerHTML =
`
Contact Number:
${contactInfo.contactNumber}
Name:
${contactInfo.contactName}
Relationship:
${contactInfo.contactPersonRelationship}
Last Update
${contactInfo.updateTimeStamp}
`+
'Edit' +
`
`
} else {
$('#emergencyContact_modal').modal("show");
var dynamicCard = document.getElementById('modal_contact_form');
dynamicCard.innerHTML = ('No Information Available')
}
}
function showVehicleInfo(email, leaseID) {
// console.log(email)
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp1.open("GET", baseurl + "/rentaladmin/getVehicleInfoPM?email=" + email + "&leaseID=" + leaseID);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
var res = JSON.parse(this.responseText);
var response = JSON.parse(res['response']);
$('#showvehicleinfoModal').modal("show");
var modalContent = document.getElementById('vehicleContent');
modalContent.innerHTML = '';
var table = document.createElement('table');
table.className = 'table';
var thead = document.createElement('thead');
if (response == null) {
showVehicleInfoModal(leaseID, '', '')
} else {
thead.innerHTML = `
Reg. Number
Model
Color
Type
Timestamp
`;
var tbody = document.createElement('tbody');
var hasValidVehicle = false; // Flag to check if valid vehicles exist
for (var i = 0; i < response.length; i++) {
var vehicleInfo = response[i];
console.log(vehicleInfo);
// Skip processing for null or empty vehicle_id
if (vehicleInfo.vehicle_id === null || !vehicleInfo.vehicle || vehicleInfo.vehicle.length === 0) {
continue;
}
hasValidVehicle = true; // Set the flag to true as we found a valid vehicle
for (var j = 0; j < vehicleInfo.vehicle.length; j++) {
// Skip invalid or null vehicle details
if (!vehicleInfo.vehicle[j].registration_number || !vehicleInfo.vehicle[j].model ||
!vehicleInfo.vehicle[j].vehicle_color || !vehicleInfo.vehicle[j].vehicle_type) {
continue;
}
if (i == response.length - 1) {
var lengthOfVehicleInfo = vehicleInfo.vehicle ? vehicleInfo.vehicle.length : 0;
tbody.innerHTML += `
`;
}
}
table.appendChild(tbody);
}
// Show the "No Vehicle Info" section only if no valid vehicles are found
if (!hasValidVehicle) {
thead.innerHTML = `
No Vehicle Info to show. To add a vehicle, click below:
Add Vehicle Info
`;
}
table.appendChild(tbody);
}
table.appendChild(thead);
modalContent.appendChild(table);
}
}
xmlhttp1.send();
}
//----------------------------------------------------------------------------------------------------------------------
// BELOW AJAX IS FOR CREATE LEASE FLOW(LANDLORD CLICKS ON CREATE LEASE BUTTON---> FILLS FORM AND MAIL IS SENT TO TENANT )
// this is ajax on submit button in new-lease.html when landlord sends it by create lease button
function inviteCreatedLease(type) {
var webBaseURL = window.location.protocol + "//" + window.location.host;
// rental address
var houseNo = $("#houseNo").val();
var streetAddress = $("#streetAddress").val();
var zip = $("#zip").val();
let zip_check = /^[0-9]{5,6}$/;
var city = $("#city").val();
var state = $("#state").val();
var country = $("#country").val();
//applicant details
var fullName = $('#fullName').val();
var mail = $('#mail').val();
var phoneNo = $('#phone_no').val();
var principalOwner = $("#principalOwner").val();
var tenant = $("#tenant").val();
//terms
var leaseStartDate = $("#leaseStartDate").val();
var leaseEndDate = $("#leaseEndDate").val();
// rent
var rentAmount = $("#rentAmount").val();
var rentPayDate = $("#rentPayDate").val();
var rentTo = $("#rentTo").val();
var percentElectricityBill = $("#percentElectricityBill").val();
var electricityBillAmount = $("#electricityBillAmount").val();
var percentWaterBill = $("#percentWaterBill").val();
var waterBillAmount = $("#waterBillAmount").val();
var percentPhoneBill = $("#percentPhoneBill").val();
var phoneBillAmount = $("#phoneBillAmount").val();
var percentOtherBill = $("#percentOtherBill").val();
var otherBillAmount = $("#otherBillAmount").val();
//house hold rules
var cleaning = $("#cleaning").val();
var kitchenUse = $("#kitchenUse").val();
var overnightGuests = $("#overnightGuests").val();
var useOfAppliances = $("#useOfAppliances").val();
var smoking = $("#smoking").val();
var useOfCommonAreas = $("#useOfCommonAreas").val();
var alcoholUse = $("#alcoholUse").val();
var telephoneUse = $("#telephoneUse").val();
var studyingHours = $("#studyingHours").val();
var personalItemsShared = $("#personalItemsShared").val();
var music = $("#music").val();
var bedroomAssignment = $("#bedroomAssignment").val();
var pets = $("#pets").val();
var other = $("#other").val();
//deposits
var lastPaidDate = formatDate($("#lastPaidDate").val());
var lastPaidAmount = $("#lastPaidAmount").val();
var securityDeposit = formatDate($("#securityDeposit").val());
var securityAmount = $("#securityAmount").val();
var refundDeposit = $("#refundDeposit").val();
var refundPaidDate = formatDate($("#refundPaidDate").val());
var refundDuration = $("#refundDuration").val();
//lead based paint discloser
var agreementDay = $("#agreementDay").val();
var agreementMonth = $("#agreementMonth").val();
var agreementYear = $("#agreementYear").val();
// conflict resolution
var conflictionDecision = $("input:radio[name=conflicResolution]:checked").val();
var other_programs1 = $("#other_programs1").val();
var other_programs2 = $("#other_programs2").val();
var other_programs3 = $("#other_programs3").val();
var other_programs4 = $("#other_programs4").val();
var other_programs5 = $("#other_programs5").val();
var other_programs6 = $("#other_programs6").val();
var other_programs7 = $("#other_programs7").val();
var other_programs8 = $("#other_programs8").val();
var other_programs9 = $("#other_programs9").val();
var other_programs10 = $("#other_programs10").val();
var other_programs11 = $("#other_programs11").val();
var copy = $("input:radio[name=other_radio]:checked").val();
var leadBasedInput1 = $("#leadBasedInput1").val();
var leadBasedInput2 = $("#leadBasedInput2").val();
var leaseTermType = $("#leaseTermType").val();
// this is to clear error after user puts fills valid values
$(".container span").html("");
var permanentAddress = $("#permanentAddress").val();
var paymentMethod = $("#paymentMethod").val();
var minimumObligationPeriod = $("#minimumObligationPeriod").val();
var minimumObligationNoticePeriod = $("#minimumObligationNoticePeriod").val();
var monthtoMonthNoticePeriod = $("#monthtoMonthNoticePeriod").val();
var utilityExpenses = $("input:radio[name=utilityExpenses]:checked").val();
var fixedTermDuration = $("#fixedTermDuration").val();
// this is to clear error after user puts fills valid values
$("fieldset span").html("");
if (type == "RESIDENTIAL") {
var isHouseHoldRuleChecked = document.getElementById("check_1").checked;
var isConflictResolutionChecked = document.getElementById("check_2").checked;
var isPrivacyChecked = document.getElementById("check_3").checked;
var isDepositsChecked = document.getElementById("check_4").checked;
var isOtherAgreementChecked = document.getElementById("check_5").checked;
var isMegansLawChecked = document.getElementById("check_6").checked;
var isPaintDisclosureChecked = document.getElementById("check_7").checked;
// this is to populate error below fields if user fills wrong input
if (houseNo == "" || houseNo == null) {
document.getElementById("house").innerHTML = "This field is mandatory";
document.getElementById("houseNo").focus();
return false;
}
if (streetAddress == "" || streetAddress == null) {
document.getElementById("").innerHTML = "This field is mandatory";
document.getElementById("streetAddress").focus();
return false;
}
if (zip == "" || zip == null) {
document.getElementById("rentalzip").innerHTML = "This field is mandatory";
document.getElementById("zip").focus();
return false;
}
if (city == "" || city == null) {
document.getElementById("rentalcity").innerHTML = "This field is mandatory";
document.getElementById("city").focus();
return false;
}
if (state == "" || state == null) {
document.getElementById("rentalstate").innerHTML = "This field is mandatory";
document.getElementById("state").focus();
return false;
}
if (country == "" || country == null) {
document.getElementById("rentalcountry").innerHTML = "This field is mandatory";
document.getElementById("country").focus();
return false;
}
if (fullName == "" || fullName == null) {
document.getElementById("applicantname").innerHTML = "This field is mandatory";
document.getElementById("fullName").focus();
return false;
}
if (mail == null || mail == "") {
document.getElementById("applicantmail").innerHTML = "This field is mandatory";
document.getElementById("mail").focus();
return false;
}
if (principalOwner == "" || principalOwner == null) {
document.getElementById("principal_owner").innerHTML = "This field is mandatory";
document.getElementById("principalOwner").focus();
return false;
}
if (tenant == "" || tenant == null) {
document.getElementById("tenant_name").innerHTML = "This field is mandatory";
document.getElementById("tenant").focus();
return false;
}
if (leaseTermType == "" || leaseTermType == null) {
document.getElementById("error_leaseTerm").innerHTML = "This field is mandatory";
document.getElementById("leaseTermType").focus();
return false;
}
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("applicantleaseStartDate").innerHTML = "This field is mandatory";
document.getElementById("leaseStartDate").focus();
return false;
}
if (leaseTermType != "Month-By-Month") {
if (leaseEndDate == null || leaseEndDate == "") {
document.getElementById("applicantleaseEndDate").innerHTML = "This field is mandatory";
document.getElementById("leaseEndDate").focus();
return false;
}
} else {
// Clear the leaseEndDate value when "Month-By-Month" is selected
leaseEndDate = "";
}
// lease Start Date should be previous than End Date
if (leaseEndDate != null && leaseEndDate != "" && leaseStartDate > leaseEndDate) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date";
document.getElementById("leaseEndDate").focus();
return false;
}
if (leaseTermType != "Month-By-Month") {
if (leaseEndDate <= leaseStartDate && leaseEndDate != null && leaseEndDate != "") {
document.getElementById("applicantleaseEndDate").innerHTML = "Lease end date should be greater than today!!";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (!zip_check.test(zip) && zip != "") {
$('#zip').focus();
$('#rentalzip').html("Invalid Zip Code !!");
return false;
} else {
document.getElementById("rentalzip").innerHTML = "";
}
var electricityBill = rentAmount / percentElectricityBill;
if (document.getElementById('ElectricityCheck').checked && electricityBillAmount != electricityBill) {
document.getElementById("rentboxelectricityBillAmount").innerHTML = "Invalid Number";
document.getElementById("electricityBillAmount").focus();
return false;
}
var waterBill = rentAmount / percentWaterBill;
if (document.getElementById('WaterCheck').checked && waterBillAmount != waterBill) {
document.getElementById("rentboxpercentWaterBillAmount").innerHTML = "Invalid Number";
document.getElementById("waterBillAmount").focus();
return false;
}
var phoneBill = rentAmount / percentPhoneBill;
if (document.getElementById('PhoneCheck').checked && phoneBillAmount != phoneBill) {
document.getElementById("rentboxphoneBillAmount").innerHTML = "Invalid Number";
document.getElementById("phoneBillAmount").focus();
return false;
}
var otherBill = rentAmount / percentOtherBill;
if (document.getElementById('OtherCheck').checked && otherBillAmount != otherBill) {
document.getElementById("rentboxotherBillAmount").innerHTML = "Invalid Number";
document.getElementById("otherBillAmount").focus();
return false;
}
const monthAbbreviations = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
];
const currentDate = new Date();
const day = currentDate.getDate();
const monthIndex = currentDate.getMonth(); // 0-based index
const year = currentDate.getFullYear();
const monthAbbreviation = monthAbbreviations[monthIndex];
const formattedDate = `${monthAbbreviation} ${day.toString().padStart(2, '0')}, ${year}`;
if (document.getElementById('check_4').checked && securityDeposit != formattedDate) {
document.getElementById("conflictsecurityDeposit").innerHTML = "please select today's date";
document.getElementById("securityDeposit").focus();
return false;
}
if (document.getElementById('check_7').checked && $("#leadBasedInput1").val() == "") {
document.getElementById("errorLeadBased1").innerHTML = "This field is mandatory";
document.getElementById("leadBasedInput1").focus();
return false;
}
if (document.getElementById('check_7').checked && $("#leadBasedInput2").val() == "") {
document.getElementById("errorLeadBased2").innerHTML = "This field is mandatory";
document.getElementById("leadBasedInput2").focus();
return false;
}
if (rentAmount == "" || rentAmount == null) {
document.getElementById("rentOfAmount").innerHTML = "This field is mandatory";
document.getElementById("rentAmount").focus();
return false;
}
if (rentPayDate == "" || rentPayDate == null) {
document.getElementById("rentOfPayDate").innerHTML = "This field is mandatory";
document.getElementById("rentPayDate").focus();
return false;
}
if (rentTo == "" || rentTo == null) {
document.getElementById("rentTo_error").innerHTML = "This field is mandatory";
document.getElementById("rentTo").focus();
return false;
}
if (document.getElementById('check_7').checked && $("#leadBasedInput1").val() == "") {
document.getElementById("errorLeadBased1").innerHTML = "This field is mandatory";
document.getElementById("leadBasedInput1").focus();
return false;
}
if (document.getElementById('check_7').checked && $("#leadBasedInput2").val() == "") {
document.getElementById("errorLeadBased2").innerHTML = "This field is mandatory";
document.getElementById("leadBasedInput2").focus();
return false;
}
} else if (type === "PAYING-GUEST") {
leaseStartDate = ($("#monthtoMonthStartDate").val() || $("#fixedTermStartDate").val() || $("#minObligationStartDate").val());
leaseEndDate = $("#fixedTermEndDate").val();
leaseTermType = $("input:radio[name=leaseTermType]:checked").val();
tenant = $("#fullName").val();
utilityExpenses = $("input:radio[name=utilityExpenses]:checked").val();
var includedRadio = document.getElementById("includedRadio");
var notIncludedRadio = document.getElementById("notIncludedRadio");
// phoneNo = document.getElementById("phone_no");
if (houseNo == "" || houseNo == null) {
document.getElementById("house").innerHTML = "This field is mandatory";
document.getElementById("houseNo").focus();
return false;
}
if (streetAddress == "" || streetAddress == null) {
document.getElementById("streetAddress").innerHTML = "This field is mandatory";
document.getElementById("street").focus();
return false;
}
if (zip == "" || zip == null) {
document.getElementById("rentalzip").innerHTML = "This field is mandatory";
document.getElementById("zip").focus();
return false;
}
if (city == "" || city == null) {
document.getElementById("rentalcity").innerHTML = "This field is mandatory";
document.getElementById("city").focus();
return false;
}
if (state == "" || state == null) {
document.getElementById("rentalstate").innerHTML = "This field is mandatory";
document.getElementById("state").focus();
return false;
}
if (country == "" || country == null) {
document.getElementById("rentalcountry").innerHTML = "This field is mandatory";
document.getElementById("country").focus();
return false;
}
if (principalOwner == "" || principalOwner == null) {
document.getElementById("principal_owner").innerHTML = "This field is mandatory";
document.getElementById("principalOwner").focus();
return false;
}
if (fullName == "" || fullName == null) {
document.getElementById("applicantname").innerHTML = "This field is mandatory";
document.getElementById("fullName").focus();
return false;
}
if (mail == null || mail == "") {
document.getElementById("applicantmail").innerHTML = "This field is mandatory";
document.getElementById("mail").focus();
return false;
}
if (leaseTermType == "" || leaseTermType == null) {
document.getElementById("error_leaseTermType").innerHTML = "Lease term is mandatory";
document.getElementById("durationType1").focus(); // Issue
return false;
}
if (leaseTermType === "Month-to-Month") {
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("conflictMonthtoMonthDate").innerHTML = "This field is Mandatory";
document.getElementById("monthtoMonthStartDate").focus();
return false;
}
if (monthtoMonthNoticePeriod == "" || monthtoMonthNoticePeriod == null) {
document.getElementById("conflictMonthytoMonthNotice").innerHTML = "This field is mandatory";
document.getElementById("monthtoMonthNoticePeriod").focus();
return false;
}
}
if (leaseTermType === "Fixed-Term") {
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("conflictfixedTermStartDate").innerHTML = "This field is mandatory";
document.getElementById("fixedTermStartDate").focus();
return false;
}
if (leaseEndDate == "" || leaseEndDate == null) {
document.getElementById("conflictfixedTermEndDate").innerHTML = "This field is mandatory";
document.getElementById("fixedTermEndDate").focus();
return false;
}
if (fixedTermDuration == "" || fixedTermDuration == null) {
document.getElementById("conflictfixedDuration").innerHTML = "This field is mandatory";
document.getElementById("fixedTermDuration");
return false;
}
if (leaseEndDate != null && leaseEndDate != "" && leaseStartDate > leaseEndDate) {
document.getElementById("conflictfixedTermEndDate").innerHTML = "Invalid Date";
document.getElementById("fixedTermEndDate").focus();
return false;
}
}
if (leaseTermType === "Minimum-Term-Obligation") {
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("conflictminObligationDate").innerHTML = "This field is Mandatory";
document.getElementById("minObligationStartDate").focus();
return false;
}
if (minimumObligationPeriod == "" || minimumObligationPeriod == null) {
document.getElementById("conflictMinimumObligationPeriod").innerHTML = "This field is mandatory";
document.getElementById("minimumObligationPeriod").focus();
return false;
}
if (minimumObligationNoticePeriod == "" || minimumObligationNoticePeriod == null) {
document.getElementById("conflictminimumObligationNoticePeriod").innerHTML = "This field is mandatory";
document.getElementById("minimumObligationNoticePeriod").focus();
return false;
}
}
if (rentAmount == "" || rentAmount == null) {
document.getElementById("errorMonthlyRent").innerHTML = "This field is mandatory";
document.getElementById("rentAmount").focus();
return false;
}
if (rentPayDate == "" || rentPayDate == null) {
document.getElementById("conflictDate").innerHTML = "This field is mandatory";
document.getElementById("rentPayDate").focus();
return false;
}
if (paymentMethod == "" || paymentMethod == null) {
document.getElementById("errorPaymentMethod").innerHTML = "This field is mandatory";
document.getElementById("paymentMethod").focus();
return false;
}
if (!includedRadio.checked && !notIncludedRadio.checked) {
document.getElementById("utilityExpensesError").innerHTML = "Please choose one of the options for utility expenses.";
document.getElementById("includedRadio").focus();
// document.getElementById("notIncludedRadio").focus();
return false;
}
} else if (type == "RESIDENTIAL LEASE 1") {
// this is to populate error below fields if user fills wrong input
if (houseNo == "" || houseNo == null) {
document.getElementById("house").innerHTML = "This field is mandatory";
document.getElementById("houseNo").focus();
return false;
}
if (streetAddress == "" || streetAddress == null) {
document.getElementById("").innerHTML = "This field is mandatory";
document.getElementById("streetAddress").focus();
return false;
}
if (zip == "" || zip == null) {
document.getElementById("rentalzip").innerHTML = "This field is mandatory";
document.getElementById("zip").focus();
return false;
}
if (city == "" || city == null) {
document.getElementById("rentalcity").innerHTML = "This field is mandatory";
document.getElementById("city").focus();
return false;
}
if (state == "" || state == null) {
document.getElementById("rentalstate").innerHTML = "This field is mandatory";
document.getElementById("state").focus();
return false;
}
if (country == "" || country == null) {
document.getElementById("rentalcountry").innerHTML = "This field is mandatory";
document.getElementById("country").focus();
return false;
}
if (fullName == "" || fullName == null) {
document.getElementById("applicantname").innerHTML = "This field is mandatory";
document.getElementById("fullName").focus();
return false;
}
if (mail == null || mail == "") {
document.getElementById("applicantmail").innerHTML = "This field is mandatory";
document.getElementById("mail").focus();
return false;
}
if (principalOwner == "" || principalOwner == null) {
document.getElementById("principal_owner").innerHTML = "This field is mandatory";
document.getElementById("principalOwner").focus();
return false;
}
if (tenant == "" || tenant == null) {
document.getElementById("tenant_name").innerHTML = "This field is mandatory";
document.getElementById("tenant").focus();
return false;
}
if (leaseTermType == "" || leaseTermType == null) {
document.getElementById("error_leaseTerm").innerHTML = "This field is mandatory";
document.getElementById("leaseTermType").focus();
return false;
}
if (leaseStartDate == "" || leaseStartDate == null) {
document.getElementById("applicantleaseStartDate").innerHTML = "This field is mandatory";
document.getElementById("leaseStartDate").focus();
return false;
}
var today = new Date();
today.setHours(0, 0, 0, 0);
var oneDayBeforeToday = new Date(today);
oneDayBeforeToday.setDate(today.getDate() - 1);
var selectedDate = new Date(leaseStartDate);
selectedDate.setHours(0, 0, 0, 0);
if (selectedDate.getTime() < oneDayBeforeToday.getTime()) {
document.getElementById("applicantleaseStartDate").innerHTML = "Lease start date should not be earlier than one day before today's date";
document.getElementById("leaseStartDate").focus();
return false;
}
if (leaseTermType != "Month-By-Month") {
if (leaseEndDate == null || leaseEndDate == "") {
document.getElementById("applicantleaseEndDate").innerHTML = "This field is mandatory";
document.getElementById("leaseEndDate").focus();
return false;
}
} else {
// Clear the leaseEndDate value when "Month-By-Month" is selected
leaseEndDate = "";
}
// lease Start Date should be previous than End Date
if (leaseEndDate != null && leaseEndDate != "" && leaseStartDate >= leaseEndDate) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date";
document.getElementById("leaseEndDate").focus();
return false;
}
if (leaseTermType == "Weekly") {
var weekDifference = Math.floor((new Date(leaseEndDate) - selectedDate) / (1000 * 60 * 60 * 24 * 7));
// Check if there is at least a week difference
if (weekDifference < 1) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a week between lease start and end dates for weekly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (leaseTermType == "Bi-Weekly") {
var biWeekDifference = Math.floor((new Date(leaseEndDate) - selectedDate) / (1000 * 60 * 60 * 24 * 7 * 2));
// Check if there is at least a two-week difference
if (biWeekDifference < 1) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a two-week difference between lease start and end dates for bi-weekly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (leaseTermType == "Yearly") {
var oneYearLater = new Date(selectedDate);
oneYearLater.setFullYear(oneYearLater.getFullYear() + 1);
// Check if there is at least a 365-day difference
if (oneYearLater.getTime() > new Date(leaseEndDate).getTime()) {
document.getElementById("applicantleaseEndDate").innerHTML = "Invalid Date. There must be at least a 365-day difference between lease start and end dates for yearly leases.";
document.getElementById("leaseEndDate").focus();
return false;
}
}
if (rentAmount == "" || rentAmount == null) {
document.getElementById("rentOfAmount").innerHTML = "This field is mandatory";
document.getElementById("rentAmount").focus();
return false;
}
if (rentPayDate == "" || rentPayDate == null) {
document.getElementById("rentOfPayDate").innerHTML = "This field is mandatory";
document.getElementById("rentPayDate").focus();
return false;
}
if (rentTo == "" || rentTo == null) {
document.getElementById("rentTo_error").innerHTML = "This field is mandatory";
document.getElementById("rentTo").focus();
return false;
}
}
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
$("#lease_submit").prop("disabled", true)
xmlhttp1.open("POST", baseurl + "/rentaladmin/invitecreatedlease?email=" + mail + "&webBaseURL=" + webBaseURL
+ "&type=" + type, true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
var res = JSON.parse(this.responseText);
$("#lease_submit").prop("disabled", false)
var s = res.rspnsMsg;
// console.log(s);
var s = s.replace(/[{}]/g, "");
let pairs = s.split(', ')
objec = pairs.reduce((objec, data) => {
let [k, v] = data.split('=')
objec[k] = v
return objec
}, {})
// this is to populate error below fields if user fills wrong input
if (objec.houseNo == "Invalid House Number!!") {
document.getElementById("house").innerHTML = objec.houseNo;
document.getElementById("houseNo").focus();
return false;
}
if (objec.streetAddress == "Invalid Street Address!!") {
document.getElementById("street").innerHTML = objec.streetAddress;
document.getElementById("streetAddress").focus();
return false;
}
if (objec.zip == "Invalid zip!!") {
document.getElementById("rentalzip").innerHTML = objec.zip;
document.getElementById("zip").focus();
return false;
}
if (objec.city == "Invalid City!!") {
document.getElementById("rentalcity").innerHTML = objec.city;
document.getElementById("city").focus();
return false;
}
if (objec.state == "Invalid State!!") {
document.getElementById("rentalstate").innerHTML = objec.state;
document.getElementById("state").focus();
return false;
}
if (objec.country == "Invalid Country!!") {
document.getElementById("rentalcountry").innerHTML = objec.country;
document.getElementById("country").focus();
return false;
}
if (objec.name == "Invalid Name!!") {
document.getElementById("applicantname").innerHTML = objec.name;
document.getElementById("fullName").focus();
return false;
}
if (objec.email == "Invalid email!!") {
document.getElementById("applicantmail").innerHTML = objec.email;
document.getElementById("mail").focus();
return false;
}
if (objec.phoneNo == "Invalid Phone Number!!") {
document.getElementById("applicantphone_no").innerHTML = objec.phoneNo;
document.getElementById("phone_no").focus();
return false;
}
if (objec.principalOwner == "Invalid Name!!") {
document.getElementById("principal_owner").innerHTML = objec.principalOwner;
document.getElementById("principalOwner").focus();
return false;
}
if (objec.tenant == "Invalid Name!!") {
document.getElementById("tenant_name").innerHTML = objec.tenant;
document.getElementById("tenant").focus();
return false;
}
if (objec.leaseStartDate == "This field is mandatory") {
document.getElementById("applicantleaseStartDate").innerHTML = objec.leaseStartDate;
document.getElementById("leaseStartDate").focus();
return false;
}
if (objec.rentAmount == "Invalid Number!!") {
document.getElementById("rentOfAmount").innerHTML = objec.rentAmount;
document.getElementById("rentAmount").focus();
return false;
}
if (objec.rentPayDate == "Invalid !!") {
document.getElementById("rentOfPayDate").innerHTML = objec.rentPayDate;
document.getElementById("rentPayDate").focus();
return false;
}
if (objec.rentTo == "Invalid Name!!") {
document.getElementById("rentTo_error").innerHTML = objec.rentTo;
document.getElementById("rentTo").focus();
return false;
}
if (objec.percentElectricityBill == "Invalid Number!!") {
document.getElementById("rentboxpercentElectricityBill").innerHTML = objec.percentElectricityBill;
document.getElementById("percentElectricityBill").focus();
return false;
}
if (objec.electricityBillAmount == "Invalid Number!!") {
document.getElementById("rentboxelectricityBillAmount").innerHTML = objec.electricityBillAmount;
document.getElementById("electricityBillAmount").focus();
return false;
}
if (objec.percentWaterBill == "Invalid Number!!") {
document.getElementById("rentboxpercentWaterBill").innerHTML = objec.percentWaterBill;
document.getElementById("percentWaterBill").focus();
return false;
}
if (objec.waterBillAmount == "Invalid Number!!") {
document.getElementById("rentboxpercentWaterBillAmount").innerHTML = objec.waterBillAmount;
document.getElementById("waterBillAmount").focus();
return false;
}
if (objec.percentPhoneBill == "Invalid Number!!") {
document.getElementById("rentboxpercentPhoneBill").innerHTML = objec.percentPhoneBill;
document.getElementById("percentPhoneBill").focus();
return false;
}
if (objec.phoneBillAmount == "Invalid Number!!") {
document.getElementById("rentboxphoneBillAmount").innerHTML = objec.phoneBillAmount;
document.getElementById("phoneBillAmount").focus();
return false;
}
if (objec.percentOtherBill == "Invalid Number!!") {
document.getElementById("rentboxpercentOtherBill").innerHTML = objec.percentOtherBill;
document.getElementById("percentOtherBill").focus();
return false;
}
if (objec.otherBillAmount == "Invalid Number!!") {
document.getElementById("rentboxotherBillAmount").innerHTML = objec.otherBillAmount;
document.getElementById("otherBillAmount").focus();
return false;
}
if (objec.cleaning == "Invalid Characters!!") {
document.getElementById("housecleaning").innerHTML = objec.cleaning;
document.getElementById("cleaning").focus();
return false;
}
if (objec.kitchenUse == "Invalid Characters!!") {
document.getElementById("housekitchenUse").innerHTML = objec.kitchenUse;
document.getElementById("kitchenUse").focus();
return false;
}
if (objec.overnightGuests == "Invalid Characters!!") {
document.getElementById("houseovernightGuests").innerHTML = objec.overnightGuests;
document.getElementById("overnightGuests").focus();
return false;
}
if (objec.useOfAppliances == "Invalid Characters!!") {
document.getElementById("houseuseOfAppliances").innerHTML = objec.useOfAppliances;
document.getElementById("useOfAppliances").focus();
return false;
}
if (objec.smoking == "Invalid Characters!!") {
document.getElementById("housesmoking").innerHTML = objec.smoking;
document.getElementById("smoking").focus();
return false;
}
if (objec.useOfCommonAreas == "Invalid Characters!!") {
document.getElementById("houseuseOfCommonAreas").innerHTML = objec.useOfCommonAreas;
document.getElementById("useOfCommonAreas").focus();
return false;
}
if (objec.alcoholUse == "Invalid Characters!!") {
document.getElementById("housealcoholUse").innerHTML = objec.alcoholUse;
document.getElementById("alcoholUse").focus();
return false;
}
if (objec.telephoneUse == "Invalid Characters!!") {
document.getElementById("housetelephoneUse").innerHTML = objec.telephoneUse;
document.getElementById("telephoneUse").focus();
return false;
}
if (objec.studyingHours == "Invalid Characters!!") {
document.getElementById("housestudyingHours").innerHTML = objec.studyingHours;
document.getElementById("studyingHours").focus();
return false;
}
if (objec.personalItemsShared == "Invalid Characters!!") {
document.getElementById("housepersonalItemsShared").innerHTML = objec.personalItemsShared;
document.getElementById("personalItemsShared").focus();
return false;
}
if (objec.music == "Invalid Characters!!") {
document.getElementById("housemusic").innerHTML = objec.music;
document.getElementById("music").focus();
return false;
}
if (objec.bedroomAssignment == "Invalid Characters!!") {
document.getElementById("housebedroomAssignment").innerHTML = objec.bedroomAssignment;
document.getElementById("bedroomAssignment").focus();
return false;
}
if (objec.pets == "Invalid Characters!!") {
document.getElementById("housepets").innerHTML = objec.pets;
document.getElementById("pets").focus();
return false;
}
if (objec.other == "Invalid Characters!!") {
document.getElementById("houseother").innerHTML = objec.other;
document.getElementById("other").focus();
return false;
}
if (objec.lastPaidDate == "Invalid Number!!") {
document.getElementById("conflictlastPaidDate").innerHTML = objec.lastPaidDate;
document.getElementById("lastPaidDate").focus();
return false;
}
if (objec.lastPaidAmount == "Invalid Number!!") {
document.getElementById("conflictlastPaidAmount").innerHTML = objec.lastPaidAmount;
document.getElementById("lastPaidAmount").focus();
return false;
}
if (objec.securityDeposit == "Invalid Number!!") {
document.getElementById("conflictsecurityDeposit").innerHTML = objec.securityDeposit;
document.getElementById("securityDeposit").focus();
return false;
}
if (objec.securityAmount == "Invalid Number!!") {
document.getElementById("conflictsecurityAmount").innerHTML = objec.securityAmount;
document.getElementById("securityAmount").focus();
return false;
}
if (objec.refundDeposit == "Invalid Number!!") {
document.getElementById("depositrefundDeposit").innerHTML = objec.refundDeposit;
document.getElementById("refundDeposit").focus();
return false;
}
if (objec.refundPaidDate == "Invalid Number!!") {
document.getElementById("depositrefundPaidDate").innerHTML = objec.refundPaidDate;
document.getElementById("refundPaidDate").focus();
return false;
}
if (objec.refundDuration == "Invalid Number!!") {
document.getElementById("depositrefundDuration").innerHTML = objec.refundDuration;
document.getElementById("refundDuration").focus();
return false;
}
if (objec.optionSelected == "Please fill A or B only") {
document.getElementById("errorOtherPr11").innerHTML = objec.refundDuration;
document.getElementById("other_programs11").focus();
return false;
}
if (objec.acknowledgedTenant1 == "Please fill valid name") {
document.getElementById("errorLeadBased1").innerHTML = objec.acknowledgedTenant1;
document.getElementById("leadBasedInput1").focus();
return false;
}
if (objec.acknowledgedTenant2 == "Please fill valid name") {
document.getElementById("errorLeadBased2").innerHTML = objec.acknowledgedTenant2;
document.getElementById("leadBasedInput2").focus();
return false;
}
if (objec.agreementDay == "Invalid Number!!") {
document.getElementById("leadagreementDay").innerHTML = objec.agreementDay;
}
if (objec.agreementMonth == "Invalid Number!!") {
document.getElementById("leadagreementMonth").innerHTML = objec.agreementMonth;
}
if (objec.agreementYear == "Invalid Number!!") {
document.getElementById("leadagreementYear").innerHTML = objec.agreementYear;
}
$('#basicModal').modal("show");
$("#modal_message").html("
Mail sent to the tenant
");
$("#modal_title").html("SUCCESS!!");
} else if ((this.status == 403 || this.status == 401) && this.readyState == 4) {
window.location.href = window.location.protocol + "//" + window.location.host + "/admin/pages-error-404.html"
} else if (this.status == 500) {
var res = JSON.parse(this.responseText);
if (res.response === "401 UNAUTHORIZED") {
$('#employee_modal_message').modal("show");
$("#modal_message_content").html("
"
}
}
document.getElementById('transaction_table').innerHTML = tableData;
}
};
xmlhttp1.send();
}
}
//------------------------------------------------------------------------------------------------------------------------------------------
// Below ajaxes are for request to apply flow : first applicant requests for application form --- his details along with property is added in
// unsubmitted applications (invite-applicant.html page) and when property owner clicks invite button then status changes to unsubmitted with update in time stamp
// and application form is sent to the applicant
// this is for request button (getProperty.html-- Unsecured)
function requestForApplication(propertyID) {
var email = $("#email").val();
var fullName = $("#full_name").val();
var phoneNumber = $("#phoneNumber").val();
$("#error_name").html("");
$("#error_mail").html("");
$("#error_phoneNumber").html("");
if (fullName == "" || fullName == null) {
$("#error_name").html("Please fill your name");
return false;
}
if (email == "" || email == null) {
$("#error_mail").html("Please fill your email address");
return false;
}
if (phoneNumber == "" || phoneNumber == null) {
$("#error_phoneNumber").html("Please fill your number");
return false;
}
//window.alert("Request is recorded");
var phoneRe = /^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\./0-9]*$/g;
var digits = phoneNumber.replace(/\D/g, "");
if (!phoneRe.test(digits)) {
$("#error_phoneNumber").html("Please fill valid phone number");
return false;
}
var xmlhttp1;
try {
xmlhttp1 = new XMLHttpRequest();
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("BROWSER BROKE");
return false;
}
}
}
xmlhttp1.open("POST", baseurl + "/rentalunsecured/requesttoapply?propertyID=" + propertyID + "&email=" + email
+ "&fullName=" + fullName + "&phoneNumber=" + phoneNumber, true);
xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
xmlhttp1.onreadystatechange = function () {
if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) {
var res = JSON.parse(this.responseText);
var s = res.rspnsMsg;
var s = s.replace(/[{}]/g, "");
const obj = Object.fromEntries([s.split("=")])
document.getElementById("error_mail").innerHTML = "";
if (email == "") {
$("#error_mail").html("Please fill Mail Id");
return false;
}
if (obj.error == "Invalid Mail Id!") {
document.getElementById("error_mail").innerHTML = obj.error;
}
if (res.rspnsMsg == "GOOD") {
// $('#basicModal').modal("show");
// $("#modal_message").html("