Function
Function
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inventory</title>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.1/xlsx.full.min.js"></script>
</head>
<body>
<h1>Inventory Management</h1>
<table id="inventoryTable">
<thead>
<tr>
<th>Date</th>
<th>Item Code</th>
<th>Name</th>
<th>Category</th>
<th>Quantity</th>
<th>Cost Price</th>
<th>Selling Price</th>
<th>Consumer Price</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="tableBody">
<!-- Data will be dynamically inserted here -->
</tbody>
</table>
<script type="module">
import { initializeApp } from
"https://www.gstatic.com/firebasejs/10.3.0/firebase-app.js";
import { getDatabase, ref, onValue, set, remove, get, update } from
"https://www.gstatic.com/firebasejs/10.3.0/firebase-database.js";
const firebaseConfig = {
apiKey: "AIzaSyC3JRUCohz7pZZ2kZ1vSItq6vjalorZTa0",
authDomain: "systemstore-e0c45.firebaseapp.com",
databaseURL: "https://systemstore-e0c45-default-rtdb.asia-
southeast1.firebasedatabase.app",
projectId: "systemstore-e0c45",
storageBucket: "systemstore-e0c45.appspot.com",
messagingSenderId: "252593844424",
appId: "1:252593844424:web:2a8385f44b48dff586f5fd",
measurementId: "G-QS8881KHKK"
};
editMode = true;
currentItemCode = itemCode;
}
editMode = false;
currentItemCode = null;
}
row.appendChild(actionCell);
jsonData.forEach((item) => {
const itemCode = item['Item Code'];
if (itemCode) {
const itemRef = ref(database, 'products/' + itemCode);
set(itemRef, item).catch((error) => {
alert("Failed to upload item: " + error.message);
});
}
});