Advertisement
VladislavNechepaev

Untitled

Dec 29th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="https://freshservicecounter.ringteam.com/ringteam_portal_customization.js"></script>
  2. <script>
  3.   jQuery(document).on('ready', async function(){
  4.     console.log('[INIT]')
  5.     if (window.location.pathname === "/support/catalog/items/149") {
  6.       const durationList = {
  7.         "...": false,
  8.         "Full day": true,
  9.         "Half day": true,
  10.         "Short visit (up to 2 hours)": false
  11.       }
  12.       const officeList = {
  13.         "...": false,
  14.         "Toronto": true,
  15.         "Lviv": true,
  16.         "Lab64": true,
  17.         "Lab72": true,
  18.         "Lab72 / 1": false,
  19.         "Rancho 1": false,
  20.         "Rancho 2": false,
  21.         "QA Studio": false,
  22.         "New QA Studio": false,
  23.         "Community": false,
  24.         "Lab62": true
  25.       }
  26.       const officeMeido = {
  27.         "...": false,
  28.         "Toronto": true,
  29.         "Lviv": false,
  30.         "Lab64": true,
  31.         "Lab72": true,
  32.         "Lab72 / 1": false,
  33.         "Rancho 1": false,
  34.         "Rancho 2": false,
  35.         "QA Studio": false,
  36.         "New QA Studio": false,
  37.         "Community": false,
  38.         "Lab62": true
  39.       }
  40.       const officeCapacity = ["Toronto","Lab64","Lab62"]
  41.       const officeAddress = {
  42.         "...": "",
  43.         "Toronto": "м. Київ, вул. Велика Васильківська 100, 8 поверх",
  44.         "Lviv": "м. Львів, вул. Поповича, 9",
  45.         "Lab64": "м. Київ, вул. Велика Васильківська 64",
  46.         "Lab72": "м. Київ, вул. Велика Васильківська 72",
  47.         "Lab72 / 1": "м. Київ, вул. Велика Васильківська 72",
  48.         "Rancho 1": "м. Київ, пров. Малокитаївський, 12",
  49.         "Rancho 2": "м. Київ, вул. Травнева 28",
  50.         "QA Studio": "м. Київ, вул. Північно-Сирецька 1-3",
  51.         "New QA Studio": "м. Київ, просп. Перемоги 53",
  52.         "Community": "м. Київ, вул. Євгена Коновальця 44, 2 поверх",
  53.         "Lab62": "м. Київ, вул. Велика Васильківська 62"
  54.       }
  55.       const accessWeek = {
  56.         "...": false,
  57.         "Current week": true,
  58.         "Next week": true
  59.       }
  60.       const mealTypes = [
  61.         "Non-vegan",
  62.         "Vegan"
  63.       ]
  64.         var fsFields = {
  65.       duration: "requested_item_values_149_requested_item_value_attributes_cf_visit_duration_270753",
  66.       support_with_lunch: "requested_item_values_149_requested_item_value_attributes_cf_support_with_lunch_270753",
  67.       access_week: "requested_item_values_149_requested_item_value_attributes_cf_access_type_270753",
  68.       lunch_type: "requested_item_values_149_requested_item_value_attributes_cf_select_your_meal_preference_270753",
  69.       office: "requested_item_values_149_requested_item_value_attributes_cf_office_270753",
  70.       dates: [
  71.         "requested_item_values_149_requested_item_value_attributes_cf_day1_270753_date",
  72.         "requested_item_values_149_requested_item_value_attributes_cf_day2_270753_date",
  73.         "requested_item_values_149_requested_item_value_attributes_cf_day3_270753_date",
  74.         "requested_item_values_149_requested_item_value_attributes_cf_day4_270753_date",
  75.         "requested_item_values_149_requested_item_value_attributes_cf_day5_270753_date"              //ДОБАВИТЬ ДОПОЛНИТЕЛЬНІЕ ДНИ - скопировать айдишники каждого поля_ТЕСТОВІЙ РЕКВЕСТ//
  76.       ],
  77.       additional_locations: [
  78.         "requested_item_values_149_requested_item_value_attributes_cf_do_you_plan_to_visit_any_additional_location_during_the_requested_period_nbsp_270753",
  79.         "requested_item_values_149_requested_item_value_attributes_cf_additional_location_2_270753"
  80.       ],
  81.       meido: "requested_item_values_149_requested_item_value_attributes_cf_meido_body_270753",
  82.       document_text: "requested_item_values_149_requested_item_value_attributes_cf__270753",
  83.       document_check: "requested_item_values_149_requested_item_value_attributes_cf_v_270753",
  84.       addloc: "requested_item_values_149_requested_item_value_attributes_cf_additional_location_data_270753",
  85.       addloc_text: "requested_item_values_149_requested_item_value_attributes_cf_additional_location_270753"
  86.     }
  87.  
  88.       // -------------------------
  89.         var meidoActive
  90.         if (window.location.pathname === "/support/catalog/items/136") {
  91.           meidoActive = false
  92.         } else if (window.location.pathname === "/support/catalog/items/149") {
  93.           meidoActive = true
  94.         }
  95.         meidoToken = "test"
  96.       // -------------------------
  97.  
  98.       // -------------------------
  99.         var capacityActive = true
  100.       // -------------------------
  101.  
  102.           // ====================================================================
  103.           // ====================================================================
  104.           // ====================================================================
  105.  
  106.       const fsNative = {
  107.         duration: document.getElementById(fsFields.duration),
  108.         support_with_lunch: document.getElementById(fsFields.support_with_lunch).parentNode.childNodes.item(0),
  109.         access_week: document.getElementById(fsFields.access_week),
  110.         lunch_type: document.getElementById(fsFields.lunch_type),
  111.         office: document.getElementById(fsFields.office),
  112.         meido: document.getElementById(fsFields.meido),
  113.         dates: getElemList(fsFields.dates),
  114.         additional_locations: getElemList(fsFields.additional_locations),
  115.         document_text: document.getElementById(fsFields.document_text),
  116.         document_check: document.getElementById(fsFields.document_check).parentNode.childNodes.item(0),
  117.         addloc: document.getElementById(fsFields.addloc),
  118.         addloc_text: document.getElementById(fsFields.addloc_text)
  119.       }
  120.  
  121.       var activeDateCount = 0
  122.       const today = new Date()
  123.       const todayGlobal = today.toLocaleDateString()
  124.       const weekdayGlobal = today.getDay()
  125.       const currentHoursGlobal = today.getHours()
  126.         const currentMinutesGlobal = today.getMinutes()
  127.       var selectedDatesGlobal = []
  128.       var capacityCheck = true
  129.       var additionalLocationInfo = {}
  130.       var addLocationTable
  131.       var lastSelectedOffice
  132.  
  133.       const durationSelector = replaceInputWithDropdown(fsFields.duration, durationList, "duration")
  134.             durationSelector.parentNode.hidden = true
  135.       const officeSelector = replaceInputWithDropdown(fsFields.office, officeList, "office")
  136.       const accessWeekSelector = replaceInputWithDropdown(fsFields.access_week, accessWeek, "access-week")
  137.       const lunchTypeSelector = createSimplifiedDropdown(fsFields.lunch_type, mealTypes, "lunch_type")
  138.       const lunchCheckboxLabel = document.createTextNode("Please support me with lunch")                          // to add text Lunch will be provided in case your visit durayion is more than 2 hours//
  139.       const lunchCheckbox = createCustomCheckbox(document.getElementById(fsFields.support_with_lunch).parentNode, "show-lunch", lunchCheckboxLabel)
  140.       const dateList = createCustomDates(fsNative.dates)
  141.       const additionalOfficesList = createAdditionalOfficeSelectors(fsFields.additional_locations, officeList)
  142.       const capacityDisplay = createCapacityDisplay(fsNative.dates[0].parentNode.parentNode)
  143.       //--- capacity ---
  144.       if (capacityActive) {
  145.         fsNative.addloc.parentNode.hidden = true
  146.         fsNative.addloc_text.parentNode.hidden = true
  147.         fsNative.additional_locations.forEach(elem => { elem.parentNode.hidden = true })
  148.       }
  149.  
  150.  
  151.           //add hotDeskCheckbox
  152.       const hotdeskCheckboxLabel = document.createTextNode("I don`t have a permanent seat and would like to book a hot desk.");
  153.       const hotdeskCheckboxContainer = document.createElement('div');
  154.       document.getElementById(fsFields.office).parentNode.appendChild(hotdeskCheckboxContainer);
  155.       const hotdeskCheckbox = createCustomCheckbox(hotdeskCheckboxContainer, "show-hotdesk", hotdeskCheckboxLabel);
  156.       hotdeskCheckbox.checked = false;
  157.       const hotdeskText = document.createElement("p");
  158.       hotdeskText.innerHTML = "Please, follow the <a href='https://ringukraine.officespacesoftware.com/visual-directory/floors/139' style='color:blue;cursor:pointer;' target='_blank'>link</a> for hot desks booking system (applicable only for Full/half-day visit). Here`re <a href='https://docs.google.com/document/d/1llpCz3RbK0cBew7kSJhZPQwD5Om8Kgj0tTq-1kgONx4/edit' style='color:blue;cursor:pointer;' target='_blank'>instructions</a> on how to make a booking.";
  159.       hotdeskCheckboxContainer.appendChild(hotdeskText);
  160.  
  161.       const documentCheckboxLabel = document.createElement("span")
  162.       documentCheckboxLabel.innerHTML = "Я, {{ current_user.phone }}, ознайомився з документом та підтверджую що мій стан відповідає нормам відвідування офісу згідно з заявою.<br>*[✓] <i>означає, що дана відмітка прирівнюється до власноручного/факсимільного відтворення підпису особи.</i>"
  163.       const documentCheckbox = createCustomCheckbox(fsNative.document_check.parentNode, "document-check", documentCheckboxLabel)
  164.       const documentText = createDocumentSection(fsNative.document_text, todayGlobal)
  165.  
  166.       const dateControlAdd = document.createElement("button")
  167.       dateControlAdd.innerHTML = "+"
  168.       const dateControlRemove = document.createElement("button")
  169.       dateControlRemove.innerHTML = "-"
  170.  
  171.       lunchCheckbox.parentNode.hidden = true;
  172.       lunchTypeSelector.parentNode.hidden = true;
  173.       hotdeskCheckboxContainer.hidden = true;
  174.       hotdeskText.hidden = true;
  175.  
  176.       //durationSelector.addEventListener("change", function(){ renderController() })
  177.       officeSelector.addEventListener("change", function(){ renderController() })
  178.       accessWeekSelector.addEventListener("change", function(){ renderController() })
  179.       lunchCheckbox.addEventListener("change", function(){ renderController() })
  180.       hotdeskCheckbox.addEventListener("change", function(){ renderController() })
  181.       lunchTypeSelector.addEventListener("change", function(){ renderController() })
  182.  
  183.       dateList.forEach(dateElem => {
  184.         jQuery(dateElem).datepicker("option", {
  185.           onSelect: function() {
  186.             renderController()
  187.           }
  188.         })
  189.       })
  190.  
  191.       dateControlAdd.addEventListener("click", function(e){
  192.         e.preventDefault()
  193.         activeDateCount += 1
  194.         renderController()
  195.       })
  196.       dateControlRemove.addEventListener("click", function(e){
  197.         e.preventDefault()
  198.         activeDateCount -= 1
  199.         renderController()
  200.       })
  201.       additionalOfficesList.forEach(elem => {
  202.         elem.addEventListener("change", function(){ renderController() })
  203.       })
  204.  
  205.  
  206.       documentCheckbox.addEventListener("change", function(){ renderController() })
  207.  
  208.       var meidoMenu
  209.       document.getElementById(fsFields.meido).parentNode.style.display = "none"
  210.       if (meidoActive) {
  211.         const elems = document.getElementsByClassName("main pull-left")
  212.         meidoMenu = await meidoInit(elems[0], dateList, fsFields.meido, 125, false)  // change 125 to required limit
  213.         meidoMenu.hidden = true
  214.         renderController()
  215.       } else {
  216.         renderController()
  217.       }
  218.  
  219.       jQuery("input[type=\"submit\"]").each((index, elem) => {
  220.         elem.onclick = function(e){
  221.           if (!capacityCheck) {
  222.             e.stopImmediatePropagation()
  223.             e.preventDefault()
  224.               alert("Please check the capactiy for selected dates")                     //поменять нотифай если нужно!//
  225.           }
  226.         }
  227.       })
  228.  
  229.       function renderController(){
  230.         var values = {
  231.           duration: "Full day",
  232.           office: officeSelector.value,
  233.           access_week: accessWeekSelector.value
  234.         }
  235.  
  236.         fsNative.duration.value = values.duration === "..." ? "" : values.duration
  237.         fsNative.office.value = values.office === "..." ? "" : values.office
  238.  
  239.         if (capacityActive) {
  240.           if (values.office === "...") {
  241.             lastSelectedOffice = values.office
  242.             for (let elem of document.getElementsByClassName("addtable-container")) {
  243.               elem.innerHTML = ""
  244.             }
  245.             additionalLocationInfo = {}
  246.             populateAddLocation()
  247.           }
  248.           if (values.office !== "..." && values.office !== lastSelectedOffice) {
  249.             lastSelectedOffice = values.office
  250.             addLocationTable = buildAddLocationTable(values.office)
  251.             const addTableContainers = document.getElementsByClassName("addtable-container")
  252.             var index = 1
  253.             for (let elem of addTableContainers) {
  254.               elem.innerHTML = ""
  255.               const table = addLocationTable.cloneNode(true)
  256.               console.log(table.querySelectorAll('.add-office-label'))
  257.               for (let elem of table.querySelectorAll('.add-office-label')) {
  258.                 elem.htmlFor = elem.htmlFor + "_" + index
  259.               }
  260.               for (let elem of table.querySelectorAll('.add-office-checkbox')) {
  261.                 elem.id = elem.id + "_" + index
  262.                 elem.onclick = function(){ handleAddLocation(this) }
  263.               }
  264.               ++index
  265.               elem.appendChild(table)
  266.             }
  267.             additionalLocationInfo = {}
  268.             populateAddLocation()
  269.           }
  270.         }
  271.  
  272.         if (fsNative.office.value === 'Toronto') {
  273.           hotdeskCheckboxContainer.hidden = false;
  274.         } else {
  275.           hotdeskCheckbox.checked = false;
  276.           hotdeskCheckboxContainer.hidden = true;
  277.         }
  278.         if (!hotdeskCheckbox.checked) {
  279.           hotdeskText.hidden = true;
  280.         } else {
  281.           hotdeskText.hidden = false;
  282.         }
  283.  
  284.         const accessWeekChanged = fsNative.access_week.value === values.access_week ? false : true
  285.         fsNative.access_week.value = values.access_week === "..." ? "" : values.access_week
  286.         var datesInRequest = dateList.map(x => x.value).filter(x => !!x)
  287.         if (activeDateCount === 0) datesInRequest = datesInRequest[0] ? [datesInRequest[0]] : []
  288.         const today = new Date().toISOString().split("T")[0]
  289.         if (durationList[values.duration] && officeList[values.office] && accessWeek[values.access_week] && datesInRequest.length && !(datesInRequest.length === 1 && datesInRequest[0] === today) && !accessWeekChanged) {
  290.           lunchCheckbox.parentNode.hidden = false
  291.         } else {
  292.           lunchCheckbox.parentNode.hidden = true
  293.           lunchCheckbox.checked = false
  294.         }
  295.  
  296.         values.support_with_lunch = lunchCheckbox.checked
  297.         fsNative.support_with_lunch.value = lunchCheckbox.checked ? "1" : "0"
  298.         if (values.support_with_lunch) {
  299.           if (meidoActive) {
  300.             if (weekdayGlobal === 6 || weekdayGlobal === 0 || (weekdayGlobal === 5 && currentHoursGlobal >= 19 && currentMinutesGlobal >= 30) || values.access_week === "Current week" || !officeMeido[values.office]) {
  301.               lunchTypeSelector.parentNode.hidden = false
  302.               lunchTypeSelector.value = lunchTypeSelector.value ? lunchTypeSelector.value : mealTypes[0]
  303.               meidoMenu.hidden = true
  304.             } else {
  305.               lunchTypeSelector.parentNode.hidden = true
  306.               lunchTypeSelector.value = null
  307.               meidoMenu.hidden = false
  308.             }
  309.           } else {
  310.             lunchTypeSelector.parentNode.hidden = false
  311.             lunchTypeSelector.value = lunchTypeSelector.value ? lunchTypeSelector.value : mealTypes[0]
  312.           }
  313.         } else {
  314.           lunchTypeSelector.parentNode.hidden = true
  315.           lunchTypeSelector.value = null
  316.           if (meidoActive) meidoMenu.hidden = true
  317.         }
  318.  
  319.         values.lunch_type = lunchTypeSelector.value
  320.         fsNative.lunch_type.value = values.lunch_type ? values.lunch_type : ""
  321.  
  322.         const dateLimits = (values.access_week === "...") ? null : calcDateLimits(values.access_week === "Current week" ? true : false)
  323.         const dateLimitsRaw = dateLimits ? dateLimits.map(x => new Date(x).valueOf()) : null
  324.         var existingDates = []
  325.         var lastUsedFound = false;
  326.         if (accessWeekChanged) activeDateCount = 0
  327.         dateList.forEach((dateElem, index) => {
  328.           const dateNativeElem = fsNative.dates[index]
  329.           const timeNativeElem = document.getElementById(fsFields.dates[index].substring(0, fsFields.dates[index].length - 4) + "time")
  330.           const errorElem = document.getElementById("date_custom_" + (index+1) + "-error")
  331.           if (errorElem) errorElem.style.display = "none"
  332.           if (accessWeekChanged && index === 0) dateElem.value = null
  333.           const dateRawValue = new Date(dateElem.value).valueOf()
  334.           if (existingDates.includes(dateRawValue)) dateElem.value = null
  335.           if (dateLimits) {
  336.             jQuery("#date_custom_"+(index+1)).datepicker("option", {
  337.               minDate: new Date(dateLimits[0]),
  338.               maxDate: new Date(dateLimits[1])
  339.             })
  340.             dateElem.disabled = false
  341.             if (dateRawValue < dateLimitsRaw[0] || dateRawValue > dateLimitsRaw[1]) dateElem.value = null
  342.           } else {
  343.             dateElem.disabled = true
  344.           }
  345.           existingDates.push(dateRawValue)
  346.           const controlWrapper = document.getElementById("controls_" + index)
  347.           controlWrapper.innerHTML = ""
  348.           const addLocations = document.getElementById("addtable_" + (index+1)).querySelectorAll('.add-office-checkbox')
  349.           if (dateElem.value && dateElem.value !== "") {
  350.             dateNativeElem.value = reverseForFS(dateElem.value)
  351.             timeNativeElem.value = "00:00"
  352.             if (capacityActive) document.getElementById("addtable_wrapper_" + (index+1)).style.display = "block"
  353.           } else {
  354.             dateNativeElem.value = null
  355.             timeNativeElem.value = null
  356.             if (capacityActive) {
  357.               document.getElementById("addtable_wrapper_" + (index+1)).style.display = "none"
  358.               for (let checkbox of addLocations) {
  359.                 checkbox.checked = false
  360.               }
  361.             }
  362.           }
  363.           controlWrapper.style.display = "inline-block"
  364.           if (index < activeDateCount) {
  365.             dateElem.disabled = true
  366.             dateElem.parentNode.style.display = "block"
  367.           } else if (index === activeDateCount) {
  368.             if (dateLimits) dateElem.disabled = false
  369.             if (index > 0 && dateList[index-1].value) {
  370.                     const nextDate = new Date(dateList[index-1].value)
  371.                   nextDate.setDate(nextDate.getDate() + 1)
  372.               jQuery("#date_custom_"+(index+1)).datepicker("option", {
  373.                 minDate: nextDate
  374.               })
  375.                 }
  376.             dateElem.parentNode.style.display = "block"
  377.             if (activeDateCount > 0) controlWrapper.appendChild(dateControlRemove)
  378.             if (activeDateCount < dateList.length-1) {
  379.               controlWrapper.appendChild(dateControlAdd)
  380.               dateControlAdd.disabled = !dateElem.value
  381.             }
  382.           } else {
  383.             dateElem.parentNode.style.display = "none"
  384.             dateElem.value = null
  385.             dateNativeElem.value = null
  386.             timeNativeElem.value = null
  387.           }
  388.         })
  389.  
  390.  
  391.         if (capacityActive === true) {
  392.           const selectedDates = dateList.map(x => x.value).filter(x => !!x)
  393.           for (let date in additionalLocationInfo) {
  394.             if (!selectedDates.includes(date)) delete additionalLocationInfo[date]
  395.           }
  396.           populateAddLocation()
  397.           if (selectedDates.length && JSON.stringify(selectedDates) !== selectedDatesGlobal) {
  398.             fetch(`https://freshservicecounter.ringteam.com/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${JSON.stringify(selectedDates)}`)
  399.             .then(res => {
  400.               return res.json()
  401.             })
  402.             .then(res => {
  403.             // main capacity
  404.               for (let officeName in res) {
  405.                 if (values.office === officeName) {
  406.                   capacityDisplay.innerHTML = ""
  407.                   const office = document.createElement("div")
  408.                   office.innerHTML = `<b>Office:</b> ${officeName}`
  409.                   const limit = document.createElement("div")
  410.                   limit.innerHTML = `<b>Limit:</b> ${res[officeName].limit} visitors per day`
  411.                   limit.style.borderBottom = "1px dotted grey"
  412.                   capacityDisplay.appendChild(office)
  413.                   capacityDisplay.appendChild(limit)
  414.                   var capacityDataArray = []
  415.                   for (let date in res[officeName].capacity) {
  416.                     capacityDataArray.push({ date: date, capacity: res[officeName].capacity[date] })
  417.                   }
  418.                   capacityDataArray.sort((x,y) => { return x.date > y.date ? 1 : -1 })
  419.                   capacityCheck = true
  420.                   capacityDataArray.forEach(obj => {
  421.                     const dateElem = document.createElement("div")
  422.                     dateElem.innerHTML = `<b>${obj.date}:</b> ${obj.capacity} visitors confirmed`
  423.                     //console.log(obj.capacity, res.limit)
  424.                     if (obj.capacity / res[officeName].limit >= 0.7) dateElem.style.color = "orange"
  425.                     if (obj.capacity >= res[officeName].limit) {
  426.                       dateElem.style.color = "red"
  427.                       capacityCheck = false
  428.                     }
  429.                     capacityDisplay.appendChild(dateElem)
  430.                   })
  431.                       capacityDisplay.hidden = false
  432.                 } else {
  433.                   //additional capacity
  434.                   dateList.forEach(dateElem => {
  435.                     var elem = dateElem.parentNode.getElementsByClassName("capacity_" + officeName)[0]
  436.                     elem.innerHTML = `${res[officeName].capacity[dateElem.value]}/${res[officeName].limit} confirmed`
  437.                   })
  438.                 }
  439.               }
  440.             })
  441.           } else {
  442.             capacityDisplay.hidden = true
  443.             capacityCheck = capacityDisplay.hidden
  444.           }
  445.             selectedDatesGlobal = JSON.stringify(selectedDates)
  446.         }
  447.  
  448.         if (meidoActive && values.access_week === "Next week") {
  449.           meidoCart.calcDateCollection()
  450.         } else {
  451.               fsNative.meido.innerHTML = null
  452.         }
  453.  
  454.         values.additional_offices = []
  455.         additionalOfficesList.forEach((elem, index) => {
  456.           values.additional_offices.push(elem.value)
  457.           if ((index === 0 && values.office !== "...") || (index > 0 && values.additional_offices[index-1] !== "...")) {
  458.             elem.parentNode.style.display = "block"
  459.           } else {
  460.             elem.parentNode.style.display = "none"
  461.             elem.value = "..."
  462.           }
  463.           fsNative.additional_locations[index].value = elem.value === "..." ? null : elem.value
  464.         })
  465.  
  466.         values.document_check = documentCheckbox.checked
  467.         fsNative.document_check.value = documentCheckbox.checked ? "1" : "0"
  468.         fsNative.document_check.checked = documentCheckbox.checked
  469.         const documentLocations = [values.office, values.additional_offices].flat().map(x => officeAddress[x]).filter(x => !!x).join(", ")
  470.         document.getElementById("doc-address").innerHTML = documentLocations
  471.         // =================================================
  472.         var text = `Заява на допуск до користування Простором Товариства з обмеженою відповідальністю «ТекХостинг» (далі – ТОВ «ТекХостинг»)
  473.  
  474. Я, фізична особа-підприємець ${"{{ current_user.phone }}"}, прошу допустити мене до користування офісним простором ТОВ «ТекХостинг» (далі – Простір), що знаходиться за адресою: ${documentLocations}.
  475.  
  476.  
  477. Я підтверджую, що на момент надання мені доступу до користування Простором:
  478.  
  479. • у мене відсутні будь-які ознаки ГРВІ, а саме: підвищена температура тіла (більше 37,2 С), кашель, утруднене дихання тощо;
  480. • я ознайомлений(а) з рекомендаціями МОЗ та ВООЗ щодо попередження зараження COVID-19 та їх дотримуюсь;
  481. • протягом останніх 14 днів я не перебував(ла) за межами України та не контактував(ла) з особами, щодо яких наявна підозра/хворими на COVID-19.
  482.  
  483. Я зобов’язуюсь під час користування Простором дотримуватися посилених санітарно-гігієнічних норм, а також рекомендацій МОЗ та ВООЗ щодо запобігання поширенню COVID-19, а саме:
  484.  
  485. • носити медичну маску/респіратор;
  486. • ретельно мити руки з милом протягом 20-40 сек. та регулярно обробляти їх антисептичним засобом під час перебування в Просторі;
  487. • дотримуватися дистанції min 1,5 (півтора) метри від інших відвідувачів Простору.
  488.  
  489. Дата: ${todayGlobal}`
  490.         // =================================================
  491.         fsNative.document_text.value = text
  492.       }
  493.  
  494.       function buildAddLocationTable(excluded){
  495.         const table = document.createElement('table')
  496.         table.style.margin = "10px"
  497.         const row = document.createElement('tr')
  498.         row.style.width = "800px"
  499.         row.style.display = "block"
  500.         table.appendChild(row)
  501.         var cellCount = 0
  502.         for (let office in officeList) {
  503.           if (office !== "..." && office !== excluded) {
  504.             var currentRow
  505.             if (cellCount <= 2) {
  506.               currentRow = table.childNodes[table.childNodes.length - 1]
  507.               ++cellCount
  508.             } else {
  509.               currentRow = document.createElement('tr')
  510.               table.appendChild(currentRow)
  511.               cellCount = 1
  512.             }
  513.             const cell = document.createElement('td')
  514.             cell.style.display = "inline-flex"
  515.             const label = document.createElement('label')
  516.             label.htmlFor = office
  517.             label.className += "add-office-label"
  518.             label.innerHTML = office
  519.             const checkbox = document.createElement('input')
  520.             checkbox.type = "checkbox"
  521.             checkbox.id = office
  522.             checkbox.className += "add-office-checkbox"
  523.               //checkbox.style.display = "inline-block"
  524.             checkbox.style.marginRight = "5px"
  525.             const capacity = document.createElement('span')
  526.             capacity.className += "capacity_" + office
  527.               //capacity.style.display = "inline-block"
  528.             capacity.style.marginLeft = "10px"
  529.  
  530.             cell.appendChild(checkbox)
  531.             cell.appendChild(label)
  532.             cell.appendChild(capacity)
  533.             cell.style.width = "33%"
  534.             currentRow.appendChild(cell)
  535.           }
  536.         }
  537.         return table
  538.       }
  539.  
  540.       function handleAddLocation(elem){
  541.         const dateId = elem.id[elem.id.length - 1]
  542.         const locationName = elem.id.substring(0, elem.id.length - 2)
  543.         const dateElem = document.getElementById("date_custom_" + dateId)
  544.         if (elem.checked) {
  545.           if (!additionalLocationInfo[dateElem.value]) additionalLocationInfo[dateElem.value] = []
  546.           additionalLocationInfo[dateElem.value].push(locationName)
  547.         } else {
  548.           const removed = additionalLocationInfo[dateElem.value].splice(additionalLocationInfo[dateElem.value].indexOf(locationName), 1)
  549.           if (!additionalLocationInfo[dateElem.value].length) delete additionalLocationInfo[dateElem.value]
  550.         }
  551.         populateAddLocation()
  552.       }
  553.  
  554.       function populateAddLocation(){
  555.         fsNative.addloc.innerHTML = JSON.stringify(additionalLocationInfo)
  556.         var text = []
  557.         for (let date in additionalLocationInfo) {
  558.           text.push(`${date}: ${additionalLocationInfo[date].join(", ")}`)
  559.         }
  560.         fsNative.addloc_text.innerHTML = text.join("; \n")
  561.       }
  562.     }
  563.  
  564.     if (window.location.pathname === "/support/catalog/items/136") {
  565.       const durationList = {
  566.         "...": false,
  567.         "Full day": true,
  568.         "Half day": true,
  569.         "Short visit (up to 2 hours)": false
  570.       }
  571.       const officeList = {
  572.         "...": false,
  573.         "Toronto": true,
  574.         "Lviv": true,
  575.         "Lab64": true,
  576.         "Lab72": true,
  577.         "Lab72 / 1": false,
  578.         "Rancho 1": false,
  579.         "Rancho 2": false,
  580.         "QA Studio": false,
  581.         "New QA Studio": false,
  582.         "Community": false,
  583.         "Lab62": true
  584.       }
  585.       const officeMeido = {
  586.         "...": false,
  587.         "Toronto": true,
  588.         "Lviv": false,
  589.         "Lab64": true,
  590.         "Lab72": true,
  591.         "Lab72 / 1": false,
  592.         "Rancho 1": false,
  593.         "Rancho 2": false,
  594.         "QA Studio": false,
  595.         "New QA Studio": false,
  596.         "Community": false,
  597.         "Lab62": true
  598.       }
  599.       const officeCapacity = ["Toronto"]
  600.       const officeAddress = {
  601.         "...": "",
  602.         "Toronto": "м. Київ, вул. Велика Васильківська 100, 8 поверх",
  603.         "Lviv": "м. Львів, вул. Поповича, 9",
  604.         "Lab64": "м. Київ, вул. Велика Васильківська 64",
  605.         "Lab72": "м. Київ, вул. Велика Васильківська 72",
  606.         "Lab72 / 1": "м. Київ, вул. Велика Васильківська 72",
  607.         "Rancho 1": "м. Київ, пров. Малокитаївський, 12",
  608.         "Rancho 2": "м. Київ, вул. Травнева 28",
  609.         "QA Studio": "м. Київ, вул. Північно-Сирецька 1-3",
  610.         "New QA Studio": "м. Київ, просп. Перемоги 53",
  611.         "Community": "м. Київ, вул. Євгена Коновальця 44, 2 поверх",
  612.         "Lab62": "м. Київ, вул. Велика Васильківська 62"
  613.       }
  614.       const accessWeek = {
  615.         "...": false,
  616.         "Current week": true,
  617.         "Next week": true
  618.       }
  619.       const mealTypes = [
  620.         "Non-vegan",
  621.         "Vegan"
  622.       ]
  623.         var fsFields = {
  624.       duration: "requested_item_values_136_requested_item_value_attributes_cf_visit_duration_270753",
  625.       support_with_lunch: "requested_item_values_136_requested_item_value_attributes_cf_support_with_lunch_270753",
  626.       access_week: "requested_item_values_136_requested_item_value_attributes_cf_access_type_270753",
  627.       lunch_type: "requested_item_values_136_requested_item_value_attributes_cf_select_your_meal_preference_270753",
  628.       office: "requested_item_values_136_requested_item_value_attributes_cf_office_270753",
  629.       dates: [
  630.         "requested_item_values_136_requested_item_value_attributes_cf_day1_270753_date",
  631.         "requested_item_values_136_requested_item_value_attributes_cf_day2_270753_date",
  632.         "requested_item_values_136_requested_item_value_attributes_cf_day3_270753_date",
  633.         "requested_item_values_136_requested_item_value_attributes_cf_day4_270753_date",
  634.         "requested_item_values_136_requested_item_value_attributes_cf_day5_270753_date",
  635.         "requested_item_values_136_requested_item_value_attributes_cf_day6_270753_date",
  636.         "requested_item_values_136_requested_item_value_attributes_cf_day7_270753_date"            //ДОБАВИТЬ ДОПОЛНИТЕЛЬНІЕ ДНИ - скопировать айдишники каждого поля_ РЕАЛЬНІЙ РЕКВЕСТ//
  637.       ],
  638.       additional_locations: [
  639.         "requested_item_values_136_requested_item_value_attributes_cf_do_you_plan_to_visit_any_additional_location_during_the_requested_period_nbsp_270753",
  640.         "requested_item_values_136_requested_item_value_attributes_cf_additional_location_2_270753"
  641.       ],
  642.       meido: "requested_item_values_136_requested_item_value_attributes_cf_meido_body_270753",
  643.       document_text: "requested_item_values_136_requested_item_value_attributes_cf__270753",
  644.       document_check: "requested_item_values_136_requested_item_value_attributes_cf_v_270753",
  645.       addloc: "requested_item_values_149_requested_item_value_attributes_cf_additional_location_data_270753",
  646.       addloc_text: "requested_item_values_149_requested_item_value_attributes_cf_additional_location_270753"
  647.     }
  648.  
  649.       // -------------------------
  650.         var meidoActive
  651.         if (window.location.pathname === "/support/catalog/items/136") {
  652.           meidoActive = false
  653.         } else if (window.location.pathname === "/support/catalog/items/149") {
  654.           meidoActive = true
  655.         }
  656.         meidoToken = "test"
  657.       // -------------------------
  658.  
  659.       // -------------------------
  660.         var capacityActive = true
  661.       // -------------------------
  662.  
  663.           // ====================================================================
  664.           // ====================================================================
  665.           // ====================================================================
  666.  
  667.       const fsNative = {
  668.         duration: document.getElementById(fsFields.duration),
  669.         support_with_lunch: document.getElementById(fsFields.support_with_lunch).parentNode.childNodes.item(0),
  670.         access_week: document.getElementById(fsFields.access_week),
  671.         lunch_type: document.getElementById(fsFields.lunch_type),
  672.         office: document.getElementById(fsFields.office),
  673.         meido: document.getElementById(fsFields.meido),
  674.         dates: getElemList(fsFields.dates),
  675.         additional_locations: getElemList(fsFields.additional_locations),
  676.         document_text: document.getElementById(fsFields.document_text),
  677.         document_check: document.getElementById(fsFields.document_check).parentNode.childNodes.item(0),
  678.         addloc: document.getElementById(fsFields.addloc),
  679.         addloc_text: document.getElementById(fsFields.addloc_text)
  680.       }
  681.  
  682.       var activeDateCount = 0
  683.       const today = new Date()
  684.       const todayGlobal = today.toLocaleDateString()
  685.       const weekdayGlobal = today.getDay()
  686.       const currentHoursGlobal = today.getHours()
  687.       const currentMinutesGlobal = today.getMinutes()
  688.       var selectedDatesGlobal = []
  689.       var capacityCheck = true
  690.  
  691.       const durationSelector = replaceInputWithDropdown(fsFields.duration, durationList, "duration")
  692.             durationSelector.parentNode.hidden = true
  693.       const officeSelector = replaceInputWithDropdown(fsFields.office, officeList, "office")
  694.       const accessWeekSelector = replaceInputWithDropdown(fsFields.access_week, accessWeek, "access-week")
  695.       const lunchTypeSelector = createSimplifiedDropdown(fsFields.lunch_type, mealTypes, "lunch_type")
  696.       const lunchCheckboxLabel = document.createTextNode("Please support me with lunch")                          // to add text Lunch will be provided in case your visit durayion is more than 2 hours//
  697.       const lunchCheckbox = createCustomCheckbox(document.getElementById(fsFields.support_with_lunch).parentNode, "show-lunch", lunchCheckboxLabel)
  698.       const dateList = createCustomDates(fsNative.dates)
  699.       const additionalOfficesList = createAdditionalOfficeSelectors(fsFields.additional_locations, officeList)
  700.       const capacityDisplay = createCapacityDisplay(fsNative.dates[0].parentNode.parentNode)
  701.  
  702.       fsNative.addloc.parentNode.hidden = true
  703.       fsNative.addloc_text.parentNode.hidden = true
  704.       for (let elem of document.getElementsByClassName("addloc-header")) {
  705.         elem.hidden = true
  706.       }
  707.  
  708.           //add hotDeskCheckbox
  709.       const hotdeskCheckboxLabel = document.createTextNode("I don`t have a permanent seat and would like to book a hot desk.");
  710.       const hotdeskCheckboxContainer = document.createElement('div');
  711.       document.getElementById(fsFields.office).parentNode.appendChild(hotdeskCheckboxContainer);
  712.       const hotdeskCheckbox = createCustomCheckbox(hotdeskCheckboxContainer, "show-hotdesk", hotdeskCheckboxLabel);
  713.       hotdeskCheckbox.checked = false;
  714.       const hotdeskText = document.createElement("p");
  715.       hotdeskText.innerHTML = "Please, follow the <a href='https://ringukraine.officespacesoftware.com/visual-directory/floors/139' style='color:blue;cursor:pointer;' target='_blank'>link</a> for hot desks booking system (applicable only for Full/half-day visit). Here`re <a href='https://docs.google.com/document/d/1llpCz3RbK0cBew7kSJhZPQwD5Om8Kgj0tTq-1kgONx4/edit' style='color:blue;cursor:pointer;' target='_blank'>instructions</a> on how to make a booking.";
  716.       hotdeskCheckboxContainer.appendChild(hotdeskText);
  717.  
  718.       const documentCheckboxLabel = document.createElement("span")
  719.       documentCheckboxLabel.innerHTML = "Я, {{ current_user.phone }}, ознайомився з документом та підтверджую що мій стан відповідає нормам відвідування офісу згідно з заявою.<br>*[✓] <i>означає, що дана відмітка прирівнюється до власноручного/факсимільного відтворення підпису особи.</i>"
  720.       const documentCheckbox = createCustomCheckbox(fsNative.document_check.parentNode, "document-check", documentCheckboxLabel)
  721.       const documentText = createDocumentSection(fsNative.document_text, todayGlobal)
  722.  
  723.       const dateControlAdd = document.createElement("button")
  724.       dateControlAdd.innerHTML = "+"
  725.       const dateControlRemove = document.createElement("button")
  726.       dateControlRemove.innerHTML = "-"
  727.  
  728.       lunchCheckbox.parentNode.hidden = true;
  729.       lunchTypeSelector.parentNode.hidden = true;
  730.       hotdeskCheckboxContainer.hidden = true;
  731.       hotdeskText.hidden = true;
  732.  
  733.       //durationSelector.addEventListener("change", function(){ renderController() })
  734.       officeSelector.addEventListener("change", function(){ renderController() })
  735.       accessWeekSelector.addEventListener("change", function(){ renderController() })
  736.       lunchCheckbox.addEventListener("change", function(){ renderController() })
  737.       hotdeskCheckbox.addEventListener("change", function(){ renderController() })
  738.       lunchTypeSelector.addEventListener("change", function(){ renderController() })
  739.  
  740.       dateList.forEach(dateElem => {
  741.         jQuery(dateElem).datepicker("option", {
  742.           onSelect: function() {
  743.             renderController()
  744.           }
  745.         })
  746.       })
  747.  
  748.       dateControlAdd.addEventListener("click", function(e){
  749.         e.preventDefault()
  750.         activeDateCount += 1
  751.         renderController()
  752.       })
  753.       dateControlRemove.addEventListener("click", function(e){
  754.         e.preventDefault()
  755.         activeDateCount -= 1
  756.         renderController()
  757.       })
  758.       additionalOfficesList.forEach(elem => {
  759.         elem.addEventListener("change", function(){ renderController() })
  760.       })
  761.  
  762.  
  763.       documentCheckbox.addEventListener("change", function(){ renderController() })
  764.  
  765.       var meidoMenu
  766.            document.getElementById(fsFields.meido).parentNode.style.display = "none"
  767.       if (meidoActive) {
  768.  
  769.         const elems = document.getElementsByClassName("main pull-left")
  770.         meidoMenu = await meidoInit(elems[0], dateList, fsFields.meido, 125, false)  // change 125 to required limit
  771.         console.log(meidoMenu)
  772.         meidoMenu.hidden = true
  773.         console.log("calling renderController")
  774.         renderController()
  775.       } else {
  776.         renderController()
  777.       }
  778.  
  779.       jQuery("input[type=\"submit\"]").each((index, elem) => {
  780.         elem.onclick = function(e){
  781.           if (!capacityCheck) {
  782.             e.stopImmediatePropagation()
  783.             e.preventDefault()
  784.               alert("Please check the capactiy for selected dates")                     //поменять нотифай если нужно!//
  785.           }
  786.         }
  787.       })
  788.  
  789.       function renderController(){
  790.         var values = {
  791.           //duration: durationSelector.value,
  792.           duration: "Full day",
  793.           office: officeSelector.value,
  794.           access_week: accessWeekSelector.value
  795.         }
  796.  
  797.         fsNative.duration.value = values.duration === "..." ? "" : values.duration
  798.         fsNative.office.value = values.office === "..." ? "" : values.office
  799.            if (fsNative.office.value === 'Toronto') {
  800.             hotdeskCheckboxContainer.hidden = false;
  801.           } else {
  802.             hotdeskCheckbox.checked = false;
  803.             hotdeskCheckboxContainer.hidden = true;
  804.           }
  805.         if (!hotdeskCheckbox.checked) {
  806.                 hotdeskText.hidden = true;
  807.             } else {
  808.                 hotdeskText.hidden = false;
  809.             }
  810.  
  811.         const accessWeekChanged = fsNative.access_week.value === values.access_week ? false : true
  812.         fsNative.access_week.value = values.access_week === "..." ? "" : values.access_week
  813.         var datesInRequest = dateList.map(x => x.value).filter(x => !!x)
  814.         if (activeDateCount === 0) datesInRequest = datesInRequest[0] ? [datesInRequest[0]] : []
  815.         const today = new Date().toISOString().split("T")[0]
  816.         if (durationList[values.duration] && officeList[values.office] && accessWeek[values.access_week] && datesInRequest.length && !(datesInRequest.length === 1 && datesInRequest[0] === today) && !accessWeekChanged) {
  817.           lunchCheckbox.parentNode.hidden = false
  818.         } else {
  819.           lunchCheckbox.parentNode.hidden = true
  820.           lunchCheckbox.checked = false
  821.         }
  822.  
  823.         values.support_with_lunch = lunchCheckbox.checked
  824.         fsNative.support_with_lunch.value = lunchCheckbox.checked ? "1" : "0"
  825.         if (values.support_with_lunch) {
  826.           if (meidoActive) {
  827.             if (weekdayGlobal === 6 || weekdayGlobal === 0 || (weekdayGlobal === 5 && currentHoursGlobal >= 19 && currentMinutesGlobal >= 30) || values.access_week === "Current week" || !officeMeido[values.office]) {
  828.               lunchTypeSelector.parentNode.hidden = false
  829.               lunchTypeSelector.value = lunchTypeSelector.value ? lunchTypeSelector.value : mealTypes[0]
  830.               meidoMenu.hidden = true
  831.             } else {
  832.               lunchTypeSelector.parentNode.hidden = true
  833.               lunchTypeSelector.value = null
  834.               meidoMenu.hidden = false
  835.             }
  836.           } else {
  837.             lunchTypeSelector.parentNode.hidden = false
  838.             lunchTypeSelector.value = lunchTypeSelector.value ? lunchTypeSelector.value : mealTypes[0]
  839.           }
  840.         } else {
  841.           lunchTypeSelector.parentNode.hidden = true
  842.           lunchTypeSelector.value = null
  843.           if (meidoActive) meidoMenu.hidden = true
  844.         }
  845.  
  846.         values.lunch_type = lunchTypeSelector.value
  847.         fsNative.lunch_type.value = values.lunch_type ? values.lunch_type : ""
  848.  
  849.         const dateLimits = (values.access_week === "...") ? null : calcDateLimits(values.access_week === "Current week" ? true : false)
  850.         const dateLimitsRaw = dateLimits ? dateLimits.map(x => new Date(x).valueOf()) : null
  851.         var existingDates = []
  852.         var lastUsedFound = false;
  853.         if (accessWeekChanged) activeDateCount = 0
  854.         dateList.forEach((dateElem, index) => {
  855.           const dateNativeElem = fsNative.dates[index]
  856.           const timeNativeElem = document.getElementById(fsFields.dates[index].substring(0, fsFields.dates[index].length - 4) + "time")
  857.           const errorElem = document.getElementById("date_custom_" + (index+1) + "-error")
  858.           if (errorElem) errorElem.style.display = "none"
  859.           if (accessWeekChanged && index === 0) dateElem.value = null
  860.           const dateRawValue = new Date(dateElem.value).valueOf()
  861.           if (existingDates.includes(dateRawValue)) dateElem.value = null
  862.           if (dateLimits) {
  863.             jQuery("#date_custom_"+(index+1)).datepicker("option", {
  864.               minDate: new Date(dateLimits[0]),
  865.               maxDate: new Date(dateLimits[1])
  866.             })
  867.             dateElem.disabled = false
  868.             if (dateRawValue < dateLimitsRaw[0] || dateRawValue > dateLimitsRaw[1]) dateElem.value = null
  869.           } else {
  870.             dateElem.disabled = true
  871.           }
  872.           existingDates.push(dateRawValue)
  873.           const controlWrapper = document.getElementById("controls_" + index)
  874.           controlWrapper.innerHTML = ""
  875.           if (dateElem.value) {
  876.             dateNativeElem.value = reverseForFS(dateElem.value)
  877.             timeNativeElem.value = "00:00"
  878.           } else {
  879.             dateNativeElem.value = null
  880.             timeNativeElem.value = null
  881.           }
  882.           controlWrapper.style.display = "inline"
  883.           if (index < activeDateCount) {
  884.             dateElem.disabled = true
  885.             dateElem.parentNode.style.display = "block"
  886.           } else if (index === activeDateCount) {
  887.             if (dateLimits) dateElem.disabled = false
  888.             if (index > 0 && dateList[index-1].value) {
  889.               const nextDate = new Date(dateList[index-1].value)
  890.               nextDate.setDate(nextDate.getDate() + 1)
  891.               jQuery("#date_custom_"+(index+1)).datepicker("option", {
  892.                 minDate: nextDate
  893.               })
  894.             }
  895.             dateElem.parentNode.style.display = "block"
  896.             if (activeDateCount > 0) controlWrapper.appendChild(dateControlRemove)
  897.             if (activeDateCount < dateList.length-1) {
  898.               controlWrapper.appendChild(dateControlAdd)
  899.               dateControlAdd.disabled = !dateElem.value
  900.             }
  901.           } else {
  902.             dateElem.parentNode.style.display = "none"
  903.             dateElem.value = null
  904.             dateNativeElem.value = null
  905.             timeNativeElem.value = null
  906.           }
  907.         })
  908.  
  909.  
  910.           if (capacityActive === true) {
  911.         const selectedDates = dateList.map(x => x.value).filter(x => !!x)
  912.         if (officeCapacity.includes(values.office) && selectedDates.length && JSON.stringify(selectedDates) !== selectedDatesGlobal) {
  913.           fetch(`https://freshservicecounter.ringteam.com/getcapacity?office=${values.office}&dates=${JSON.stringify(selectedDates)}`)
  914.           .then(res => {
  915.             return res.json()
  916.           })
  917.           .then(res => {
  918.             console.log(res)
  919.             capacityDisplay.innerHTML = ""
  920.             const office = document.createElement("div")
  921.             office.innerHTML = `<b>Office:</b> ${res.office}`
  922.             const limit = document.createElement("div")
  923.             limit.innerHTML = `<b>Limit:</b> ${res.limit} visitors per day`
  924.             limit.style.borderBottom = "1px dotted grey"
  925.             capacityDisplay.appendChild(office)
  926.             capacityDisplay.appendChild(limit)
  927.             var capacityDataArray = []
  928.             for (let date in res.capacity) {
  929.               capacityDataArray.push({ date: date, capacity: res.capacity[date] })
  930.             }
  931.             capacityDataArray.sort((x,y) => { return x.date > y.date ? 1 : -1 })
  932.             console.log(capacityDataArray)
  933.             capacityDataArray.forEach(obj => {
  934.               const dateElem = document.createElement("div")
  935.               dateElem.innerHTML = `<b>${obj.date}:</b> ${obj.capacity} visitors confirmed`
  936.               if (obj.capacity / res.limit >= 0.7) dateElem.style.color = "orange"
  937.                 if (obj.capacity >= res.limit){
  938.                 dateElem.style.color = "red"
  939.                 capacityCheck = false
  940.               }
  941.               capacityDisplay.appendChild(dateElem)
  942.             })
  943.             capacityDisplay.hidden = false
  944.           })
  945.         } else {
  946.           //capacityDisplay.innerHTML = ""
  947.           if (!officeCapacity.includes(values.office)) capacityDisplay.hidden = true
  948.         }
  949.         selectedDatesGlobal = JSON.stringify(selectedDates)
  950.         }
  951.         if (meidoActive && values.access_week === "Next week") {
  952.           meidoCart.calcDateCollection()
  953.         } else {
  954.           fsNative.meido.innerHTML = null
  955.         }
  956.  
  957.         values.additional_offices = []
  958.         additionalOfficesList.forEach((elem, index) => {
  959.           values.additional_offices.push(elem.value)
  960.           if ((index === 0 && values.office !== "...") || (index > 0 && values.additional_offices[index-1] !== "...")) {
  961.             elem.parentNode.style.display = "block"
  962.           } else {
  963.             elem.parentNode.style.display = "none"
  964.             elem.value = "..."
  965.           }
  966.           fsNative.additional_locations[index].value = elem.value === "..." ? null : elem.value
  967.         })
  968.  
  969.         values.document_check = documentCheckbox.checked
  970.         fsNative.document_check.value = documentCheckbox.checked ? "1" : "0"
  971.         fsNative.document_check.checked = documentCheckbox.checked
  972.         const documentLocations = [values.office, values.additional_offices].flat().map(x => officeAddress[x]).filter(x => !!x).join(", ")
  973.         document.getElementById("doc-address").innerHTML = documentLocations
  974.         // =================================================
  975.         var text = `Заява на допуск до користування Простором Товариства з обмеженою відповідальністю «ТекХостинг» (далі – ТОВ «ТекХостинг»)
  976.  
  977. Я, фізична особа-підприємець ${"{{ current_user.phone }}"}, прошу допустити мене до користування офісним простором ТОВ «ТекХостинг» (далі – Простір), що знаходиться за адресою: ${documentLocations}.
  978.  
  979.  
  980. Я підтверджую, що на момент надання мені доступу до користування Простором:
  981.  
  982. • у мене відсутні будь-які ознаки ГРВІ, а саме: підвищена температура тіла (більше 37,2 С), кашель, утруднене дихання тощо;
  983. • я ознайомлений(а) з рекомендаціями МОЗ та ВООЗ щодо попередження зараження COVID-19 та їх дотримуюсь;
  984. • протягом останніх 14 днів я не перебував(ла) за межами України та не контактував(ла) з особами, щодо яких наявна підозра/хворими на COVID-19.
  985.  
  986. Я зобов’язуюсь під час користування Простором дотримуватися посилених санітарно-гігієнічних норм, а також рекомендацій МОЗ та ВООЗ щодо запобігання поширенню COVID-19, а саме:
  987.  
  988. • носити медичну маску/респіратор;
  989. • ретельно мити руки з милом протягом 20-40 сек. та регулярно обробляти їх антисептичним засобом під час перебування в Просторі;
  990. • дотримуватися дистанції min 1,5 (півтора) метри від інших відвідувачів Простору.
  991.  
  992. Дата: ${todayGlobal}`
  993.         // =================================================
  994.         fsNative.document_text.value = text
  995.       }
  996.     }
  997. })
  998. </script>
  999.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement