veggie-ledger-tracker / add-transaction.html
UltraFastBrother's picture
I'm like dont get salary, I do work like bringing vegetables, grocery and other for home asked either by Mother, Father, Brother and they gave certain money and I returen certain, I want this type and want like time, date, expense occured, tracking, reports, and change also, and maintain balance and all
1503282 verified
Raw History Blame Contribute Delete
7.39 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Veggie Ledger | Add Transaction</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#4CAF50',
secondary: '#8BC34A',
}
}
}
}
</script>
</head>
<body class="bg-gray-50">
<custom-navbar></custom-navbar>
<main class="container mx-auto px-4 py-8">
<div class="max-w-2xl mx-auto">
<div class="flex items-center gap-4 mb-6">
<a href="/transactions.html" class="text-gray-500 hover:text-primary transition-colors">
<i data-feather="arrow-left"></i>
</a>
<h1 class="text-2xl font-bold text-gray-800">Add New Transaction</h1>
</div>
<div class="bg-white rounded-lg shadow-md p-6">
<form id="transaction-form" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label for="date" class="block text-sm font-medium text-gray-700 mb-1">Date</label>
<input type="date" id="date" name="date" required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
<div>
<label for="time" class="block text-sm font-medium text-gray-700 mb-1">Time</label>
<input type="time" id="time" name="time" required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
</div>
</div>
<div>
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<input type="text" id="description" name="description" required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
placeholder="e.g. Vegetables, Grocery, etc.">
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label for="type" class="block text-sm font-medium text-gray-700 mb-1">Type</label>
<select id="type" name="type" required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
<option value="" disabled selected>Select type</option>
<option value="expense">Expense</option>
<option value="income">Income (Received Money)</option>
</select>
</div>
<div>
<label for="person" class="block text-sm font-medium text-gray-700 mb-1">Person</label>
<select id="person" name="person" required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary">
<option value="" disabled selected>Select person</option>
<option value="Mother">Mother</option>
<option value="Father">Father</option>
<option value="Brother">Brother</option>
<option value="Sister">Sister</option>
<option value="Other">Other</option>
</select>
</div>
</div>
<div>
<label for="amount" class="block text-sm font-medium text-gray-700 mb-1">Amount (₹)</label>
<input type="number" id="amount" name="amount" required min="0" step="0.01"
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
placeholder="0.00">
</div>
<div class="flex justify-end gap-4 pt-4">
<button type="button" onclick="window.location.href='/transactions.html'"
class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Cancel
</button>
<button type="submit"
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-white bg-primary hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Save Transaction
</button>
</div>
</form>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
<script src="script.js"></script>
<script>
feather.replace();
document.getElementById('transaction-form').addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const date = document.getElementById('date').value;
const time = document.getElementById('time').value;
const description = document.getElementById('description').value;
const type = document.getElementById('type').value;
const person = document.getElementById('person').value;
const amount = parseFloat(document.getElementById('amount').value);
// Create new transaction (in a real app, this would be saved to a database)
const newTransaction = {
id: transactions.length + 1,
date,
time,
description,
type,
person,
amount,
balance: 0 // This would be calculated based on previous transactions
};
transactions.unshift(newTransaction);
// Show success message and redirect
alert('Transaction added successfully!');
window.location.href = '/transactions.html';
});
// Set default date to today
document.getElementById('date').valueAsDate = new Date();
</script>
</body>
</html>