393 lines
14 KiB
HTML
393 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Donor Revenue Report — Undo Designs</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--navy: #0C1A3A;
|
|
--navy-2: #12244C;
|
|
--navy-3: #1a2f5e;
|
|
--navy-4: #0a1428;
|
|
--cyan: #00D4FF;
|
|
--cyan-dim: rgba(0,212,255,.12);
|
|
--cyan-glow: rgba(0,212,255,.06);
|
|
--blue: #1B8EF8;
|
|
--green: #10D98A;
|
|
--green-dim: rgba(16,217,138,.12);
|
|
--red: #F04438;
|
|
--red-dim: rgba(240,68,56,.12);
|
|
--amber: #F79009;
|
|
--w1: rgba(255,255,255,.95);
|
|
--w2: rgba(255,255,255,.65);
|
|
--w3: rgba(255,255,255,.35);
|
|
--w4: rgba(255,255,255,.10);
|
|
--w5: rgba(255,255,255,.05);
|
|
--border: rgba(255,255,255,.07);
|
|
--border-c: rgba(0,212,255,.18);
|
|
--mono: 'JetBrains Mono', monospace;
|
|
--disp: 'Space Grotesk', sans-serif;
|
|
--body: 'Inter', sans-serif;
|
|
--radius: 10px;
|
|
}
|
|
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
font-family: var(--body);
|
|
background: var(--navy-4);
|
|
color: var(--w1);
|
|
min-height: 100vh;
|
|
-webkit-font-smoothing: antialiased;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
body::before {
|
|
content: '';
|
|
position: fixed; inset: 0; pointer-events: none; z-index: 0;
|
|
background-image: radial-gradient(circle, rgba(0,212,255,.07) 1px, transparent 1px);
|
|
background-size: 28px 28px;
|
|
}
|
|
|
|
header {
|
|
position: sticky; top: 0; z-index: 100;
|
|
background: rgba(12,26,58,.85);
|
|
backdrop-filter: blur(12px);
|
|
border-bottom: 1px solid var(--border);
|
|
padding: 0 32px;
|
|
height: 60px;
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
}
|
|
.logo {
|
|
display: flex; align-items: center; gap: 10px;
|
|
font-family: var(--disp); font-size: 15px; font-weight: 600;
|
|
color: var(--w1); text-decoration: none;
|
|
}
|
|
.logo-icon {
|
|
width: 30px; height: 30px;
|
|
background: linear-gradient(135deg, var(--navy-3), var(--navy-2));
|
|
border: 1px solid var(--border-c);
|
|
border-radius: 7px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.logo-icon svg { width: 16px; height: 16px; }
|
|
.logo span { color: var(--cyan); }
|
|
|
|
main {
|
|
position: relative; z-index: 1;
|
|
flex: 1;
|
|
max-width: 720px;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
padding: 48px 24px 80px;
|
|
}
|
|
|
|
.page-title { margin-bottom: 40px; }
|
|
.eyebrow {
|
|
font-family: var(--mono); font-size: 10px;
|
|
letter-spacing: .16em; text-transform: uppercase;
|
|
color: var(--cyan); margin-bottom: 10px;
|
|
}
|
|
.page-title h1 {
|
|
font-family: var(--disp); font-size: 28px; font-weight: 700;
|
|
color: var(--w1); line-height: 1.2; margin-bottom: 8px;
|
|
}
|
|
.page-title p { font-size: 14px; color: var(--w2); line-height: 1.6; max-width: 520px; }
|
|
|
|
.card {
|
|
background: var(--navy-2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 24px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.file-zone {
|
|
border: 1.5px dashed var(--border);
|
|
border-radius: 8px;
|
|
padding: 28px 20px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
transition: all .2s;
|
|
position: relative;
|
|
}
|
|
.file-zone:hover, .file-zone.drag-over { border-color: var(--cyan); background: var(--cyan-glow); }
|
|
.file-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
|
|
.file-zone-icon {
|
|
width: 36px; height: 36px; margin: 0 auto 10px;
|
|
background: var(--w5); border-radius: 8px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.file-zone-icon svg { width: 18px; height: 18px; color: var(--w3); }
|
|
.file-zone-label { font-size: 13px; color: var(--w2); }
|
|
.file-zone-label strong { color: var(--cyan); }
|
|
.file-zone-sub { font-size: 11px; color: var(--w3); margin-top: 4px; }
|
|
.file-chosen { font-family: var(--mono); font-size: 11px; color: var(--green); margin-top: 8px; }
|
|
|
|
.tb-file-list { list-style: none; margin-top: 12px; }
|
|
.tb-file-list li {
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
padding: 8px 12px; border: 1px solid var(--border);
|
|
border-radius: 6px; margin-bottom: 6px;
|
|
font-family: var(--mono); font-size: 11px; color: var(--w2);
|
|
background: var(--w5);
|
|
}
|
|
.tb-file-list li span { color: var(--cyan); margin-right: 8px; }
|
|
.tb-remove { background: none; border: none; cursor: pointer; color: var(--w3); font-size: 14px; padding: 0 4px; transition: color .15s; }
|
|
.tb-remove:hover { color: var(--red); }
|
|
|
|
.btn {
|
|
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
|
padding: 11px 22px; border-radius: 8px; border: none;
|
|
font-family: var(--disp); font-size: 13px; font-weight: 600;
|
|
cursor: pointer; transition: all .2s; text-decoration: none;
|
|
width: 100%; margin-top: 16px;
|
|
}
|
|
.btn-primary { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: var(--navy); }
|
|
.btn-primary:hover { filter: brightness(1.08); }
|
|
.btn-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
|
|
|
|
.spinner {
|
|
display: none;
|
|
align-items: center; gap: 8px;
|
|
font-family: var(--mono); font-size: 11px; color: var(--w3);
|
|
margin-top: 12px;
|
|
}
|
|
.spinner.visible { display: flex; }
|
|
.spinner-dot {
|
|
width: 6px; height: 6px; border-radius: 50%; background: var(--cyan);
|
|
animation: pulse 1s infinite ease-in-out;
|
|
}
|
|
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
|
|
|
|
.error-note {
|
|
display: none;
|
|
font-size: 12px; color: var(--red); background: var(--red-dim);
|
|
border: 1px solid rgba(240,68,56,.2); border-radius: 8px;
|
|
padding: 12px 14px; margin-top: 12px;
|
|
}
|
|
.error-note.visible { display: block; }
|
|
|
|
.result-card { display: none; }
|
|
.result-card.visible { display: block; }
|
|
.result-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
|
|
.result-icon {
|
|
width: 32px; height: 32px; border-radius: 8px;
|
|
background: var(--green-dim); display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.result-icon svg { width: 16px; height: 16px; }
|
|
.result-title { font-family: var(--disp); font-size: 15px; font-weight: 600; color: var(--w1); }
|
|
.result-sub { font-size: 12px; color: var(--w3); margin-top: 2px; }
|
|
|
|
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
|
|
.stat-box { background: var(--w5); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
|
|
.stat-value { font-family: var(--mono); font-size: 18px; font-weight: 500; color: var(--cyan); line-height: 1; }
|
|
.stat-value.positive { color: var(--green); }
|
|
.stat-value.negative { color: var(--red); }
|
|
.stat-label { font-size: 10px; color: var(--w3); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }
|
|
|
|
.section-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--w3); margin-bottom: 10px; }
|
|
.donor-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
|
|
.donor-chip {
|
|
font-family: var(--mono); font-size: 10.5px; color: var(--w2);
|
|
background: var(--w5); border: 1px solid var(--border); border-radius: 20px;
|
|
padding: 4px 10px;
|
|
}
|
|
|
|
footer { position: relative; z-index: 1; text-align: center; padding: 20px; font-size: 11px; color: var(--w3); border-top: 1px solid var(--border); }
|
|
footer a { color: var(--cyan); text-decoration: none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<a class="logo" href="/">
|
|
<div class="logo-icon">
|
|
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M2 4h12M2 8h8M2 12h5" stroke="#00D4FF" stroke-width="1.5" stroke-linecap="round"/>
|
|
</svg>
|
|
</div>
|
|
Donor <span>Revenue Report</span>
|
|
</a>
|
|
</header>
|
|
|
|
<main>
|
|
<div class="page-title">
|
|
<div class="eyebrow">Planeterra International Foundation</div>
|
|
<h1>Donor Revenue Report</h1>
|
|
<p>Upload the revenue trial balance and the expense trial balance to generate one formatted financial extract sheet per donor.</p>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="file-zone" id="tbZone" style="cursor:default">
|
|
<input type="file" id="tbFileInput" accept=".xlsx,.xls" multiple style="display:none">
|
|
<div class="file-zone-icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
<polyline points="14,2 14,8 20,8"/>
|
|
</svg>
|
|
</div>
|
|
<div class="file-zone-label" id="tbDropLabel"><strong>Drop trial balance files here</strong> or <span style="color:var(--cyan);cursor:pointer" id="tbBrowseBtn">browse</span></div>
|
|
<div class="file-zone-sub">Revenue trial balance + expense trial balance (.xlsx)</div>
|
|
</div>
|
|
<ul class="tb-file-list" id="tbFileList"></ul>
|
|
|
|
<button class="btn btn-primary" id="processBtn" disabled>Generate Report</button>
|
|
|
|
<div class="spinner" id="spinner">
|
|
<div class="spinner-dot"></div>
|
|
Processing…
|
|
</div>
|
|
<div class="error-note" id="errorNote"></div>
|
|
</div>
|
|
|
|
<div class="card result-card" id="resultCard">
|
|
<div class="result-header">
|
|
<div class="result-icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="#10D98A" stroke-width="2.5">
|
|
<polyline points="20,6 9,17 4,12"/>
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<div class="result-title">Report generated</div>
|
|
<div class="result-sub" id="resultSub"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-box">
|
|
<div class="stat-value" id="statDonors">—</div>
|
|
<div class="stat-label">Donor Sheets</div>
|
|
</div>
|
|
<div class="stat-box">
|
|
<div class="stat-value" id="statRevenue">—</div>
|
|
<div class="stat-label">Total Revenue (CAD)</div>
|
|
</div>
|
|
<div class="stat-box">
|
|
<div class="stat-value" id="statExpense">—</div>
|
|
<div class="stat-label">Total Expense (CAD)</div>
|
|
</div>
|
|
<div class="stat-box">
|
|
<div class="stat-value" id="statSurplus">—</div>
|
|
<div class="stat-label">Surplus / (Deficit)</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section-label">Donors Included</div>
|
|
<div class="donor-list" id="donorList"></div>
|
|
|
|
<button class="btn btn-primary" id="downloadBtn">Download Report</button>
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
Built by <a href="https://undodesigns.com" target="_blank">Undo Designs</a> · Donor Revenue Report v1
|
|
</footer>
|
|
|
|
<script>
|
|
const $ = id => document.getElementById(id);
|
|
|
|
// ── Multi-file upload ──────────────────────────────────────────────────────
|
|
const tbFiles = [];
|
|
|
|
function renderFileList() {
|
|
const list = $('tbFileList');
|
|
list.innerHTML = '';
|
|
tbFiles.forEach((file, idx) => {
|
|
const li = document.createElement('li');
|
|
li.innerHTML = `<span>${idx + 1}</span>${file.name}
|
|
<button class="tb-remove" data-idx="${idx}" title="Remove">✕</button>`;
|
|
list.appendChild(li);
|
|
});
|
|
list.querySelectorAll('.tb-remove').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
tbFiles.splice(+btn.dataset.idx, 1);
|
|
renderFileList();
|
|
$('processBtn').disabled = tbFiles.length === 0;
|
|
});
|
|
});
|
|
$('tbDropLabel').innerHTML = tbFiles.length
|
|
? `<strong>${tbFiles.length} file${tbFiles.length > 1 ? 's' : ''} selected</strong> — <span style="color:var(--cyan);cursor:pointer" id="tbBrowseBtn">add more</span>`
|
|
: `<strong>Drop trial balance files here</strong> or <span style="color:var(--cyan);cursor:pointer" id="tbBrowseBtn">browse</span>`;
|
|
document.getElementById('tbBrowseBtn')?.addEventListener('click', () => $('tbFileInput').click());
|
|
}
|
|
|
|
$('tbBrowseBtn').addEventListener('click', () => $('tbFileInput').click());
|
|
$('tbFileInput').addEventListener('change', () => {
|
|
Array.from($('tbFileInput').files).forEach(f => {
|
|
if (!tbFiles.find(x => x.name === f.name)) tbFiles.push(f);
|
|
});
|
|
$('tbFileInput').value = '';
|
|
$('processBtn').disabled = tbFiles.length === 0;
|
|
renderFileList();
|
|
});
|
|
|
|
const zone = $('tbZone');
|
|
zone.addEventListener('dragover', e => { e.preventDefault(); zone.classList.add('drag-over'); });
|
|
zone.addEventListener('dragleave', () => zone.classList.remove('drag-over'));
|
|
zone.addEventListener('drop', e => {
|
|
e.preventDefault(); zone.classList.remove('drag-over');
|
|
Array.from(e.dataTransfer.files)
|
|
.filter(f => f.name.endsWith('.xlsx') || f.name.endsWith('.xls'))
|
|
.forEach(f => { if (!tbFiles.find(x => x.name === f.name)) tbFiles.push(f); });
|
|
$('processBtn').disabled = tbFiles.length === 0;
|
|
renderFileList();
|
|
});
|
|
|
|
// ── Process ───────────────────────────────────────────────────────────────
|
|
let lastFilename = '';
|
|
|
|
function fmtMoney(n) {
|
|
const sign = n < 0 ? '-' : '';
|
|
return sign + '$' + Math.abs(n).toLocaleString('en-US', {minimumFractionDigits: 2});
|
|
}
|
|
|
|
$('processBtn').addEventListener('click', async () => {
|
|
if (tbFiles.length === 0) return;
|
|
|
|
$('processBtn').disabled = true;
|
|
$('spinner').classList.add('visible');
|
|
$('errorNote').classList.remove('visible');
|
|
$('resultCard').classList.remove('visible');
|
|
|
|
const fd = new FormData();
|
|
tbFiles.forEach((f, i) => fd.append(`trial_balance_file_${i}`, f));
|
|
|
|
try {
|
|
const r = await fetch('/donor-report/api/process', { method: 'POST', body: fd });
|
|
const d = await r.json();
|
|
|
|
if (d.status === 'ok') {
|
|
lastFilename = d.filename;
|
|
$('resultSub').textContent = d.filename;
|
|
$('statDonors').textContent = d.donors;
|
|
$('statRevenue').textContent = fmtMoney(d.total_revenue);
|
|
$('statExpense').textContent = fmtMoney(d.total_expense);
|
|
const surplusEl = $('statSurplus');
|
|
surplusEl.textContent = fmtMoney(d.surplus_deficit);
|
|
surplusEl.className = 'stat-value ' + (d.surplus_deficit >= 0 ? 'positive' : 'negative');
|
|
$('donorList').innerHTML = d.donor_names.map(n => `<div class="donor-chip">${n}</div>`).join('');
|
|
$('resultCard').classList.add('visible');
|
|
} else {
|
|
$('errorNote').textContent = d.error || 'Unexpected error';
|
|
$('errorNote').classList.add('visible');
|
|
}
|
|
} catch (e) {
|
|
$('errorNote').textContent = 'Network error: ' + e.message;
|
|
$('errorNote').classList.add('visible');
|
|
}
|
|
|
|
$('spinner').classList.remove('visible');
|
|
$('processBtn').disabled = false;
|
|
});
|
|
|
|
$('downloadBtn').addEventListener('click', () => {
|
|
if (lastFilename) window.location.href = '/donor-report/api/download/' + encodeURIComponent(lastFilename);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|