jQuery("input[type=\"submit\"]").each((index, elem) => { elem.onclick = async function(e){ e.preventDefault() if (checkBrowser()) { if (!capacityCheckMain || !capacityCheckAdditional || !parkingCheck) { renderController(true) alert("Please check the capactiy for selected dates") //поменять нотифай если нужно!// } else { document.getElementById("request_catalog_item").submit() } } else { const mainOffice = fsNative.office.value const addLocInfo = JSON.parse(fsNative.addloc.innerHTML) const data = await fetch(`https://freshservicecounter.ringteam.com/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${selectedDatesGlobal}${parkingActive ? "&getparking=true" : ""}`) //const data = await fetch(`http://localhost:5000/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${selectedDatesGlobal}${parkingActive ? "&getparking=true" : ""}`) const json = await data.json() var immediateCapacityCheck = true for (let office in json) { for (let date in json[office].capacity) { if (json[office].capacity[date] >= json[office].limit && (office === mainOffice || (addLocInfo[date] && addLocInfo[date].includes(office)))) immediateCapacityCheck = false } } console.log(capacityCheckMain, capacityCheckAdditional, parkingCheck, immediateCapacityCheck) if (!capacityCheckMain || !capacityCheckAdditional || !parkingCheck || !immediateCapacityCheck) { renderController(true) alert("Please check the capactiy for selected dates") //поменять нотифай если нужно!// } else { document.getElementById("request_catalog_item").submit() } } return e.returnValue } })