diff --git a/assets/js/project_details.js b/assets/js/project_details.js
index 2b50d12..628e7a2 100644
--- a/assets/js/project_details.js
+++ b/assets/js/project_details.js
@@ -62,8 +62,12 @@ document.addEventListener('DOMContentLoaded', function () {
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 = ``;
+ let value = cell.textContent.replace(/€/g, '').replace(/,/g, '');
+ let numericValue = parseFloat(value);
+ if (isNaN(numericValue)) {
+ numericValue = 0;
+ }
+ cell.innerHTML = ``;
}
}
diff --git a/project_details.php b/project_details.php
index 3c64bfd..d6fa67f 100644
--- a/project_details.php
+++ b/project_details.php
@@ -218,7 +218,8 @@ if (!$project) {
diff --git a/project_finance_details.php b/project_finance_details.php
new file mode 100644
index 0000000..7555ee3
--- /dev/null
+++ b/project_finance_details.php
@@ -0,0 +1,153 @@
+prepare("SELECT name FROM projects WHERE id = :id");
+ $stmt->execute([':id' => $project_id]);
+ $project_name = $stmt->fetchColumn();
+
+ // Fetch financial data
+ $stmt = $pdo->prepare("SELECT * FROM projectFinanceMonthly");
+ $stmt->execute();
+ $financial_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ } catch (PDOException $e) {
+ $db_error = "Database error: " . $e->getMessage();
+ }
+} else {
+ $page_title = "Project ID not provided";
+}
+
+$page_title = $project_name ? "Financial Data for " . htmlspecialchars($project_name) : "Project Not Found";
+
+?>
+
+
+
+
+
+
+
+
+
+ Debug Mode: Showing all data from projectFinanceMonthly table.
+
+
+
+
+ Project not found or no ID provided.
+
+ No financial data found for this project.
+
+
+
+
+
+
+
+ 'Metric',
+ 'month' => 'Month',
+ 'opening_balance' => 'Opening Balance',
+ 'payment' => 'Payment',
+ 'wip' => 'WIP',
+ 'expenses' => 'Expenses',
+ 'cost' => 'Cost',
+ 'nsr' => 'NSR',
+ 'margin' => 'Margin',
+ 'is_confirmed' => 'Confirmed',
+ 'createdAt' => 'Created At',
+ 'updatedAt' => 'Updated At',
+ 'value' => 'Value',
+ 'is_overridden' => 'Overridden',
+ 'id' => 'ID',
+ ];
+
+ // Get the headers from the first row, but exclude projectId
+ $headers = [];
+ if (!empty($financial_data)) {
+ $headers = array_keys($financial_data[0]);
+ // Remove projectId from headers
+ $headers = array_filter($headers, fn($h) => $h !== 'projectId');
+ }
+
+ foreach ($headers as $key) {
+ $display_header = isset($header_map[$key]) ? $header_map[$key] : htmlspecialchars($key);
+ echo "| " . $display_header . " | ";
+ }
+ ?>
+
+
+
+
+
+ ' : '';
+ } elseif ($key === 'month') {
+ try {
+ $date = new DateTime($value);
+ $formatted_value = $date->format('F Y');
+ } catch (Exception $e) {
+ // keep original value if format fails
+ }
+ }
+
+ echo "| " . $formatted_value . " | ";
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file