prepare($query); $stmt->execute($params); $exportResults = $stmt->fetchAll(); // Group for Chart (Hours per Day) $grouped = []; foreach ($exportResults as $row) { $grouped[$row['entry_date']] = ($grouped[$row['entry_date']] ?? 0) + (float)$row['hours']; } ksort($grouped); $chartData = [ 'labels' => array_keys($grouped), 'values' => array_values($grouped) ]; } // Handle Calendar Report $cal_month = $_GET['month'] ?? date('Y-m'); $calendarData = []; if ($report_type === 'calendar') { $stmt = db()->prepare(" SELECT entry_date, SUM(hours) as total_hours FROM labour_entries WHERE tenant_id = ? AND DATE_FORMAT(entry_date, '%Y-%m') = ? GROUP BY entry_date "); $stmt->execute([$tenant_id, $cal_month]); $calendarData = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); } // Fetch helper data $employees = db()->prepare("SELECT id, name FROM employees WHERE tenant_id = ? ORDER BY name"); $employees->execute([$tenant_id]); $employeeList = $employees->fetchAll(); $teams = db()->prepare("SELECT id, name FROM teams WHERE tenant_id = ? ORDER BY name"); $teams->execute([$tenant_id]); $teamList = $teams->fetchAll(); $projects = db()->prepare("SELECT id, name FROM projects WHERE tenant_id = ? ORDER BY name"); $projects->execute([$tenant_id]); $projectList = $projects->fetchAll(); $labourTypes = db()->prepare("SELECT id, name FROM labour_types WHERE tenant_id = ? ORDER BY name"); $labourTypes->execute([$tenant_id]); $labourTypeList = $labourTypes->fetchAll(); $pageTitle = "SR&ED Manager - Reports"; include __DIR__ . '/includes/header.php'; ?>
Hold Ctrl/Cmd to select multiple
Detailed Labour Records
Date Employee Project Activity Hours
No records found for the selected criteria.
Total Hours:
Hours Breakdown
Monthly Labour Calendar -
Sun
Mon
Tue
Wed
Thu
Fri
Sat
'; } // Days of month for ($day = 1; $day <= $days_in_month; $day++) { $current_date = date('Y-m-', strtotime($cal_month)) . str_pad((string)$day, 2, '0', STR_PAD_LEFT); $hours = $calendarData[$current_date] ?? 0; ?>
0): ?> h
'; } ?>