Advertisement
VladislavNechepaev

Untitled

Apr 2nd, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery("input[type=\"submit\"]").each((index, elem) => {
  2.         elem.onclick = async function(e){
  3.           e.preventDefault()
  4.           if (checkBrowser()) {
  5.             if (!capacityCheckMain || !capacityCheckAdditional || !parkingCheck) {
  6.               renderController(true)
  7.               alert("Please check the capactiy for selected dates")                     //поменять нотифай если нужно!//  
  8.             } else {
  9.               document.getElementById("request_catalog_item").submit()
  10.             }
  11.           } else {
  12.             const mainOffice = fsNative.office.value
  13.             const addLocInfo = JSON.parse(fsNative.addloc.innerHTML)
  14.             const data = await fetch(`https://freshservicecounter.ringteam.com/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${selectedDatesGlobal}${parkingActive ? "&getparking=true" : ""}`)
  15.                                    //const data = await fetch(`http://localhost:5000/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${selectedDatesGlobal}${parkingActive ? "&getparking=true" : ""}`)
  16.             const json = await data.json()
  17.             var immediateCapacityCheck = true
  18.             for (let office in json) {
  19.               for (let date in json[office].capacity) {
  20.                 if (json[office].capacity[date] >= json[office].limit && (office === mainOffice || (addLocInfo[date] && addLocInfo[date].includes(office)))) immediateCapacityCheck = false
  21.               }
  22.             }
  23.             console.log(capacityCheckMain, capacityCheckAdditional, parkingCheck, immediateCapacityCheck)
  24.             if (!capacityCheckMain || !capacityCheckAdditional || !parkingCheck || !immediateCapacityCheck) {
  25.               renderController(true)
  26.               alert("Please check the capactiy for selected dates")                     //поменять нотифай если нужно!//  
  27.             } else {
  28.               document.getElementById("request_catalog_item").submit()
  29.             }
  30.           }
  31.           return e.returnValue
  32.         }
  33.       })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement