diff --git a/assets/js/project_details.js b/assets/js/project_details.js
new file mode 100644
index 0000000..2046209
--- /dev/null
+++ b/assets/js/project_details.js
@@ -0,0 +1,76 @@
+
+document.addEventListener('DOMContentLoaded', function () {
+ const overrideBtn = document.getElementById('override-btn');
+
+ if (overrideBtn) {
+ overrideBtn.addEventListener('click', function () {
+ const projectId = this.dataset.projectId;
+ const month = this.dataset.month;
+
+ if (this.textContent.trim() === 'Override') {
+ this.textContent = 'Save';
+ this.classList.remove('btn-warning');
+ this.classList.add('btn-success');
+
+ makeEditable('WIP', month);
+ makeEditable('Opening-Balance', month);
+ makeEditable('Billings', month);
+ makeEditable('Expenses', month);
+
+ } else if (this.textContent.trim() === 'Save') {
+ const wip = document.getElementById(`wip-${month}-input`).value;
+ const openingBalance = document.getElementById(`opening-balance-${month}-input`).value;
+ const billings = document.getElementById(`billings-${month}-input`).value;
+ const expenses = document.getElementById(`expenses-${month}-input`).value;
+
+ const formData = new FormData();
+ formData.append('projectId', projectId);
+ formData.append('month', month);
+ formData.append('wip', wip);
+ formData.append('openingBalance', openingBalance);
+ formData.append('billings', billings);
+ formData.append('expenses', expenses);
+
+ fetch('save_override.php', {
+ method: 'POST',
+ body: formData
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ this.textContent = 'Overridden';
+ this.classList.remove('btn-success');
+ this.classList.add('btn-secondary');
+ this.disabled = true;
+
+ updateCell('WIP', month, wip);
+ updateCell('Opening-Balance', month, openingBalance);
+ updateCell('Billings', month, billings);
+ updateCell('Expenses', month, expenses);
+ } else {
+ alert('Error saving override: ' + data.error);
+ }
+ })
+ .catch(error => {
+ console.error('Error:', error);
+ alert('An unexpected error occurred.');
+ });
+ }
+ });
+ }
+
+ function makeEditable(metric, month) {
+ const cell = document.getElementById(`${metric.toLowerCase().replace(/\s/g, '-')}-${month}`);
+ if (cell) {
+ const value = cell.textContent.replace(/€/g, '').replace(/,/g, '');
+ cell.innerHTML = ``;
+ }
+ }
+
+ function updateCell(metric, month, value) {
+ const cell = document.getElementById(`${metric.toLowerCase().replace(/\s/g, '-')}-${month}`);
+ if (cell) {
+ cell.innerHTML = `€${parseFloat(value).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
+ }
+ }
+});
diff --git a/db/migrations/005_create_project_finance_monthly_table.sql b/db/migrations/005_create_project_finance_monthly_table.sql
index e0d9ee7..10ea925 100644
--- a/db/migrations/005_create_project_finance_monthly_table.sql
+++ b/db/migrations/005_create_project_finance_monthly_table.sql
@@ -3,7 +3,6 @@ CREATE TABLE IF NOT EXISTS `projectFinanceMonthly` (
`projectId` INT NOT NULL,
`metricName` VARCHAR(255) NOT NULL,
`month` DATE NOT NULL,
- `amount` DECIMAL(15, 2) NOT NULL,
`createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updatedAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`projectId`) REFERENCES `projects`(`id`) ON DELETE CASCADE,
diff --git a/db/migrations/009_add_value_and_overridden_to_project_finance_monthly.sql b/db/migrations/009_add_value_and_overridden_to_project_finance_monthly.sql
new file mode 100644
index 0000000..2d86e84
--- /dev/null
+++ b/db/migrations/009_add_value_and_overridden_to_project_finance_monthly.sql
@@ -0,0 +1,4 @@
+
+ALTER TABLE `projectFinanceMonthly`
+ADD COLUMN `value` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
+ADD COLUMN `is_overridden` BOOLEAN NOT NULL DEFAULT FALSE;
diff --git a/db/migrations/010_fix_project_finance_monthly_table.sql b/db/migrations/010_fix_project_finance_monthly_table.sql
new file mode 100644
index 0000000..2918ad7
--- /dev/null
+++ b/db/migrations/010_fix_project_finance_monthly_table.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `projectFinanceMonthly` ADD COLUMN `metricName` VARCHAR(255) NOT NULL AFTER `projectId`;
+ALTER TABLE `projectFinanceMonthly` ADD COLUMN `value` DECIMAL(15, 2) NOT NULL DEFAULT 0.00;
+ALTER TABLE `projectFinanceMonthly` ADD COLUMN `is_overridden` BOOLEAN NOT NULL DEFAULT FALSE;
\ No newline at end of file
diff --git a/project_details.php b/project_details.php
index 08fc482..3249c0e 100644
--- a/project_details.php
+++ b/project_details.php
@@ -236,17 +236,35 @@ if (!$project) {
Metric
-
-
-
+
+
+
+
+
+
+
+