// 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 + "/landlord/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; var landlordName = document.getElementById('landlord_name'); if (landlordName) landlordName.innerText = res.response; } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/landlord/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 + "/landlord/login.html" } } }; xmlhttp1.send(); } // format Date 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]); } } // login function function initLogin() { 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', landlordClientId); 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); window.location.href = window.location.protocol + "//" + window.location.host + "/landlord/index.html"; } 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) } } // sending reset password mail once manager creates account for landlord function sendResetPassMail(clientId) { var webBaseURL = window.location.protocol + "//" + window.location.host; var email = document.getElementById("username").value; document.getElementById('username').innerHTML = ""; if (!email) { document.getElementById('username_error').innerHTML = "This field is mandatory" document.getElementById('username').focus(); return false; } 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 + "/rentalunsecured/sendresetpassmail?emailID=" + email + "&webBaseURL=" + webBaseURL + "&clientId=" + clientId, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = res.response; // Getting errors on fields var s = res.rspnsMsg; var s = s.replace(/[{}]/g, ""); const obj = Object.fromEntries([s.split("=")]) 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 + "/landlord/forgot-password.html" } else if (this.status == 500 && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/landlord/forgot-password.html" } }; xmlhttp.send(); } function resetAccount(tokenId, userId) { var email = document.getElementById("email").value; var firstName = document.getElementById("firstName").value; var lastName = document.getElementById("lastName").value; var password = document.getElementById("password").value; var confirmPassword = document.getElementById("confirmPassword").value; if (!firstName) { document.getElementById('firstname_error').innerHTML = "This field is mandatory" document.getElementById('firstName').focus(); return false; } if (!lastName) { document.getElementById('lastname_error').innerHTML = "This field is mandatory" document.getElementById('lastName').focus(); return false; } if (!email) { document.getElementById('email_error').innerHTML = "This field is mandatory" document.getElementById('email').focus(); return false; } if (!password) { document.getElementById('password_error').innerHTML = "This field is mandatory" document.getElementById('password').focus(); return false; } if (!confirmPassword) { document.getElementById('confirmpass_error').innerHTML = "This field is mandatory" document.getElementById('confirmPassword').focus(); return false; } if (!password) { 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/resetlandlordaccount?tokenID=" + tokenId + "&user_id=" + userId, 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": email, "firstName": firstName, "lastName": lastName, "password": password, "roles": [] })); } 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 resetPassword(tokenId, userId) { var password = document.getElementById("password").value; var confirmPassword = document.getElementById("confirmPassword").value; if (!password) { document.getElementById('password_error').innerHTML = "This field is mandatory" document.getElementById('password').focus(); return false; } if (!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=" + landlordClientId, 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;; 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 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 + "/landlord/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 + "/landlord/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 + "/landlord/login.html" } } }; xmlhttp1.send(); } // this ajax is for edit profile for landlord function editProfileLanlord() { 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; } 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 + "/landlord/editlandlordprofile", 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 + "/landlord/pages-error-404.html" } else if (this.status == 500 && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/landlord/pages-error-404.html" } }; xmlhttp1.send(JSON.stringify({ "emailID": Email, "firstName": FirstName, "lastName": LastName, "phoneNumber": Phone1, "roles": [] })); } // this ajax is for change password function changeLandlordPassword() { var xmlhttp1; 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; } 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 + "/landlord/changelandlordpassword?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 + "/landlord/login.html" } }; 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 + "/landlord/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 (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"]; if (response[i].lease["leaseEndDate"] == null || response[i].lease["leaseEndDate"] == "") { var leaseEndDate = "Not Mentioned" } else { var leaseEndDate = formatDateForTables(response[i].lease["leaseEndDate"]) } 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) + '' } } else { tableData += "No Lease Documents for now"; } } document.getElementById('approvedLease').innerHTML = tableData; } }; xmlhttp1.send(); } function getPropertyDetails() { var xmlhttp1; var properties = document.getElementById("properties"); var webBaseURL = window.location.protocol + "//" + window.location.host; 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 + "/landlord/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++) { var s = JSON.parse(response[i].imageList); var copyLink = webBaseURL + "" + "/propertydetails.html?propertyID=" + "" + response[i].propertyId; var firstImage = s != null ? s[0].imageLink : "../admin/assets/img/img for card.jpg"; if (response[i].isPropertyRented) { temphtml += `
Image Title

${response[i].propertyInfo.type}

$${response[i].propertyInfo.rentAmount}/${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} Sq Ft ${response[i].propertyInfo.bedrooms} Bedrooms ${response[i].propertyInfo.bathrooms} Bathrooms ${response[i].propertyInfo.furnishing} ${response[i].propertyInfo.carParking} Covered

`; } else { temphtml += `
Image Title

${response[i].propertyInfo.type}

$${response[i].propertyInfo.rentAmount}/${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} Sq Ft ${response[i].propertyInfo.bedrooms} Bedrooms ${response[i].propertyInfo.bathrooms} Bathrooms ${response[i].propertyInfo.furnishing} ${response[i].propertyInfo.carParking} Covered

`; } } properties.innerHTML = temphtml; } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/landlord/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 + "/landlord/login.html" } } }; xmlhttp1.send(); } function getTransactionOfProperty() { var propertyID = $('#propertyDropdown').val(); var fromDate = $('#fromDate').val(); var toDate = $('#toDate').val(); var from = $('#from').val(); var to = $('#to').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; } } } var path; path = "/landlord/gettransactionbyproperty?propertyID=" + propertyID if (from && to) { path += "&from=" + from + "&to=" + to; } xmlhttp1.open("GET", baseurl + path, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.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 == "Escrow Debit-Landlord" || response[i].transactionType == "Escrow Debit-PM") ? (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].name + ''; tableData += '' + ((response[i].account == '' || response[i].account == null) ? '-' : (response[i].account)) + ''; tableData += '' + response[i].transactionType + ''; tableData += '' + amountExp + ''; } } else { tableData = "No transactions for now" } } document.getElementById('transaction_table').innerHTML = tableData; } } }; xmlhttp1.send(); } function getPropertyList() { var xmlhttp1; var properties = document.getElementById("propertyDropdown"); 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 + "/landlord/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++) { temphtml += `` } properties.innerHTML = temphtml; } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/landlord/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 + "/landlord/login.html" } } }; xmlhttp1.send(); } function getEscrowDetails() { var propertyID = $('#propertyDropdown').val(); var fromDate = $('#fromDate').val(); var toDate = $('#toDate').val(); var from = $('#from').val(); var to = $('#to').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; } } } var path; path = "/landlord/gettransactiondetailsbyproperty?propertyID=" + propertyID if (from && to) { path += "&payment_date_from=" + from + "&payment_date_to=" + to; } xmlhttp1.open("GET", baseurl + path, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.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[0].totalEscrowCredit); var dynamicCard = document.querySelector('.summary_card'); let totalEscrowCredit = (response[0].totalEscrowCredit); let totalEscrowDebit = (response[0].totalEscrowDebit); let remainingBalance = totalEscrowCredit - totalEscrowDebit; // for (i = 0; i < response.length; i++) { dynamicCard.innerHTML = `
Escrow Account Details:
Credit

$${totalEscrowCredit}

Debit

$${totalEscrowDebit}

Remaining Balance
$${remainingBalance}
`; // } } // document.getElementById('transaction_table').innerHTML = tableData; } } }; xmlhttp1.send(); } function fetchLandlordFaq() { 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 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]); } } 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 copyText(copyLink) { var body = $(window.document.body); var textarea = $('