integrated pharmacy dashboard with aiinvoice

This commit is contained in:
2026-11-25 10:24:28 +05:30
parent e6cca0fe46
commit 303e3f4a09
20 changed files with 14633 additions and 59 deletions
+279
View File
@@ -0,0 +1,279 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Local GRN Records — Test Dashboard</title>
<style>
:root {
--primary: #0284c7;
--success: #059669;
--danger: #dc2626;
--warning: #d97706;
--bg: #f8fafc;
--surface: #ffffff;
--border: #e2e8f0;
--text: #0f172a;
--muted: #64748b;
--radius: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.topbar {
background: var(--surface);
border-bottom: 1px solid var(--border);
padding: 14px 32px;
display: flex;
align-items: center;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 100;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 10px; }
.local-pill {
background: #fef9c3;
border: 1px solid #fde68a;
color: #92400e;
font-size: 11px;
font-weight: 700;
padding: 3px 10px;
border-radius: 999px;
letter-spacing: 0.5px;
text-transform: uppercase;
}
.back-link { color: var(--primary); text-decoration: none; font-size: 13px; }
.back-link:hover { text-decoration: underline; }
.container { max-width: 1400px; margin: 0 auto; padding: 32px 24px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.page-header p { color: var(--muted); font-size: 13px; }
/* Stat Cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.success { color: var(--success); }
.stat-value.danger { color: var(--danger); }
.stat-value.primary { color: var(--primary); }
/* Endpoint Info */
.endpoint-box {
background: #0f172a;
color: #e2e8f0;
border-radius: var(--radius);
padding: 18px 24px;
margin-bottom: 28px;
font-family: 'Courier New', monospace;
font-size: 13px;
}
.endpoint-box .label { color: #94a3b8; margin-bottom: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-family: sans-serif; }
.endpoint-box .url { color: #34d399; font-weight: 600; }
.endpoint-box .key { color: #fbbf24; }
.endpoint-box .sep { color: #475569; margin: 0 8px; }
/* Table */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-toolbar { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-toolbar h2 { font-size: 14px; font-weight: 600; }
.search-box { padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; width: 240px; outline: none; }
.search-box:focus { border-color: var(--primary); }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f1f5f9; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 10px 14px; font-size: 13px; vertical-align: middle; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.success { background: #d1fae5; color: #065f46; }
.badge.local { background: #dbeafe; color: #1e40af; }
.badge.pending { background: #fef3c7; color: #92400e; }
/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); width: 90%; max-width: 760px; max-height: 85vh; display: flex; flex-direction: column; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px 24px; overflow-y: auto; }
pre { background: #0f172a; color: #e2e8f0; border-radius: 6px; padding: 16px; font-size: 12px; white-space: pre-wrap; word-break: break-all; line-height: 1.6; }
/* Refresh badge */
.refresh-btn { padding: 7px 14px; background: var(--primary); color: white; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.refresh-btn:hover { background: #0369a1; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty p { font-size: 15px; margin-bottom: 6px; }
.empty small { font-size: 12px; }
</style>
</head>
<body>
<div class="topbar">
<div class="topbar-title">
GRN Records
<span class="local-pill">Local Test</span>
</div>
<a href="/dashboard" class="back-link">Back to Dashboard</a>
</div>
<div class="container">
<div class="page-header">
<h1>Local GRN Test Records</h1>
<p>All GRNs received from your local n8n workflow. These are stored in the <strong>invoice</strong> database, table <strong>grn_records</strong>.</p>
</div>
<!-- Endpoint Info Box -->
<div class="endpoint-box">
<div class="label">n8n HTTP Node — Point these to your local server</div>
<div>
<span style="color:#94a3b8">OCR Endpoint :</span>
<span class="url">http://localhost:8080/process-invoice</span>
<span class="sep">|</span>
<span style="color:#94a3b8">Header :</span>
<span class="key">x-api-key: 971dcea6c47445f6f7405fa2d14e116b1d81dae6c10330571e8d4220c013b523</span>
</div>
<div style="margin-top:8px">
<span style="color:#94a3b8">GRN Endpoint :</span>
<span class="url">http://localhost:8080/dmhApiRef/grn/createGRN.php</span>
<span class="sep">|</span>
<span style="color:#94a3b8">Header :</span>
<span class="key">x-api-key: nirajAi26@DMH</span>
</div>
<div style="margin-top:8px">
<span style="color:#94a3b8">JSON API :</span>
<span class="url">GET http://localhost:8080/api/grn/records</span>
</div>
</div>
<!-- Stats -->
{% set total = records | length %}
{% set success_count = records | selectattr('status', 'equalto', 'created') | list | length %}
<div class="stats">
<div class="stat-card">
<div class="stat-label">Total GRNs</div>
<div class="stat-value primary">{{ total }}</div>
</div>
<div class="stat-card">
<div class="stat-label">Created</div>
<div class="stat-value success">{{ success_count }}</div>
</div>
<div class="stat-card">
<div class="stat-label">Total Items</div>
<div class="stat-value primary">{{ records | sum(attribute='items_inserted') }}</div>
</div>
<div class="stat-card">
<div class="stat-label">Unique Sellers</div>
<div class="stat-value primary">{{ records | map(attribute='seller_name') | unique | list | length }}</div>
</div>
</div>
<!-- Table -->
<div class="table-wrap">
<div class="table-toolbar">
<h2>GRN Records (last 200)</h2>
<div style="display:flex;gap:10px;align-items:center">
<input type="text" class="search-box" id="searchBox" placeholder="Search GRN, invoice, seller..." oninput="filterTable()">
<button class="refresh-btn" onclick="location.reload()">Refresh</button>
</div>
</div>
{% if records %}
<div style="overflow-x:auto">
<table id="grnTable">
<thead>
<tr>
<th>GRN No</th>
<th>Invoice Number</th>
<th>Invoice ID</th>
<th>Seller Name</th>
<th>PO Number</th>
<th>Amount (₹)</th>
<th>Items</th>
<th>Source</th>
<th>Received At</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for r in records %}
<tr onclick="showDetail({{ r.id }})">
<td><strong>{{ r.grn_no }}</strong></td>
<td>{{ r.invoice_number or '—' }}</td>
<td style="color:var(--muted);font-size:12px">{{ r.invoice_id or '—' }}</td>
<td>{{ r.seller_name or '—' }}</td>
<td style="font-size:12px">{{ r.po_number or '—' }}</td>
<td style="text-align:right"><strong>{{ "%.2f"|format(r.invoice_amount|float) if r.invoice_amount else '0.00' }}</strong></td>
<td style="text-align:center">{{ r.items_inserted }}</td>
<td><span class="badge local">{{ r.source or 'n8n' }}</span></td>
<td style="color:var(--muted);font-size:12px">{{ r.received_at }}</td>
<td><span class="badge success">{{ r.status }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty">
<p>No GRN records yet.</p>
<small>Run your n8n workflow with the local endpoint to see records appear here.</small>
</div>
{% endif %}
</div>
</div>
<!-- Detail Modal -->
<div class="modal-overlay" id="detailModal">
<div class="modal">
<div class="modal-header">
<h3 id="modalTitle">GRN Detail</h3>
<button class="modal-close" onclick="closeModal()">×</button>
</div>
<div class="modal-body">
<pre id="modalContent">Loading...</pre>
</div>
</div>
</div>
<script>
function showDetail(id) {
document.getElementById('modalTitle').textContent = 'Loading...';
document.getElementById('modalContent').textContent = 'Loading...';
document.getElementById('detailModal').classList.add('open');
fetch('/grn/records/' + id)
.then(r => r.json())
.then(data => {
document.getElementById('modalTitle').textContent = 'GRN: ' + (data.grn_no || 'N/A');
document.getElementById('modalContent').textContent = JSON.stringify(data, null, 2);
})
.catch(e => {
document.getElementById('modalContent').textContent = 'Error: ' + e;
});
}
function closeModal() {
document.getElementById('detailModal').classList.remove('open');
}
document.getElementById('detailModal').addEventListener('click', function(e) {
if (e.target === this) closeModal();
});
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeModal();
});
function filterTable() {
const q = document.getElementById('searchBox').value.toLowerCase();
const rows = document.querySelectorAll('#grnTable tbody tr');
rows.forEach(row => {
row.style.display = row.textContent.toLowerCase().includes(q) ? '' : 'none';
});
}
</script>
</body>
</html>