From e02e0e21d0561aae66bf04eb9ecd1d3494f9d13c Mon Sep 17 00:00:00 2001 From: DevEnv nis2-agile Date: Tue, 10 Mar 2026 12:00:26 +0100 Subject: [PATCH] [FEAT] licenseExt: sezione dati destinatario pre-compila form + link pronto + modale con recipient data --- application/controllers/InviteController.php | 6 ++ public/licenseExt.html | 78 +++++++++++++++++--- 2 files changed, 72 insertions(+), 12 deletions(-) diff --git a/application/controllers/InviteController.php b/application/controllers/InviteController.php index adbd8c8..f2be642 100644 --- a/application/controllers/InviteController.php +++ b/application/controllers/InviteController.php @@ -210,6 +210,12 @@ class InviteController extends BaseController $row['used_by_org'] = $org; } + // Parsa metadata per esporre recipient strutturato + if (!empty($row['metadata'])) { + $meta = json_decode($row['metadata'], true) ?? []; + $row['metadata_recipient'] = $meta['recipient'] ?? null; + } + $this->jsonSuccess($row); } diff --git a/public/licenseExt.html b/public/licenseExt.html index 5c4e336..cf1b2ff 100644 --- a/public/licenseExt.html +++ b/public/licenseExt.html @@ -366,8 +366,9 @@ body { background: var(--bg-main); }
- + +
Solo riferimento interno — non visibile al cliente
@@ -387,6 +388,32 @@ body { background: var(--bg-main); }
+ + + +

Dati destinatario — pre-compilano il form di registrazione del cliente

+
+
+ + +
+
+ + +
+
+ + +
Il cliente vedrà questa email pre-compilata nel form
+
+
+ + +
Pre-compila il campo P.IVA nel form di registrazione
+
+
+ +
@@ -697,6 +724,16 @@ async function generateLicense() { const email = document.getElementById('gRestEmail').value.trim(); if (email) body.restrict_email = email; + // Dati destinatario — pre-compilano il form di registrazione + const rcpFirst = document.getElementById('gRcpFirst').value.trim(); + const rcpLast = document.getElementById('gRcpLast').value.trim(); + const rcpEmail = document.getElementById('gRcpEmail').value.trim(); + const rcpVat = document.getElementById('gRcpVat').value.trim(); + if (rcpFirst) body.recipient_first_name = rcpFirst; + if (rcpLast) body.recipient_last_name = rcpLast; + if (rcpEmail) body.recipient_email = rcpEmail; + if (rcpVat) body.recipient_vat = rcpVat; + const btn = document.getElementById('genBtn'); const ldr = document.getElementById('genLoading'); btn.style.display = 'none'; ldr.style.display = ''; @@ -718,20 +755,27 @@ async function generateLicense() { function renderGenResult(invites) { const res = document.getElementById('genResult'); const list = document.getElementById('genTokenList'); - list.innerHTML = invites.map((inv, i) => ` -
-
+ list.innerHTML = invites.map((inv, i) => { + const r = inv.recipient; + const recipientLine = r ? `
+ 👤 ${[r.first_name, r.last_name].filter(Boolean).join(' ')}${r.email ? ` <${r.email}>` : ''}${r.vat ? ` · P.IVA ${r.vat}` : ''} — form pre-compilato ✓ +
` : ''; + return ` +
+
Licenza #${i+1} — ${inv.plan} · ${inv.duration_months} mesi · ID: ${inv.id} -
-
${inv.token}
-
- URL: ${inv.invite_url} · Scade invito: ${new Date(inv.expires_at).toLocaleDateString('it-IT')} ${inv.max_users_per_org ? ` · Max utenti/org: ${inv.max_users_per_org}` : ''} ${inv.price_eur ? ` · € ${inv.price_eur}` : ''}
-
- `).join(''); +
${inv.token}
+
+ 🔗 Link da inviare al cliente: ${inv.invite_url} + +
+ ${recipientLine} +
`; + }).join(''); res.classList.add('show'); res.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } @@ -757,7 +801,8 @@ function exportCsv() { } function resetForm() { - ['gLabel','gIssuedTo','gReseller','gNotes','gRestVat','gRestEmail','gPrice','gMaxUsers'].forEach(id => { + ['gLabel','gIssuedTo','gReseller','gNotes','gRestVat','gRestEmail','gPrice','gMaxUsers', + 'gRcpFirst','gRcpLast','gRcpEmail','gRcpVat'].forEach(id => { document.getElementById(id).value = ''; }); document.getElementById('gPlan').value = 'professional'; @@ -819,7 +864,7 @@ async function showDetail(id) {
Reseller
${inv.reseller_name || '—'}
-
Destinatario
${inv.issued_to || '—'}
+
Rif. interno
${inv.issued_to || '—'}
Creato
${new Date(inv.created_at).toLocaleString('it-IT')}
${inv.used_at ? `
Usato il
${new Date(inv.used_at).toLocaleString('it-IT')}
` : ''}
@@ -834,6 +879,15 @@ async function showDetail(id) { ${inv.used_by_org.name} ${inv.used_by_org.sector || ''} · ${inv.used_by_org.nis2_entity_type || ''}
` : ''} + ${inv.metadata_recipient ? (() => { const r = inv.metadata_recipient; return ` +
+
👤 Dati destinatario (pre-compilano il form)
+
+ ${[r.first_name, r.last_name].filter(Boolean).join(' ')} + ${r.email ? `${r.email}` : ''} + ${r.vat ? `P.IVA: ${r.vat}` : ''} +
+
`; })() : ''} ${inv.notes ? `
Note: ${inv.notes}
` : ''}
${inv.status === 'pending' ? `` : ''}