manual item code
This commit is contained in:
@@ -0,0 +1,684 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Admin Dashboard - Invoice Extraction Pro</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: #f5f7fa;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background: white;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding: 15px 30px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.navbar-right {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navbar-right a {
|
||||
padding: 8px 16px;
|
||||
background: #f0f0f0;
|
||||
border-radius: 6px;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.navbar-right a:hover { background: #e0e0e0; }
|
||||
|
||||
.container { max-width: 1200px; margin: 0 auto; padding: 30px; }
|
||||
|
||||
.header { margin-bottom: 30px; }
|
||||
.header h1 { font-size: 28px; margin-bottom: 8px; }
|
||||
.header p { color: #888; font-size: 15px; }
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 2px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.tab-button {
|
||||
padding: 12px 20px;
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #888;
|
||||
border-bottom: 3px solid transparent;
|
||||
margin-bottom: -2px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.tab-button.active {
|
||||
color: #667eea;
|
||||
border-bottom-color: #667eea;
|
||||
}
|
||||
|
||||
.tab-button:hover {
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab-content.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 15px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 18px;
|
||||
border-left: 4px solid #667eea;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.06);
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.day-block {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 20px 24px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.06);
|
||||
}
|
||||
|
||||
.day-block h2 {
|
||||
font-size: 17px;
|
||||
margin-bottom: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.day-block h2 .today-badge {
|
||||
display: inline-block;
|
||||
margin-left: 8px;
|
||||
padding: 2px 10px;
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
border-radius: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
table.stats-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.stats-table th {
|
||||
background: #f8f9fa;
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
border-bottom: 2px solid #e0e0e0;
|
||||
font-weight: 600;
|
||||
color: #555;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stats-table td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #eee;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.stats-table tbody tr:hover { background: #f8f9fa; }
|
||||
|
||||
.num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
|
||||
.tag {
|
||||
display: inline-block;
|
||||
padding: 3px 9px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.tag.matched { background: #d4edda; color: #155724; }
|
||||
.tag.manual { background: #e2d9f3; color: #4b2a85; }
|
||||
.tag.missing { background: #f8d7da; color: #721c24; }
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-state-icon { font-size: 42px; margin-bottom: 12px; }
|
||||
|
||||
/* User Management Styles */
|
||||
.user-management-section {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 20px 24px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.06);
|
||||
}
|
||||
|
||||
.management-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.management-header h3 {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #5568d3;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.users-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.users-table th {
|
||||
background: #f8f9fa;
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 2px solid #e0e0e0;
|
||||
font-weight: 600;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.users-table td {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.users-table tbody tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.admin-badge {
|
||||
display: inline-block;
|
||||
padding: 3px 8px;
|
||||
background: #ffc107;
|
||||
color: #000;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 1000;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal.active {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 30px;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
float: right;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
|
||||
.modal-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.modal-buttons button {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #e0e0e0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
background: #d0d0d0;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 12px 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.message.success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
|
||||
.message.error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.container { padding: 15px; }
|
||||
.stats-table { font-size: 12px; }
|
||||
.stats-table th, .stats-table td { padding: 7px 8px; }
|
||||
.management-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar">
|
||||
<div class="navbar-brand"> Admin Dashboard — Invoice Pro</div>
|
||||
<div class="navbar-right">
|
||||
<a href="{{ url_for('dashboard') }}">← Back to Dashboard</a>
|
||||
<a href="{{ url_for('logout') }}">Logout</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>Admin Dashboard</h1>
|
||||
<p>Manage users and view invoice processing statistics</p>
|
||||
</div>
|
||||
|
||||
<!-- Tab Navigation -->
|
||||
<div class="tabs">
|
||||
<button class="tab-button active" onclick="switchTab('statistics')">📊 Statistics</button>
|
||||
<button class="tab-button" onclick="switchTab('users')">👥 User Management</button>
|
||||
</div>
|
||||
|
||||
<!-- Statistics Tab -->
|
||||
<div id="statistics" class="tab-content active">
|
||||
<div class="summary-grid">
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">PDFs Today</div>
|
||||
<div class="summary-value">{{ summary.today_pdfs }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">Active Users Today</div>
|
||||
<div class="summary-value">{{ summary.today_active_users }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">Total PDFs Processed</div>
|
||||
<div class="summary-value">{{ summary.total_pdfs }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">Total Items Seen</div>
|
||||
<div class="summary-value">{{ summary.total_items }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">Item Codes Added Manually</div>
|
||||
<div class="summary-value">{{ summary.total_manual }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">Items Still Missing a Code</div>
|
||||
<div class="summary-value">{{ summary.total_missing }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if stats %}
|
||||
{% for day in stats %}
|
||||
<div class="day-block">
|
||||
<h2>
|
||||
{{ day.date }}
|
||||
{% if day.date == today %}<span class="today-badge">TODAY</span>{% endif %}
|
||||
</h2>
|
||||
<table class="stats-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th class="num">PDFs</th>
|
||||
<th class="num">Items</th>
|
||||
<th class="num">With Code</th>
|
||||
<th class="num">Auto-Matched</th>
|
||||
<th class="num">Manual</th>
|
||||
<th class="num">Missing</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in day.users %}
|
||||
<tr>
|
||||
<td>{{ u.username }}</td>
|
||||
<td class="num">{{ u.pdfs_processed }}</td>
|
||||
<td class="num">{{ u.total_items }}</td>
|
||||
<td class="num">{{ u.items_with_code }}</td>
|
||||
<td class="num"><span class="tag matched">{{ u.items_auto_matched }}</span></td>
|
||||
<td class="num"><span class="tag manual">{{ u.items_manual }}</span></td>
|
||||
<td class="num">
|
||||
{% if u.items_missing > 0 %}<span class="tag missing">{{ u.items_missing }}</span>
|
||||
{% else %}0{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="day-block">
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">📭</div>
|
||||
<p>No invoices have been processed yet.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- User Management Tab -->
|
||||
<div id="users" class="tab-content">
|
||||
<div id="messageContainer"></div>
|
||||
|
||||
<div class="user-management-section">
|
||||
<div class="management-header">
|
||||
<h3>👥 Registered Users</h3>
|
||||
<button class="btn btn-primary" onclick="openAddUserModal()">+ Add New User</button>
|
||||
</div>
|
||||
|
||||
{% if all_users %}
|
||||
<table class="users-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Registered</th>
|
||||
<th>Last Login</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in all_users %}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ user.username }}</strong>
|
||||
{% if user.is_admin %}<span class="admin-badge">👑 ADMIN</span>{% endif %}
|
||||
</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>{{ user.created_at[:10] if user.created_at else 'N/A' }}</td>
|
||||
<td>{{ user.last_login[:10] if user.last_login else 'Never' }}</td>
|
||||
<td>
|
||||
{% if user.is_active %}
|
||||
<span style="color: #28a745;">✓ Active</span>
|
||||
{% else %}
|
||||
<span style="color: #dc3545;">✗ Inactive</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if user.username != 'admin' %}
|
||||
<button class="btn btn-danger" onclick="deleteUser('{{ user.username }}')">Delete</button>
|
||||
{% else %}
|
||||
<span style="color: #888; font-size: 12px;">Protected</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">👥</div>
|
||||
<p>No users registered yet.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add User Modal -->
|
||||
<div id="addUserModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<span class="modal-close" onclick="closeAddUserModal()">×</span>
|
||||
<div class="modal-header">Add New User</div>
|
||||
<form onsubmit="submitAddUser(event)">
|
||||
<div class="form-group">
|
||||
<label>Username</label>
|
||||
<input type="text" id="newUsername" required placeholder="Enter username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Email</label>
|
||||
<input type="email" id="newEmail" required placeholder="Enter email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
<input type="password" id="newPassword" required placeholder="Enter password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Confirm Password</label>
|
||||
<input type="password" id="newPasswordConfirm" required placeholder="Confirm password">
|
||||
</div>
|
||||
<div class="modal-buttons">
|
||||
<button type="button" class="btn btn-cancel" onclick="closeAddUserModal()">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Add User</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function switchTab(tabName) {
|
||||
// Hide all tabs
|
||||
document.querySelectorAll('.tab-content').forEach(tab => tab.classList.remove('active'));
|
||||
document.querySelectorAll('.tab-button').forEach(btn => btn.classList.remove('active'));
|
||||
|
||||
// Show selected tab
|
||||
document.getElementById(tabName).classList.add('active');
|
||||
event.target.classList.add('active');
|
||||
}
|
||||
|
||||
function openAddUserModal() {
|
||||
document.getElementById('addUserModal').classList.add('active');
|
||||
}
|
||||
|
||||
function closeAddUserModal() {
|
||||
document.getElementById('addUserModal').classList.remove('active');
|
||||
document.getElementById('addUserForm')?.reset();
|
||||
}
|
||||
|
||||
function submitAddUser(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const username = document.getElementById('newUsername').value;
|
||||
const email = document.getElementById('newEmail').value;
|
||||
const password = document.getElementById('newPassword').value;
|
||||
const passwordConfirm = document.getElementById('newPasswordConfirm').value;
|
||||
|
||||
if (password !== passwordConfirm) {
|
||||
showMessage('Passwords do not match!', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
fetch('/api/admin/add-user', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
email: email,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showMessage('User added successfully!', 'success');
|
||||
closeAddUserModal();
|
||||
setTimeout(() => location.reload(), 1500);
|
||||
} else {
|
||||
showMessage(data.message || 'Failed to add user', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage('Error: ' + error.message, 'error');
|
||||
});
|
||||
}
|
||||
|
||||
function deleteUser(username) {
|
||||
if (confirm(`Are you sure you want to delete user "${username}"? This cannot be undone.`)) {
|
||||
fetch('/api/admin/delete-user', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: username
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showMessage('User deleted successfully!', 'success');
|
||||
setTimeout(() => location.reload(), 1500);
|
||||
} else {
|
||||
showMessage(data.message || 'Failed to delete user', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage('Error: ' + error.message, 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage(message, type) {
|
||||
const container = document.getElementById('messageContainer');
|
||||
container.innerHTML = `<div class="message ${type}">${message}</div>`;
|
||||
setTimeout(() => container.innerHTML = '', 5000);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user