// HTML include another HTML function includeHTML() { var z, i, elmnt, file, xhttp; /*loop through a collection of all HTML elements:*/ z = document.getElementsByTagName("*"); for (i = 0; i < z.length; i++) { elmnt = z[i]; /*search for elements with a certain attribute:*/ file = elmnt.getAttribute("w3-include-html"); if (file) { /*make an HTTP request using the attribute value as the file name:*/ xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState == 4) { if (this.status == 200) { elmnt.innerHTML = this.responseText; } if (this.status == 404) { elmnt.innerHTML = "Page not found."; } /*remove the attribute, and call this function once more:*/ elmnt.removeAttribute("w3-include-html"); includeHTML(); } } xhttp.open("GET", file, true); xhttp.send(); /*exit the function:*/ return; } } }; // for getting user information on each page function getUserInfo() { 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 + "/renter/getuserinfo", 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); var user = document.getElementById("profile_name"); user.innerHTML = res.response; } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } else if (this.status == 500) { var res = JSON.parse(this.responseText); if (res.response === "403 FORBIDDEN") { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } } }; xmlhttp1.send(); } // login function function initLogin() { var location = localStorage.getItem("location"); var email = $("#username").val(); var pass = $("#password").val(); var xmlhttpAuth; try { xmlhttpAuth = new XMLHttpRequest(); } catch (e) { try { xmlhttpAuth = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpAuth = new ActiveXObject( "Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttpAuth.open("POST", baseurl + "/authentication/getGenericJWTToken", true); xmlhttpAuth.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttpAuth.setRequestHeader('clientID', renterClientId); xmlhttpAuth.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { var res = JSON.parse(this.responseText); if (res.token != "Invalid User or Password / Or Account Locked") { localStorage.setItem('token', res.token); if (location == null) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/index.html" }else if(location == window.location.protocol + "//" + window.location.host + "/" || location == window.location.protocol + "//" + window.location.host + "/index.html" || location == window.location.protocol + "//" + window.location.host){ window.location.href = window.location.protocol + "//" + window.location.host + "/renter/index.html" } else { window.location.href = location } } else { $("#error_message").show(); $("#error_message").html("Invalid User or Password / Or Account Locked"); } } } xmlhttpAuth.send(JSON.stringify({ "username": email, "password": pass })); } function signout() { window.localStorage.removeItem("token"); // window.location.reload(); } function addClassOnToggle() { var toggleClicked = document.body.classList.contains('toggle-sidebar'); if (toggleClicked) { document.body.classList.remove('toggle-sidebar'); // console.log(toggleClicked) } else { document.body.classList.add('toggle-sidebar'); // console.log(toggleClicked) } } function CheckLeaseSigned() { 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 + "/renter/listleasedocs", 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']); // console.log(response); tableData = ''; if (response.length == 0) { var dashboard = document.getElementById('main'); dashboard.innerHTML = "

Welcome to Rents4Me

"; } } } }; xmlhttp1.send(); } function listLeaseDocs() { 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 + "/renter/listleasedocs", 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']); console.log(response); tableData = ''; if (response.length > 0) { for (var i = 0; i < response.length; i++) { var propertyAddress = response[i].lease["houseNo"] + ", " + response[i].lease["streetAddress"] + ", " + response[i].lease["city"] + ", " + response[i].lease["zip"] + ", " + response[i].lease["state"]; var leaseEndDate = response[i].lease["leaseEndDate"] == null || response[i].lease["leaseEndDate"] == "" ? "Not Mentioned" : formatDateForTables(response[i].lease["leaseEndDate"]); var lengthOfVehicleInfo = response[i].tenantVehicle.vehicle==null ? 0 : response[i].tenantVehicle.vehicle.length; let emergencyContactInfo = ''; let addendumsInfo = ``; tableData += ''; tableData += '' + (i + 1) + ''; tableData += '' + propertyAddress + ''; tableData += '' + '' + ''; tableData += '' + formatDateForTables(response[i].lease["leaseStartDate"]) + ''; tableData += '' + leaseEndDate + ''; tableData += '' + response[i].lease["leaseTermType"] + ''; tableData += '' + getDateInClientFormat(response[i].updateTimeStamp) + ''; tableData += '' + '' + ''; tableData += `${emergencyContactInfo}`; tableData += `${addendumsInfo}`; tableData += ''; } } else { tableData += "No Lease Documents for now"; } } 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:
`+ ''+ `
` } } 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 + "/renter/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}
`+ ''+ `
` }else { $('#emergencyContact_modal').modal("show"); var dynamicCard = document.getElementById('modal_contact_form'); dynamicCard.innerHTML = ('No Information Available') } } function showVehicleInfoModal(leaseID, totalVehicles, vehicleData) { // console.log("Lease ID: " + leaseID); var decodedVehicleData = decodeURIComponent(vehicleData); var vehicles = JSON.parse(decodedVehicleData); var showVehicleContainer = document.getElementById('display'); var editVehicleContainer = document.getElementById('edit-vehicle-container'); showVehicleContainer.innerHTML = ''; editVehicleContainer.innerHTML = ''; var leaseIdInputHtml = ` `; editVehicleContainer.innerHTML = leaseIdInputHtml; if (vehicles == null ||vehicles.length==0 ) { var show_vehicle_html = `
No Vehicle Info to show
`; var edit_vehicle_html = `
`; showVehicleContainer.innerHTML += show_vehicle_html; editVehicleContainer.innerHTML += edit_vehicle_html; } else { for (var i = 0; i < totalVehicles; i++) { var registrationNumber = vehicles[i].registration_number; var model = vehicles[i].model; var vehicleType = vehicles[i].vehicle_type; var vehicleColor = vehicles[i].vehicle_color; var show_vehicle_html = `
Vehicle Registration Number:
${registrationNumber}
Vehicle Type:
${vehicleType}
Vehicle Model:
${model}
Vehicle Color:
${vehicleColor}

`; var edit_vehicle_html = `
Vehicle Registration Number
Vehicle Type
Vehicle Model
Vehicle Color
`; showVehicleContainer.innerHTML += show_vehicle_html; editVehicleContainer.innerHTML += edit_vehicle_html; } } $('#vehicleInfoModal').modal('show'); } function addLine(firstLine) { var editVehicleContainer = document.getElementById('edit-vehicle-container'); var newIndex = editVehicleContainer.querySelectorAll('.edit_vehicle_details').length; var newLineHtml = `
Vehicle Registration Number
Vehicle Type
Vehicle Model
Vehicle Color
`; if(firstLine) document.getElementById('add-first-line').style.display = 'none'; editVehicleContainer.insertAdjacentHTML('beforeend', newLineHtml); } function removeLine(event) { var button = event.target; var editVehicleDetails = button.closest('.edit_vehicle_details'); if (editVehicleDetails) { editVehicleDetails.remove(); renameIDs(); } else { console.error('Parent element with class "edit_vehicle_details" not found.'); } } function renameIDs() { var editVehicleContainer = document.querySelectorAll('.edit_vehicle_details'); var count = -1; editVehicleContainer.forEach(function (eachRow) { count++; var inputs = eachRow.querySelectorAll("input"); inputs.forEach(function (input) { var id = input.id; input.id = id.substring(0, id.length-1) + count; }); }); } function edittenantVehicleinfo() { var leaseid = document.getElementById("leaseIdInput").value; var xmlhttp1; const vehicleData = []; var editVehicleDetailsCount = document.querySelectorAll('#edit-vehicle-container .edit_vehicle_details').length; for (let i = 0; i < editVehicleDetailsCount; i++) { const registrationNumber = document.getElementById("vehicleRegistrationNumber" + i).value; const vehicleType = document.getElementById("vehicleType" + i).value; const vehicleModel = document.getElementById("vehicleModel" + i).value; const vehicleColor = document.getElementById("vehicleColor" + i).value; vehicleData.push({ model: vehicleModel, registration_number: registrationNumber, status: "", vehicle_color: vehicleColor, vehicle_type: vehicleType }); } 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 + "/renter/insertTenantVehicle?leaseID=" + leaseid, 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); var response = res.response; if (response == "VEHICLE INFO UPDATED") { $('#vehicleInfoModal').modal("hide"); window.location.reload(); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/pages-error-404.html" } else if (this.status == 500 && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/pages-error-404.html" } }; xmlhttp1.send(JSON.stringify({ vehicle: vehicleData, })); } function downloadLeasePdf(leaseID) { var fileType = "lease"; var fileName = leaseID + "_lease.pdf"; 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 + "/rentalUploadDownload/secureLeaseDownloadRental?leaseID=" + leaseID + "&type=" + fileType, true); xmlhttp1.responseType = 'arraybuffer'; xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.readyState == 4) { if (this.response.byteLength == 0) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; } else { var blob = new Blob([this.response], { type: "application/pdf" }); var link = document.createElement('a'); link.href = window.URL.createObjectURL(blob); link.download = fileName; link.click(); } } }; xmlhttp1.send(); } //Lease Pdf function listLeasePdf() { 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 + "/renter/listleasedocs", 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 newHtml = ''; // console.log(response); if (response.length > 0) { for (i = 0; i < response.length; i = i + 3) { newHtml += '
'; for (j = i; j < i + 3; j++) { if (j < response.length) { newHtml += '
PDF file Term Type-'; newHtml += response[j].lease["leaseTermType"] + ''; newHtml += '
Lease-'; newHtml += response[j].lease["leaseStartDate"]; newHtml += ' to ' + response[j].lease["leaseEndDate"]; newHtml += '
'; } } newHtml += '

'; } } } // $('.pdfrow').html = newHtml; // console.log($('.pdfrow')); document.getElementById('pdfRow').innerHTML = newHtml; } }; xmlhttp1.send(); } function getLocation() { // console.log("location-other") var locate = window.location.protocol + "//" + window.location.host + "/renter/login.html"; if (location.href === locate) { // console.log("location-login") // localStorage.removeItem("location") } else { localStorage.setItem("location", location.href); // console.log(localStorage.getItem("location")) } } function getLeaseDetails(leaseID, type) { 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 + "/renter/getlease?leaseID=" + leaseID, 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); console.log(res.response); if (res.response == null) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; } if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); document.getElementById("houseNo").value = response.houseNo; document.getElementById("streetAddress").value = response.streetAddress; document.getElementById("zip").value = response.zip; document.getElementById("city").value = response.city; document.getElementById("state").value = response.state; document.getElementById("country").value = response.country; document.getElementById("fullName").value = response.name; document.getElementById("mail").value = response.email; document.getElementById("phone_no").value = response.phoneNo; document.getElementById("rentAmount").value = response.rentAmount; document.getElementById("rentPayDate").value = response.rentPayDate; document.getElementById("principalOwner").value = response.principalOwner; } if (res.rspnsCode === 1000 && type === "RESIDENTIAL") { document.getElementById("owner").value = response.rentTo; document.getElementById("tenant").value = response.tenant; document.getElementById("leaseTermType").value = response.leaseTermType; document.getElementById("leaseStartDate").value = formatDate(response.leaseStartDate); document.getElementById("leaseEndDate").value = formatDate(response.leaseEndDate); if(response.leaseTermType == "Month-By-Month"){ $("#leaseEndDateBox").hide(); } document.getElementById("percentElectricityBill").value = response.percentElectricityBill; document.getElementById("electricityBillAmount").value = response.electricityBillAmount; document.getElementById("percentWaterBill").value = response.percentWaterBill; document.getElementById("waterBillAmount").value = response.waterBillAmount; document.getElementById("percentPhoneBill").value = response.percentPhoneBill; document.getElementById("phoneBillAmount").value = response.phoneBillAmount; document.getElementById("percentOtherBill").value = response.percentOtherBill; document.getElementById("otherBillAmount").value = response.otherBillAmount; if (response.isHouseHoldRuleChecked) { // pageUrl = "leaseaddendums/householdrules.html"; pageName = "household-rules.html"; loadAddendums(response, pageName); } if (response.isDepositsChecked) { // pageUrl = "leaseaddendums/deposits.html"; pageName = "deposits.html"; loadAddendums(response, pageName); } if (response.isPaintDisclosureChecked) { // pageUrl="leaseaddendums/paintdisclosure.html" pageName = "paint-disclosure.html" loadAddendums(response, pageName); } if (response.isConflictResolutionChecked) { // pageUrl="leaseaddendums/conflictresolutions.html"; pageName = "conflict-resolutions.html" loadAddendums(response, pageName); } if (response.isPrivacyChecked == true) { // pageUrl="leaseaddendums/privacy.html"; pageName = "privacy.html"; loadAddendums(response, pageName); // $("#privacy").load("admin/leaseaddendums/privacy.html"); } if (response.isMegansLawChecked) { pageName = "megans-law.html"; loadAddendums(response, pageName); // $("#megans_law").load("leaseaddendums/meganlaw.html"); } if (response.isOtherAgreementChecked) { pageName = "other-agreements.html"; // pageUrl= "leaseaddendums/otheragreements.html"; loadAddendums(response, pageName); } } if(res.rspnsCode === 1000 && type === "PAYING-GUEST") { setInterval(function(){ $('#monthtoMonthStartDate').prop("type", "text"); $('#fixedTermStartDate').prop("type", "text"); $('#fixedTermEndDate').prop("type", "text"); $('#minObligationStartDate').prop("type", "text"); }, 1000); document.getElementById("permanentAddress").value = response.guestPermanentAddress; if(response.leaseTermType!=null && response.leaseTermType!= ""){ document.querySelector(`input[name="leaseTermType"][value="${response.leaseTermType}"`).checked = true; } var leaseTermType = response.leaseTermType; if(leaseTermType == "Month-to-Month"){ setInterval(function(){ document.getElementById("monthtoMonthStartDate").value = formatDate(response.leaseStartDate); },1000) }else if(leaseTermType == "Fixed-Term"){ setInterval(function(){ document.getElementById("fixedTermStartDate").value = formatDate(response.leaseStartDate); document.getElementById("fixedTermEndDate").value = formatDate(response.leaseEndDate); },1000) }else { setInterval(function(){ document.getElementById("minObligationStartDate").value = response.leaseStartDate; },1000) } document.getElementById("monthtoMonthNoticePeriod").value = response.monthToMonthNoticePeriod; document.getElementById("minimumObligationNoticePeriod").value = response.minimumObligationNoticePeriod; document.getElementById("minimumObligationPeriod").value = response.minimumObligationPeriod; document.getElementById("paymentMethod").value = response.paymentMethod; console.log(response.paymentMethod); document.getElementById("fixedTermDuration").value = response.fixedTermDuration; if(response.utilityExpenses!=null && response.utilityExpenses!= ""){ document.querySelector(`input[name="utilityExpenses"][value="${response.utilityExpenses}"`).checked = true; } } if(res.rspnsCode === 1000 && type=="RESIDENTIAL-LEASE-1"){ setInterval(function (){ $('#lastPaidDate').prop("type", "text"); $('#securityDeposit').prop("type", "text"); $('#refundPaidDate').prop("type", "text"); $('#leaseStartDate').prop("type", "text"); $('#leaseEndDate').prop("type", "text"); document.getElementById("leaseStartDate").value = formatDate(response.leaseStartDate); }, 2000) document.getElementById("rentTo").value = response.rentTo; document.getElementById("tenant").value = response.tenant; document.getElementById("leaseTermType").value = response.leaseTermType; document.getElementById("leaseEndDate").value = formatDate(response.leaseEndDate); if (response.leaseTermType == "Month-By-Month") { $("#leaseEndDateBox").hide(); } document.getElementById("percentElectricityBill").value = response.percentElectricityBill; document.getElementById("electricityBillAmount").value = response.electricityBillAmount; document.getElementById("percentWaterBill").value = response.percentWaterBill; document.getElementById("waterBillAmount").value = response.waterBillAmount; document.getElementById("percentPhoneBill").value = response.percentPhoneBill; document.getElementById("phoneBillAmount").value = response.phoneBillAmount; document.getElementById("percentOtherBill").value = response.percentOtherBill; document.getElementById("otherBillAmount").value = response.otherBillAmount; document.getElementById("cleaning").value = response.cleaning; document.getElementById("kitchenUse").value = response.kitchenUse; document.getElementById("overnightGuests").value = response.overnightGuests; document.getElementById("useOfAppliances").value = response.useOfAppliances; document.getElementById("smoking").value = response.smoking; document.getElementById("useOfCommonAreas").value = response.useOfCommonAreas; document.getElementById("alcoholUse").value = response.alcoholUse; document.getElementById("telephoneUse").value = response.telephoneUse; document.getElementById("studyingHours").value = response.studyingHours; document.getElementById("personalItemsShared").value = response.personalItemsShared; document.getElementById("music").value = response.music; document.getElementById("bedroomAssignment").value = response.bedroomAssignment; document.getElementById("pets").value = response.pets; document.getElementById("other").value = response.other; setInterval(function () { document.getElementById("lastPaidDate").value = response.lastPaidDate; document.getElementById("securityDeposit").value = response.securityDeposit; document.getElementById("refundPaidDate").value = response.refundPaidDate; }, 2000); document.getElementById("lastPaidAmount").value = response.lastPaidAmount; document.getElementById("securityAmount").value = response.securityAmount; document.getElementById("refundDeposit").value = response.refundDeposit; document.getElementById("refundDuration").value = response.refundDuration; document.getElementById("leadBasedInput1").value = response.acknowledgedTenant1; document.getElementById("leadBasedInput2").value = response.acknowledgedTenant2; if (response.conflictResolution != null && response.conflictResolution != "") { document.querySelector(`input[name="conflicResolution"][value="${response.conflictResolution}"`).checked = true; } document.getElementById("other_programs1").value = response.otherAgreements[0]; document.getElementById("other_programs2").value = response.otherAgreements[1]; document.getElementById("other_programs3").value = response.otherAgreements[2]; document.getElementById("other_programs4").value = response.otherAgreements[3]; document.getElementById("other_programs5").value = response.otherAgreements[4]; document.getElementById("other_programs6").value = response.otherAgreements[5]; document.getElementById("other_programs7").value = response.otherAgreements[6]; document.getElementById("other_programs8").value = response.otherAgreements[7]; document.getElementById("other_programs9").value = response.otherAgreements[8]; document.getElementById("other_programs10").value = response.otherAgreements[9]; document.getElementById("other_programs11").value = response.optionSelected; if (response.copy != null && response.copy != "") { document.querySelector(`input[name="other_radio"][value="${response.copy}"`).checked = true; } } if (res.rspnsCode === 1000 && type == "RESIDENTIAL-LEASE-May-15") { document.getElementById("percentElectricityBill").value = response.percentElectricityBill; document.getElementById("electricityBillAmount").value = response.electricityBillAmount; document.getElementById("percentWaterBill").value = response.percentWaterBill; document.getElementById("waterBillAmount").value = response.waterBillAmount; document.getElementById("percentPhoneBill").value = response.percentPhoneBill; document.getElementById("phoneBillAmount").value = response.phoneBillAmount; document.getElementById("percentOtherBill").value = response.percentOtherBill; document.getElementById("otherBillAmount").value = response.otherBillAmount; document.getElementById("leaseStartDate").value = response.leaseStartDate; document.getElementById("leaseTermType").value = response.leaseTermType; document.getElementById("leaseEndDate").value = response.leaseEndDate; document.getElementById("other_programs1").value = response.otherAgreements[0]; document.getElementById("other_programs2").value = response.otherAgreements[1]; document.getElementById("other_programs3").value = response.otherAgreements[2]; document.getElementById("other_programs4").value = response.otherAgreements[3]; document.getElementById("other_programs5").value = response.otherAgreements[4]; document.getElementById("securityAmount").value = response.securityAmount; // document.getElementById("securityDeposit").value = formatDateBack(response.securityDeposit); // document.getElementById("other_programs6").value = response.otherAgreements[5]; if (response.leaseTermType == "Month-By-Month") { $("#leaseEndDateBox").css("display", "none"); } } } // else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { // window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" // } }; xmlhttp1.send(); } // this is for getting html template from backend -- for lease form function loadAddendums(response, pageName) { 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 + "/rentalunsecured/returnhtmltemplate?pageName=" + pageName, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.status == 200 && xmlhttp1.responseText != null && xmlhttp1.responseText != "" && xmlhttp1.readyState == 4) { var res = JSON.parse(this.responseText); // console.log(res.response); if (pageName == "household-rules.html") { document.getElementById("household_rules").innerHTML = res.response; document.getElementById("cleaning").value = response.cleaning; document.getElementById("kitchenUse").value = response.kitchenUse; document.getElementById("overnightGuests").value = response.overnightGuests; document.getElementById("useOfAppliances").value = response.useOfAppliances; document.getElementById("smoking").value = response.smoking; document.getElementById("useOfCommonAreas").value = response.useOfCommonAreas; document.getElementById("alcoholUse").value = response.alcoholUse; document.getElementById("telephoneUse").value = response.telephoneUse; document.getElementById("studyingHours").value = response.studyingHours; document.getElementById("personalItemsShared").value = response.personalItemsShared; document.getElementById("music").value = response.music; document.getElementById("bedroomAssignment").value = response.bedroomAssignment; document.getElementById("pets").value = response.pets; document.getElementById("other").value = response.other; } if (pageName == "deposits.html") { setInterval(function () { document.getElementById("lastPaidDate").value = response.lastPaidDate; document.getElementById("securityDeposit").value = response.securityDeposit; document.getElementById("refundPaidDate").value = response.refundPaidDate; }, 2000); document.getElementById("deposits").innerHTML = res.response; document.getElementById("lastPaidAmount").value = response.lastPaidAmount; document.getElementById("securityAmount").value = response.securityAmount; document.getElementById("refundDeposit").value = response.refundDeposit; document.getElementById("refundDuration").value = response.refundDuration; } if (pageName == "paint-disclosure.html") { document.getElementById("paint_disclosure").innerHTML = res.response; document.getElementById("leadBasedInput1").value = response.acknowledgedTenant1; document.getElementById("leadBasedInput2").value = response.acknowledgedTenant2; // document.getElementById("agreementYear").value = response.agreementYear; } if (pageName == "conflict-resolutions.html") { document.getElementById("conflict_resolutions").innerHTML = res.response; if(response.conflictResolution!=null && response.conflictResolution!=""){ document.querySelector(`input[name="conflicResolution"][value="${response.conflictResolution}"`).checked = true; } } if (pageName == "other-agreements.html") { document.getElementById("other_agreements").innerHTML = res.response; document.getElementById("other_programs1").value = response.otherAgreements[0]; document.getElementById("other_programs2").value = response.otherAgreements[1]; document.getElementById("other_programs3").value = response.otherAgreements[2]; document.getElementById("other_programs4").value = response.otherAgreements[3]; document.getElementById("other_programs5").value = response.otherAgreements[4]; document.getElementById("other_programs6").value = response.otherAgreements[5]; document.getElementById("other_programs7").value = response.otherAgreements[6]; document.getElementById("other_programs8").value = response.otherAgreements[7]; document.getElementById("other_programs9").value = response.otherAgreements[8]; document.getElementById("other_programs10").value = response.otherAgreements[9]; document.getElementById("other_programs11").value = response.optionSelected; if(response.copy!=null && response.copy!= ""){ document.querySelector(`input[name="other_radio"][value="${response.copy}"`).checked = true; } } if (pageName == "privacy.html") { document.getElementById("privacy").innerHTML = res.response; } if (pageName == "megans-law.html") { document.getElementById("megans_law").innerHTML = res.response; } } } xmlhttp1.send(); } // this is ajax on submit button in leaseform.html function submitLease(leaseID) { var tenantSign = $("#tenant_sign").val(); var ip = $("#ipaddress").val(); if (tenantSign == null || tenantSign == "") { $("#sign_error").html("This field is required"); 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 + "/renter/submitlease?leaseID=" + leaseID + "&sign=" + tenantSign + "&ip=" + ip, 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 response = res.response; window.location.href = window.location.protocol + "//" + window.location.host + "/submitted.html"; } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } }; xmlhttp1.send(); } // Set Renter profile information on page function getuserprofiledetails() { var xmlhttp1; var firstName = document.getElementById("userFirstName"); var lastName = document.getElementById("userLastName"); var Email = document.getElementById("userEmail"); var Phone = document.getElementById("userPhone"); 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 + "/renter/getuserprofiledetails", 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']); firstName.innerHTML = response['firstName']; lastName.innerHTML = response['lastName']; Email.innerHTML = response['emailID']; Phone.innerHTML = response['phoneNumber']; document.getElementById("FirstName").value = response.firstName; document.getElementById("LastName").value = response.lastName; document.getElementById("Email").value = response.emailID; document.getElementById("Phone1").value = response.phoneNumber } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } else if (this.status == 500) { var res = JSON.parse(this.responseText); if (res.response === "403 FORBIDDEN") { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } } }; xmlhttp1.send(); } // Set Property details on page function getPropertyDetails() { var xmlhttp1; var properties = document.getElementById("properties"); 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 + "/renter/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); var temphtml = ""; if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); // console.log(response); for (var i = 0; i < response.length; i++) { if(!response[i].isPropertyRented){ // console.log("xzjcvk"); temphtml += `

${response[i].propertyInfo.type==null?"--":response[i].propertyInfo.type}

${response[i].propertyInfo.rentalRate==null?"--":response[i].propertyInfo.rentalRate}


${response[i].propertyInfo.houseNo +", "+ response[i].propertyInfo.streetAddress + ", " + response[i].propertyInfo.city + ", " + response[i].propertyInfo.state + "- " + response[i].propertyInfo.zip + ", " + response[i].propertyInfo.country}

${response[i].propertyInfo.squareFeet==null?"--":response[i].propertyInfo.squareFeet} Sq Ft

${response[i].propertyInfo.furnishing==null?"--":response[i].propertyInfo.furnishing }

${response[i].propertyInfo.bedrooms==null?"--":response[i].propertyInfo.bedrooms } Bedrooms

${response[i].propertyInfo.carParking==null?"--":response[i].propertyInfo.carParking } ${response[i].propertyInfo.carParkingType==null?"--":response[i].propertyInfo.carParkingType }

${response[i].propertyInfo.bathrooms==null?"--":response[i].propertyInfo.bathrooms } Bathroom

$${response[i].propertyInfo.rentAmount==null?"--":response[i].propertyInfo.rentAmount }

`; } } properties.innerHTML = temphtml; } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } else if (this.status == 500) { var res = JSON.parse(this.responseText); if (res.response === "403 FORBIDDEN") { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } } }; xmlhttp1.send(); } //Set Property Owner details on page function getPropertyOwnerInfo() { var xmlhttp1; var fullName = document.getElementById("adminFullName"); var Email = document.getElementById("adminEmail"); var Phone = document.getElementById("adminNumber"); 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 + "/renter/getpropertyownerinfo", 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']); // console.log(response); fullName.innerHTML = response.firstName + " " + response.lastName; Email.innerHTML = response.emailID; Phone.innerHTML = response.phoneNumber; } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } else if (this.status == 500) { var res = JSON.parse(this.responseText); if (res.response === "403 FORBIDDEN") { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } } }; xmlhttp1.send(); } //Format Date in Month day, year function formatDate(nonFormatDate) { // checking for null condition -- error undefinded if(nonFormatDate==null || nonFormatDate==""){ return nonFormatDate; }else{ var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var date = nonFormatDate.split("-"); return (months[Number(date[1]) - 1] + " " + date[2] + ", " + date[0]); } } function formatDateForTables(nonFormatDate) { // checking for null condition -- error undefinded if(nonFormatDate==null || nonFormatDate==""){ return nonFormatDate; }else{ var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var date = nonFormatDate.split("-"); var day = date[2].split(" "); return (months[Number(date[1]) - 1] + " " + day[0] + ", " + date[0] ); } } // this ajax is for edit profile for renter function editProfileRenter() { var xmlhttp1; var FirstName = document.getElementById("FirstName").value; var LastName = document.getElementById("LastName").value; var Email = document.getElementById("Email").value; var Phone1 = document.getElementById("Phone1").value; document.getElementById('FirstName_error').innerHTML = ""; document.getElementById('LastName_error').innerHTML = ""; document.getElementById('Email_error').innerHTML = ""; document.getElementById('phone1_error').innerHTML = ""; if (FirstName == null || FirstName == "") { document.getElementById('FirstName_error').innerHTML = "This field is mandatory" document.getElementById('FirstName').focus(); return false; } if (LastName == null || LastName == "") { document.getElementById('LastName_error').innerHTML = "This field is mandatory" document.getElementById('LastName').focus(); return false; } if (Email == null || Email == "") { document.getElementById('Email_error').innerHTML = "This field is mandatory" document.getElementById('Email').focus(); return false; } // if (Phone1 == null || Phone1 == "") { // document.getElementById('phone1_error').innerHTML = "This field is mandatory" // document.getElementById('Phone1').focus(); // return false; // } 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 + "/renter/editrenterprofile", 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); var response = res.response; var s = res.rspnsMsg; 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 }, {}) if (response == "EDIT PROFILE SUCCESSFULLY") { $('#basicModal').modal("show"); $("#modal_message").html("

Your Account has been updated.

"); $("#modal_title").html("SUCCESS!!"); } else { $('#basicModal').modal("show"); $("#modal_message").html("

Something went wrong.

"); $("#modal_title").html("OOPs!!"); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/pages-error-404.html" } else if (this.status == 500 && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/pages-error-404.html" } }; xmlhttp1.send(JSON.stringify({ "emailID": Email, "firstName": FirstName, "lastName": LastName, "phoneNumber": Phone1, "roles": [] })); } // this ajax is for change password from renter dashboard function changeRenterPassword() { var currentPassword = document.getElementById("currentPassword").value; var newPassword = document.getElementById("newPassword").value; var confirmPassword = document.getElementById("renewPassword").value; document.getElementById('currentPassword_error').innerHTML = ""; document.getElementById('newPassword_error').innerHTML = ""; document.getElementById('renewPassword_error').innerHTML = ""; if (currentPassword == null || currentPassword == "") { document.getElementById('currentPassword_error').innerHTML = "This field is mandatory" document.getElementById('currentPassword').focus(); return false; } if (newPassword == null || newPassword == "") { document.getElementById('newPassword_error').innerHTML = "This field is mandatory" document.getElementById('newPassword').focus(); return false; } if (confirmPassword == null || confirmPassword == "") { document.getElementById('renewPassword_error').innerHTML = "This field is mandatory" document.getElementById('renewPassword').focus(); return false; } if (newPassword != confirmPassword) { alert("Confirm Password not Same as New Password"); 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 + "/renter/changerenterpassword?currentPassword=" + currentPassword + "&newPassword=" + newPassword + "&confirmPassword=" + confirmPassword, 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); var response = res.response;; // console.log(response); if (response == "PASSWORD CHANGED SUCCESSFULLY") { $('#basicModal').modal("show"); $("#modal_message").html("

Your password has been updated.

"); $("#modal_title").html("SUCCESS!!"); } else { $('#basicModal').modal("show"); $("#modal_message").html("

Something went wrong.

"); $("#modal_title").html("OOPs!!"); } //console.log(response); } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } else if (this.status == 500 && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/pages-error-404.html" } }; xmlhttp1.send(); } function getTransactionsList(pageNumber, searchVal, fromDate, toDate) { 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; } } } if ((searchVal == null || searchVal == "") && (fromDate == null || fromDate == "") && (toDate == null || toDate == "")) { xmlhttp1.open("GET", baseurl + "/renter/listtransactions?pageNumber=" + pageNumber + "&pageSize=" + 5, 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); if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); // console.log(response); tableData = ''; if (response.length > 0) { for (i = 0; i < response.length; i++) { var sign; (response[i].transactionType == "Debit" || response[i].transactionType== "Charge")? (sign="-"): (sign="+") tableData += ''; tableData += '' + formatDateForTables(response[i].createTimeStamp) + ''; tableData += '' + formatDate(response[i].payDate) + ''; tableData += '' + response[i].name + ''; tableData += '' + response[i].account + ''; tableData += '' + response[i].transactionType + ''; tableData += '' + sign + response[i].amount + ''; tableData += '' + response[i].address + ''; tableData += '' + response[i].details + ''; } } else { tableData = "No Transactions for now" } } document.getElementById('transaction_table').innerHTML = tableData; } }; xmlhttp1.send(); } else if (searchVal != null) { xmlhttp1.open("GET", baseurl + "/renter/listtransactions?pageNumber=" + pageNumber + "&pageSize=" + 5 + "&keyword=" + searchVal, 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); if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); // console.log(response); tableData = ''; if (response.length > 0) { for (i = 0; i < response.length; i++) { var sign; (response[i].transactionType == "Debit" || response[i].transactionType== "Charge")? (sign="-"): (sign="+") tableData += ''; tableData += '' + formatDateForTables(response[i].createTimeStamp) + ''; tableData += '' + formatDate(response[i].payDate) + ''; tableData += '' + response[i].name + ''; tableData += '' + response[i].account + ''; tableData += '' + response[i].transactionType + ''; tableData += '' + sign + response[i].amount + ''; tableData += '' + response[i].address + ''; tableData += '' + response[i].details + ''; } } } document.getElementById('transaction_table').innerHTML = tableData; } }; xmlhttp1.send(); } else { xmlhttp1.open("GET", baseurl + "/renter/listtransactions?pageNumber=" + pageNumber + "&pageSize=" + 5 + "&fromDate=" + fromDate + "&toDate=" + toDate, 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); if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); // console.log(response); tableData = ''; if (response.length > 0) { for (i = 0; i < response.length; i++) { var sign; (response[i].transactionType == "Debit" || response[i].transactionType== "Charge")? (sign="-"): (sign="+") tableData += ''; tableData += '' + formatDateForTables(response[i].createTimeStamp) + ''; tableData += '' + formatDate(response[i].payDate) + ''; tableData += '' + response[i].name + ''; tableData += '' + response[i].account + ''; tableData += '' + response[i].transactionType + ''; tableData += '' + sign + response[i].amount + ''; tableData += '' + response[i].address + ''; tableData += '' + response[i].details + ''; } } } document.getElementById('transaction_table').innerHTML = tableData; } }; xmlhttp1.send(); } } function listTransaction() { return new Promise(function (resolve, reject) { 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 + "/renter/listtransactions", 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); // console.log(res) // var dynamicCard = document.querySelector('.fine-table'); if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); resolve(response.length) } } }; xmlhttp1.send(); }) } function unsubmittedLease() { 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 + "/renter/listofintiallease" ,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"]); // console.log(response); tableData = ""; if (response.length > 0) { for (i = 0; i < response.length; i++) { var leaseType = response[i].leaseType; var link; // console.log(leaseType); if(leaseType == "RESIDENTIAL"){ link = "/renter/leaseform.html?leaseID=" + response[i].leaseID; } else link = "/renter/lease-generic-form.html?leaseID=" + response[i].leaseID + "&pageName=" + leaseType; var propertyAddress = response[i].lease["houseNo"] + ", " + response[i].lease["streetAddress"] + ", " + response[i].lease["city"] + ", " + response[i].lease["zip"] + ", " + response[i].lease["state"]; tableData += ""; tableData += '' + (i + 1) + ""; tableData += '' + propertyAddress + ""; tableData += '' + "Unsubmitted" + ""; tableData += '' + `
`; tableData += '' + getDateInClientFormat(response[i].createTimeStamp) + ""; tableData += '' + ((response[i].lease.leaseExpiryDate==null)?"Not Mentioned":formatDate(response[i].lease.leaseExpiryDate)) + ""; } } else { tableData = "No Pending Leases for now"; } } document.getElementById("unsubmittedLeaseList").innerHTML = tableData; } }; xmlhttp1.send(); } function resetPassword(tokenId, userId) { var password = document.getElementById("password").value; var confirmPassword = document.getElementById("confirmPassword").value; if (password == null || password == "") { document.getElementById('password_error').innerHTML = "This field is mandatory" document.getElementById('password').focus(); return false; } if (confirmPassword == null || confirmPassword == "") { document.getElementById('confirmpass_error').innerHTML = "This field is mandatory" document.getElementById('confirmPassword').focus(); return false; } if(password!= confirmPassword){ document.getElementById('confirmpass_error').innerHTML = "Confirm Password does not matches password" document.getElementById('confirmPassword').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; } } } xmlhttp1.open("POST", baseurl + "/rentalunsecured/resetpassword?tokenID="+ tokenId + "&user_id=" + userId + "&clientId=" + renterClientId, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = res.response;; // console.log(response); if(response == "PASSWORD UPDATED SUCCESSFULLY"){ $('#error_msg').hide(); $('#success_message').show() var submitBtn = $("#login_form_submit"); submitBtn.prop('disabled', true); } else{ $('#success_message').hide() $('#error_msg').show(); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } else if(this.status == 500 && this.readyState == 4){ window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } }; xmlhttp1.send(JSON.stringify({ "emailID": userId, "password": password, "roles": [] })); } function sendResetMail(clientId) { var webBaseURL = window.location.protocol + "//" + window.location.host; var email = document.getElementById("username").value; document.getElementById('username').innerHTML = ""; if (email == null || email == "") { document.getElementById('username_error').innerHTML = "This field is mandatory" document.getElementById('username').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; } } } xmlhttp1.open("POST", baseurl + "/rentalunsecured/sendresetpassmail?emailID="+ email + "&webBaseURL=" + webBaseURL + "&clientId=" + clientId, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = res.response;; var s = res.rspnsMsg; // console.log(s); var s = s.replace(/[{}]/g, ""); const obj = Object.fromEntries([s.split("=")]) // console.log(response); if (obj.error == "Invalid Mail Id!!") { var error = document.getElementById("username_error"); error.innerHTML = obj.error; } if(response == "ERROR SENDING RESET MAIL"){ $('#success_message').hide() $('#error_msg').show() $('#error_msg').html(response); }else if(response == "PASSWORD RESET EMAIL SEND TO USER"){ $('#error_msg').hide(); $('#success_message').show() }else if(response == "Please enter email id for which account has been created"){ $('#success_message').hide() $('#error_msg').show() $('#error_msg').html(response); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } else if(this.status == 500 && this.readyState == 4){ window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } }; xmlhttp1.send(); } function getTransactionDetailByID(){ var leaseID = $('#propertyDropdown').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; } } } var path = "/renter/gettransactionbyid?leaseID=" + leaseID; xmlhttp.open("GET", baseurl + path, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { tableData = ''; var response = JSON.parse(res['response']); // console.log(response); if (response.length > 0) { for (i = 0; i < response.length; i++) { var amountExp; (response[i].transactionType == "Dues" ) ? (amountExp = `

(${Number(response[i].amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')})

`) : (amountExp = `${Number(response[i].amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}`) tableData += ''; tableData += '' + ( i + 1) + ''; tableData += '' + formatDate(response[i].payDate) + ''; tableData += '' + ((response[i].details==''||response[i].details==null)? '-' : response[i].details) + ''; tableData += '' + ((response[i].account=='' ||response[i].account==null)?'-' : (response[i].account)) + ''; tableData += '' + response[i].transactionType + ''; tableData += '' + response[i].transactionSubType + ''; tableData += '' + amountExp + ''; } }else { tableData = "No transactions for now" } } document.getElementById('transaction_table').innerHTML = tableData; } } }; xmlhttp.send(); } function getTransactionSummary(leaseID){ 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; } } } var path = "/renter/gettransactionsummary?leaseID=" + leaseID; xmlhttp.open("GET", baseurl + path, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = function () { if (this.readyState === 4) { 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']); // console.log(response); var dynamicCard = document.querySelector('.security_deposit'); let securityDepositCharge=(response.totalSecurityDepositCharge); let securityDepositPayment=(response.totalSecurityDepositPayment); let sdBalance; if(Number( securityDepositPayment)< Number(securityDepositCharge)){ sdBalance = `

${securityDepositPayment}/${securityDepositCharge}

`; }else { sdBalance = `

${securityDepositPayment}/${securityDepositCharge}

`; } let finalSettlement; (response.noticeSent)? finalSettlement = "$" + response.finalSettlementAmount : finalSettlement = "-" var netSum = String(response.tenantBalance); let netExp; (netSum.charAt(0) == '-') ? (netExp = '

' + netSum.substring(0, 1) + '$' + netSum.substring(1) + '

') : (netExp = '

'+'$' + netSum + '

'); let securityDuesExp; let securityDepositDues = String(response.tenantSecurityDeposit); (securityDepositDues.charAt(0) == "-") ? securityDuesExp = securityDepositDues.substring(1) : securityDuesExp = securityDepositDues dynamicCard.innerHTML = `
Credit Offers-PM:

$${response.pmCreditOffer}

Credit Offers-Landlord:

$${response.landlordCreditOffer}

Balance:
${netExp}
Security Deposit Details: (Security Deposit/Dues)
$${response.totalSecurityDeposit}/$${securityDuesExp}
Final Settlement Details:

${finalSettlement}

`; } } } }; xmlhttp.send(); } function loadAllProperties() { 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("GET", baseurl + "/renter/listleases", false); 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 != "") { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); // console.log(response); var dropdown = ''; for (var i = 0; i < response.length; i++) { if(response[i].isLeaseOngoing) { dropdown += ''; }else if(response[i].isLeaseExpired) { dropdown += ''; }else{ dropdown += ''; } } $("#propertyDropdown").html(dropdown); } } }; xmlhttp.send(); } function getDateInClientFormat(dValue) { if (dValue.length > 10) { var date = new Date(dValue + " UTC").toString().replace("/", "-");; var finalDate = date.substring(4, 10) + ", " + date.substring(11, 15) + " " + date.substring(16, 21); // console.log(date) return finalDate; } else { if (dValue == null || dValue == "") { return dValue; } else { var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var date = dValue.split("-"); // console.log(date) return (months[Number(date[1]) - 1] + " " + date[2] + ", " + date[0]); } } } function getLatestLeaseID() { return new Promise(function(resolve, reject){ 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("GET", baseurl + "/renter/getlatestleaseid", false); 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 != "") { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); console.log(response); $(`#propertyDropdown option[value = '${response}'] `).prop('selected', true); resolve(response); } } }; xmlhttp.send(); }) } function fetchRenterFaq() { const xhttp = new XMLHttpRequest(); xhttp.onload = function () { let s = this.responseText; let Answer = ""; let Question = ""; let mode = "Q"; var faqsbody = document.getElementById("faq-group-2"); let faqhtml = ""; let faqid=0; for (i = 0; i < s.length; i++) { if (s.charAt(i) == "#") { // document.getElementById("Answer").innerHTML='
'+Answer; faqhtml += `
${Answer}
`; Question = ""; mode = "Q"; } else if (s.charAt(i) == ">") { faqhtml += `

`; Answer = ""; mode = "A"; } else { if (mode == "Q") { Question += s.charAt(i); } else { Answer += s.charAt(i); } } } faqhtml += `
${Answer}
`; faqsbody.innerHTML = faqhtml; }; xhttp.open("GET", "faq.md", true); xhttp.send(); } function getLeaseForm(pageName){ 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("GET", baseurl + "/renter/getleaseform?pageName=" + pageName , false); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = function () { // console.log("Hello") if (xmlhttp.status == 200 && xmlhttp.responseText != null && xmlhttp.responseText != "" && xmlhttp.readyState == 4) { var res = JSON.parse(this.responseText); document.getElementById("lease-form").innerHTML = res.response; } } xmlhttp.send(); } function getSubmittedLeases(){ 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 + "/renter/listsubmittedleases" ,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"]); // console.log(response); tableData = ""; if (response.length > 0) { for (i = 0; i < response.length; i++) { var leaseType = response[i].leaseType; var link; // console.log(leaseType); if(leaseType == "RESIDENTIAL"){ link = "/renter/leaseform.html?leaseID=" + response[i].leaseID + "&page=view-lease"; } else link = "/renter/lease-generic-form.html?leaseID=" + response[i].leaseID + "&pageName=" + leaseType + "&page=view-lease"; var propertyAddress = response[i].lease["houseNo"] + ", " + response[i].lease["streetAddress"] + ", " + response[i].lease["city"] + ", " + response[i].lease["zip"] + ", " + response[i].lease["state"]; tableData += ""; tableData += '' + (i + 1) + ""; tableData += '' + propertyAddress + ""; tableData += '' + `
`; } } else { tableData = "No Submitted Leases for now"; } } document.getElementById("unsubmittedLeaseList").innerHTML = tableData; } }; xmlhttp1.send(); } function getSubmittedLeaseDetails(leaseID, type) { 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 + "/renter/getsubmittedleasedetails?leaseID=" + leaseID, 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); // console.log(res); if (res.response == null) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; } if (res.rspnsCode === 1000) { var response = JSON.parse(res['response']); document.getElementById("houseNo").value = response.houseNo; document.getElementById("streetAddress").value = response.streetAddress; document.getElementById("zip").value = response.zip; document.getElementById("city").value = response.city; document.getElementById("state").value = response.state; document.getElementById("country").value = response.country; document.getElementById("fullName").value = response.name; document.getElementById("mail").value = response.email; document.getElementById("phone_no").value = response.phoneNo; document.getElementById("rentAmount").value = response.rentAmount; document.getElementById("rentPayDate").value = response.rentPayDate; document.getElementById("principalOwner").value = response.principalOwner; } if (res.rspnsCode === 1000 && type === "RESIDENTIAL") { document.getElementById("owner").value = response.rentTo; document.getElementById("tenant").value = response.tenant; document.getElementById("leaseTermType").value = response.leaseTermType; document.getElementById("leaseStartDate").value = formatDate(response.leaseStartDate); document.getElementById("leaseEndDate").value = formatDate(response.leaseEndDate); if(response.leaseTermType == "Month-By-Month"){ $("#leaseEndDateBox").hide(); } document.getElementById("percentElectricityBill").value = response.percentElectricityBill; document.getElementById("electricityBillAmount").value = response.electricityBillAmount; document.getElementById("percentWaterBill").value = response.percentWaterBill; document.getElementById("waterBillAmount").value = response.waterBillAmount; document.getElementById("percentPhoneBill").value = response.percentPhoneBill; document.getElementById("phoneBillAmount").value = response.phoneBillAmount; document.getElementById("percentOtherBill").value = response.percentOtherBill; document.getElementById("otherBillAmount").value = response.otherBillAmount; if (response.isHouseHoldRuleChecked) { // pageUrl = "leaseaddendums/householdrules.html"; pageName = "household-rules.html"; loadAddendums(response, pageName); } if (response.isDepositsChecked) { // pageUrl = "leaseaddendums/deposits.html"; pageName = "deposits.html"; loadAddendums(response, pageName); } if (response.isPaintDisclosureChecked) { // pageUrl="leaseaddendums/paintdisclosure.html" pageName = "paint-disclosure.html" loadAddendums(response, pageName); } if (response.isConflictResolutionChecked) { // pageUrl="leaseaddendums/conflictresolutions.html"; pageName = "conflict-resolutions.html" loadAddendums(response, pageName); } if (response.isPrivacyChecked == true) { // pageUrl="leaseaddendums/privacy.html"; pageName = "privacy.html"; loadAddendums(response, pageName); // $("#privacy").load("admin/leaseaddendums/privacy.html"); } if (response.isMegansLawChecked) { pageName = "megans-law.html"; loadAddendums(response, pageName); // $("#megans_law").load("leaseaddendums/meganlaw.html"); } if (response.isOtherAgreementChecked) { pageName = "other-agreements.html"; // pageUrl= "leaseaddendums/otheragreements.html"; loadAddendums(response, pageName); } } if(res.rspnsCode === 1000 && type === "PAYING-GUEST") { setInterval(function(){ $('#monthtoMonthStartDate').prop("type", "text"); $('#fixedTermStartDate').prop("type", "text"); $('#fixedTermEndDate').prop("type", "text"); $('#minObligationStartDate').prop("type", "text"); }, 1000); document.getElementById("permanentAddress").value = response.guestPermanentAddress; if(response.leaseTermType!=null && response.leaseTermType!= ""){ document.querySelector(`input[name="leaseTermType"][value="${response.leaseTermType}"`).checked = true; } var leaseTermType = response.leaseTermType; if(leaseTermType == "Month-to-Month"){ setInterval(function(){ document.getElementById("monthtoMonthStartDate").value = formatDate(response.leaseStartDate); },1000) }else if(leaseTermType == "Fixed-Term"){ setInterval(function(){ document.getElementById("fixedTermStartDate").value = formatDate(response.leaseStartDate); document.getElementById("fixedTermEndDate").value = formatDate(response.leaseEndDate); },1000) }else { setInterval(function(){ document.getElementById("minObligationStartDate").value = response.leaseStartDate; },1000) } document.getElementById("monthtoMonthNoticePeriod").value = response.monthToMonthNoticePeriod; document.getElementById("minimumObligationNoticePeriod").value = response.minimumObligationNoticePeriod; document.getElementById("minimumObligationPeriod").value = response.minimumObligationPeriod; document.getElementById("paymentMethod").value = response.paymentMethod; console.log(response.paymentMethod); document.getElementById("fixedTermDuration").value = response.fixedTermDuration; if(response.utilityExpenses!=null && response.utilityExpenses!= ""){ document.querySelector(`input[name="utilityExpenses"][value="${response.utilityExpenses}"`).checked = true; } } } // else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { // window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" // } }; xmlhttp1.send(); } function getVehicleInfo() { 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/getTenantVehicle", 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.readyState == 4) { var response = JSON.parse(this.responseText); var res = JSON.parse(response['response']); // console.log(response.response); var vehicles = res.vehicle; // console.log(vehicles); var showVehicleContainer = document.getElementById('show-vehicle-container'); var editVehicleContainer = document.getElementById('edit-vehicle-container'); for (var i = 0; i < vehicles.length; i++) { var vehicle = vehicles[i]; var show_vehicle_html = `
Vehicle Registration Number:
${vehicle.registration_number}
Vehicle Type:
${vehicle.vehicle_type}
Vehicle Model:
${vehicle.model}
Vehicle Color:
${vehicle.vehicle_color}
`; var edit_vehicle_html = `
Vehicle Registration Number
Vehicle Type
Vehicle Model
Vehicle Color
`; showVehicleContainer.innerHTML += show_vehicle_html; editVehicleContainer.innerHTML += edit_vehicle_html; } } }; xmlhttp1.send(); } function addStyleOnSideMenu(navLinkId) { var docElement = navLinkId + " " + "a" setTimeout(function () { $(docElement).removeClass("collapsed"); }, 100) var ulElement = navLinkId + " ul" setTimeout(function () { $(ulElement).addClass("show"); }, 100) var ind = location.pathname.lastIndexOf('/'); var href = location.pathname.slice(ind + 1); // console.log(href); setTimeout(function () { $("#sidebar").find('a[href="' + href + '"]').addClass("active") }, 100) } function getAddendum() { 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 + "/renter/getaddedums", 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); let isAddendumAvailable = false; if (res.rspnsCode === 1000) { var response = JSON.parse(res["response"]); // console.log(response); var tableData = ""; if (response.length > 0) { for (var i = 0; i < response.length; i++) { var addendumData = JSON.parse(response[i].addendumData); // console.log(addendumData) for (var j = 0; j < addendumData.length; j++) { var addendum = addendumData[j]; // console.log(addendum.tenantSignature); if(addendum.tenantSignature==null && addendum.deleteFlag!='1' && addendum.status=='INIT'){ isAddendumAvailable = true; var link = "/renter/addendum-detail.html?addendumID=" + addendum.addendumID +"&leaseID=" + addendum.leaseId; tableData += ""; tableData += `${addendum.propertyAddress}`; tableData += `${addendum.type}`; tableData += `${getDateInClientFormat(addendum.dateOfAddendum)}`; tableData += `${getDateInClientFormat(addendum.startDate)}`; tableData += `${getDateInClientFormat(addendum.endDate)}`; tableData += '' + `
`; tableData += ""; } } } } if(!isAddendumAvailable){ tableData = "No Pending Addendums for now"; } document.getElementById("addendumsList").innerHTML = tableData; } } }; xmlhttp1.send(); } function getAddendumDetails(addendumID, leaseID){ 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 + "/renter/getaddendumdetail?addendumID=" + addendumID + "&leaseID=" + leaseID, 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); console.log(res) if (res.rspnsCode === 1000) { var response = JSON.parse(res["response"]); console.log(response) document.getElementById('type').value = response.type; document.getElementById('startDate').value = response.startDate; document.getElementById('endDate').value = response.endDate; document.getElementById('dateOfAddendum').value = response.dateOfAddendum; document.getElementById('addendum_1').value = response.addendums[0]; document.getElementById('addendum_2').value = response.addendums[1]; document.getElementById('addendum_3').value = response.addendums[2]; document.getElementById('addendum_4').value = response.addendums[3]; document.getElementById('addendum_5').value = response.addendums[4]; document.getElementById('addendum_6').value = response.addendums[5]; document.getElementById('addendum_7').value = response.addendums[6]; document.getElementById('addendum_8').value = response.addendums[7]; document.getElementById('addendum_9').value = response.addendums[7]; document.getElementById('addendum_10').value = response.addendums[9]; } } }; xmlhttp1.send(); } function signAddendum(leaseID, addendumID) { var tenantSign = $("#tenant_sign").val(); var ip = $("#ipaddress").val(); // alert(ip); if (tenantSign == null || tenantSign == "") { $("#sign_error").html("This field is required"); 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 + "/renter/singaddendum?leaseID=" + leaseID + "&addendumID=" + addendumID + "&tenantSignature=" + tenantSign + "&tenantIP=" + ip, 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 response = res.response; window.location.href = window.location.protocol + "//" + window.location.host + "/renter/leasedocument.html"; } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } }; xmlhttp1.send(); } function getAddendumHistory(leaseID) { 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 + "/renter/getaddendumhistory?leaseID=" + leaseID, 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 response = JSON.parse(res['response']); // console.log(res); { $('#modalScrollable').modal("show"); $('#modal_message_addendum').empty(); var dynamicCard = document.getElementById('modal_message_addendum'); if(response!=null){ for (i = 0; i < response.length; i++) { // console.log(JSON.parse(response[i].tenantSignature)) let sign = (response[i].tenantSignature); if(sign!=null){ var fetch = document.getElementById('modal_message_addendum').innerHTML; dynamicCard.innerHTML = `
Type:
${response[i].type}
Date of Addendum:
${response[i].dateOfAddendum}
Start Date:
${response[i].startDate}
End Date:
${response[i].endDate}
Document:

` + fetch; } } }else { var fetch = document.getElementById('modal_message_addendum').innerHTML; dynamicCard.innerHTML = `

No addendums available

`; } } } } xmlhttp1.send(); } function downloadAddendumPdf(addendumID, leaseID) { var fileType = "addendums"; var fileName = addendumID + "_addendums.pdf"; 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 + "/rentalUploadDownload/secureAddendumDownloadRental?leaseID=" + leaseID +"&addendumID=" + addendumID + "&type=" + fileType, true); xmlhttp1.responseType = 'arraybuffer'; xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.readyState == 4) { if (this.response.byteLength == 0) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; } else { var blob = new Blob([this.response], { type: "application/pdf" }); var link = document.createElement('a'); link.href = window.URL.createObjectURL(blob); link.download = fileName; link.click(); } } }; xmlhttp1.send(); } function getRenterIPAddress() { 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("GET", baseurl + "/renter/getuseripaddress", true); 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 != "") { var res = JSON.parse(this.responseText); // var response = JSON.parse(res['response']); // console.log(res.response); document.getElementById("ipaddress").value = res.response } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } else if (this.status == 500) { var res = JSON.parse(this.responseText); if (res.response === "403 FORBIDDEN") { window.location.href = window.location.protocol + "//" + window.location.host + "/renter/login.html" } } }; xmlhttp.send(); } function formatDateBack(nonFormatDate) { // checking for null condition -- error undefinded if (nonFormatDate == null || nonFormatDate == "") { return nonFormatDate; } else { var months = { 'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12' }; var date = nonFormatDate.replace(",", "").split(" "); // console.log([date[2], months[date[0]], date[1]].join('-')) return [date[2], months[date[0]], date[1]].join('-');; } }