From c76337f9a8a7be02817cec451358029c578f0001 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 26 Nov 2025 17:09:25 +0000 Subject: [PATCH] over5 --- assets/js/project_details.js | 8 +- project_details.php | 3 +- project_finance_details.php | 153 +++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 project_finance_details.php 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) {
Billing Expenses - Forecasting + Forecasting + View Data
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"; + +?> + + + + + + <?php echo $page_title; ?> + + + + + + +
+ Project Financials +
+
+ + +
+ + +
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 ""; + } + ?> + + + + + + ' : ''; + } elseif ($key === 'month') { + try { + $date = new DateTime($value); + $formatted_value = $date->format('F Y'); + } catch (Exception $e) { + // keep original value if format fails + } + } + + echo ""; + } + ?> + + + +
" . $display_header . "
" . $formatted_value . "
+
+
+
+ +
+
+ + + + \ No newline at end of file