148 lines
6.9 KiB
PHP
148 lines
6.9 KiB
PHP
<?php
|
|
// Get project metadata from environment variables
|
|
$project_name = !empty($_SERVER['PROJECT_NAME']) ? $_SERVER['PROJECT_NAME'] : 'Scheduler';
|
|
$project_description = !empty($_SERVER['PROJECT_DESCRIPTION']) ? $_SERVER['PROJECT_DESCRIPTION'] : 'Employee Schedule Management';
|
|
$project_image_url = !empty($_SERVER['PROJECT_IMAGE_URL']) ? $_SERVER['PROJECT_IMAGE_URL'] : ''; // Default image if none
|
|
|
|
// Sample Data for the Grid
|
|
$employees = [
|
|
['id' => 1, 'name' => 'Daniel Miller'],
|
|
['id' => 2, 'name' => 'Sophia Chen'],
|
|
['id' => 3, 'name' => 'James Wilson'],
|
|
['id' => 4, 'name' => 'Olivia Garcia'],
|
|
];
|
|
|
|
// Get current week
|
|
$date = new DateTime();
|
|
$week_start = clone $date;
|
|
$week_start->modify('monday this week');
|
|
$days_of_week = [];
|
|
for ($i = 0; $i < 7; $i++) {
|
|
$days_of_week[] = (clone $week_start)->modify("+$i days");
|
|
}
|
|
|
|
$shifts = [
|
|
// Monday
|
|
['date' => $days_of_week[0]->format('Y-m-d'), 'employee_id' => 1, 'start_time' => '08:00', 'end_time' => '16:00', 'location' => 'Main Office'],
|
|
['date' => $days_of_week[0]->format('Y-m-d'), 'employee_id' => 3, 'start_time' => '09:00', 'end_time' => '17:00', 'location' => 'Warehouse'],
|
|
// Tuesday
|
|
['date' => $days_of_week[1]->format('Y-m-d'), 'employee_id' => 2, 'start_time' => '10:00', 'end_time' => '18:00', 'location' => 'Main Office'],
|
|
// Wednesday
|
|
['date' => $days_of_week[2]->format('Y-m-d'), 'employee_id' => 1, 'start_time' => '08:30', 'end_time' => '16:30', 'location' => 'Remote'],
|
|
['date' => $days_of_week[2]->format('Y-m-d'), 'employee_id' => 4, 'start_time' => '11:00', 'end_time' => '19:00', 'location' => 'Main Office'],
|
|
// Thursday
|
|
['date' => $days_of_week[3]->format('Y-m-d'), 'employee_id' => 2, 'start_time' => '09:00', 'end_time' => '17:00', 'location' => 'Warehouse'],
|
|
['date' => $days_of_week[3]->format('Y-m-d'), 'employee_id' => 3, 'start_time' => '12:00', 'end_time' => '20:00', 'location' => 'Main Office'],
|
|
// Friday
|
|
['date' => $days_of_week[4]->format('Y-m-d'), 'employee_id' => 4, 'start_time' => '09:00', 'end_time' => '17:00', 'location' => 'Main Office'],
|
|
];
|
|
|
|
function find_shifts_for_employee_and_day($employee_id, $date, $shifts) {
|
|
$result = [];
|
|
foreach ($shifts as $shift) {
|
|
if ($shift['employee_id'] == $employee_id && $shift['date'] == $date) {
|
|
$result[] = $shift;
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($project_name); ?> - Weekly Schedule</title>
|
|
|
|
<!-- SEO and Meta Tags -->
|
|
<meta name="description" content="<?php echo htmlspecialchars($project_description); ?>">
|
|
<meta property="og:title" content="<?php echo htmlspecialchars($project_name); ?>">
|
|
<meta property="og:description" content="<?php echo htmlspecialchars($project_description); ?>">
|
|
<?php if ($project_image_url): ?>
|
|
<meta property="og:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
|
|
<meta name="twitter:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
|
|
<?php endif; ?>
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
|
|
<!-- Stylesheets -->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
|
|
<!-- Icons -->
|
|
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container-fluid my-4">
|
|
|
|
<!-- Header -->
|
|
<header class="d-flex justify-content-between align-items-center main-header glass-panel">
|
|
<h1 class="h4 m-0 fw-bold"><?php echo htmlspecialchars($project_name); ?></h1>
|
|
<div class="d-flex align-items-center">
|
|
<button class="btn btn-primary me-3">Publish Schedule</button>
|
|
<div class="avatar">M</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Main Content -->
|
|
<main>
|
|
<div class="schedule-grid-container glass-panel p-3">
|
|
<table class="schedule-grid">
|
|
<thead>
|
|
<tr>
|
|
<th>Employee</th>
|
|
<?php foreach ($days_of_week as $day): ?>
|
|
<th class="text-center">
|
|
<?php echo $day->format('D'); ?><br>
|
|
<small><?php echo $day->format('M j'); ?></small>
|
|
</th>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($employees as $employee): ?>
|
|
<tr class="employee-row">
|
|
<td><?php echo htmlspecialchars($employee['name']); ?></td>
|
|
<?php foreach ($days_of_week as $day): ?>
|
|
<td class="text-center">
|
|
<?php
|
|
$shifts_for_day = find_shifts_for_employee_and_day($employee['id'], $day->format('Y-m-d'), $shifts);
|
|
<?php
|
|
if (empty($shifts_for_day)):
|
|
echo 'Off';
|
|
else:
|
|
foreach ($shifts_for_day as $shift):
|
|
?>
|
|
<span class="shift-time"><?php echo htmlspecialchars($shift['start_time']); ?> - <?php echo htmlspecialchars($shift['end_time']); ?></span>
|
|
<span class="shift-location">
|
|
<i data-feather="map-pin" width="12" height="12"></i>
|
|
<?php echo htmlspecialchars($shift['location']); ?>
|
|
</span>
|
|
<?php
|
|
endforeach;
|
|
endif;
|
|
?>
|
|
</td>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</main>
|
|
|
|
</div>
|
|
|
|
<!-- Scripts -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
<script>
|
|
feather.replace();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|