[av_google_map height=’230px’ zoom=’12’ saturation=’fill’ hue=’#395e7b’ maptype_control=» maptype_id=» av_uid=’av-2o93y4′]
[av_gmap_location address=’Main Street’ city=» country=’USA’ long=’-78.71148149999999′ lat=’42.9658936′ marker=’837′ imagesize=’40’ av_uid=’av-6mphg’][/av_gmap_location]
[/av_google_map]
[av_section min_height=» min_height_px=’500px’ padding=’huge’ shadow=’no-shadow’ bottom_border=’no-border-styling’ bottom_border_diagonal_color=’#333333′ bottom_border_diagonal_direction=» bottom_border_style=» custom_arrow_bg=» id=» color=’main_color’ background=’bg_color’ custom_bg=» background_gradient_color1=» background_gradient_color2=» background_gradient_direction=’diagonal_tb’ src=» attachment=» attachment_size=» attach=’scroll’ position=’top left’ repeat=’no-repeat’ video=» video_ratio=’16:9′ overlay_opacity=’0.5′ overlay_color=» overlay_pattern=» overlay_custom_pattern=» av_element_hidden_in_editor=’0′ av_uid=’av-145nae’]
[av_one_half first min_height=» vertical_alignment=’av-align-top’ space=» margin=’0px’ margin_sync=’true’ padding=’0px’ padding_sync=’true’ border=» border_color=» radius=’0px’ radius_sync=’true’ background_color=» src=» attachment=» attachment_size=» background_position=’top left’ background_repeat=’no-repeat’ animation=’bottom-to-top’ av_uid=’av-1kbp16′]
[av_heading tag=’h4′ padding=’10’ heading=’Get in touch’ color=» style=’blockquote modern-quote’ custom_font=» size=’50’ subheading_active=» subheading_size=’15’ custom_class=» admin_preview_bg=» av-desktop-hide=» av-medium-hide=» av-small-hide=» av-mini-hide=» av-medium-font-size-title=» av-small-font-size-title=» av-mini-font-size-title=» av-medium-font-size=» av-small-font-size=» av-mini-font-size=» margin=» av_uid=’av-t0tjo’][/av_heading]
[av_contact email=’mail@enfold-minimal.com’ title=» button=’Submit’ on_send=» sent=’Your message has been sent! Thanks a lot for contacting me, I will reply as fast as humanly possible. Thats usually within 2 workdays :)’ link=’manually,http://’ subject=» autorespond=» captcha=» hide_labels=’aviaTBhide_labels’ form_align=» color=» av_uid=’av-15kpak’ admin_preview_bg=»]
[av_contact_field label=’Name’ type=’text’ options=» check=’is_empty’ width=’element_half’ av_uid=’av-gl5t0′ multi_select=» av_contact_preselect=»][/av_contact_field]
[av_contact_field label=’E-Mail’ type=’text’ options=» check=’is_email’ width=’element_half’ av_uid=’av-aysb8′ multi_select=» av_contact_preselect=»][/av_contact_field]
[av_contact_field label=’Phone’ type=’text’ options=» check=» width=’element_half’ av_uid=’av-jum78′][/av_contact_field]
[av_contact_field label=’City/Town’ type=’text’ options=» check=» width=’element_half’ av_uid=’av-4xl8′][/av_contact_field]
[av_contact_field label=’Message’ type=’textarea’ check=’is_empty’ options=» multi_select=» width=» av_uid=’av-dldek’ av_contact_preselect=»][/av_contact_field]
[/av_contact]
[av_codeblock wrapper_element=» wrapper_element_attributes=» codeblock_type=» alb_description=» id=» custom_class=» template_class=» av_uid=’av-m2xlwtl1′ sc_version=’1.0′]
document.getElementById('item-form').addEventListener('submit', function(event) { event.preventDefault(); // Prevent the default form submission
//const nameValue = document.getElementById('q1').value.trim(); const nameValue = document.getElementById('q1').value; console.log(nameValue) const phoneValue = document.getElementById('q2').value; const emailValue = document.getElementById('q3').value;
if (!nameValue || !phoneValue) { alert('Пожалуйста, заполните имя и телефон'); } else { const formData = new FormData(this); // Get form data
var formValues = {}; // Object to store form values var fieldGroups = [];
formData.forEach(function(value, key){ formValues[key] = value;
const groupIndex = parseInt(key.replace(/\D/g, '')); // Extract group index from input name if (!fieldGroups[groupIndex]) { fieldGroups[groupIndex] = {}; } fieldGroups[groupIndex][key] = value; });
//console.log(formValues); // Display form values in the console console.log(fieldGroups); // Display form values grouped by field groups // Create modal element const modal = document.createElement('div'); modal.style.position = 'fixed'; modal.style.top = '50%'; modal.style.left = '50%'; modal.style.transform = 'translate(-50%, -50%)'; modal.style.background = '#efeeb7'; modal.style.padding = '20px'; modal.style.border = '1px solid #ccc'; modal.style.zIndex = '9999'; modal.style.display = 'flex'; modal.style.alignItems = 'center';
// Add message to the modal const message = document.createElement('div'); message.textContent = 'Ваш запрос в обработке'; modal.appendChild(message);
// Add spinning circle element (spinner) to the modal const spinner = document.createElement('div'); spinner.classList.add('spinner'); spinner.style.border = '4px solid rgba(0, 0, 0, 0.1)'; spinner.style.borderTop = '4px solid #333'; spinner.style.borderRadius = '50%'; spinner.style.width = '20px'; spinner.style.height = '20px'; spinner.style.marginLeft = '10px'; spinner.style.animation = 'spin 0.6s linear infinite';
modal.appendChild(spinner);
document.body.appendChild(modal);
const webhook = 'https://ramad-ved.bitrix24.ru/rest/23/lma031o6k9af3l4k/'; var contact = '' const data = { 'fields':{ 'NAME': `${nameValue}`, 'PHONE': [{ VALUE: phoneValue, VALUE_TYPE: "WORK" }], 'EMAIL': [{ VALUE: emailValue, VALUE_TYPE: "WORK" }] } };
fetch(`${webhook}/crm.contact.add`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { console.log(result, 'смотри есть айди реквезита'); contact = result console.log('Что с контактом ', contact) const data1 = { 'fields':{ 'CONTACT_ID': `${result['result']}`, 'TITLE': 'Новая сделка - заявка с сайта', 'SOURCE_ID': 'UC_K5AOPV', } };
fetch(`${webhook}/crm.deal.add`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data1) }) .then(response => response.json()) .then(result => { console.log(result['result'], 'смотри есть айди реквезита сделки'); //for (const element of fieldGroups) { // console.log(element); // Вывод каждого элемента массива в консоль //} console.log('Обрати внимание ---> ', fieldGroups)
Object.keys(fieldGroups).forEach(key => { console.log(key); console.log(fieldGroups[key]);
tt = fieldGroups[key] console.log('Это тт', tt) var name1 = ''
Object.keys(tt).forEach(key => { if (tt[key].hasOwnProperty('name')) { console.log('Полный ключ, содержащий "name":', key); name1 = tt[key] } }); var keyWithFullName = Object.keys(tt).find(key => key.includes('name')); console.log('Полный ключ, содержащий "name":', keyWithFullName); name1 = keyWithFullName
var name2 = '' var keyWithFullName1 = Object.keys(tt).find(key => key.includes('unit')); //console.log('Полный ключ, содержащий "name":', keyWithFullName); name2 = keyWithFullName1
var name3 = '' var keyWithFullName3 = Object.keys(tt).find(key => key.includes('quantity')); //console.log('Полный ключ, содержащий "name":', keyWithFullName); name3 = keyWithFullName3
var name4 = '' var keyWithFullName4 = Object.keys(tt).find(key => key.includes('places')); //console.log('Полный ключ, содержащий "name":', keyWithFullName); name4 = keyWithFullName4
var name5 = '' var keyWithFullName5 = Object.keys(tt).find(key => key.includes('photo')); console.log('Полный ключ, содержащий "name555":', keyWithFullName5); name5 = keyWithFullName5
////////************* const fileInput = document.querySelector(`input[name="${name5}"]`); console.log(`input[name="${name5}"]`) const file = fileInput.files[0]; const fileName = file.name;
var fieldName = fileName;
const readAsDataURL = (file) => { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = function(event) { const base64String = event.target.result.split(',')[1]; resolve(base64String); };
reader.readAsDataURL(file); }); };
const processData = async () => { // Assuming file is defined as the file you want to convert const base64String = await readAsDataURL(file);
console.log('Base64 representation of the file:', base64String);
const data103 = { 'entityTypeId': 150, 'fields': { 'TITLE': fieldGroups[key][name1], 'ufCrm7_1714100895276': result['result'], 'ufCrm7_1714030001272': fieldGroups[key][name2], 'ufCrm7_1714030021388': fieldGroups[key][name3], 'ufCrm7_1714878325': fieldGroups[key][name4], 'ufCrm7_1714013841445': [fieldName, base64String], } };
console.log(data103); return data103 };
processData().then(data => { fetch(`${webhook}/crm.item.add`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => { if (response.ok) { console.log('Данные успешно отправлены', response); } else { console.error('Произошла ошибка при отправке данных', response); } }) .catch(error => { console.error('Произошла ошибка при отправке данных:', error); }); });
//////// 20 ////////
});
}) .catch(error => { console.error('Error:', error); });
}) .catch(error => { console.error('Error:', error); }); //// sdelka = ''
setTimeout(function() { document.body.removeChild(modal); alert('Заявка отправлена') }, 5000); // Modal disappears after 5 seconds
} });
[/av_codeblock]
[/av_one_half][av_one_half min_height=» vertical_alignment=’av-align-top’ space=» margin=’0px’ margin_sync=’true’ padding=’0px’ padding_sync=’true’ border=» border_color=» radius=’0px’ radius_sync=’true’ background_color=» src=» attachment=» attachment_size=» background_position=’top left’ background_repeat=’no-repeat’ animation=’bottom-to-top’ av_uid=’av-1kbp16-1′]
[av_heading tag=’h4′ padding=’10’ heading=’We are located in’ color=» style=’blockquote modern-quote’ custom_font=» size=’50’ subheading_active=» subheading_size=’15’ custom_class=» admin_preview_bg=» av-desktop-hide=» av-medium-hide=» av-small-hide=» av-mini-hide=» av-medium-font-size-title=» av-small-font-size-title=» av-mini-font-size-title=» av-medium-font-size=» av-small-font-size=» av-mini-font-size=» margin=» av_uid=’av-acuyk’][/av_heading]
[av_textblock size=» font_color=» color=» av-medium-font-size=» av-small-font-size=» av-mini-font-size=» av_uid=’av-31jcro’ admin_preview_bg=»]
Main Street 1, Williamsville
Buffalo, USA
office@enfold-law.com
+555 334 759 213
[/av_textblock]
[av_textblock size=» font_color=» color=» av_uid=’av-175vxm’]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.
[/av_textblock]
[/av_one_half][/av_section]