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'; ?>
| Type | Filename | Size | Uploaded By | Created At | Linked Entry | Actions |
|---|---|---|---|---|---|---|
| No files found in the system. | ||||||
| Labour Expense = ucfirst($f['entity_type']) ?> | = htmlspecialchars($f['file_name']) ?> | = formatBytes((int)$f['file_size']) ?> | = htmlspecialchars($f['uploaded_by'] ?? 'System') ?> | = date('M j, Y', strtotime($f['created_at'])) ?> | = htmlspecialchars($f['linked_entry_info'] ?? 'N/A') ?> | View |