Oferta

Ofertă Panouri Publicitare Stradale

Furnizor:

Oras:

Adresa:

Judet:

Poza:

Format:

Numar fete:

Cod:

Locatie:

Marime:

Suprafata:

Decor:

GPS:

Tip strada:

Link Google Maps:

Map:

Schita productie:

Perioada Start:

Perioada End:

document.getElementById(‘export-btn’).addEventListener(‘click’, function () {
const allPosts = document.querySelectorAll(‘.brz-posts__item’); // Select all posts
const selectedPosts = [];

// Collect data from selected posts
allPosts.forEach((post) => {
const checkbox = post.querySelector(‘input[name=”select-post”]’); // Select the checkbox inside the post
if (checkbox && checkbox.checked) {
const spans = post.querySelectorAll(“span.text-population”);
const links = post.querySelectorAll(“.link–external”);

const furnizorElement = spans[0];
const orasElement = spans[1];
const adresaElement = spans[2];
const pictureEl = links[0]; // Assuming the picture link is the first in the list
const formatElement = spans[4];
const numarFeteElement = spans[5];
const codElement = spans[6];
const locationElement = spans[7];
const sizeElement = spans[8];
const surfaceElement = spans[9];
const decorElement = spans[10];
const gpsElement = spans[11];
const linkGoogleMapsElement = links[1]; // Google Maps link
const mapElement = links[2]; // Map link
const schitaProductieElement = links[3]; // Schita Productie link

const furnizor = furnizorElement ? furnizorElement.innerText.trim() : ‘No Furnizor Found’;
const oras = orasElement ? orasElement.innerText.trim() : ‘No Oras Found’;
const adresa = adresaElement ? adresaElement.innerText.trim() : ‘No Adresa Found’;
const picture = pictureEl ? pictureEl.href : ‘No Image Link Found’;
const format = formatElement ? formatElement.innerText.trim() : ‘No Format Found’;
const numarFete = numarFeteElement ? numarFeteElement.innerText.trim() : ‘No Numar Fete Found’;
const cod = codElement ? codElement.innerText.trim() : ‘No Cod Found’;
const location = locationElement ? locationElement.innerText.trim() : ‘No Location Found’;
const size = sizeElement ? sizeElement.innerText.trim() : ‘No Size Found’;
const surface = surfaceElement ? surfaceElement.innerText.trim() : ‘No Surface Found’;
const decor = decorElement ? decorElement.innerText.trim() : ‘No Decor Found’;
const gps = gpsElement ? gpsElement.innerText.trim() : ‘No GPS Found’;
const linkGoogleMaps = linkGoogleMapsElement ? linkGoogleMapsElement.href : ‘No Google Maps Link Found’;
const map = mapElement ? mapElement.href : ‘No Map Link Found’;
const schitaProductie = schitaProductieElement ? schitaProductieElement.href : ‘No Schita Productie Link Found’;

selectedPosts.push({
Furnizor: furnizor,
Oras: oras,
Adresa: adresa,
Picture: picture,
Format: format,
Numar_Fete: numarFete,
Cod: cod,
Location: location,
Size: size,
Surface: surface,
Decor: decor,
GPS: gps,
Google_Maps_Link: linkGoogleMaps,
Map: map,
Schita_Productie: schitaProductie
});
}
});

if (selectedPosts.length === 0) {
alert(‘Please select at least one post to export.’);
return;
}

const worksheet = XLSX.utils.json_to_sheet(selectedPosts); // Convert JSON data to worksheet

// Add hyperlinks to specific columns
selectedPosts.forEach((post, index) => {
const rowIndex = index + 2; // Row index starts at 2 (1-based indexing)
if (post.Picture !== ‘No Image Link Found’) {
worksheet[`D${rowIndex}`] = { t: ‘s’, v: ‘Click aici’, l: { Target: post.Picture } }; // Picture link
}
if (post.Google_Maps_Link !== ‘No Google Maps Link Found’) {
worksheet[`M${rowIndex}`] = { t: ‘s’, v: ‘Click aici’, l: { Target: post.Google_Maps_Link } }; // Google Maps link
}
if (post.Map !== ‘No Map Link Found’) {
worksheet[`N${rowIndex}`] = { t: ‘s’, v: ‘Click aici’, l: { Target: post.Map } }; // Map link
}
if (post.Schita_Productie !== ‘No Schita Productie Link Found’) {
worksheet[`O${rowIndex}`] = { t: ‘s’, v: ‘Click aici’, l: { Target: post.Schita_Productie } }; // Schita Productie link
}
});

const workbook = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(workbook, worksheet, ‘Posts’); // Append the worksheet to the workbook

// Generate current date and time for filename
const now = new Date();
const date = now.toISOString().split(‘T’)[0]; // YYYY-MM-DD
const time = now.toTimeString().split(‘ ‘)[0].replace(/:/g, ‘-‘); // HH-MM-SS

const fileName = `Disponibil VanBerry ${date} – ${time}.xlsx`;

// Download the Excel file
XLSX.writeFile(workbook, fileName);
});

© Copyright 2025. Toate drepturile rezervate VAN BERRY HIGHWAY MEDIA