function ConfirmationPage() { var self = this; var imageCdn = "https://i.static-companeo.com"; var contextVersion = "?23.10.26"; var visibilityNumber = 4; var ret = ``; var facHtmlList = []; var userData = {}; var confirmation_text = { "bb_survey_confirmation_modal_address_title": "To help us find more suppliers that meet your needs, please add your business address.", "lib_address": "Address:", "bb_api_field_error": "Oops! Please fill in this field ...", "cancel": "Cancel", "btn_finish": "Submit", "bb_confirmation_page_user_request_recorded_success": function (fullname) { return `Thank you ${fullname} ,
Your request has been taken into account!` }, "bb_api_confirm_rfq_saved": "QUOTATION(S) REQUEST(S) REGISTERED", "bb_api_confirm_goto_extranet": 'You can consult at any time the details of your requests on your account Companeo.', "ph_confirm_page_ft_intro": "Here is the list of suppliers to whom we will send your request.", "ph_confirm_page_click_intro": "Following your request, we have selected the following service providers.
Visit their website to get more detail on their offers and subscribe directly online:", "ph_confirm_page_match_intro": "Here is the list of suppliers to whom we will send your request. We may call you before sending, this call will be recorded for quality reasons.", "ph_confirm_delete_lead": "Delete this supplier", "ph_confirm_remove_fac": "Delete this supplier", "ph_confirm_page_deselect_reason": "Please select a reason", "bb_confirmation_page_supplier_cancel_reason_current_supplier": "Current supplier", "bb_confirmation_page_supplier_cancel_reason_already_work": "Has already been my supplier", "bb_confirmation_page_supplier_cancel_reason_quote_received": "Request already received", "bb_confirmation_page_supplier_cancel_reason_bad_reputation": "Poor reputation", "bb_confirmation_page_supplier_cancel_reason_other": "Other", "bb_api_confirm_call_back_title": "In order to allow you to receive your quotes as quickly as possible, we may call you.", "bb_api_confirm_next_step_title": "Now what?", "bb_api_confirm_next_step_extranet": "Find all your information on your Companeo account, as well as the suppliers contact details who will carry out your quotes.", "bb_api_confirm_tricks": "TIP", "bb_api_confirm_buyingguide": function (category_name) { return `Buy smart with our buying guide ${category_name} !` }, "bb_api_confirm_tricks": "TIP", "bePrefix": '', "ph_confirm_page_registered_request": `Your requests have been registered`, "ph_confirm_page_transmit_request": `We are transmitting your information to our suppliers`, "ph_confirm_page_contact": `You will be contacted shortly`, "ph_confirm_page_request_number": `ph_confirm_page_request_number`, "ph_confirm_page_fac_list": `Which suppliers will contact you?`, "ph_confirm_page_fac_default_description": `Companeo Approved Supplier in :1`, "ph_confirm_page_fac_learn_more": `Find out more`, "ph_confirm_page_delete_fac": `To deselect some suppliers`, "ph_confirm_page_delete_fac_cta": `click here`, "ph_confirm_page_delete_fac_cta_abort": `Cancel`, "ph_confirm_page_qa_no_cas_available": `Unfortunately, we don’t have a supplier at the moment`, "ph_confirm_page_qa_no_cas_available_detail": `We’ll get back to you if a supplier matches your request`, "ph_confirm_page_no_cas_available": `Unfortunately, we don’t have a supplier at the moment`, "ph_confirm_page_companeo_call_back": `We’ll get back to you if a supplier matches your request`, }; function __(value, val) { return (typeof confirmation_text[value] == 'function') ? confirmation_text[value](val) : confirmation_text[value]; } _removeSelected = function(e) { // remove selected items from data and send information to the server let checkedList = e.closest(".presta-list").querySelectorAll('input[class=prestaSelection]:checked'); if (checkedList.length > 0) { checkedList.forEach((elem) => { let data = { ...elem.dataset, ...{"reason": "CAS deselected by user"} }; delete userData.blockList[data.listindex].facList[data.itemindex] store.removeFac(data); }) // reindex array userData.blockList[e.dataset.listindex].facList = userData.blockList[e.dataset.listindex].facList.filter(val => val); // remove all elements let cardList = e.closest(".presta-list").querySelectorAll('.card-presta'); for (let i = 0; i < cardList.length; i++) { cardList[i].remove() } // find after what element to add the new html let d1 = e.closest(".presta-list").querySelector('.presta-list__cat'); // generate and insert a new html d1.insertAdjacentHTML('afterend', _facList(userData.blockList[e.dataset.listindex], e.dataset.listindex)); } let nextElement = e.nextElementSibling; while (nextElement) { if (nextElement.classList.contains('presta-footer')) { const initialText = __('ph_confirm_page_delete_fac_cta'); const textNextToBtn = __('ph_confirm_page_delete_fac') + ' '; const initialTextNode = document.createTextNode(textNextToBtn); nextElement.firstChild.textContent = initialText; nextElement.prepend(initialTextNode); break; } nextElement = nextElement.nextElementSibling; } removeAllVisibility(e); } _toggleAllVisibility = function(e) { // change text const initialText = __('ph_confirm_page_delete_fac_cta'); const textNextToBtn = __('ph_confirm_page_delete_fac') + ' '; if (e.textContent.toLowerCase().includes(initialText.toLowerCase())) { // check if the first element is a text node // then remove it if (e.parentElement.childNodes[0].nodeType === 3) { e.parentElement.removeChild(e.parentElement.childNodes[0]); } e.textContent = __('ph_confirm_page_delete_fac_cta_abort'); // show trash button e.closest(".presta-list").querySelector(".presta-trash").style.display = "block" // show checkboxes e.closest(".presta-list").classList.add('show-checkbox') } else { const initialTextNode = document.createTextNode(textNextToBtn); const pNode = e.parentElement; pNode.prepend(initialTextNode); e.textContent = initialText; removeAllVisibility(e); } } const removeAllVisibility = function (e) { // show trash button e.closest(".presta-list").querySelector(".presta-trash").style.display = "none" // show checkboxes e.closest(".presta-list").classList.remove('show-checkbox') } // self.test = function () { // // Good data for test : remove after development + integration // var ldata = `{"status": "success", "message": "getConfirmation", "data": {"fullname": "rf BALTARD", "cliId": 9190271, "ratioMax": 4, "blockList": [{"categoryList": {"name": "VoIP, Voix sur IP, telephonie IP", "rfq_id": 20408110 }, "guideBlocks": [{"cat_id": "6062", "group_categ": "636010", "cat_type": "Primary", "visible": true, "group_qa_active": true, "cat_lib": "Opérateurs telecoms et FAI", "rfq_image": "https://www.lcompaneo-fr.lan/i/fr_FR/rfq/_6062.jpeg", "permalink_url": "operateur-telecoms", "cg_portal_url": "https://www.lcompaneo-fr.lan/operateur-telecoms"}, {"cat_id": "1341", "group_categ": "740010", "cat_type": "Focus", "visible": true, "group_qa_active": true, "cat_lib": "Fournisseur délectricité", "rfq_image": "https://www.lcompaneo-fr.lan/i/fr_FR/rfq/1341_1341.jpeg", "permalink_url": "energie-fournisseur-electricite-gaz", "cg_portal_url": "https://www.lcompaneo-fr.lan/energie-fournisseur-electricite-gaz"}, {"cat_id": "344", "group_categ": "207010", "cat_type": "Primary", "visible": true, "group_qa_active": true, "cat_lib": "Permanence Téléphonique", "rfq_image": "https://www.lcompaneo-fr.lan/i/fr_FR/rfq/344_344.jpeg", "permalink_url": "permanence-telephonique", "cg_portal_url": "https://www.lcompaneo-fr.lan/permanence-telephonique"} ], "facList": [{"facName": "FMI TELECOM", "tradingName": "FMI TELECOM", "facId": "202357", "permalinkFacHomepage": "https://www.lcompaneo-fr.lan/standard-telephonique/annuaire/fmi-telecom", "isUrlActive": true, "offerId": "58143", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/202357.gif", "fac_resume": "est un opérateur de télécommunication proposant ses services sur les 3 principaux réseaux Orange, SFR et Bouygues Télécom. ", "pack_online": false }, {"facName": "MY IBS", "tradingName": "MY IBS", "facId": "175557", "permalinkFacHomepage": "https://www.lcompaneo-fr.lan/standard-telephonique/annuaire/my-ibs", "isUrlActive": true, "offerId": "58431", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/175557.gif", "fac_resume": "
le spécialiste de la bureautique pour les TPE/ PME depuis plus de 8 ans. 
Les domaines de limprimerie, des télécoms et de linformatique sont nos 3 compétences.
", "pack_online": false }, {"facName": "ETM", "tradingName": "ETM", "facId": "194892", "permalinkFacHomepage": "https://www.lcompaneo-fr.lan/standard-telephonique/annuaire/etm", "isUrlActive": true, "offerId": "56981", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/194892.gif", "fac_resume": "intégrateur et opérateur de nouvelle génération, fournit des solutions Télécoms innovantes aux Entreprises depuis plus de 40 ans. 
Installation de standard téléphonique, Téléphonie VoIP dans le Cloud (IP Centrex), Fibre optique, outils collaboratifs et sécurité.
", "pack_online": false }, {"facName": "TECH TELECOM", "tradingName": "TECH TELECOM", "facId": "41685", "permalinkFacHomepage": "", "isUrlActive": false, "offerId": "43671", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": null, "fac_resume": "", "pack_online": false }, {"facName": "KERTEL", "tradingName": "KERTEL", "facId": "188172", "permalinkFacHomepage": "", "isUrlActive": false, "offerId": "56416", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": null, "fac_resume": "", "pack_online": false }, {"facName": "BOUYGUES TELECOM ENTREPRISES", "tradingName": "BOUYGUES TELECOM ENTREPRISES", "facId": "192146", "permalinkFacHomepage": "", "isUrlActive": false, "offerId": "55384", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/192146.gif", "fac_resume": "", "pack_online": false }, {"facName": "CUBE", "tradingName": "CUBE", "facId": "6824", "permalinkFacHomepage": "https://www.lcompaneo-fr.lan/standard-telephonique/annuaire/cube", "isUrlActive": true, "offerId": "12209", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/6824.gif", "fac_resume": " existe depuis 2002. Dirigée par Cyrille PATRIGEON, elle propose d’accompagner les PMI, PME et TPE de Paris et sa région dans la conception, l’installation, le suivi et la maintenance de leurs réseaux informatiques et téléphoniques. Sa vocation ? Proposer un service de qualité, une solution globale et une tranquillité aux entreprises. Informatique, infogérance, téléphonie et solutions de mobilité, Cube s’occupe des réseaux, de la prévention des problèmes techniques éventuels, d’être un interlocuteur et une solution unique avec Be Cube ! et des techniciens experts dédiés.", "pack_online": false }, {"facName": "PRECTEL", "tradingName": "PRECTEL", "facId": "6427", "permalinkFacHomepage": "https://www.lcompaneo-fr.lan/standard-telephonique/annuaire/prectel", "isUrlActive": true, "offerId": "11224", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/6427.gif", "fac_resume": "

est intégrateur de solutions de communication pour les TPE/PME depuis 1949.

 

 

", "pack_online": false }, {"facName": "5EME AVENUE", "tradingName": "5EME AVENUE", "facId": "172746", "permalinkFacHomepage": "", "isUrlActive": false, "offerId": "51065", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": null, "fac_resume": "", "pack_online": false }, {"facName": "SISTEO COMMUNICATIONS", "tradingName": "SISTEO COMMUNICATIONS", "facId": "12569", "permalinkFacHomepage": "", "isUrlActive": false, "offerId": "31479", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/12569.gif", "fac_resume": "est spécialisé depuis 2005, sur les systèmes téléphoniques, informatiques, périphériques et sécurité.", "pack_online": false }, {"facName": "Paritel", "tradingName": "Paritel", "facId": "5158", "permalinkFacHomepage": "https://www.lcompaneo-fr.lan/standard-telephonique/annuaire/paritel", "isUrlActive": true, "offerId": "35454", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": "/i/fr_FR/faclogobig/5158.gif", "fac_resume": ", filiale du Groupe Global Concept, est le spécialiste des solutions télécoms pour les TPE-PME et professions libérales.", "pack_online": false }, {"facName": "E - LEADS Distributeur BOUYGUES", "tradingName": "E - LEADS Distributeur BOUYGUES", "facId": "13478", "permalinkFacHomepage": "", "isUrlActive": false, "offerId": "34724", "rfqId": "20408110", "cliId": 9190271, "ratioMax": 4, "bigLogo": null, "fac_resume": "est spécialisé dans les télécoms", "pack_online": false } ], "isFasttracked": false, "isClic": false, "isMatch": true } ], "category_name": "VoIP, Voix sur IP, telephonie IP", "cg_permalink": "standard-telephonique"} }`; // var response = JSON.parse(ldata); // userData = response.data; // console.log(response) // document.getElementById('jsConfirmationCallback').innerHTML = self.render(userData) // } /** * Modal Address * @param data * @returns {string} */ function modalEditAddress(data) { // Modal Edit Company return `
${__("bb_api_field_error")}
icon-phone icon-confirm icon-cross icon-exclamation icon-disable icon-address ` } /** * 3 cards * @param data * @param isMatch * @returns {string} * @private */ function _cards(data, isMatch) { var rfqId = ``; for (let index in data) { if (undefined !== data[index].categoryList.rfq_id) { rfqId = `n° ${data[index].categoryList.rfq_id}`; break; } } ret = `

${__("ph_confirm_page_registered_request")}

` + `${rfqId}` + `

` + (isMatch ? __("ph_confirm_page_transmit_request") : __("ph_confirm_page_no_cas_available")) + `

` + (isMatch ? __("ph_confirm_page_contact") : __("ph_confirm_page_companeo_call_back")) + `

`; return ret; } function _cardsNoFacs(block) { return `
` + `

${block.categoryList.name}

` + `

${__('ph_confirm_page_qa_no_cas_available')}

${__('ph_confirm_page_qa_no_cas_available_detail')}

` + `
`; } /** * Fac list HTML * @param data * @returns {string} * @private */ function _listFac(data) { let cardsMatchExists = false; let cardsNoMatchExists = false; for (let x in data) { let block = data[x]; if (block.facList?.length > 0) { if (x === '0') { cardsMatchExists = true; ret = _cards(data, true); ret += `

${__('ph_confirm_page_fac_list')}

` } ret += `
` + `

${block.categoryList.name}

`; ret += _facList(block, x) ret += `
` } else { if (x === '0') { ret += _cards(data, false); cardsNoMatchExists = true; } else if (cardsMatchExists || !cardsNoMatchExists) { ret += _cardsNoFacs(block) } } } return ret; } /** * Fac list builder * @param block * @param listindex * @returns {string} * @private */ function _facList(block, listindex) { var res = ``; var iter = block.facList.length > visibilityNumber ? visibilityNumber : block.facList.length for (let y = 0; y < iter; y++) { res += _facInfo(block.facList[y], listindex, y); } return res; } /** * Fac Information * @param facData * @param listindex * @param itemindex * @returns {string} * @private */ function _facInfo(facData, listindex, itemindex) { var noLogo = (undefined === facData.bigLogo || facData.bigLogo === "" || null === facData.bigLogo); var res = `
` + `
` + (noLogo ? `` : `${facData.tradingName}`) + `
` + `

${facData.tradingName}

${facData.fac_resume}

` + (facData.pack_online && facData.permalinkFacHomepage !== "" ? `${__('ph_confirm_page_fac_learn_more')}` : '' ) + `
` facHtmlList.push(res) return res; } /** * Main render * @param data * @returns {string} */ self.render = function (data) { userData = data var html = ``; html = `
` + `
` + _listFac(data.blockList) + `
` + `
` + modalEditAddress(data); return html; } return self; }