27 lines
722 B
PHP
27 lines
722 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
$employee_id = (int)($_GET['employee_id'] ?? 0);
|
|
$start_date = $_GET['start_date'] ?? '';
|
|
$end_date = $_GET['end_date'] ?? '';
|
|
|
|
if (!$employee_id || !$start_date || !$end_date) {
|
|
echo json_encode([]);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$db = db();
|
|
$stmt = $db->prepare("
|
|
SELECT entry_date, SUM(hours) as total_hours
|
|
FROM labour_entries
|
|
WHERE employee_id = ? AND entry_date BETWEEN ? AND ?
|
|
GROUP BY entry_date
|
|
");
|
|
$stmt->execute([$employee_id, $start_date, $end_date]);
|
|
echo json_encode($stmt->fetchAll());
|
|
} catch (Exception $e) {
|
|
echo json_encode(['error' => $e->getMessage()]);
|
|
}
|