| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750 |
- /* Audit Express Self - Livinweb */
- const appEl = document.getElementById('app');
- const API_BASE = appEl?.dataset?.apiBase || '/api';
- const BOOKING_URL = appEl?.dataset?.bookingUrl || '';
- const DEVIS_URL = appEl?.dataset?.devisUrl || '';
- /* ── Catalogue packs ── */
- const PACK_CATALOGUE = [
- {
- id: 'onboarding-v1',
- title: 'Onboarding collaborateur',
- desc: "Clarté du flux, traçabilité, continuité — auditez votre process d'intégration.",
- tag: 'Pré-configuré',
- tagStyle: 'tag--pre',
- },
- {
- id: 'validation-facture',
- title: 'Validation de facture',
- desc: 'Contrôles, séparation des tâches, preuve — évaluez votre circuit factures.',
- tag: 'Pré-configuré',
- tagStyle: 'tag--pre',
- },
- {
- id: 'process-generique',
- title: 'Process générique',
- desc: 'Applicable à tout process opérationnel : achat, production, relation client, support, projet…',
- tag: 'Universel',
- tagStyle: 'tag--new',
- },
- {
- id: 'process-generique-v2',
- title: 'Diagnostic d\'opportunité',
- desc: 'Évaluez sur 8 axes si ce process est prioritaire à automatiser : friction, volume, risque, données, outils, variabilité, collaboration, déploiement.',
- tag: 'Diagnostic d\'opportunité',
- tagStyle: 'tag--v2',
- },
- {
- id: 'transformation-excel',
- title: 'Transformation fichier Excel',
- desc: 'Votre fichier Excel vous coûte-t-il du temps, des erreurs ou de la maîtrise ? 14 questions pour savoir s\'il faut le garder, l\'optimiser ou le transformer en application web.',
- tag: 'Transformation Excel',
- tagStyle: 'tag--excel',
- },
- {
- id: 'intervention-sav-maintenance-terrain-v2-compact',
- title: 'Intervention SAV / Maintenance terrain',
- desc: '16 questions pour auditer votre process d\'interventions terrain : canal d\'entrée, affectation, traçabilité, KPI, résilience et coût caché.',
- tag: 'Pré-configuré',
- tagStyle: 'tag--pre',
- },
- {
- id: 'internal-requests-validations-v2',
- title: 'Demandes internes & validations',
- desc: '16 questions pour auditer votre process de demandes internes (achats, RH, IT, juridique, marketing…) : point d\'entrée, catégorisation, règles de validation, traçabilité, résilience et coût.',
- tag: 'Pré-configuré',
- tagStyle: 'tag--pre',
- },
- {
- id: 'collecte-terrain-qualite-conformite-v2',
- title: 'Collecte terrain / qualité / conformité',
- desc: '16 questions pour auditer checklists, contrôles, non-conformités et traçabilité audit : clarté, fiabilité, preuve, résilience et coût.',
- tag: 'Pré-configuré',
- tagStyle: 'tag--pre',
- },
- ];
- /* ── Outils à venir ── */
- const COMING_SOON_TOOLS = [
- {
- id: 'process-mapper',
- title: 'Process Mapper',
- desc: 'Cartographiez visuellement votre process étape par étape, identifiez les goulots d\'étranglement et générez une documentation structurée prête à partager.',
- },
- ];
- const state = {
- view: 'landing',
- packId: null,
- pack: null,
- idx: 0,
- answers: {},
- optional: {},
- result: null,
- emailUnlocked: false,
- unlockExiting: false,
- captureEmail: '',
- notifyTool: '',
- roiInputs: { volume: '', tempsActuel: '', tempsCible: '', salaireNet: '', tauxErreurs: '', tempsErreur: '', delaiActuel: '', delaiCible: '' },
- roiResult: null,
- qwfSignals: {},
- qwfResult: null,
- excelSignals: {},
- excelResult: null,
- excelQual: { outil: null, personnes: null, consequence: [] },
- excelStep: 1,
- };
- let autoAdvanceTimer = null;
- /* ── DOM helpers ── */
- function h(tag, attrs = {}, children = []) {
- const el = document.createElement(tag);
- for (const [k, v] of Object.entries(attrs || {})) {
- if (k === 'class') el.className = v;
- else if (k.startsWith('on') && typeof v === 'function') el.addEventListener(k.slice(2).toLowerCase(), v);
- else if (v !== undefined && v !== null && v !== false) el.setAttribute(k, String(v));
- }
- for (const child of (Array.isArray(children) ? children : [children])) {
- if (child == null) continue;
- el.appendChild(typeof child === 'string' ? document.createTextNode(child) : child);
- }
- return el;
- }
- function storageKey(packId) { return `aes_${packId}_v1`; }
- function saveProgress() {
- if (!state.packId) return;
- localStorage.setItem(storageKey(state.packId), JSON.stringify({ answers: state.answers, optional: state.optional }));
- }
- function loadProgress(packId) {
- try {
- const obj = JSON.parse(localStorage.getItem(storageKey(packId)) || '{}');
- return {
- answers: typeof obj?.answers === 'object' ? obj.answers : {},
- optional: typeof obj?.optional === 'object' ? obj.optional : {},
- };
- } catch { return { answers: {}, optional: {} }; }
- }
- async function apiJson(path, { method = 'GET', body } = {}) {
- const headers = {};
- if (body) {
- headers['Content-Type'] = 'application/json';
- const csrf = appEl?.dataset?.csrfToken;
- if (csrf) headers['X-CSRF-Token'] = csrf;
- }
- const res = await fetch(`${API_BASE}${path}`, {
- method,
- headers: Object.keys(headers).length ? headers : undefined,
- body: body ? JSON.stringify(body) : undefined,
- credentials: 'same-origin',
- });
- const data = await res.json().catch(() => ({}));
- if (!res.ok) throw new Error(data?.error || 'Erreur API');
- return data;
- }
- function setView(v) { state.view = v; render(); }
- /* ── Navigation globale (exposée pour la navbar) ── */
- const VIEW_TO_NAV = {
- select: 'nav-diag',
- intro: 'nav-diag',
- quiz: 'nav-diag',
- computing: 'nav-diag',
- optional: 'nav-diag',
- results: 'nav-diag',
- roi: 'nav-roi',
- 'roi-results': 'nav-roi',
- qwf: 'nav-qwf',
- 'qwf-results': 'nav-qwf',
- excel: 'nav-excel',
- 'excel-results': 'nav-excel',
- };
- const VIEW_LABELS = {
- select: 'Diagnostic process',
- intro: null,
- quiz: null,
- computing: null,
- optional: null,
- results: null,
- roi: 'ROI Calculator',
- 'roi-results': 'ROI Calculator',
- qwf: 'Quick Wins Finder',
- 'qwf-results': 'Quick Wins Finder',
- excel: 'Excel → Application',
- 'excel-results': 'Excel → Application',
- };
- function getNavLabel() {
- if (['intro', 'quiz', 'computing', 'optional', 'results'].includes(state.view)) {
- return state.pack?.pack_title || 'Diagnostic process';
- }
- return VIEW_LABELS[state.view] || null;
- }
- function updateNavbar() {
- const crumb = document.getElementById('navBreadcrumb');
- if (crumb) crumb.textContent = getNavLabel() || '';
- document.querySelectorAll('.navbar__dropdown-item').forEach(el => el.classList.remove('active'));
- if (state.view !== 'landing') {
- let navId = VIEW_TO_NAV[state.view];
- if (!navId && state.packId === 'process-generique-v2') navId = 'nav-v2';
- if (navId) document.getElementById(navId)?.classList.add('active');
- }
- }
- window._ae = {
- goStart,
- goDiag: () => setView('select'),
- goV2: () => selectPack('process-generique-v2'),
- goRoi: () => setView('roi'),
- goQwf: () => setView('qwf'),
- goExcel: () => { state.excelStep = 1; setView('excel'); },
- };
- function hasOptionalQuestions() {
- const opt = state.pack?.optional_questions || {};
- return Object.keys(opt).length > 0;
- }
- function goStart() {
- Object.assign(state, { packId: null, pack: null, idx: 0, answers: {}, optional: {}, result: null, emailUnlocked: false, unlockExiting: false, captureEmail: '' });
- setView('landing');
- }
- async function selectPack(packId) {
- state.packId = packId;
- const saved = loadProgress(packId);
- state.answers = saved.answers;
- state.optional = saved.optional;
- try {
- const data = await apiJson(`/pack.php?pack=${encodeURIComponent(packId)}`);
- state.pack = data.pack;
- state.idx = 0;
- setView('intro');
- } catch (e) {
- alert('Impossible de charger le pack : ' + (e.message || ''));
- }
- }
- function levelColor(level) {
- return { A: '#1e8a5e', B: '#1e8a5e', C: '#c07c10', D: '#b83040' }[level] || '#2F506D';
- }
- /* ── COMING-SOON card helper ── */
- function makeComingSoonCard(tool) {
- return h('div', {
- class: 'pack-card pack-card--soon',
- onClick: () => {
- state.notifyTool = tool.id;
- document.getElementById('notifyDialog')?.showModal();
- },
- }, [
- h('span', { class: 'tag tag--soon' }, ['Bientôt disponible']),
- h('div', { class: 'title', style: 'margin-top:8px' }, [tool.title]),
- h('div', { class: 'desc' }, [tool.desc]),
- h('div', { class: 'soon-overlay' }, [
- h('div', { class: 'soon-overlay__label' }, ['Bientôt disponible']),
- h('div', { class: 'soon-overlay__text' }, ['Me notifier du lancement →']),
- ]),
- ]);
- }
- /* ── NOTIFY DIALOG (Coming soon) ── */
- function renderNotifyDialog() {
- const toolMeta = COMING_SOON_TOOLS.find(t => t.id === state.notifyTool);
- const toolName = toolMeta?.title || 'cet outil';
- const onSubmit = async (e) => {
- e.preventDefault();
- const email = e.target.querySelector('input[type="email"]').value.trim();
- if (!email) return;
- const btn = e.target.querySelector('button[type="submit"]');
- btn.disabled = true;
- btn.textContent = 'Envoi…';
- try {
- await apiJson('/notify.php', { method: 'POST', body: { email, tool: state.notifyTool } });
- const body = document.querySelector('#notifyDialog .dialog__body');
- if (body) {
- body.innerHTML = '';
- body.appendChild(h('div', { style: 'text-align:center;padding:20px 0' }, [
- h('div', { class: 'h2', style: 'color:var(--good);margin-bottom:8px' }, ['C\'est noté !']),
- h('p', { class: 'lead' }, [`Vous serez parmi les premiers informés du lancement de ${toolName}.`]),
- h('button', {
- class: 'btn btn--primary', style: 'margin-top:16px',
- onClick: () => document.getElementById('notifyDialog')?.close(),
- }, ['Fermer']),
- ]));
- }
- } catch (err) {
- btn.disabled = false;
- btn.textContent = 'Me prévenir au lancement →';
- alert('Erreur : ' + (err.message || 'Réessayez.'));
- }
- };
- return h('dialog', { id: 'notifyDialog', class: 'dialog' }, [
- h('div', { class: 'dialog__inner' }, [
- h('div', { class: 'dialog__head' }, [
- h('strong', {}, [`Soyez informé : ${toolName}`]),
- h('button', {
- class: 'btn btn--outline', style: 'padding:6px 12px;font-size:13px', type: 'button',
- onClick: () => document.getElementById('notifyDialog')?.close(),
- }, ['Fermer']),
- ]),
- h('div', { class: 'dialog__body' }, [
- h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
- `${toolName} est en cours de développement. Laissez votre email et on vous prévient en priorité au lancement.`,
- ]),
- h('form', { onSubmit }, [
- h('div', { class: 'field' }, [
- h('label', { for: 'notifyEmail' }, ['Email professionnel']),
- h('input', {
- id: 'notifyEmail', type: 'email', required: 'required',
- placeholder: 'vous@entreprise.com', autocomplete: 'email',
- }),
- ]),
- h('div', { class: 'btnrow', style: 'margin-top:14px' }, [
- h('button', { class: 'btn btn--primary', type: 'submit' }, ['Me prévenir au lancement →']),
- ]),
- h('p', { class: 'hint' }, ['Aucun spam. Désabonnement en 1 clic.']),
- ]),
- ]),
- ]),
- ]);
- }
- /* ── LANDING (page d'accueil) ── */
- function renderLanding() {
- const diagnosticV2 = PACK_CATALOGUE.find(p => p.id === 'process-generique-v2');
- const makeCard = (attrs, children) => h('div', attrs, children);
- /* Audits & Diagnostics */
- const auditCards = [
- makeCard({ class: 'pack-card', onClick: () => setView('select') }, [
- h('span', { class: 'tag tag--pre' }, ['Diagnostic']),
- h('div', { class: 'title' }, ['Diagnostic process', h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, ['Évaluez votre process sur 5 piliers en 20 questions. Packs pré-configurés (onboarding, facture) ou questionnaire universel.']),
- ]),
- diagnosticV2 ? makeCard({ class: 'pack-card', onClick: () => selectPack(diagnosticV2.id) }, [
- h('span', { class: `tag ${diagnosticV2.tagStyle}` }, [diagnosticV2.tag]),
- h('div', { class: 'title' }, [diagnosticV2.title, h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, [diagnosticV2.desc]),
- ]) : null,
- makeCard({ class: 'pack-card', onClick: () => { state.excelStep = 1; setView('excel'); } }, [
- h('span', { class: 'tag tag--excel' }, ['Excel → Application']),
- h('div', { class: 'title' }, ['Dois-je transformer mon Excel ?', h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, ['15 signaux pour savoir si votre fichier Excel a atteint ses limites et si une application web est justifiée.']),
- ]),
- ].filter(Boolean);
- /* Calculateurs rapides */
- const calcCards = [
- makeCard({ class: 'pack-card', onClick: () => setView('roi') }, [
- h('span', { class: 'tag tag--roi' }, ['ROI Calculator']),
- h('div', { class: 'title' }, ['ROI Calculator', h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, ['Chiffrez le gain mensuel et le ROI annuel. Identifiez les 2 leviers qui pèsent le plus sur votre process.']),
- ]),
- makeCard({ class: 'pack-card', onClick: () => setView('qwf') }, [
- h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder']),
- h('div', { class: 'title' }, ['Quick Wins Finder', h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, ['7 signaux → 3 actions concrètes et priorisées avec résultat attendu, effort et délai typique.']),
- ]),
- ];
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('h1', { class: 'h1' }, ['Choisissez un outil']),
- h('p', { class: 'lead' }, ['Diagnostiquez et optimisez vos process opérationnels.']),
- /* Section 1 : Audits & Diagnostics */
- h('div', { class: 'landing-section' }, [
- h('div', { class: 'section-label section-label--audit' }, ['Audits & Diagnostics']),
- h('div', { class: 'grid grid--2' }, auditCards),
- ]),
- /* Section 2 : Calculateurs rapides */
- h('div', { class: 'landing-section' }, [
- h('div', { class: 'section-label section-label--calc' }, ['Calculateurs rapides']),
- h('div', { class: 'grid grid--2' }, calcCards),
- ]),
- /* Section 3 : Conseil (booking) */
- BOOKING_URL ? h('div', { class: 'landing-section' }, [
- h('div', { class: 'section-label section-label--conseil' }, ['Conseil & accompagnement']),
- h('div', { class: 'grid grid--2' }, [
- h('a', {
- class: 'pack-card pack-card--link',
- href: BOOKING_URL,
- target: '_blank',
- rel: 'noreferrer',
- }, [
- h('span', { class: 'tag tag--booking' }, ['Prise de décision']),
- h('div', { class: 'title' }, ['Faisabilité d\'automatisation d\'un process', h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, ['Moins d\'une heure. Prenez rendez-vous pour évaluer ensemble si votre process est prioritaire à automatiser.']),
- ]),
- ]),
- ]) : null,
- /* Section 4 : Bientôt disponible */
- h('div', { class: 'landing-section' }, [
- h('div', { class: 'section-label' }, ['Bientôt disponible']),
- h('div', { class: 'grid grid--2' }, COMING_SOON_TOOLS.map(makeComingSoonCard)),
- ]),
- ]),
- renderNotifyDialog(),
- ]);
- }
- /* ── SELECT (page Diagnostic process) ── */
- function renderSelect() {
- const makeCard = (p, featured = false) =>
- h('div', { class: `pack-card${featured ? ' pack-card--featured' : ''}`, onClick: () => selectPack(p.id) }, [
- h('span', { class: `tag ${p.tagStyle}` }, [p.tag]),
- h('div', { class: 'title' }, [p.title, h('span', { class: 'arrow' }, [' →'])]),
- h('div', { class: 'desc' }, [p.desc]),
- ]);
- const preConfigured = PACK_CATALOGUE.filter(p => p.tag === 'Pré-configuré');
- const generic = PACK_CATALOGUE.find(p => p.id === 'process-generique');
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('h1', { class: 'h1' }, ['Choisissez le process à diagnostiquer']),
- h('p', { class: 'lead' }, ['Utilisez le questionnaire universel ou un pack pré-configuré.']),
- h('div', { class: 'section-label section-label--featured', style: 'margin-top:18px' }, ['Process universel']),
- h('div', { class: 'grid grid--2' }, generic ? [makeCard(generic, true)] : []),
- h('div', { class: 'section-label', style: 'margin-top:24px' }, ['Packs pré-configurés']),
- h('div', { class: 'grid grid--2' }, preConfigured.map(makeCard)),
- h('div', { class: 'btnrow', style: 'margin-top:18px' }, [
- h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
- ]),
- ]),
- ]);
- }
- /* ── INTRO ── */
- function renderIntro() {
- const meta = PACK_CATALOGUE.find(p => p.id === state.packId);
- const answeredCount = Object.keys(state.answers).length;
- const total = state.pack?.questions?.length || 20;
- const hasSaved = answeredCount > 0;
- const startFresh = () => {
- state.answers = {};
- state.optional = {};
- state.idx = 0;
- state.emailUnlocked = false;
- state.unlockExiting = false;
- state.captureEmail = '';
- saveProgress();
- setView('quiz');
- };
- const resume = () => {
- const qs = state.pack?.questions || [];
- let resumeIdx = 0;
- for (let i = 0; i < qs.length; i++) {
- if (state.answers[qs[i].id]) resumeIdx = i;
- }
- state.idx = Math.min(resumeIdx + 1, qs.length - 1);
- setView('quiz');
- };
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('span', { class: `tag ${meta?.tagStyle || ''}`, style: 'margin-bottom:12px;display:inline-block' }, [
- state.pack?.pack_title || '',
- ]),
- h('h1', { class: 'h1' }, ['Avant de commencer']),
- h('p', { class: 'lead' }, [
- 'Répondez franchement. Le score sert à prioriser, pas à juger. ',
- `Temps estimé : ${total <= 15 ? 5 : 7} minutes. Questions : ${total}.`,
- ]),
- state.pack?.pack_description
- ? h('p', { style: 'color:var(--muted);font-size:14px;margin-top:0' }, [state.pack.pack_description])
- : null,
- hasSaved
- ? h('div', { class: 'resume-notice' }, [
- h('span', {}, [`Progression sauvegardée : ${answeredCount} / ${total} questions`]),
- ])
- : null,
- h('div', { class: 'btnrow' }, [
- h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Choisir un autre outil']),
- hasSaved
- ? h('button', { class: 'btn btn--outline', onClick: startFresh }, ['Recommencer à zéro'])
- : null,
- h('button', { class: 'btn btn--primary', onClick: hasSaved ? resume : startFresh }, [
- hasSaved ? `Reprendre (Q${Math.min(Object.keys(state.answers).length + 1, total)}) →` : 'Commencer →',
- ]),
- ]),
- ]),
- ]);
- }
- /* ── QUIZ ── */
- function renderQuiz() {
- const q = state.pack?.questions?.[state.idx];
- if (!q) return h('div', { class: 'card' }, ['Chargement…']);
- const total = state.pack.questions.length;
- const pos = state.idx + 1;
- const pct = Math.round(((pos - 1) / total) * 100);
- const selected = state.answers[q.id] || '';
- const opts = (q.options || []).map(opt => {
- const id = `opt_${q.id}_${opt.id}`;
- const isSelected = selected === opt.id;
- const isNa = opt.id === 'NA' || opt.id === 'DK' || opt.id.toLowerCase().endsWith('_na') || opt.id.toLowerCase().endsWith('_dk');
- return h('label', { class: `opt${isSelected ? ' opt--selected' : ''}${isNa ? ' opt--na' : ''}`, for: id }, [
- h('input', {
- id, type: 'radio', name: q.id, value: opt.id,
- checked: isSelected ? 'checked' : null,
- onChange: (e) => {
- state.answers[q.id] = e.target.value;
- saveProgress();
- render();
- if (autoAdvanceTimer) clearTimeout(autoAdvanceTimer);
- autoAdvanceTimer = setTimeout(() => {
- autoAdvanceTimer = null;
- const t = state.pack?.questions?.length || 0;
- if (state.idx < t - 1) { state.idx++; saveProgress(); render(); }
- else setView(hasOptionalQuestions() ? 'optional' : 'computing');
- }, 380);
- },
- }),
- h('div', {}, [h('strong', {}, [opt.label])]),
- ]);
- });
- const canPrev = state.idx > 0;
- const canNext = !!selected;
- const isLast = state.idx === total - 1;
- const next = async () => {
- if (!canNext) return;
- if (!isLast) { state.idx++; saveProgress(); render(); return; }
- setView(hasOptionalQuestions() ? 'optional' : 'computing');
- };
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { class: 'quizHead' }, [
- h('span', { class: 'tag', style: 'font-size:11px' }, [state.pack.pack_title]),
- h('div', { class: 'quizStep' }, [
- h('strong', {}, [`${pos}`]),
- h('span', {}, [` / ${total}`]),
- ]),
- ]),
- h('div', { class: 'progressWrap' }, [
- h('div', { class: 'progress' }, [h('div', { style: `width:${pct}%` })]),
- h('div', { class: 'progressMeta' }, [
- h('span', { class: 'progressPct' }, [`${pct}\u00a0%`]),
- h('span', { class: 'progressRemain' }, [
- isLast ? 'Dernière question' : `encore ${total - pos} question${total - pos > 1 ? 's' : ''}`,
- ]),
- ]),
- ]),
- h('div', { class: 'qTitle' }, [q.label]),
- q.help ? h('p', { class: 'qHelp' }, [q.help]) : null,
- h('div', { class: 'options' }, opts),
- h('div', { class: 'btnrow', style: 'margin-top:18px' }, [
- h('button', { class: 'btn btn--outline', disabled: canPrev ? null : 'disabled', onClick: () => { state.idx--; saveProgress(); render(); } }, ['← Précédent']),
- h('button', { class: `btn ${canNext ? 'btn--primary' : 'btn--outline'}`, disabled: canNext ? null : 'disabled', onClick: next }, [
- isLast ? 'Voir mon résultat →' : 'Suivant →',
- ]),
- ]),
- h('p', { class: 'hint', style: 'margin-top:10px' }, ['Vous pouvez modifier vos réponses avant la fin.']),
- ]),
- ]);
- }
- /* ── COMPUTING (skip optional, submit directly) ── */
- function renderComputing() {
- (async () => {
- try {
- const data = await apiJson('/score.php', {
- method: 'POST',
- body: { pack_id: state.packId, answers: state.answers, optional: state.optional },
- });
- state.result = data.result;
- saveProgress();
- setView('results');
- } catch (e) { alert(e.message || 'Erreur'); }
- })();
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card', style: 'text-align:center;padding:40px 20px' }, [
- h('div', { class: 'h2' }, ['Calcul en cours…']),
- h('p', { class: 'lead' }, ['Analyse de vos réponses et génération du diagnostic.']),
- ]),
- ]);
- }
- /* ── OPTIONAL ── */
- function renderOptional() {
- const opt = state.pack?.optional_questions || {};
- const volumeKey = Object.keys(opt).find(k => opt[k]?.required_for_cost);
- const volumeQ = volumeKey ? opt[volumeKey] : null;
- const makeRadioGroup = (q, stateKey, storeAsNumber = true) => {
- const cur = state.optional[stateKey];
- return h('div', { class: 'field' }, [
- h('label', {}, [q.label]),
- h('div', { class: 'options', style: 'margin-top:6px' }, q.options.map(o => {
- const id = `opt_${stateKey}_${o.id}`;
- const val = String(o.value ?? o.id);
- const onCh = (e) => {
- const v = e.target.value;
- state.optional[stateKey] = storeAsNumber && /^-?\d+(\.\d+)?$/.test(v) ? Number(v) : v;
- saveProgress();
- };
- return h('label', { class: 'opt', for: id }, [
- h('input', {
- id, type: 'radio', name: stateKey, value: val,
- checked: String(cur) === val ? 'checked' : null,
- onChange: onCh,
- }),
- h('div', {}, [h('strong', {}, [o.label])]),
- ]);
- })),
- ]);
- };
- const netSalaryInput = h('div', { class: 'field' }, [
- h('label', { for: 'opt_net_salary' }, ['Salaire net mensuel estimé des personnes impliquées']),
- h('input', {
- id: 'opt_net_salary', type: 'number', min: '0', step: '100',
- placeholder: '3500',
- value: state.optional.net_salary !== undefined ? String(state.optional.net_salary) : '',
- onInput: (e) => { state.optional.net_salary = e.target.value ? Number(e.target.value) : undefined; saveProgress(); },
- }),
- h('div', { class: 'field-hint' }, [
- 'Coût chargé France = salaire net × 1,82 / 152 h/mois (charges salariales + patronales).',
- state.optional.net_salary
- ? ` → ${Math.round(state.optional.net_salary * COEFF_CHARGE_FR / HEURES_MOIS)} €/h estimé.`
- : ' Par défaut : 3 500 €/mois → ~42 €/h.',
- ]),
- ]);
- const compute = async () => {
- try {
- const optWithCost = { ...state.optional };
- const sn = state.optional.net_salary;
- if (sn) {
- optWithCost.hourly_cost = Math.round(sn * COEFF_CHARGE_FR / HEURES_MOIS);
- }
- const data = await apiJson('/score.php', {
- method: 'POST',
- body: { pack_id: state.packId, answers: state.answers, optional: optWithCost },
- });
- state.result = data.result;
- saveProgress();
- setView('results');
- } catch (e) { alert(e.message || 'Erreur'); }
- };
- const qualKeys = Object.keys(opt).filter(k => k !== volumeKey && k !== 'net_salary' && opt[k]?.options);
- const hasCost = volumeQ || state.pack?.cost_hidden;
- const qualBlocks = qualKeys.map(k => makeRadioGroup(opt[k], k, false));
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('span', { class: 'tag tag--new', style: 'margin-bottom:12px;display:inline-block' }, ['Optionnel']),
- h('h1', { class: 'h1' }, [hasCost ? 'Quelques infos pour le coût caché' : 'Quelques infos pour personnaliser vos résultats']),
- h('p', { class: 'lead' }, [hasCost ? 'Ces données servent uniquement à estimer le coût caché en heures/mois (indicatif). Vous pouvez passer.' : 'Ces données nous aident à mieux qualifier votre contexte. Vous pouvez passer.']),
- ...qualBlocks,
- volumeQ ? makeRadioGroup(volumeQ, volumeKey) : null,
- hasCost ? netSalaryInput : null,
- h('div', { class: 'btnrow', style: 'margin-top:20px' }, [
- h('button', { class: 'btn btn--outline', onClick: () => setView('quiz') }, ['← Retour']),
- h('button', { class: 'btn btn--primary', onClick: compute }, ['Voir mes résultats →']),
- ]),
- ]),
- ]);
- }
- /* ── RESULTS ── */
- function renderResults() {
- const r = state.result;
- if (!r) return h('div', { class: 'card' }, ['Calcul en cours…']);
- const dotColor = levelColor(r.level);
- const cost = r.cost_hidden;
- const unlocked = state.emailUnlocked;
- const pillarRows = (r.pillars || []).map(p => {
- const pct = p.max ? Math.round((p.score / p.max) * 100) : 0;
- return h('div', { class: 'pRow' }, [
- h('div', { class: 'name' }, [p.label]),
- h('div', { class: 'val' }, [`${p.score}/${p.max}`]),
- h('div', { class: 'bar' }, [h('div', { style: `width:${pct}%` })]),
- ]);
- });
- const riskItems = (r.risks_top3 || []).map(x =>
- h('li', {}, [
- h('strong', {}, [x.title]),
- h('div', { class: 'hint' }, [x.what_happens]),
- ])
- );
- const winItems = (r.quick_wins_preview || []).map(x =>
- h('li', {}, [
- h('strong', {}, [x.title]),
- h('div', { class: 'hint' }, [`${x.effect} ; Effort : ${x.effort}`]),
- ])
- );
- /* ── Excel Diagnostic ── */
- const xl = r.excel_diagnostic || null;
- const renderExcelDiagnostic = () => {
- if (!xl) return null;
- const doulColor = xl.douleur >= 65 ? '#b83040' : xl.douleur >= 35 ? '#c07c10' : '#1e8a5e';
- const cplxColor = xl.complexite >= 60 ? '#b83040' : xl.complexite >= 35 ? '#c07c10' : '#1e8a5e';
- const verdictColor = { transformer: '#b83040', intermediaire: '#c07c10', optimiser: '#1e8a5e' }[xl.verdict.code] || '#2F506D';
- const meter = (score, label, color) =>
- h('div', { class: 'v2-meter' }, [
- h('div', { class: 'v2-meter__num', style: `color:${color}` }, [String(score)]),
- h('div', { class: 'v2-meter__sub' }, ['/100']),
- h('div', { class: 'v2-meter__lbl' }, [label]),
- h('div', { class: 'v2-meter__track' }, [
- h('div', { class: 'v2-meter__fill', style: `width:${score}%;background:${color}` }),
- ]),
- ]);
- return h('div', { class: 'card v2-diagnostic' }, [
- h('div', { class: 'v2-meters' }, [
- meter(xl.douleur, 'Douleur actuelle (collaboration, friction, risque)', doulColor),
- meter(xl.complexite, 'Complexité du fichier (technique, gouvernance)', cplxColor),
- ]),
- h('div', { class: 'v2-badges' }, [
- h('span', { class: 'v2-verdict-badge', style: `border-color:${verdictColor};color:${verdictColor}` }, [
- `${xl.verdict.label} — ${xl.verdict.desc}`,
- ]),
- h('span', { class: `v2-tag-badge${xl.tag === 'optimiser' ? ' v2-tag-badge--qw' : xl.tag === 'intermediaire' ? ' v2-tag-badge--qw' : ' v2-tag-badge--proj'}` }, [
- xl.tag_label,
- ]),
- ]),
- ]);
- };
- const renderExcelMiniPlan = () => {
- if (!xl || !unlocked) return null;
- const actionList = (items, startNum) =>
- h('ol', { class: 'v2-plan-list', start: String(startNum) },
- (items || []).map(a => h('li', {}, [
- h('strong', {}, [a.title]),
- h('span', { class: 'hint' }, [` - ${a.effect} ; Effort : ${a.effort}`]),
- ]))
- );
- return h('div', { class: 'v2-mini-plan' }, [
- h('div', { class: 'v2-plan-cols' }, [
- h('div', { class: 'card v2-plan-section' }, [
- h('div', { class: 'v2-plan-title' }, ['3 actions immédiates']),
- actionList(xl.actions, 1),
- ]),
- h('div', { class: 'card v2-plan-section v2-plan-section--qw' }, [
- h('div', { class: 'v2-plan-title' }, ['2 quick wins possibles']),
- actionList(xl.quick_wins, 4),
- ]),
- ]),
- xl.risque_majeur ? h('div', { class: 'v2-plan-risk-block' }, [
- h('div', { class: 'v2-plan-title v2-plan-title--risk' }, ['1 risque majeur à adresser en parallèle']),
- h('div', { class: 'v2-plan-risk-card' }, [
- h('strong', {}, [xl.risque_majeur.title]),
- h('p', { class: 'hint', style: 'margin-top:4px' }, [xl.risque_majeur.what_happens]),
- ]),
- ]) : null,
- ]);
- };
- /* ── V2 Diagnostic ── */
- const v2 = r.v2_diagnostic || null;
- const renderV2Diagnostic = () => {
- if (!v2) return null;
- const potColor = v2.potentiel >= 70 ? '#1e8a5e' : v2.potentiel >= 40 ? '#c07c10' : '#b83040';
- const cplxColor = v2.complexite <= 35 ? '#1e8a5e' : v2.complexite <= 65 ? '#c07c10' : '#b83040';
- const verdictColor = { prioritaire: '#1e8a5e', candidat: '#c07c10', attente: '#5e789a' }[v2.verdict.code] || '#2F506D';
- const meter = (score, label, color) =>
- h('div', { class: 'v2-meter' }, [
- h('div', { class: 'v2-meter__num', style: `color:${color}` }, [String(score)]),
- h('div', { class: 'v2-meter__sub' }, ['/100']),
- h('div', { class: 'v2-meter__lbl' }, [label]),
- h('div', { class: 'v2-meter__track' }, [
- h('div', { class: 'v2-meter__fill', style: `width:${score}%;background:${color}` }),
- ]),
- ]);
- return h('div', { class: 'card v2-diagnostic' }, [
- h('div', { class: 'v2-meters' }, [
- meter(v2.potentiel, 'Potentiel d\'automatisation', potColor),
- meter(v2.complexite, 'Complexité de mise en œuvre', cplxColor),
- ]),
- h('div', { class: 'v2-badges' }, [
- h('span', { class: 'v2-verdict-badge', style: `border-color:${verdictColor};color:${verdictColor}` }, [
- `${v2.verdict.label} - ${v2.verdict.desc}`,
- ]),
- h('span', { class: `v2-tag-badge${v2.tag === 'quick_win' ? ' v2-tag-badge--qw' : ' v2-tag-badge--proj'}` }, [
- v2.tag_label,
- ]),
- ]),
- ]);
- };
- const renderMiniPlan = () => {
- if (!v2 || !unlocked) return null;
- const actionList = (items, startNum) =>
- h('ol', { class: 'v2-plan-list', start: String(startNum) },
- (items || []).map(a => h('li', {}, [
- h('strong', {}, [a.title]),
- h('span', { class: 'hint' }, [` - ${a.effect} ; Effort : ${a.effort}`]),
- ]))
- );
- return h('div', { class: 'v2-mini-plan' }, [
- h('div', { class: 'v2-plan-cols' }, [
- h('div', { class: 'card v2-plan-section' }, [
- h('div', { class: 'v2-plan-title' }, ['3 actions immédiates']),
- actionList(v2.actions, 1),
- ]),
- h('div', { class: 'card v2-plan-section v2-plan-section--qw' }, [
- h('div', { class: 'v2-plan-title' }, ['2 quick wins possibles']),
- actionList(v2.quick_wins, 4),
- ]),
- ]),
- v2.risque_majeur ? h('div', { class: 'v2-plan-risk-block' }, [
- h('div', { class: 'v2-plan-title v2-plan-title--risk' }, ['1 risque majeur à adresser en parallèle']),
- h('div', { class: 'v2-plan-risk-card' }, [
- h('strong', {}, [v2.risque_majeur.title]),
- h('p', { class: 'hint', style: 'margin-top:4px' }, [v2.risque_majeur.what_happens]),
- ]),
- ]) : null,
- ]);
- };
- /* ── Unlock gate ── */
- const renderUnlockGate = () => {
- const onUnlock = (e) => {
- e.preventDefault();
- const email = e.target.querySelector('input[type="email"]').value.trim();
- if (!email.includes('@') || email.length < 5) return;
- state.captureEmail = email;
- state.unlockExiting = true;
- render();
- setTimeout(() => {
- state.emailUnlocked = true;
- state.unlockExiting = false;
- saveProgress();
- render();
- setTimeout(() => document.getElementById('pdfDialog')?.showModal(), 50);
- }, 320);
- };
- const exiting = state.unlockExiting;
- return h('div', { class: 'unlock-gate' + (exiting ? ' unlock-gate--exiting' : '') }, [
- h('div', { class: 'unlock-gate__inner' }, [
- h('div', { class: 'unlock-gate__icon' }, ['↓']),
- h('div', { class: 'h2', style: 'margin-bottom:6px' }, ['Débloquez vos axes d\'amélioration']),
- h('p', { class: 'lead', style: 'margin-bottom:20px' }, [
- 'Entrez votre email professionnel pour accéder aux 5 actions prioritaires et télécharger votre PDF synthèse.',
- ]),
- h('form', { class: 'unlock-form', onSubmit: onUnlock }, [
- h('div', { class: 'unlock-row' }, [
- h('input', {
- type: 'email', required: 'required',
- placeholder: 'vous@entreprise.com',
- autocomplete: 'email',
- }),
- h('button', { class: 'btn btn--primary btn--unlock', type: 'submit' }, ['Débloquer →']),
- ]),
- h('p', { class: 'hint', style: 'margin-top:8px;text-align:center' }, [
- 'Aucun spam. Désinscription en 1 clic.',
- ]),
- ]),
- ]),
- ]);
- };
- /* ── CTAs débloqués ── */
- const renderUnlockedCtas = () =>
- h('div', { class: 'unlocked-ctas unlocked-ctas--entering' }, [
- h('div', { class: 'unlocked-ctas__inner' }, [
- /* En-tête */
- h('div', { class: 'h2', style: 'margin-bottom:6px' }, ['Et maintenant ?']),
- h('p', { class: 'lead', style: 'margin-bottom:24px' }, [
- 'Votre diagnostic révèle des opportunités concrètes. Réservez un entretien offert avec un consultant pour les prioriser et définir votre plan d\'action.',
- ]),
- /* CTAs commerciaux */
- h('div', { class: 'cta-block' }, [
- BOOKING_URL ? h('div', { style: 'display:flex;flex-direction:column;align-items:center;width:100%' }, [
- h('span', { class: 'cta-offert' }, ['30 min offert']),
- h('a', {
- class: 'btn btn--primary btn--cta-main',
- href: BOOKING_URL, target: '_blank', rel: 'noreferrer',
- }, ['Découvrir les opportunités suite à mon audit - Entretien de 30 min offert avec un consultant']),
- ]) : null,
- DEVIS_URL ? h('a', {
- class: 'btn btn--outline btn--cta-secondary',
- href: DEVIS_URL,
- }, ['Demander un devis']) : null,
- ]),
- h('p', { class: 'hint', style: 'text-align:center;margin-top:10px' }, [
- 'Pas d\'engagement. On analyse vos résultats ensemble et on vous propose une solution adaptée.',
- ]),
- /* Séparateur */
- h('hr', { style: 'border:none;border-top:1px solid var(--border,#e2e8f0);margin:24px 0' }),
- /* Actions secondaires */
- h('div', { class: 'btnrow', style: 'justify-content:center;gap:10px' }, [
- h('button', {
- class: 'btn btn--outline',
- onClick: () => document.getElementById('pdfDialog')?.showModal(),
- }, ['Télécharger mon PDF']),
- h('button', {
- class: 'btn btn--outline',
- style: 'font-size:13px',
- onClick: goStart,
- }, ['Diagnostiquer un autre process']),
- ]),
- ]),
- ]);
- return h('div', { class: 'grid' }, [
- /* Score header */
- h('div', { class: 'card' }, [
- h('div', { style: 'display:flex;align-items:center;gap:10px;margin-bottom:16px' }, [
- h('span', { class: 'tag' }, [state.pack?.pack_title || '']),
- ]),
- h('div', { class: 'scoreBox' }, [
- h('div', {}, [
- h('div', { class: 'scoreLabel' }, ['Score global']),
- h('div', { class: 'scoreBig' }, [`${r.score_total}/100`]),
- h('div', { class: 'level-badge', style: 'margin-top:10px' }, [
- h('span', { class: 'level-dot', style: `background:${dotColor}` }),
- h('span', {}, [`${r.level} - ${r.level_label}`]),
- ]),
- h('div', { class: 'confidence' }, [`Confiance du diagnostic : ${r.confidence?.label || ''}`]),
- ]),
- ]),
- h('div', { class: 'pillars' }, pillarRows),
- ]),
- /* V2 : carte diagnostic (toujours visible) */
- v2 ? renderV2Diagnostic() : null,
- /* Excel : carte diagnostic (toujours visible) */
- xl ? renderExcelDiagnostic() : null,
- /* Non-V2/Excel : risques (visibles uniquement après déblocage) */
- !v2 && !xl && unlocked && !state.unlockExiting ? h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['3 risques probables']),
- riskItems.length
- ? h('ol', { class: 'list' }, riskItems)
- : h('p', { class: 'muted small' }, ['Aucun risque majeur détecté.']),
- ]) : null,
- /* Non-V2/Excel : coût caché (visible uniquement après déblocage) */
- !v2 && !xl && unlocked && !state.unlockExiting && cost ? h('div', { class: 'cost-block' }, [
- h('div', { class: 'h2' }, ['Coût caché estimé']),
- h('div', { class: 'cost-figures' }, [
- h('div', { class: 'cost-fig' }, [
- h('span', { class: 'val' }, [`${cost.hours_per_month} h`]),
- h('span', { class: 'lbl' }, ['par mois (estimé)']),
- ]),
- h('div', { class: 'cost-fig' }, [
- h('span', { class: 'val' }, [`~${cost.eur_per_month} €`]),
- h('span', { class: 'lbl' }, ['par mois (indicatif)']),
- ]),
- ]),
- h('p', { class: 'hint' }, ['Estimation indicative, à valider par mesure réelle.']),
- ]) : null,
- /* Gate (formulaire déblocage) ou contenu débloqué - gate visible pendant animation de sortie */
- !unlocked || state.unlockExiting ? renderUnlockGate() : null,
- /* V2 : mini plan (débloqué) */
- v2 ? renderMiniPlan() : null,
- /* Excel : mini plan (débloqué) */
- xl ? renderExcelMiniPlan() : null,
- /* Non-V2/Excel : quick wins (débloqués) */
- !v2 && !xl && unlocked && !state.unlockExiting ? h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['5 quick wins prioritaires']),
- winItems.length
- ? h('ol', { class: 'list' }, winItems)
- : h('p', { class: 'muted small' }, ['-']),
- h('p', { class: 'hint', style: 'margin-top:8px' }, ['Le PDF contient les 5 actions avec détail effort/impact.']),
- ]) : null,
- /* CTA débloqué */
- unlocked && !state.unlockExiting ? renderUnlockedCtas() : null,
- renderPdfDialog(),
- ]);
- }
- /* ── PDF DIALOG ── */
- function renderPdfDialog() {
- const onSubmit = async (e) => {
- e.preventDefault();
- const email = e.target.email.value.trim();
- if (!email) return;
- try {
- const headers = { 'Content-Type': 'application/json' };
- const csrf = appEl?.dataset?.csrfToken;
- if (csrf) headers['X-CSRF-Token'] = csrf;
- const res = await fetch(`${API_BASE}/pdf.php`, {
- method: 'POST',
- headers,
- credentials: 'same-origin',
- body: JSON.stringify({
- pack_id: state.packId, answers: state.answers,
- optional: state.optional, booking_url: BOOKING_URL, email,
- }),
- });
- if (!res.ok) { const j = await res.json().catch(() => ({})); throw new Error(j?.error || 'Erreur PDF'); }
- const blob = await res.blob();
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.href = url; a.download = `controle-technique-${state.packId}.pdf`;
- document.body.appendChild(a); a.click(); a.remove(); URL.revokeObjectURL(url);
- document.getElementById('pdfDialog')?.close();
- } catch (err) { alert(err.message || 'Erreur'); }
- };
- return h('dialog', { id: 'pdfDialog', class: 'dialog' }, [
- h('form', { class: 'dialog__inner', onSubmit }, [
- h('div', { class: 'dialog__head' }, [
- h('strong', {}, ['Télécharger votre synthèse PDF']),
- h('button', { class: 'btn btn--outline', style: 'padding:6px 12px;font-size:13px', type: 'button',
- onClick: () => document.getElementById('pdfDialog')?.close() }, ['Fermer']),
- ]),
- h('div', { class: 'dialog__body' }, [
- h('div', { class: 'field' }, [
- h('label', { for: 'pdfEmail' }, ['Email professionnel']),
- h('input', {
- id: 'pdfEmail', name: 'email', type: 'email', required: 'required',
- placeholder: 'vous@entreprise.com',
- value: state.captureEmail || '',
- }),
- ]),
- h('label', { class: 'check' }, [
- h('input', { type: 'checkbox', required: 'required' }),
- h('span', {}, ['J\'accepte de recevoir mon PDF et un email de suivi éventuel.']),
- ]),
- h('div', { class: 'btnrow', style: 'margin-top:14px' }, [
- h('button', { class: 'btn btn--primary', type: 'submit' }, ['Télécharger mon PDF →']),
- ]),
- h('p', { class: 'hint' }, ['Désinscription en 1 clic. Suppression des données sur demande.']),
- ]),
- ]),
- ]);
- }
- /* ════════════════════════════════════════════════════
- ROI CALCULATOR - données & calcul
- ════════════════════════════════════════════════════ */
- // Coût chargé France : net → brut (÷0,78) → coût employeur (×1,42) ≈ net × 1,82
- // Base légale 35h : 35 × 52 / 12 ≈ 152 h/mois
- const COEFF_CHARGE_FR = 1.82;
- const HEURES_MOIS = 152;
- const ROI_DEFAULTS = { salaireNet: 3500, tauxErreurs: 10, tempsErreur: 15 };
- function computeRoi(inp) {
- const v = Math.max(0, parseFloat(inp.volume) || 0);
- const tA = Math.max(0, parseFloat(inp.tempsActuel) || 0);
- const tC = Math.max(0, parseFloat(inp.tempsCible) || 0);
- const sn = inp.salaireNet !== '' ? (parseFloat(inp.salaireNet) || 0) : ROI_DEFAULTS.salaireNet;
- const ch = Math.round((sn * COEFF_CHARGE_FR) / HEURES_MOIS * 100) / 100;
- const te = inp.tauxErreurs !== '' ? (parseFloat(inp.tauxErreurs) || 0) : ROI_DEFAULTS.tauxErreurs;
- const tpe = inp.tempsErreur !== '' ? (parseFloat(inp.tempsErreur) || 0) : ROI_DEFAULTS.tempsErreur;
- const usedDefaults = [inp.salaireNet, inp.tauxErreurs, inp.tempsErreur].filter(x => x === '').length;
- const confidence = usedDefaults === 0 ? 'Fort' : usedDefaults <= 1 ? 'Moyen' : 'Faible';
- const gainTempsMin = v * Math.max(0, tA - tC);
- const gainTempsH = gainTempsMin / 60;
- const gainTraitement = gainTempsH * ch;
- const nbErreurs = v * (te / 100);
- const gainErreursMin = nbErreurs * tpe;
- const gainErreursH = gainErreursMin / 60;
- const gainErreurs = gainErreursH * ch;
- const roiMensuel = gainTraitement + gainErreurs;
- const roiAnnuel = roiMensuel * 12;
- const levers = [
- { label: 'Gain de traitement', euros: gainTraitement, heures: gainTempsH, detail: `${v} cas × ${Math.max(0, tA - tC)} min gagnées` },
- { label: 'Réduction des erreurs', euros: gainErreurs, heures: gainErreursH, detail: `~${Math.round(nbErreurs * 10) / 10} erreurs évitées × ${tpe} min` },
- ].sort((a, b) => b.euros - a.euros);
- const conclusion =
- roiAnnuel >= 50000 ? 'À ce niveau, l\'investissement se rentabilise en quelques semaines - difficile de ne pas le faire.' :
- roiAnnuel >= 20000 ? 'À ce niveau, ça se rentabilise en moins de 3 mois sur la plupart des projets.' :
- roiAnnuel >= 5000 ? 'Des gains concrets et mesurables - suffisant pour déclencher une discussion interne.' :
- 'Des gains modestes en valeur absolue, mais chaque heure récupérée libère du temps à forte valeur.';
- return { gainTempsH, gainTraitement, gainErreursH, gainErreurs, roiMensuel, roiAnnuel, levers, conclusion, confidence, usedDefaults, coutHoraire: ch, salaireNet: sn };
- }
- function renderRoi() {
- const inp = state.roiInputs;
- const roiField = (key, label, unit, required, placeholder, defHint) =>
- h('div', { class: 'roi-field' }, [
- h('label', { for: `roi_${key}` }, [
- label,
- h('span', { class: 'roi-unit' }, [` (${unit})`]),
- ]),
- h('input', {
- id: `roi_${key}`, type: 'number', min: '0', step: 'any',
- required: required ? 'required' : null,
- placeholder: placeholder != null ? String(placeholder) : undefined,
- value: inp[key] !== undefined ? String(inp[key]) : '',
- onInput: (e) => { state.roiInputs[key] = e.target.value; },
- }),
- defHint ? h('div', { class: 'field-hint' }, [defHint]) : null,
- ]);
- return h('div', { class: 'grid' }, [
- h('form', { class: 'card', onSubmit: (e) => { e.preventDefault(); state.roiResult = computeRoi(state.roiInputs); setView('roi-results'); } }, [
- h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--roi' }, ['ROI Calculator'])]),
- h('h1', { class: 'h1' }, ['Calculez le gain potentiel de votre optimisation']),
- h('p', { class: 'lead' }, [
- 'Renseignez vos données - les valeurs par défaut permettent d\'avancer sans avoir tous les chiffres.',
- ]),
- h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Données de base']),
- h('p', { class: 'hint', style: 'margin:0 0 10px' }, ['Ces 3 champs sont nécessaires au calcul.']),
- h('div', { class: 'roi-grid' }, [
- roiField('volume', 'Volume mensuel', 'cas/mois', true, 80),
- roiField('tempsActuel', 'Temps actuel par cas', 'min', true, 45),
- roiField('tempsCible', 'Temps cible après opt.', 'min', true, 20),
- ]),
- h('div', { class: 'section-label', style: 'margin-top:20px' }, ['Paramètres de coût']),
- h('p', { class: 'hint', style: 'margin:0 0 10px' }, ['Pré-remplis avec des valeurs types - modifiez si vous les connaissez.']),
- h('div', { class: 'roi-grid' }, [
- roiField('salaireNet', 'Salaire net mensuel estimé', '€/mois', false, null, 'Par défaut : 3 500 €/mois → ~42 €/h chargé'),
- roiField('tauxErreurs', 'Taux erreurs / retours', '%', false, null, 'Par défaut : 10 %'),
- roiField('tempsErreur', 'Temps perdu par erreur', 'min', false, null, 'Par défaut : 15 min'),
- ]),
- h('p', { class: 'hint', style: 'margin:4px 0 0;font-style:italic' }, [
- 'Coût chargé France = salaire net × 1,82 / 152 h/mois (charges salariales + patronales estimées).',
- ]),
- h('div', { class: 'btnrow', style: 'margin-top:24px' }, [
- h('button', { class: 'btn btn--outline', type: 'button', onClick: () => setView('landing') }, ['← Retour']),
- h('button', { class: 'btn btn--primary', type: 'submit' }, ['Calculer mon ROI →']),
- ]),
- ]),
- ]);
- }
- function renderRoiResults() {
- const r = state.roiResult;
- if (!r) { setView('roi'); return h('div', {}); }
- const fmt = (n) => Math.round(n).toLocaleString('fr-FR');
- const fmtH = (n) => n < 1 ? `${Math.round(n * 60)} min` : `${(Math.round(n * 10) / 10).toLocaleString('fr-FR')} h`;
- const confClass = { Fort: 'confidence-pill--fort', Moyen: 'confidence-pill--moyen', Faible: 'confidence-pill--faible' }[r.confidence] || '';
- const confLabel = {
- Fort: '● Confiance forte - vos propres chiffres',
- Moyen: '◐ Confiance moyenne - mix données + défauts',
- Faible: '○ Confiance faible - majorité de valeurs par défaut',
- }[r.confidence] || '';
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { style: 'display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:12px' }, [
- h('span', { class: 'tag tag--roi' }, ['ROI Calculator - Résultats']),
- h('span', { class: `confidence-pill ${confClass}` }, [confLabel]),
- ]),
- h('div', { class: 'roi-hero' }, [
- h('div', { class: 'roi-hero__item' }, [
- h('div', { class: 'roi-hero__val' }, [`${fmt(r.roiMensuel)} €`]),
- h('div', { class: 'roi-hero__lbl' }, ['ROI mensuel estimé']),
- h('div', { class: 'roi-hero__sub' }, [`≈ ${fmt(r.roiAnnuel)} €/an`]),
- ]),
- h('div', { class: 'roi-hero__sep' }),
- h('div', { class: 'roi-hero__item' }, [
- h('div', { class: 'roi-hero__val' }, [fmtH(r.gainTempsH + r.gainErreursH)]),
- h('div', { class: 'roi-hero__lbl' }, ['Heures récupérées / mois']),
- ]),
- ]),
- ]),
- h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['Les 2 leviers qui pèsent le plus']),
- h('div', { class: 'lever-cards' }, r.levers.map((l, i) =>
- h('div', { class: `lever-card${i === 0 ? ' lever-card--top' : ''}` }, [
- h('div', { class: 'lever-card__lbl' }, [i === 0 ? '🏆 Levier principal' : 'Levier secondaire']),
- h('div', { style: 'font-weight:700;font-size:15px;color:var(--navy);margin:4px 0 2px' }, [l.label]),
- h('div', { class: 'lever-card__amt' }, [`${fmt(l.euros)} €/mois`]),
- h('div', { class: 'lever-card__det' }, [`${fmtH(l.heures)} récupérées ; ${l.detail}`]),
- ])
- )),
- ]),
- h('div', { class: 'conclusion-box' }, [
- h('p', {}, [r.conclusion]),
- h('p', { class: 'hint' }, [
- `Hypothèse coût : ${Math.round(r.coutHoraire)} €/h chargé (base ${r.salaireNet.toLocaleString('fr-FR')} € net/mois × 1,82 / 152 h — France).`,
- ]),
- r.usedDefaults > 0
- ? h('p', { class: 'hint' }, [
- `${r.usedDefaults} valeur${r.usedDefaults > 1 ? 's' : ''} par défaut utilisée${r.usedDefaults > 1 ? 's' : ''} - affinez avec vos chiffres réels pour plus de précision.`,
- ])
- : null,
- ]),
- h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['Et maintenant ?']),
- h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
- 'Utilisez ces chiffres pour déclencher une décision. La prochaine étape : identifier les 3 actions concrètes à mettre en œuvre.',
- ]),
- h('div', { class: 'btnrow' }, [
- BOOKING_URL ? h('a', { class: 'btn btn--primary', href: BOOKING_URL, target: '_blank', rel: 'noreferrer' }, ['Entretien 30 min offert avec un consultant']) : null,
- h('button', { class: BOOKING_URL ? 'btn btn--outline' : 'btn btn--primary', onClick: () => setView('qwf') }, ['Trouver mes 3 quick wins →']),
- ]),
- h('div', { class: 'btnrow', style: 'margin-top:6px' }, [
- h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('roi') }, ['← Modifier mes données']),
- h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('landing') }, ['Autres outils']),
- ]),
- ]),
- ]);
- }
- /* ════════════════════════════════════════════════════
- QUICK WINS FINDER - données & calcul
- ════════════════════════════════════════════════════ */
- const QW_LIBRARY = [
- {
- id: 'statuts-notifications',
- title: 'Statuts uniques + notifications ciblées',
- result: 'Fin des relances et visibilité instantanée sur l\'avancement',
- setup: 'Statut central (ex : "à valider", "en cours IT", "bloqué", "terminé") + notifications automatiques aux bons rôles',
- prereqs: 'Définir un owner, les statuts métier, accès boîtes mail ou Teams',
- effort: 'S à M', delay: '2 à 4 semaines',
- impact: ['Baisse du délai global', 'Moins d\'interruptions', 'Moins de relances'],
- triggers: { relancesFrequentes: 3, validationsMultiples: 1 },
- },
- {
- id: 'formulaire-intelligent',
- title: 'Formulaire intelligent de collecte',
- result: 'Moins de retours arrière, dossiers complets dès le départ',
- setup: 'Champs conditionnels + contrôles à la saisie + pièces demandées au bon moment + validation de cohérence',
- prereqs: 'Liste des champs obligatoires, règles simples, rôles définis',
- effort: 'M', delay: '3 à 6 semaines',
- impact: ['Baisse des erreurs', 'Baisse du temps de traitement', 'Moins de rejets'],
- triggers: { erreursFréquentes: 3, validationsMultiples: 2 },
- },
- {
- id: 'suppression-double-saisie',
- title: 'Suppression de la double saisie entre outils',
- result: 'Arrêt du copier-coller Excel/email vers outil final',
- setup: 'Synchronisation des champs clés (push) ou import structuré automatique entre les outils',
- prereqs: 'Accès API ou export/import structuré, mapping des champs clés',
- effort: 'M', delay: '4 à 8 semaines',
- impact: ['Gain de temps direct', 'Moins d\'erreurs de saisie', 'Données fiables partout'],
- triggers: { doubleSaisie: 3, nbOutilsEleve: 2 },
- },
- {
- id: 'dossier-unique',
- title: 'Dossier unique par dossier',
- result: 'Fin du chaos documentaire - tout au même endroit',
- setup: 'Convention de nommage + dépôt structuré des pièces + lien unique accessible depuis le process',
- prereqs: 'Choix d\'un espace de stockage partagé, définition des règles de nommage',
- effort: 'S', delay: '1 à 3 semaines',
- impact: ['Moins de temps perdu à chercher', 'Moins d\'erreurs', 'Meilleure traçabilité'],
- triggers: { docsEparpilles: 3, erreursFréquentes: 1 },
- },
- {
- id: 'workflow-validation',
- title: 'Workflow de validation simplifié',
- result: 'Validation en un clic, délais réduits, zéro perte en route',
- setup: 'Règles de validation claires + SLA définis + tableau de bord de suivi des en-cours',
- prereqs: 'Matrice de validation, SLA définis, accès configuré pour les validateurs',
- effort: 'M', delay: '3 à 5 semaines',
- impact: ['Baisse du délai global', 'Moins de blocages', 'Meilleure traçabilité'],
- triggers: { validationsMultiples: 3, relancesFrequentes: 1 },
- },
- {
- id: 'exports-automatiques',
- title: 'Exports propres automatiques',
- result: 'Fin du reporting manuel - données toujours à jour',
- setup: 'Export planifié + format standard + envoi automatique aux destinataires',
- prereqs: 'Accès aux sources de données, liste des destinataires, fréquence définie',
- effort: 'S à M', delay: '2 à 5 semaines',
- impact: ['Temps récupéré sur le reporting', 'Fiabilité des données', 'Partage facilité'],
- triggers: { reportingManuel: 3, nbOutilsEleve: 1 },
- },
- ];
- const QWF_QUESTIONS = [
- { id: 'doubleSaisie', label: 'Des données sont saisies manuellement dans plusieurs outils différents (copier-coller, ressaisie…)' },
- { id: 'validationsMultiples', label: 'Plusieurs personnes ou étapes distinctes doivent valider chaque dossier' },
- { id: 'relancesFrequentes', label: 'Des relances sont nécessaires pour savoir où en est un dossier' },
- { id: 'docsEparpilles', label: 'Les documents d\'un dossier sont éparpillés (email, drive, bureau local…)' },
- { id: 'reportingManuel', label: 'Du reporting est préparé manuellement (copier-coller, recomposition de données)' },
- { id: 'erreursFréquentes', label: 'Des dossiers reviennent en arrière à cause d\'informations manquantes ou incorrectes' },
- { id: 'nbOutilsEleve', label: 'Ce process fait intervenir 3 outils ou plus (ERP, email, tableur, outil métier…)' },
- ];
- function computeQuickWins(signals) {
- return QW_LIBRARY
- .map(qw => {
- let score = 0;
- for (const [trigger, weight] of Object.entries(qw.triggers)) {
- if (signals[trigger]) score += weight;
- }
- return { ...qw, score };
- })
- .sort((a, b) => b.score - a.score)
- .slice(0, 3);
- }
- function renderQwf() {
- const sig = state.qwfSignals;
- const makeSignalRow = (q) => {
- const isOui = sig[q.id] === true;
- const isNon = sig[q.id] === false;
- return h('div', { class: 'signal-row' }, [
- h('span', { class: 'signal-row__lbl' }, [q.label]),
- h('div', { class: 'signal-row__btns' }, [
- h('button', {
- type: 'button',
- class: `signal-btn signal-btn--oui${isOui ? ' active' : ''}`,
- onClick: () => { state.qwfSignals[q.id] = isOui ? undefined : true; render(); },
- }, ['Oui']),
- h('button', {
- type: 'button',
- class: `signal-btn signal-btn--non${isNon ? ' active' : ''}`,
- onClick: () => { state.qwfSignals[q.id] = isNon ? undefined : false; render(); },
- }, ['Non']),
- ]),
- ]);
- };
- const answeredCount = QWF_QUESTIONS.filter(q => sig[q.id] !== undefined).length;
- const canSubmit = answeredCount >= 3;
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder'])]),
- h('h1', { class: 'h1' }, ['Identifiez vos 3 actions prioritaires']),
- h('p', { class: 'lead' }, [
- 'Répondez à ces 7 signaux pour recevoir 3 recommandations concrètes adaptées à votre process.',
- ]),
- h('div', { class: 'signal-list' }, QWF_QUESTIONS.map(makeSignalRow)),
- h('div', { class: 'btnrow', style: 'margin-top:22px' }, [
- h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
- h('button', {
- class: 'btn btn--primary',
- disabled: canSubmit ? null : 'disabled',
- onClick: () => { if (canSubmit) { state.qwfResult = computeQuickWins(state.qwfSignals); setView('qwf-results'); } },
- }, [canSubmit ? 'Voir mes 3 quick wins →' : `Répondre à encore ${3 - answeredCount} signal${3 - answeredCount > 1 ? 's' : ''}`]),
- ]),
- h('p', { class: 'hint', style: 'margin-top:8px' }, ['Répondez à au moins 3 signaux pour déverrouiller le résultat.']),
- ]),
- ]);
- }
- function renderQwfResults() {
- const qws = state.qwfResult;
- if (!qws || qws.length === 0) { setView('qwf'); return h('div', {}); }
- const makeQwCard = (qw, idx) =>
- h('div', { class: 'qw-card' }, [
- h('div', { class: 'qw-card__head' }, [
- h('div', { class: 'qw-card__num' }, [String(idx + 1)]),
- h('div', { class: 'qw-card__head-title' }, [qw.title]),
- ]),
- h('div', { class: 'qw-card__body' }, [
- h('div', { class: 'qw-card__result' }, [qw.result]),
- h('div', { class: 'qw-section' }, [
- h('div', { class: 'qw-section__lbl' }, ['Ce qu\'on met en place']),
- h('div', { class: 'qw-section__val' }, [qw.setup]),
- ]),
- h('div', { class: 'qw-section' }, [
- h('div', { class: 'qw-section__lbl' }, ['Pré-requis']),
- h('div', { class: 'qw-section__val' }, [qw.prereqs]),
- ]),
- h('div', { class: 'qw-meta' }, [
- h('span', { class: 'badge-effort' }, [`Effort : ${qw.effort}`]),
- h('span', { class: 'badge-delay' }, [`Délai : ${qw.delay}`]),
- ]),
- h('div', { class: 'impact-chips' }, qw.impact.map(i =>
- h('span', { class: 'impact-chip' }, [i])
- )),
- ]),
- ]);
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { style: 'margin-bottom:12px' }, [h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder - Résultats'])]),
- h('h1', { class: 'h1' }, ['Vos 3 actions prioritaires']),
- h('p', { class: 'lead' }, [
- 'Commencez par la première - elle a le plus fort impact selon vos signaux. Chaque fiche contient tout ce qu\'il faut pour démarrer.',
- ]),
- ]),
- h('div', { class: 'qw-cards' }, qws.map(makeQwCard)),
- h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['Et maintenant ?']),
- h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
- 'Ces 3 quick wins sont un point de départ solide. Un entretien offert avec un consultant permet de découvrir les opportunités et de cadrer le quick win n°1 en plan d\'action.',
- ]),
- h('div', { class: 'btnrow' }, [
- BOOKING_URL ? h('a', {
- class: 'btn btn--primary', href: BOOKING_URL, target: '_blank', rel: 'noreferrer',
- }, ['Découvrir les opportunités - Entretien 30 min offert']) : null,
- h('button', { class: 'btn btn--outline', onClick: () => setView('roi') }, ['Calculer le ROI →']),
- ]),
- h('div', { class: 'btnrow', style: 'margin-top:6px' }, [
- h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('qwf') }, ['← Modifier mes signaux']),
- h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('landing') }, ['Autres outils']),
- ]),
- ]),
- ]);
- }
- /* ════════════════════════════════════════════════════
- EXCEL → APPLICATION - données & calcul
- ════════════════════════════════════════════════════ */
- const EXCEL_QUESTIONS = [
- { id: 'multiUsagers', label: 'Plus d\'une personne utilise ce fichier Excel' },
- { id: 'simultaneite', label: 'Plusieurs personnes ont besoin de le modifier en même temps' },
- { id: 'erreursSaisie', label: 'Des erreurs de saisie ont déjà causé des problèmes réels (mauvais montant, perte de données…)' },
- { id: 'doubleSaisie', label: 'Des données sont copiées-collées depuis ou vers d\'autres outils (ERP, CRM, email…)' },
- { id: 'partageExterne', label: 'Le fichier est partagé avec des clients, fournisseurs ou partenaires externes' },
- { id: 'tracabilite', label: 'Vous avez besoin de savoir qui a modifié quoi et quand (historique, audit trail)' },
- { id: 'automatisation', label: 'Vous avez besoin de notifications, rappels ou alertes automatiques' },
- { id: 'complexite', label: 'Le fichier est devenu lent, fragile ou difficile à maintenir pour un non-expert' },
- { id: 'processStatuts', label: 'Ce fichier sert à gérer un processus avec des étapes, statuts ou validations' },
- { id: 'impactExternal', label: 'Une erreur ou un retard dans ce fichier peut impacter un client, un fournisseur ou la production' },
- { id: 'tempsPerdu', label: 'Vous et votre équipe passez plus de 2 heures par semaine à saisir, vérifier, corriger ou relancer autour de ce fichier' },
- { id: 'personnesCle', label: 'Une seule personne maîtrise vraiment le fonctionnement du fichier (formules, logique, macros)' },
- { id: 'processStable', label: 'Le processus géré par ce fichier est stable (il ne change pas complètement tous les mois)' },
- { id: 'vuesProfils', label: 'Vous avez besoin de vues différentes selon les profils (opérateur, manager, direction, client, RH…)' },
- { id: 'scalabilite', label: 'Si le volume d\'activité double, ce fichier risque de ne plus tenir correctement' },
- ];
- const EXCEL_QUAL_OUTIL = [
- { id: 'excel_local', label: 'Excel local / réseau' },
- { id: 'excel_partage', label: 'Excel partagé (SharePoint / OneDrive)' },
- { id: 'google_sheet', label: 'Google Sheet' },
- { id: 'les_deux', label: 'Les deux' },
- ];
- const EXCEL_QUAL_PERSONNES = [
- { id: '1', label: '1 seule' },
- { id: '2_3', label: '2 à 3' },
- { id: '4_10', label: '4 à 10' },
- { id: 'plus10', label: 'Plus de 10' },
- ];
- const EXCEL_QUAL_CONSEQUENCE = [
- { id: 'temps', label: 'Perte de temps' },
- { id: 'erreurs', label: 'Risque d\'erreur' },
- { id: 'visibilite', label: 'Manque de visibilité' },
- { id: 'conformite', label: 'Conformité / audit' },
- { id: 'client', label: 'Impact client / fournisseur' },
- ];
- function computeExcelVerdict(signals, qual = {}) {
- const total = EXCEL_QUESTIONS.length;
- const score = EXCEL_QUESTIONS.filter(q => signals[q.id] === true).length;
- if (score <= 4) {
- return {
- score, total, level: 'ok', qual,
- title: 'Excel reste adapté pour l\'instant',
- color: '#1e8a5e',
- icon: '✓',
- summary: `Avec ${score} signaux sur ${total}, votre usage d'Excel est encore maîtrisable. Continuez à l'utiliser, mais documentez vos règles et anticipez l'évolution de vos besoins.`,
- actions: [
- 'Documentez vos formules et règles métier pour faciliter la maintenance et la transmission',
- 'Mettez en place des sauvegardes automatiques et un versionnage du fichier',
- 'Réévaluez dans 6 mois si le volume d\'utilisateurs ou de données augmente',
- ],
- };
- } else if (score <= 8) {
- return {
- score, total, level: 'warn', qual,
- title: 'Vous approchez des limites d\'Excel',
- color: '#c07c10',
- icon: '⚠',
- summary: `Avec ${score} signaux sur ${total}, votre Excel fonctionne encore mais vous en perdez progressivement le contrôle. Une application dédiée deviendra nécessaire à court terme.`,
- actions: [
- 'Identifiez les 2 risques prioritaires (erreurs humaines, conflits de version, perte de données)',
- 'Explorez des solutions no-code ou low-code (Airtable, AppSheet, Make) pour une transition progressive',
- 'Planifiez la migration avant que la situation ne devienne critique ou coûteuse à réparer',
- ],
- };
- } else {
- return {
- score, total, level: 'critical', qual,
- title: 'Une application dédiée s\'impose',
- color: '#b83040',
- icon: '!',
- summary: `Avec ${score} signaux sur ${total}, Excel ne répond plus à vos besoins. Chaque jour sans application dédiée génère des risques réels et du temps perdu.`,
- actions: [
- 'Priorisez ce projet : le coût de l\'inaction (erreurs, temps perdu, risques) dépasse le coût de la transformation',
- 'Commencez par un MVP centré sur vos 2-3 pain points principaux — pas besoin de tout refaire d\'un coup',
- 'Évaluez selon votre volume : no-code (Airtable, Notion) pour de petits volumes, développement sur mesure au-delà',
- ],
- };
- }
- }
- function renderExcelTool() {
- const sig = state.excelSignals;
- const qual = state.excelQual;
- const answeredCount = EXCEL_QUESTIONS.filter(q => sig[q.id] !== undefined).length;
- const remaining = EXCEL_QUESTIONS.length - answeredCount;
- const canSubmit = answeredCount >= EXCEL_QUESTIONS.length;
- const makeSignalRow = (q) => {
- const isOui = sig[q.id] === true;
- const isNon = sig[q.id] === false;
- return h('div', { class: 'signal-row' }, [
- h('span', { class: 'signal-row__lbl' }, [q.label]),
- h('div', { class: 'signal-row__btns' }, [
- h('button', {
- type: 'button',
- class: `signal-btn signal-btn--oui${isOui ? ' active' : ''}`,
- onClick: () => { state.excelSignals[q.id] = isOui ? undefined : true; render(); },
- }, ['Oui']),
- h('button', {
- type: 'button',
- class: `signal-btn signal-btn--non${isNon ? ' active' : ''}`,
- onClick: () => { state.excelSignals[q.id] = isNon ? undefined : false; render(); },
- }, ['Non']),
- ]),
- ]);
- };
- const makeQualChips = (options, field) =>
- h('div', { class: 'qual-chips' }, options.map(opt =>
- h('button', {
- type: 'button',
- class: `qual-chip${qual[field] === opt.id ? ' active' : ''}`,
- onClick: () => { state.excelQual[field] = qual[field] === opt.id ? null : opt.id; render(); },
- }, [opt.label])
- ));
- const makeQualChipsMulti = (options, field) =>
- h('div', { class: 'qual-chips' }, options.map(opt => {
- const arr = Array.isArray(qual[field]) ? qual[field] : [];
- const isActive = arr.includes(opt.id);
- return h('button', {
- type: 'button',
- class: `qual-chip${isActive ? ' active' : ''}`,
- onClick: () => {
- const next = isActive ? arr.filter(x => x !== opt.id) : [...arr, opt.id];
- state.excelQual[field] = next;
- render();
- },
- }, [opt.label]);
- }));
- const group1 = EXCEL_QUESTIONS.slice(0, 8);
- const group2 = EXCEL_QUESTIONS.slice(8);
- const step = state.excelStep || 1;
- const group1Answered = group1.every(q => sig[q.id] !== undefined);
- const group2Answered = group2.every(q => sig[q.id] !== undefined);
- if (step === 1) {
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--excel' }, ['Excel → Application — Étape 1'])]),
- h('h1', { class: 'h1' }, ['Dois-je transformer mon fichier Excel en application ?']),
- h('p', { class: 'lead' }, ['Contexte et premiers signaux.']),
- h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Contexte de votre usage (optionnel)']),
- h('div', { class: 'qual-row' }, [
- h('div', { class: 'qual-row__lbl' }, ['Outil utilisé']),
- makeQualChips(EXCEL_QUAL_OUTIL, 'outil'),
- ]),
- h('div', { class: 'qual-row' }, [
- h('div', { class: 'qual-row__lbl' }, ['Nombre de personnes impliquées']),
- makeQualChips(EXCEL_QUAL_PERSONNES, 'personnes'),
- ]),
- h('div', { class: 'qual-row' }, [
- h('div', { class: 'qual-row__lbl' }, ['Conséquences principales ressenties (choix multiple)']),
- makeQualChipsMulti(EXCEL_QUAL_CONSEQUENCE, 'consequence'),
- ]),
- h('div', { class: 'section-label', style: 'margin-top:20px' }, ['Signaux — Usage et organisation']),
- h('div', { class: 'signal-list' }, group1.map(makeSignalRow)),
- h('div', { class: 'btnrow', style: 'margin-top:22px' }, [
- h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
- h('button', {
- class: 'btn btn--primary',
- disabled: group1Answered ? null : 'disabled',
- onClick: () => { if (group1Answered) { state.excelStep = 2; render(); } },
- }, [group1Answered ? 'Continuer — Étape 2 →' : `Répondre aux 8 signaux ci-dessus pour continuer`]),
- ]),
- h('p', { class: 'hint', style: 'margin-top:8px' }, ['Étape 1 sur 2.']),
- ]),
- ]);
- }
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--excel' }, ['Excel → Application — Étape 2'])]),
- h('h1', { class: 'h1' }, ['Signaux — Process et viabilité']),
- h('p', { class: 'lead' }, ['Ces 7 derniers signaux permettent d\'affiner le verdict.']),
- h('div', { class: 'signal-list', style: 'margin-top:18px' }, group2.map(makeSignalRow)),
- h('div', { class: 'btnrow', style: 'margin-top:22px' }, [
- h('button', { class: 'btn btn--outline', onClick: () => { state.excelStep = 1; render(); } }, ['← Étape précédente']),
- h('button', {
- class: 'btn btn--primary',
- disabled: canSubmit ? null : 'disabled',
- onClick: () => { if (canSubmit) { state.excelResult = computeExcelVerdict(state.excelSignals, state.excelQual); state.excelStep = 1; setView('excel-results'); } },
- }, [canSubmit ? 'Voir mon verdict →' : `Répondre à encore ${remaining} signal${remaining > 1 ? 's' : ''}`]),
- ]),
- h('p', { class: 'hint', style: 'margin-top:8px' }, ['Étape 2 sur 2. Répondez aux 7 signaux pour déverrouiller le verdict.']),
- ]),
- ]);
- }
- function renderExcelResults() {
- const r = state.excelResult;
- if (!r) { setView('excel'); return h('div', {}); }
- const qual = r.qual || {};
- const outilLabels = { excel_local: 'Excel local / réseau', excel_partage: 'Excel partagé (SharePoint / OneDrive)', google_sheet: 'Google Sheet', les_deux: 'Excel et Google Sheet' };
- const personnesLabels = { '1': '1 seule personne', '2_3': '2 à 3 personnes', '4_10': '4 à 10 personnes', 'plus10': 'Plus de 10 personnes' };
- const consequenceLabels = { temps: 'Perte de temps', erreurs: 'Risque d\'erreur', visibilite: 'Manque de visibilité', conformite: 'Conformité / audit', client: 'Impact client / fournisseur' };
- const consequenceArr = Array.isArray(qual.consequence) ? qual.consequence : (qual.consequence ? [qual.consequence] : []);
- const consequenceText = consequenceArr.map(id => consequenceLabels[id] || id).join(', ');
- const hasQual = qual.outil || qual.personnes || consequenceArr.length > 0;
- const qualCard = hasQual ? h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['Contexte de votre usage']),
- h('div', { class: 'qual-summary' }, [
- qual.outil ? h('div', { class: 'qual-summary__row' }, [h('span', { class: 'qual-summary__lbl' }, ['Outil : ']), outilLabels[qual.outil] || qual.outil]) : null,
- qual.personnes ? h('div', { class: 'qual-summary__row' }, [h('span', { class: 'qual-summary__lbl' }, ['Personnes impliquées : ']), personnesLabels[qual.personnes] || qual.personnes]) : null,
- consequenceText ? h('div', { class: 'qual-summary__row' }, [h('span', { class: 'qual-summary__lbl' }, ['Conséquences principales : ']), consequenceText]) : null,
- ].filter(Boolean)),
- ]) : null;
- return h('div', { class: 'grid' }, [
- h('div', { class: 'card' }, [
- h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--excel' }, ['Excel → Application - Verdict'])]),
- h('h1', { class: 'h1' }, ['Votre verdict']),
- h('div', { class: 'excel-verdict', style: `border-color:${r.color}` }, [
- h('div', { class: 'excel-verdict__icon', style: `background:${r.color}` }, [r.icon]),
- h('div', { class: 'excel-verdict__body' }, [
- h('div', { class: 'excel-verdict__score' }, [`${r.score} / ${r.total} signaux d'alerte`]),
- h('div', { class: 'excel-verdict__title', style: `color:${r.color}` }, [r.title]),
- h('div', { class: 'excel-verdict__summary' }, [r.summary]),
- ]),
- ]),
- ]),
- qualCard,
- h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['Nos recommandations']),
- h('div', { class: 'excel-actions' }, r.actions.map((action, i) =>
- h('div', { class: 'excel-action' }, [
- h('div', { class: 'excel-action__num' }, [String(i + 1)]),
- h('div', { class: 'excel-action__text' }, [action]),
- ])
- )),
- ]),
- h('div', { class: 'card' }, [
- h('div', { class: 'h2' }, ['Et maintenant ?']),
- h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
- r.level === 'ok'
- ? 'Votre Excel est encore sous contrôle. Si vos besoins évoluent, revenez faire ce diagnostic.'
- : 'Un entretien de 30 minutes permet d\'évaluer ensemble la meilleure solution pour votre situation et de chiffrer l\'effort de transformation.',
- ]),
- h('div', { class: 'btnrow' }, [
- BOOKING_URL ? h('a', {
- class: 'btn btn--primary', href: BOOKING_URL, target: '_blank', rel: 'noreferrer',
- }, ['Évaluer la solution - Entretien 30 min offert']) : null,
- h('button', { class: 'btn btn--outline', onClick: () => setView('roi') }, ['Calculer le ROI →']),
- ]),
- h('div', { class: 'btnrow', style: 'margin-top:6px' }, [
- h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => { state.excelStep = 1; setView('excel'); } }, ['← Modifier mes réponses']),
- h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('landing') }, ['Accueil']),
- ]),
- ]),
- ].filter(Boolean));
- }
- /* ── RENDER ── */
- function render() {
- if (!appEl) return;
- appEl.innerHTML = '';
- const views = {
- landing: renderLanding,
- select: renderSelect,
- intro: renderIntro,
- quiz: renderQuiz,
- computing: renderComputing,
- optional: renderOptional,
- results: renderResults,
- 'roi': renderRoi,
- 'roi-results': renderRoiResults,
- 'qwf': renderQwf,
- 'qwf-results': renderQwfResults,
- 'excel': renderExcelTool,
- 'excel-results': renderExcelResults,
- };
- appEl.appendChild((views[state.view] || renderLanding)());
- updateNavbar();
- }
- /* ── HEADER update ── */
- function initHeader() {
- const header = document.querySelector('.header');
- if (!header) return;
- header.innerHTML = '';
- const brand = document.createElement('div');
- brand.innerHTML =
- '<div class="brand__logo">Contrôle technique process</div>' +
- '<div class="brand__sub">Diagnostic self-serve ; Livinweb</div>';
- const badge = document.createElement('span');
- badge.className = 'brand__badge';
- badge.textContent = 'V1';
- header.appendChild(brand);
- header.appendChild(badge);
- }
- initHeader();
- render();
|