From 87b38e5dfa8b0092113f2a385cff40a42efd8cd8 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 15 Feb 2026 01:33:27 +0000 Subject: [PATCH] Autosave: 20260215-013327 --- expense_files.php | 88 +++++++++++++++++ expenses.php | 2 +- files.php | 97 ++++++++++++++++++ includes/header.php | 30 ++++-- labour.php | 2 +- labour_files.php | 88 +++++++++++++++++ settings.php | 233 ++++++++++++++++++++++++++++---------------- 7 files changed, 447 insertions(+), 93 deletions(-) create mode 100644 expense_files.php create mode 100644 files.php create mode 100644 labour_files.php diff --git a/expense_files.php b/expense_files.php new file mode 100644 index 0000000..4c61839 --- /dev/null +++ b/expense_files.php @@ -0,0 +1,88 @@ +prepare(" + SELECT a.*, ex.entry_date, s.name as supplier_name, p.name as project_name + FROM attachments a + JOIN expenses ex ON a.entity_id = ex.id + JOIN suppliers s ON ex.supplier_id = s.id + JOIN projects p ON ex.project_id = p.id + WHERE a.tenant_id = ? AND a.entity_type = 'expense' + ORDER BY a.created_at DESC +"); +$stmt->execute([$tenant_id]); +$files = $stmt->fetchAll(); + +function formatBytes($bytes, $precision = 2) { + $units = ['B', 'KB', 'MB', 'GB', 'TB']; + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + $bytes /= pow(1024, $pow); + return round($bytes, $precision) . ' ' . $units[$pow]; +} + +$pageTitle = "SR&ED Manager - Expense Files"; +include __DIR__ . '/includes/header.php'; +?> + +
+
+

Expense Files

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameSizeUploaded ByCreated AtLinked EntryActions
No expense files found.
+ + + +
+
+ +
+ +
+
+
+
+ - +
+
+ View +
+
+
+
+ + diff --git a/expenses.php b/expenses.php index 1065698..5558ce2 100644 --- a/expenses.php +++ b/expenses.php @@ -32,7 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_expense'])) { if (!is_dir('uploads')) mkdir('uploads', 0775, true); if (move_uploaded_file($tmp_name, $file_path)) { - $stmt = db()->prepare("INSERT INTO attachments (tenant_id, entity_type, entity_id, file_name, file_path, file_size, mime_type) VALUES (?, 'expense', ?, ?, ?, ?, ?)"); + $stmt = db()->prepare("INSERT INTO attachments (tenant_id, entity_type, entity_id, file_name, file_path, file_size, mime_type, uploaded_by) VALUES (?, 'expense', ?, ?, ?, ?, ?, 'John Manager')"); $stmt->execute([$tenant_id, $expense_id, $file_name, $file_path, $file_size, $mime_type]); } } diff --git a/files.php b/files.php new file mode 100644 index 0000000..64d4c0a --- /dev/null +++ b/files.php @@ -0,0 +1,97 @@ +prepare(" + SELECT a.*, + CASE + WHEN a.entity_type = 'labour_entry' THEN (SELECT CONCAT(le.entry_date, ' - ', e.name, ' - ', p.name) FROM labour_entries le JOIN employees e ON le.employee_id = e.id JOIN projects p ON le.project_id = p.id WHERE le.id = a.entity_id) + WHEN a.entity_type = 'expense' THEN (SELECT CONCAT(ex.entry_date, ' - ', s.name, ' - ', p.name) FROM expenses ex JOIN suppliers s ON ex.supplier_id = s.id JOIN projects p ON ex.project_id = p.id WHERE ex.id = a.entity_id) + ELSE 'Other' + END as linked_entry_info + FROM attachments a + WHERE a.tenant_id = ? + ORDER BY a.created_at DESC +"); +$stmt->execute([$tenant_id]); +$files = $stmt->fetchAll(); + +function formatBytes($bytes, $precision = 2) { + $units = ['B', 'KB', 'MB', 'GB', 'TB']; + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + $bytes /= pow(1024, $pow); + return round($bytes, $precision) . ' ' . $units[$pow]; +} + +$pageTitle = "SR&ED Manager - All Files Report"; +include __DIR__ . '/includes/header.php'; +?> + +
+
+

System Files Report

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeFilenameSizeUploaded ByCreated AtLinked EntryActions
No files found in the system.
+ + Labour + + Expense + + + + + + + + + + + View +
+
+
+
+ + + + diff --git a/includes/header.php b/includes/header.php index 5e7f483..8c9c0d4 100644 --- a/includes/header.php +++ b/includes/header.php @@ -41,17 +41,35 @@ $currentPage = basename($_SERVER['PHP_SELF']); - - -