Spaces:
Running
Running
generate Capex sheet with a downloadable excel sheet, complete with a dashboard tab, displaying all the metrics from the main sheet
Browse files- README.md +8 -5
- components/footer.js +59 -0
- components/navbar.js +82 -0
- index.html +132 -19
- script.js +222 -0
- style.css +44 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title: Capex Commander
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Capex Commander 🚀
|
| 3 |
+
colorFrom: red
|
| 4 |
+
colorTo: purple
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
components/footer.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomFooter extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
width: 100%;
|
| 9 |
+
background-color: #1e293b;
|
| 10 |
+
color: white;
|
| 11 |
+
margin-top: auto;
|
| 12 |
+
}
|
| 13 |
+
footer {
|
| 14 |
+
padding: 2rem;
|
| 15 |
+
text-align: center;
|
| 16 |
+
max-width: 1200px;
|
| 17 |
+
margin: 0 auto;
|
| 18 |
+
}
|
| 19 |
+
.footer-content {
|
| 20 |
+
display: flex;
|
| 21 |
+
flex-direction: column;
|
| 22 |
+
align-items: center;
|
| 23 |
+
gap: 1rem;
|
| 24 |
+
}
|
| 25 |
+
.footer-links {
|
| 26 |
+
display: flex;
|
| 27 |
+
gap: 1.5rem;
|
| 28 |
+
justify-content: center;
|
| 29 |
+
}
|
| 30 |
+
a {
|
| 31 |
+
color: #93c5fd;
|
| 32 |
+
text-decoration: none;
|
| 33 |
+
transition: color 0.2s;
|
| 34 |
+
}
|
| 35 |
+
a:hover {
|
| 36 |
+
color: white;
|
| 37 |
+
}
|
| 38 |
+
.copyright {
|
| 39 |
+
font-size: 0.875rem;
|
| 40 |
+
color: #9ca3af;
|
| 41 |
+
}
|
| 42 |
+
</style>
|
| 43 |
+
<footer>
|
| 44 |
+
<div class="footer-content">
|
| 45 |
+
<div class="footer-links">
|
| 46 |
+
<a href="#">Privacy Policy</a>
|
| 47 |
+
<a href="#">Terms of Service</a>
|
| 48 |
+
<a href="#">Contact Us</a>
|
| 49 |
+
</div>
|
| 50 |
+
<div class="copyright">
|
| 51 |
+
© ${new Date().getFullYear()} Capex Commander. All rights reserved.
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</footer>
|
| 55 |
+
`;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
customElements.define('custom-footer', CustomFooter);
|
components/navbar.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomNavbar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
width: 100%;
|
| 9 |
+
background-color: #1e293b;
|
| 10 |
+
color: white;
|
| 11 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
| 12 |
+
}
|
| 13 |
+
nav {
|
| 14 |
+
display: flex;
|
| 15 |
+
justify-content: space-between;
|
| 16 |
+
align-items: center;
|
| 17 |
+
padding: 1rem 2rem;
|
| 18 |
+
max-width: 1200px;
|
| 19 |
+
margin: 0 auto;
|
| 20 |
+
}
|
| 21 |
+
.logo {
|
| 22 |
+
font-size: 1.5rem;
|
| 23 |
+
font-weight: 700;
|
| 24 |
+
display: flex;
|
| 25 |
+
align-items: center;
|
| 26 |
+
}
|
| 27 |
+
.logo i {
|
| 28 |
+
margin-right: 0.75rem;
|
| 29 |
+
}
|
| 30 |
+
.nav-links {
|
| 31 |
+
display: flex;
|
| 32 |
+
gap: 1.5rem;
|
| 33 |
+
}
|
| 34 |
+
a {
|
| 35 |
+
color: white;
|
| 36 |
+
text-decoration: none;
|
| 37 |
+
font-weight: 500;
|
| 38 |
+
transition: color 0.2s;
|
| 39 |
+
display: flex;
|
| 40 |
+
align-items: center;
|
| 41 |
+
gap: 0.5rem;
|
| 42 |
+
}
|
| 43 |
+
a:hover {
|
| 44 |
+
color: #93c5fd;
|
| 45 |
+
}
|
| 46 |
+
@media (max-width: 768px) {
|
| 47 |
+
nav {
|
| 48 |
+
flex-direction: column;
|
| 49 |
+
padding: 1rem;
|
| 50 |
+
}
|
| 51 |
+
.nav-links {
|
| 52 |
+
margin-top: 1rem;
|
| 53 |
+
width: 100%;
|
| 54 |
+
justify-content: space-between;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
</style>
|
| 58 |
+
<nav>
|
| 59 |
+
<a href="/" class="logo">
|
| 60 |
+
<i data-feather="dollar-sign"></i>
|
| 61 |
+
<span>Capex Commander</span>
|
| 62 |
+
</a>
|
| 63 |
+
<div class="nav-links">
|
| 64 |
+
<a href="#">
|
| 65 |
+
<i data-feather="home"></i>
|
| 66 |
+
<span>Dashboard</span>
|
| 67 |
+
</a>
|
| 68 |
+
<a href="#">
|
| 69 |
+
<i data-feather="settings"></i>
|
| 70 |
+
<span>Settings</span>
|
| 71 |
+
</a>
|
| 72 |
+
<a href="#">
|
| 73 |
+
<i data-feather="user"></i>
|
| 74 |
+
<span>Profile</span>
|
| 75 |
+
</a>
|
| 76 |
+
</div>
|
| 77 |
+
</nav>
|
| 78 |
+
`;
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
customElements.define('custom-navbar', CustomNavbar);
|
index.html
CHANGED
|
@@ -1,19 +1,132 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Capex Commander - Capital Expenditure Tracker</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<script src="https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js"></script>
|
| 12 |
+
<script src="components/navbar.js"></script>
|
| 13 |
+
<script src="components/footer.js"></script>
|
| 14 |
+
</head>
|
| 15 |
+
<body class="bg-gray-50">
|
| 16 |
+
<custom-navbar></custom-navbar>
|
| 17 |
+
|
| 18 |
+
<main class="container mx-auto px-4 py-8">
|
| 19 |
+
<div class="flex justify-between items-center mb-8">
|
| 20 |
+
<h1 class="text-3xl font-bold text-gray-800">Capex Commander</h1>
|
| 21 |
+
<div class="flex space-x-3">
|
| 22 |
+
<button id="exportBtn" class="flex items-center bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition">
|
| 23 |
+
<i data-feather="download" class="mr-2"></i> Export to Excel
|
| 24 |
+
</button>
|
| 25 |
+
<button id="addRowBtn" class="flex items-center bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg transition">
|
| 26 |
+
<i data-feather="plus" class="mr-2"></i> Add Item
|
| 27 |
+
</button>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<div class="flex flex-col md:flex-row gap-6">
|
| 32 |
+
<!-- Data Entry Section -->
|
| 33 |
+
<div class="w-full md:w-2/3">
|
| 34 |
+
<div class="bg-white rounded-xl shadow-md overflow-hidden">
|
| 35 |
+
<div class="bg-gray-800 text-white px-6 py-4">
|
| 36 |
+
<h2 class="text-xl font-semibold">Capex Entries</h2>
|
| 37 |
+
</div>
|
| 38 |
+
<div class="overflow-x-auto">
|
| 39 |
+
<table id="capexTable" class="w-full">
|
| 40 |
+
<thead class="bg-gray-100">
|
| 41 |
+
<tr>
|
| 42 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Project</th>
|
| 43 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
|
| 44 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Description</th>
|
| 45 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Amount</th>
|
| 46 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
|
| 47 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
|
| 48 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
| 49 |
+
</tr>
|
| 50 |
+
</thead>
|
| 51 |
+
<tbody class="bg-white divide-y divide-gray-200">
|
| 52 |
+
<!-- Sample initial row -->
|
| 53 |
+
<tr>
|
| 54 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 55 |
+
<input type="text" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="Office Renovation">
|
| 56 |
+
</td>
|
| 57 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 58 |
+
<select class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded bg-transparent">
|
| 59 |
+
<option>Facilities</option>
|
| 60 |
+
<option>Technology</option>
|
| 61 |
+
<option>Equipment</option>
|
| 62 |
+
<option>Vehicles</option>
|
| 63 |
+
</select>
|
| 64 |
+
</td>
|
| 65 |
+
<td class="px-6 py-4">
|
| 66 |
+
<input type="text" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="New furniture for 2nd floor">
|
| 67 |
+
</td>
|
| 68 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 69 |
+
<input type="number" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="12500">
|
| 70 |
+
</td>
|
| 71 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 72 |
+
<input type="date" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="2023-10-15">
|
| 73 |
+
</td>
|
| 74 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 75 |
+
<select class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded bg-transparent">
|
| 76 |
+
<option>Planned</option>
|
| 77 |
+
<option>Approved</option>
|
| 78 |
+
<option>In Progress</option>
|
| 79 |
+
<option>Completed</option>
|
| 80 |
+
</select>
|
| 81 |
+
</td>
|
| 82 |
+
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
| 83 |
+
<button class="text-red-500 hover:text-red-700 delete-row">
|
| 84 |
+
<i data-feather="trash-2"></i>
|
| 85 |
+
</button>
|
| 86 |
+
</td>
|
| 87 |
+
</tr>
|
| 88 |
+
</tbody>
|
| 89 |
+
</table>
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<!-- Dashboard Section -->
|
| 95 |
+
<div class="w-full md:w-1/3">
|
| 96 |
+
<div class="bg-white rounded-xl shadow-md overflow-hidden h-full">
|
| 97 |
+
<div class="bg-gray-800 text-white px-6 py-4">
|
| 98 |
+
<h2 class="text-xl font-semibold">Capex Dashboard</h2>
|
| 99 |
+
</div>
|
| 100 |
+
<div class="p-6 space-y-6">
|
| 101 |
+
<div class="bg-blue-50 rounded-lg p-4">
|
| 102 |
+
<h3 class="text-sm font-medium text-gray-500">Total Capex</h3>
|
| 103 |
+
<p id="totalCapex" class="text-3xl font-bold text-blue-600">$12,500</p>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<div>
|
| 107 |
+
<h3 class="text-sm font-medium text-gray-500 mb-2">By Category</h3>
|
| 108 |
+
<div id="categoryChart" class="h-48">
|
| 109 |
+
<!-- Chart will be rendered here -->
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<div>
|
| 114 |
+
<h3 class="text-sm font-medium text-gray-500 mb-2">By Status</h3>
|
| 115 |
+
<div id="statusChart" class="h-48">
|
| 116 |
+
<!-- Chart will be rendered here -->
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</main>
|
| 124 |
+
|
| 125 |
+
<custom-footer></custom-footer>
|
| 126 |
+
|
| 127 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 128 |
+
<script src="script.js"></script>
|
| 129 |
+
<script>feather.replace();</script>
|
| 130 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 131 |
+
</body>
|
| 132 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 2 |
+
// Initialize Feather Icons
|
| 3 |
+
feather.replace();
|
| 4 |
+
|
| 5 |
+
// Initialize Charts
|
| 6 |
+
const categoryCtx = document.getElementById('categoryChart').getContext('2d');
|
| 7 |
+
const statusCtx = document.getElementById('statusChart').getContext('2d');
|
| 8 |
+
|
| 9 |
+
let categoryChart = new Chart(categoryCtx, {
|
| 10 |
+
type: 'doughnut',
|
| 11 |
+
data: {
|
| 12 |
+
labels: ['Facilities', 'Technology', 'Equipment', 'Vehicles'],
|
| 13 |
+
datasets: [{
|
| 14 |
+
data: [12500, 0, 0, 0],
|
| 15 |
+
backgroundColor: [
|
| 16 |
+
'#3B82F6',
|
| 17 |
+
'#10B981',
|
| 18 |
+
'#F59E0B',
|
| 19 |
+
'#EF4444'
|
| 20 |
+
],
|
| 21 |
+
borderWidth: 0
|
| 22 |
+
}]
|
| 23 |
+
},
|
| 24 |
+
options: {
|
| 25 |
+
responsive: true,
|
| 26 |
+
maintainAspectRatio: false,
|
| 27 |
+
cutout: '70%',
|
| 28 |
+
plugins: {
|
| 29 |
+
legend: {
|
| 30 |
+
position: 'bottom',
|
| 31 |
+
labels: {
|
| 32 |
+
boxWidth: 12,
|
| 33 |
+
padding: 20
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
let statusChart = new Chart(statusCtx, {
|
| 41 |
+
type: 'bar',
|
| 42 |
+
data: {
|
| 43 |
+
labels: ['Planned', 'Approved', 'In Progress', 'Completed'],
|
| 44 |
+
datasets: [{
|
| 45 |
+
label: 'Amount',
|
| 46 |
+
data: [12500, 0, 0, 0],
|
| 47 |
+
backgroundColor: '#3B82F6',
|
| 48 |
+
borderRadius: 4
|
| 49 |
+
}]
|
| 50 |
+
},
|
| 51 |
+
options: {
|
| 52 |
+
responsive: true,
|
| 53 |
+
maintainAspectRatio: false,
|
| 54 |
+
scales: {
|
| 55 |
+
y: {
|
| 56 |
+
beginAtZero: true,
|
| 57 |
+
grid: {
|
| 58 |
+
display: false
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
x: {
|
| 62 |
+
grid: {
|
| 63 |
+
display: false
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
},
|
| 67 |
+
plugins: {
|
| 68 |
+
legend: {
|
| 69 |
+
display: false
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
// Add row functionality
|
| 76 |
+
document.getElementById('addRowBtn').addEventListener('click', function() {
|
| 77 |
+
const tbody = document.querySelector('#capexTable tbody');
|
| 78 |
+
const newRow = document.createElement('tr');
|
| 79 |
+
newRow.innerHTML = `
|
| 80 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 81 |
+
<input type="text" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="">
|
| 82 |
+
</td>
|
| 83 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 84 |
+
<select class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded bg-transparent">
|
| 85 |
+
<option>Facilities</option>
|
| 86 |
+
<option>Technology</option>
|
| 87 |
+
<option>Equipment</option>
|
| 88 |
+
<option>Vehicles</option>
|
| 89 |
+
</select>
|
| 90 |
+
</td>
|
| 91 |
+
<td class="px-6 py-4">
|
| 92 |
+
<input type="text" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="">
|
| 93 |
+
</td>
|
| 94 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 95 |
+
<input type="number" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="0">
|
| 96 |
+
</td>
|
| 97 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 98 |
+
<input type="date" class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded" value="${new Date().toISOString().split('T')[0]}">
|
| 99 |
+
</td>
|
| 100 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 101 |
+
<select class="w-full border-0 focus:ring-2 focus:ring-blue-500 rounded bg-transparent">
|
| 102 |
+
<option>Planned</option>
|
| 103 |
+
<option>Approved</option>
|
| 104 |
+
<option>In Progress</option>
|
| 105 |
+
<option>Completed</option>
|
| 106 |
+
</select>
|
| 107 |
+
</td>
|
| 108 |
+
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
| 109 |
+
<button class="text-red-500 hover:text-red-700 delete-row">
|
| 110 |
+
<i data-feather="trash-2"></i>
|
| 111 |
+
</button>
|
| 112 |
+
</td>
|
| 113 |
+
`;
|
| 114 |
+
tbody.appendChild(newRow);
|
| 115 |
+
feather.replace();
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
// Delete row functionality
|
| 119 |
+
document.addEventListener('click', function(e) {
|
| 120 |
+
if (e.target.closest('.delete-row')) {
|
| 121 |
+
const row = e.target.closest('tr');
|
| 122 |
+
row.remove();
|
| 123 |
+
updateDashboard();
|
| 124 |
+
}
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
// Update dashboard when inputs change
|
| 128 |
+
document.addEventListener('input', function(e) {
|
| 129 |
+
if (e.target.tagName === 'INPUT' || e.target.tagName === 'SELECT') {
|
| 130 |
+
updateDashboard();
|
| 131 |
+
}
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
// Export to Excel functionality
|
| 135 |
+
document.getElementById('exportBtn').addEventListener('click', exportToExcel);
|
| 136 |
+
|
| 137 |
+
// Function to update dashboard metrics
|
| 138 |
+
function updateDashboard() {
|
| 139 |
+
const rows = document.querySelectorAll('#capexTable tbody tr');
|
| 140 |
+
let total = 0;
|
| 141 |
+
const categories = {
|
| 142 |
+
'Facilities': 0,
|
| 143 |
+
'Technology': 0,
|
| 144 |
+
'Equipment': 0,
|
| 145 |
+
'Vehicles': 0
|
| 146 |
+
};
|
| 147 |
+
const statuses = {
|
| 148 |
+
'Planned': 0,
|
| 149 |
+
'Approved': 0,
|
| 150 |
+
'In Progress': 0,
|
| 151 |
+
'Completed': 0
|
| 152 |
+
};
|
| 153 |
+
|
| 154 |
+
rows.forEach(row => {
|
| 155 |
+
const amount = parseFloat(row.querySelector('td:nth-child(4) input').value) || 0;
|
| 156 |
+
const category = row.querySelector('td:nth-child(2) select').value;
|
| 157 |
+
const status = row.querySelector('td:nth-child(6) select').value;
|
| 158 |
+
|
| 159 |
+
total += amount;
|
| 160 |
+
categories[category] += amount;
|
| 161 |
+
statuses[status] += amount;
|
| 162 |
+
});
|
| 163 |
+
|
| 164 |
+
// Update total
|
| 165 |
+
document.getElementById('totalCapex').textContent = '$' + total.toLocaleString();
|
| 166 |
+
|
| 167 |
+
// Update category chart
|
| 168 |
+
categoryChart.data.datasets[0].data = Object.values(categories);
|
| 169 |
+
categoryChart.update();
|
| 170 |
+
|
| 171 |
+
// Update status chart
|
| 172 |
+
statusChart.data.datasets[0].data = Object.values(statuses);
|
| 173 |
+
statusChart.update();
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// Function to export data to Excel
|
| 177 |
+
function exportToExcel() {
|
| 178 |
+
const wb = XLSX.utils.book_new();
|
| 179 |
+
|
| 180 |
+
// Create data sheet
|
| 181 |
+
const dataRows = [];
|
| 182 |
+
const headers = ['Project', 'Category', 'Description', 'Amount', 'Date', 'Status'];
|
| 183 |
+
|
| 184 |
+
dataRows.push(headers);
|
| 185 |
+
|
| 186 |
+
document.querySelectorAll('#capexTable tbody tr').forEach(row => {
|
| 187 |
+
const rowData = [
|
| 188 |
+
row.querySelector('td:nth-child(1) input').value,
|
| 189 |
+
row.querySelector('td:nth-child(2) select').value,
|
| 190 |
+
row.querySelector('td:nth-child(3) input').value,
|
| 191 |
+
parseFloat(row.querySelector('td:nth-child(4) input').value) || 0,
|
| 192 |
+
row.querySelector('td:nth-child(5) input').value,
|
| 193 |
+
row.querySelector('td:nth-child(6) select').value
|
| 194 |
+
];
|
| 195 |
+
dataRows.push(rowData);
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
const dataWs = XLSX.utils.aoa_to_sheet(dataRows);
|
| 199 |
+
XLSX.utils.book_append_sheet(wb, dataWs, "Capex Data");
|
| 200 |
+
|
| 201 |
+
// Create dashboard sheet
|
| 202 |
+
const dashboardData = [
|
| 203 |
+
['Metric', 'Value'],
|
| 204 |
+
['Total Capex', parseFloat(document.getElementById('totalCapex').textContent.replace(/[^0-9.-]+/g,""))],
|
| 205 |
+
...Object.entries(categoryChart.data.datasets[0].data).map(([i, value]) =>
|
| 206 |
+
[`${categoryChart.data.labels[i]} Capex`, value]
|
| 207 |
+
),
|
| 208 |
+
...Object.entries(statusChart.data.datasets[0].data).map(([i, value]) =>
|
| 209 |
+
[`${statusChart.data.labels[i]} Capex`, value]
|
| 210 |
+
)
|
| 211 |
+
];
|
| 212 |
+
|
| 213 |
+
const dashboardWs = XLSX.utils.aoa_to_sheet(dashboardData);
|
| 214 |
+
XLSX.utils.book_append_sheet(wb, dashboardWs, "Dashboard");
|
| 215 |
+
|
| 216 |
+
// Export the workbook
|
| 217 |
+
XLSX.writeFile(wb, 'capex_report.xlsx');
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
// Initial dashboard update
|
| 221 |
+
updateDashboard();
|
| 222 |
+
});
|
style.css
CHANGED
|
@@ -1,28 +1,54 @@
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Base styles */
|
| 2 |
body {
|
| 3 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 4 |
+
min-height: 100vh;
|
| 5 |
+
display: flex;
|
| 6 |
+
flex-direction: column;
|
| 7 |
}
|
| 8 |
|
| 9 |
+
/* Table styles */
|
| 10 |
+
table {
|
| 11 |
+
border-collapse: separate;
|
| 12 |
+
border-spacing: 0;
|
| 13 |
}
|
| 14 |
|
| 15 |
+
th {
|
| 16 |
+
position: sticky;
|
| 17 |
+
top: 0;
|
| 18 |
+
background-color: #f9fafb;
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
+
td, th {
|
| 22 |
+
padding: 0.75rem 1.5rem;
|
| 23 |
+
text-align: left;
|
| 24 |
+
vertical-align: middle;
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
+
tr:nth-child(even) {
|
| 28 |
+
background-color: #f9fafb;
|
| 29 |
}
|
| 30 |
+
|
| 31 |
+
/* Input styles */
|
| 32 |
+
input, select {
|
| 33 |
+
background-color: transparent;
|
| 34 |
+
padding: 0.25rem 0.5rem;
|
| 35 |
+
outline: none;
|
| 36 |
+
min-width: 100px;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/* Chart container */
|
| 40 |
+
.chart-container {
|
| 41 |
+
position: relative;
|
| 42 |
+
height: 100%;
|
| 43 |
+
width: 100%;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/* Animation for dashboard elements */
|
| 47 |
+
@keyframes fadeIn {
|
| 48 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 49 |
+
to { opacity: 1; transform: translateY(0); }
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.dashboard-item {
|
| 53 |
+
animation: fadeIn 0.5s ease-out forwards;
|
| 54 |
+
}
|