-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.html
More file actions
106 lines (95 loc) · 3.48 KB
/
new.html
File metadata and controls
106 lines (95 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Invoice History</title>
<style>
/* Optional: Basic styling for table */
table {
width: 100%;
border-collapse: collapse;
}
td, th {
border: 1px solid black;
padding: 10px;
text-align: left;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Date</th>
<th>Subtotal</th>
<th>VAT</th>
<th>Total1</th>
<th>Total2</th>
<th>Total3</th>
</tr>
</thead>
<tbody id="historyBody">
<!-- History rows will be inserted here -->
</tbody>
<tfoot>
<tr class="font-bold">
<td class="border px-4 py-2" colspan="3">Total (with VAT)</td>
<td class="border px-4 py-2" colspan="1" id="total1">0.00</td>
<td class="border px-4 py-2" colspan="1" id="total2">0.00</td>
<td class="border px-4 py-2" colspan="1" id="total3">0.00</td>
</tr>
</tfoot>
</table>
<script>
// Function to load invoice history and display totals
function loadHistory() {
const historyBody = document.getElementById("historyBody");
historyBody.innerHTML = ""; // Clear the table
// Retrieve the history from localStorage
const history = JSON.parse(localStorage.getItem("invoiceHistory") || "[]");
// Display each entry from the history
history.forEach(entry => {
const row = document.createElement("tr");
row.innerHTML = `
<td class="border px-4 py-2">${entry.date}</td>
<td class="border px-4 py-2">${entry.subtotal}</td>
<td class="border px-4 py-2">${entry.vat}</td>
<td class="border px-4 py-2">${entry.total1}</td>
<td class="border px-4 py-2">${entry.total2}</td>
<td class="border px-4 py-2">${entry.total3}</td>
`;
historyBody.appendChild(row);
});
// Retrieve and display the totals for all three suppliers from localStorage
const total1 = localStorage.getItem("total1") || "0.00";
const total2 = localStorage.getItem("total2") || "0.00";
const total3 = localStorage.getItem("total3") || "0.00";
document.getElementById("total1").textContent = total1;
document.getElementById("total2").textContent = total2;
document.getElementById("total3").textContent = total3;
}
// Ensure the function runs once the page is loaded
document.addEventListener("DOMContentLoaded", loadHistory);
// Example function to save history data (call this when you save invoices)
function saveHistory(entry) {
const history = JSON.parse(localStorage.getItem("invoiceHistory") || "[]");
history.push(entry);
localStorage.setItem("invoiceHistory", JSON.stringify(history));
// Save the totals for each supplier
localStorage.setItem("total1", entry.total1 || "0.00");
localStorage.setItem("total2", entry.total2 || "0.00");
localStorage.setItem("total3", entry.total3 || "0.00");
}
// Example: Saving data (Test by uncommenting this code)
saveHistory({
date: "2024-10-14",
subtotal: "500",
vat: "50",
total1: "550",
total2: "600",
total3: "650"
});
</script>
</body>
</html>