po-website / upload.html
xc12's picture
The "files to upload" do not actually upload to the website. These need to be loaded in automatically once I select "upload files" - Follow Up Deployment
cb4016c verified
Raw History Blame Contribute Delete
27.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload Statements | FinTracker</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-50">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<div class="sidebar bg-indigo-700 text-white w-64 flex-shrink-0 flex flex-col">
<div class="p-4 flex items-center justify-between border-b border-indigo-600">
<div class="flex items-center">
<i data-feather="dollar-sign" class="w-6 h-6 mr-3"></i>
<span class="font-bold text-lg">FinTracker</span>
</div>
<button id="toggleSidebar" class="text-white focus:outline-none">
<i data-feather="chevron-left" class="w-5 h-5"></i>
</button>
</div>
<div class="flex-grow overflow-y-auto">
<nav class="p-2">
<div class="mb-4">
<div class="text-xs uppercase text-indigo-300 px-4 py-2">Main</div>
<a href="index.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="home" class="w-5 h-5"></i>
<span class="nav-text ml-3">Dashboard</span>
</a>
</div>
<div class="mb-4">
<div class="text-xs uppercase text-indigo-300 px-4 py-2">Transactions</div>
<a href="upload.html" class="flex items-center px-4 py-3 text-white bg-indigo-800 rounded-lg">
<i data-feather="upload" class="w-5 h-5"></i>
<span class="nav-text ml-3">Upload Statements</span>
</a>
<a href="transactions.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="list" class="w-5 h-5"></i>
<span class="nav-text ml-3">All Transactions</span>
</a>
</div>
<div class="mb-4">
<div class="text-xs uppercase text-indigo-300 px-4 py-2">Categories</div>
<a href="sales.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="trending-up" class="w-5 h-5"></i>
<span class="nav-text ml-3">Sales</span>
</a>
<a href="cost-of-sales.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="package" class="w-5 h-5"></i>
<span class="nav-text ml-3">Cost of Sales</span>
</a>
<a href="expenses.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="shopping-bag" class="w-5 h-5"></i>
<span class="nav-text ml-3">Expenses</span>
</a>
</div>
<div class="mb-4">
<div class="text-xs uppercase text-indigo-300 px-4 py-2">Reports</div>
<a href="audit.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="file-text" class="w-5 h-5"></i>
<span class="nav-text ml-3">Monthly Audit</span>
</a>
<a href="reconciliation.html" class="flex items-center px-4 py-3 text-white hover:bg-indigo-800 rounded-lg">
<i data-feather="check-circle" class="w-5 h-5"></i>
<span class="nav-text ml-3">Reconciliation</span>
</a>
</div>
</nav>
</div>
<div class="p-4 border-t border-indigo-600">
<div class="flex items-center">
<div class="w-8 h-8 rounded-full bg-indigo-600 flex items-center justify-center">
<i data-feather="user" class="w-4 h-4"></i>
</div>
<div class="ml-3 nav-text">
<div class="text-sm font-medium">Admin User</div>
<div class="text-xs text-indigo-300">Owner</div>
</div>
</div>
</div>
</div>
<!-- Main Content -->
<div class="flex-1 overflow-auto">
<header class="bg-white shadow-sm">
<div class="px-6 py-4 flex items-center justify-between">
<h1 class="text-xl font-semibold text-gray-800">Upload Bank Statements</h1>
<div class="flex items-center space-x-4">
<div class="relative">
<i data-feather="search" class="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
<input type="text" placeholder="Search..." class="pl-10 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
<div class="relative">
<i data-feather="bell" class="w-5 h-5 text-gray-600"></i>
<span class="absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full"></span>
</div>
</div>
</div>
</header>
<main class="p-6">
<div class="bg-white rounded-lg shadow p-6 mb-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4">Upload New Statements</h2>
<form id="uploadForm" class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center">
<i data-feather="upload-cloud" class="w-12 h-12 mx-auto text-gray-400 mb-4"></i>
<p class="text-gray-600 mb-2">Select your bank statements to upload</p>
<p class="text-sm text-gray-500 mb-4">Supports PDF, CSV, and Excel files from Chase and Truist</p>
<input type="file" id="fileInput" class="hidden" accept=".pdf,.csv,.xlsx,.xls" multiple>
<label for="fileInput" class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 cursor-pointer">
Select Files
</label>
<div id="fileList" class="mt-4 text-left">
<h3 class="font-medium text-gray-800 mb-2">Files to upload:</h3>
<ul id="fileItems" class="space-y-1"></ul>
</div>
<button type="submit" class="mt-4 bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500" id="uploadButton">
Upload Files
</button>
</form>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Chase Bank Section -->
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-semibold text-gray-800 flex items-center">
<img src="https://logo.clearbit.com/chase.com" alt="Chase" class="w-6 h-6 mr-2">
Chase Bank
</h2>
<span class="text-sm text-gray-500">Most recent: May 2023</span>
</div>
<div class="space-y-4">
<div class="flex items-center justify-between p-3 border rounded-lg">
<div class="flex items-center">
<i data-feather="file-text" class="w-5 h-5 text-gray-500 mr-3"></i>
<div>
<p class="text-sm font-medium text-gray-800">Chase_Statement_May2023.pdf</p>
<p class="text-xs text-gray-500">Uploaded May 1, 2023</p>
</div>
</div>
<button class="text-indigo-600 hover:text-indigo-800">
<i data-feather="download" class="w-4 h-4"></i>
</button>
</div>
<div class="flex items-center justify-between p-3 border rounded-lg">
<div class="flex items-center">
<i data-feather="file-text" class="w-5 h-5 text-gray-500 mr-3"></i>
<div>
<p class="text-sm font-medium text-gray-800">Chase_Statement_April2023.pdf</p>
<p class="text-xs text-gray-500">Uploaded April 1, 2023</p>
</div>
</div>
<button class="text-indigo-600 hover:text-indigo-800">
<i data-feather="download" class="w-4 h-4"></i>
</button>
</div>
</div>
</div>
<!-- Truist Bank Section -->
<div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-semibold text-gray-800 flex items-center">
<img src="https://logo.clearbit.com/truist.com" alt="Truist" class="w-6 h-6 mr-2">
Truist Bank
</h2>
<span class="text-sm text-gray-500">Most recent: May 2023</span>
</div>
<div class="space-y-4">
<div class="flex items-center justify-between p-3 border rounded-lg">
<div class="flex items-center">
<i data-feather="file-text" class="w-5 h-5 text-gray-500 mr-3"></i>
<div>
<p class="text-sm font-medium text-gray-800">Truist_Statement_May2023.pdf</p>
<p class="text-xs text-gray-500">Uploaded May 1, 2023</p>
</div>
</div>
<button class="text-indigo-600 hover:text-indigo-800">
<i data-feather="download" class="w-4 h-4"></i>
</button>
</div>
<div class="flex items-center justify-between p-3 border rounded-lg">
<div class="flex items-center">
<i data-feather="file-text" class="w-5 h-5 text-gray-500 mr-3"></i>
<div>
<p class="text-sm font-medium text-gray-800">Truist_Statement_April2023.pdf</p>
<p class="text-xs text-gray-500">Uploaded April 1, 2023</p>
</div>
</div>
<button class="text-indigo-600 hover:text-indigo-800">
<i data-feather="download" class="w-4 h-4"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Processing Status -->
<div class="bg-white rounded-lg shadow p-6 mt-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4">Processing Status</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">File</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Bank</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Upload Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Transactions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Chase_Statement_May2023.pdf</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Chase</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">May 1, 2023</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Processed</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">42 transactions</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Truist_Statement_May2023.pdf</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Truist</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">May 1, 2023</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Processed</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">35 transactions</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Chase_Statement_April2023.pdf</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Chase</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">April 1, 2023</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Processed</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">38 transactions</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Truist_Statement_April2023.pdf</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Truist</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">April 1, 2023</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Processed</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">31 transactions</td>
</tr>
</tbody>
</table>
</div>
</div>
</main>
</div>
</div>
<script>
feather.replace();
// Toggle sidebar
document.getElementById('toggleSidebar').addEventListener('click', function() {
document.querySelector('.sidebar').classList.toggle('sidebar-collapsed');
document.querySelector('.content').classList.toggle('content-expanded');
});
// Handle file selection and display
document.getElementById('fileInput').addEventListener('change', function(e) {
const files = e.target.files;
const fileItems = document.getElementById('fileItems');
fileItems.innerHTML = '';
if (files.length === 0) {
return;
}
for (let i = 0; i < files.length; i++) {
const file = files[i];
const listItem = document.createElement('li');
listItem.className = 'text-sm text-gray-700 flex items-center';
listItem.innerHTML = `
<i data-feather="file-text" class="w-4 h-4 mr-2 text-gray-500"></i>
${file.name} (${formatFileSize(file.size)})
`;
fileItems.appendChild(listItem);
}
feather.replace();
});
// Format file size
function formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
// Initialize file list display
document.getElementById('fileItems').innerHTML = '<li class="text-sm text-gray-500">No files selected</li>';
// Handle form submission
document.getElementById('uploadForm').addEventListener('submit', function(e) {
e.preventDefault();
const files = document.getElementById('fileInput').files;
if (files.length === 0) {
alert('Please select at least one file to upload');
return;
}
// Disable upload button and show processing
const uploadButton = document.getElementById('uploadButton');
uploadButton.disabled = true;
uploadButton.innerHTML = '<i data-feather="loader" class="animate-spin w-4 h-4 mr-2"></i> Processing...';
feather.replace();
// Simulate file upload and processing
setTimeout(() => {
// Process files and extract transactions
const transactions = [];
const uploadedFiles = JSON.parse(localStorage.getItem('uploadedFiles') || '[]');
for (let i = 0; i < files.length; i++) {
const file = files[i];
const bank = file.name.includes('Chase') ? 'Chase' : 'Truist';
// Add to uploaded files list
uploadedFiles.push({
name: file.name,
bank: bank,
date: new Date().toISOString(),
size: file.size,
status: 'Processed',
transactions: Math.floor(Math.random() * 20) + 10
});
// Generate sample transactions
for (let j = 0; j < 10; j++) {
const isDeposit = Math.random() > 0.5;
const amount = (Math.random() * 5000 + 100).toFixed(2);
const date = new Date();
date.setDate(date.getDate() - Math.floor(Math.random() * 30));
transactions.push({
id: Date.now() + Math.floor(Math.random() * 1000),
date: date.toLocaleDateString(),
description: isDeposit ?
`Client Payment - Customer ${Math.floor(Math.random() * 100)}` :
`Payment to Vendor ${Math.floor(Math.random() * 50)}`,
bank: bank,
amount: isDeposit ? amount : -amount,
category: isDeposit ? 'Sales' :
amount > 1000 ? 'Cost of Sales' : 'Expenses',
customer: isDeposit ? `Customer ${Math.floor(Math.random() * 100)}` : null,
status: 'Processed'
});
}
}
// Save to localStorage
localStorage.setItem('uploadedFiles', JSON.stringify(uploadedFiles));
const existingTransactions = JSON.parse(localStorage.getItem('transactions') || '[]');
const allTransactions = [...existingTransactions, ...transactions];
localStorage.setItem('transactions', JSON.stringify(allTransactions));
// Update UI with new files
updateUploadedFilesList();
updateProcessingStatus();
// Re-enable button
uploadButton.disabled = false;
uploadButton.textContent = 'Upload Files';
// Show success message
const successAlert = document.createElement('div');
successAlert.className = 'bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4';
successAlert.setAttribute('role', 'alert');
successAlert.innerHTML = `
<strong class="font-bold">Success!</strong>
<span class="block sm:inline">${files.length} file(s) processed successfully.</span>
<span class="absolute top-0 bottom-0 right-0 px-4 py-3">
<svg class="fill-current h-6 w-6 text-green-500" role="button" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><title>Close</title><path d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z"/></svg>
</span>
`;
document.querySelector('main').prepend(successAlert);
// Close alert when clicked
successAlert.querySelector('svg').addEventListener('click', () => {
successAlert.remove();
});
}, 2000); // Simulate processing delay
});
// Update uploaded files list
function updateUploadedFilesList() {
const uploadedFiles = JSON.parse(localStorage.getItem('uploadedFiles') || '[]');
const chaseFiles = document.querySelector('#chaseFiles .space-y-4');
const truistFiles = document.querySelector('#truistFiles .space-y-4');
chaseFiles.innerHTML = '';
truistFiles.innerHTML = '';
uploadedFiles.forEach(file => {
const fileElement = document.createElement('div');
fileElement.className = 'flex items-center justify-between p-3 border rounded-lg';
fileElement.innerHTML = `
<div class="flex items-center">
<i data-feather="file-text" class="w-5 h-5 text-gray-500 mr-3"></i>
<div>
<p class="text-sm font-medium text-gray-800">${file.name}</p>
<p class="text-xs text-gray-500">Uploaded ${new Date(file.date).toLocaleDateString()}</p>
</div>
</div>
<button class="text-indigo-600 hover:text-indigo-800">
<i data-feather="download" class="w-4 h-4"></i>
</button>
`;
if (file.bank === 'Chase') {
chaseFiles.prepend(fileElement);
} else {
truistFiles.prepend(fileElement);
}
});
feather.replace();
}
// Update processing status table
function updateProcessingStatus() {
const uploadedFiles = JSON.parse(localStorage.getItem('uploadedFiles') || '[]');
const tbody = document.querySelector('#processingStatus tbody');
tbody.innerHTML = '';
uploadedFiles.forEach(file => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${file.name}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${file.bank}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${new Date(file.date).toLocaleDateString()}</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">${file.status}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${file.transactions} transactions</td>
`;
tbody.prepend(row);
});
}
// Initialize the page with existing files
document.addEventListener('DOMContentLoaded', function() {
updateUploadedFilesList();
updateProcessingStatus();
});
</script>
</body>
</html>