114 lines
3.6 KiB
PHP
Executable File
114 lines
3.6 KiB
PHP
Executable File
<style>
|
|
.schedule-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-bottom: 10px;
|
|
color: #fff;
|
|
}
|
|
|
|
.schedule-row label {
|
|
min-width: 100px;
|
|
}
|
|
|
|
.schedule-row input[type="text"] {
|
|
background: #fff;
|
|
border: 1px solid #ccc;
|
|
padding: 4px 6px;
|
|
color: #000;
|
|
width: 70px;
|
|
font-size: 14px;
|
|
text-align: center;
|
|
}
|
|
|
|
.alternate-week-wrapper {
|
|
margin-left: 15px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
color: #fff;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.schedule-row input[type="checkbox"] {
|
|
transform: scale(1.1);
|
|
accent-color: #00ffcc;
|
|
background-color: #000;
|
|
border: 1px solid #fff;
|
|
}
|
|
|
|
input[type="submit"] {
|
|
padding: 8px 16px;
|
|
font-weight: bold;
|
|
background: #333;
|
|
color: #fff;
|
|
border: 1px solid #555;
|
|
cursor: pointer;
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|
|
|
|
<h2>Dolgozó munkaidő beállítása</h2>
|
|
|
|
<!-- Worker selection form (GET) -->
|
|
<form method="GET" action="<?php echo site_url('admin/worker_schedule'); ?>">
|
|
<label for="worker_id">Dolgozó:</label>
|
|
<select name="worker_id" onchange="this.form.submit()" required>
|
|
<option value="">-- Válassz dolgozót --</option>
|
|
<?php foreach ($workers as $worker): ?>
|
|
<option value="<?= $worker->worker_id ?>" <?= isset($selectedWorkerId) && $selectedWorkerId == $worker->worker_id ? 'selected' : '' ?>>
|
|
<?= $worker->worker_name ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</form>
|
|
<?php
|
|
$days = ['Vasárnap', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'];
|
|
?>
|
|
<?php if (!empty($schedule)): ?>
|
|
<h3>Jelenlegi beállítások</h3>
|
|
<ul style="color: white; margin-bottom: 20px;">
|
|
<?php foreach ($schedule as $row): ?>
|
|
<li>
|
|
<?= $days[$row->weekday] ?>:
|
|
<?= substr($row->start_time, 0, 5) ?> - <?= substr($row->end_time, 0, 5) ?>
|
|
<?= $row->is_alternate_week ? '(Minden 2. hét)' : '' ?>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
|
|
<?php if (isset($selectedWorkerId)): ?>
|
|
<!-- Schedule update form (POST) -->
|
|
<form method="POST" action="<?php echo site_url('admin/store_worker_schedule'); ?>">
|
|
<input type="hidden" name="worker_id" value="<?= $selectedWorkerId ?>">
|
|
|
|
<h3>Munkaidő beállítása</h3>
|
|
<?php
|
|
$scheduleMap = [];
|
|
foreach ($schedule as $entry) {
|
|
$scheduleMap[$entry->weekday] = $entry;
|
|
}
|
|
|
|
for ($i = 0; $i < 7; $i++):
|
|
$start = isset($scheduleMap[$i]) ? $scheduleMap[$i]->start_time : '';
|
|
$end = isset($scheduleMap[$i]) ? $scheduleMap[$i]->end_time : '';
|
|
$checked = isset($scheduleMap[$i]) && $scheduleMap[$i]->is_alternate_week ? 'checked' : '';
|
|
?>
|
|
<div class="schedule-row">
|
|
<label><?= $days[$i] ?></label>
|
|
<input type="text" name="start_time[<?= $i ?>]" value="<?= substr($start, 0, 5) ?>" pattern="[0-2][0-9]:[0-5][0-9]" placeholder="HH:MM" inputmode="numeric">
|
|
<input type="text" name="end_time[<?= $i ?>]" value="<?= substr($end, 0, 5) ?>" pattern="[0-2][0-9]:[0-5][0-9]" placeholder="HH:MM" inputmode="numeric">
|
|
<div class="alternate-week-wrapper">
|
|
<input type="checkbox" id="alt_week_<?= $i ?>" name="alternate_week[<?= $i ?>]" value="1" <?= $checked ?>>
|
|
<label for="alt_week_<?= $i ?>">Minden 2. hét?</label>
|
|
</div>
|
|
|
|
<input type="hidden" name="weekday[<?= $i ?>]" value="<?= $i ?>">
|
|
</div>
|
|
<?php endfor; ?>
|
|
|
|
<input type="submit" value="Mentés">
|
|
</form>
|
|
<?php endif; ?>
|