prepare($projects_sql); $projects_stmt->execute([$tenant_id]); $all_projects = $projects_stmt->fetchAll(); $where_clauses = ["a.tenant_id = ?", "a.entity_type = 'labour_entry'"]; $params = [$tenant_id]; if (!$include_archived) { $where_clauses[] = "p.is_archived = 0"; } if ($project_filter) { $where_clauses[] = "le.project_id = ?"; $params[] = $project_filter; } if ($start_date) { $where_clauses[] = "le.entry_date >= ?"; $params[] = $start_date; } if ($end_date) { $where_clauses[] = "le.entry_date <= ?"; $params[] = $end_date; } $where_sql = implode(" AND ", $where_clauses); // Fetch Labour Files $stmt = db()->prepare(" SELECT a.*, le.entry_date, e.name as employee_name, p.name as project_name FROM attachments a JOIN labour_entries le ON a.entity_id = le.id JOIN employees e ON le.employee_id = e.id JOIN projects p ON le.project_id = p.id WHERE $where_sql ORDER BY a.created_at DESC "); $stmt->execute($params); $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 - Labour Files"; include __DIR__ . '/includes/header.php'; ?>
| Filename | Size | Uploaded By | Created At | Linked Entry | Actions |
|---|---|---|---|---|---|
| No labour files found. | |||||
| = htmlspecialchars($f['file_name']) ?> | = formatBytes((int)$f['file_size']) ?> |
|
= date('M j, Y H:i', strtotime($f['created_at'])) ?> |
= $f['entry_date'] ?>
= htmlspecialchars($f['employee_name']) ?> - = htmlspecialchars($f['project_name']) ?> |
View |