95 lines
10 KiB
PHP
95 lines
10 KiB
PHP
<?php require __DIR__ . '/settings_nav.php'; ?>
|
|
<?php if ($saved): ?><div class="alert alert-success"><?= h(t('rooms.saved')) ?></div><?php endif; ?>
|
|
<?php if ($error): ?><div class="alert alert-danger"><?= h($error) ?></div><?php endif; ?>
|
|
<form method="post" action="/settings/rooms/save"><input type="hidden" name="csrf" value="<?= h(Auth::csrf()) ?>">
|
|
<div class="alert alert-info"><?= h(t('rooms.inactive_help')) ?></div>
|
|
<div class="row row-cards">
|
|
<?php foreach ($rooms as $room):$boxNames = implode("\n", array_column(array_filter($room['boxes'], static fn ($box) => (int)$box['active'] === 1), 'name')); ?>
|
|
<div class="col-lg-6">
|
|
<div class="card h-100">
|
|
<div class="card-status-top" style="background:<?= h($room['color']) ?>"></div>
|
|
<div class="card-header">
|
|
<div>
|
|
<h3 class="card-title"><?= h($room['name']) ?></h3>
|
|
<div class="text-muted small"><code><?= h($room['code']) ?></code></div>
|
|
</div><label class="form-check form-switch ms-auto"><input class="form-check-input" type="checkbox"
|
|
name="rooms[<?= (int)$room['id'] ?>][active]" <?= $room['active'] ? 'checked' : '' ?>><span
|
|
class="form-check-label"><?= h(t('common.active')) ?></span></label>
|
|
</div>
|
|
<div class="card-body row g-3">
|
|
<div class="col-md-8"><label class="form-label"><?= h(t('common.name')) ?></label><input
|
|
class="form-control" name="rooms[<?= (int)$room['id'] ?>][name]"
|
|
value="<?= h($room['name']) ?>" maxlength="100" required></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('rooms.color')) ?></label><input
|
|
class="form-control form-control-color w-100" type="color"
|
|
name="rooms[<?= (int)$room['id'] ?>][color]" value="<?= h($room['color']) ?>"></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('rooms.type')) ?></label><select
|
|
class="form-select" name="rooms[<?= (int)$room['id'] ?>][room_type]">
|
|
<option value="collective" <?= $room['room_type'] === 'collective' ? 'selected' : '' ?>>
|
|
<?= h(t('rooms.collective')) ?></option>
|
|
<option value="boxes" <?= $room['room_type'] === 'boxes' ? 'selected' : '' ?>>
|
|
<?= h(t('rooms.with_boxes')) ?></option>
|
|
</select></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('animal.status')) ?></label><select
|
|
class="form-select"
|
|
name="rooms[<?= (int)$room['id'] ?>][status_code]"><?php foreach (['refuge' => t('status.refuge'),'soin' => t('status.soin'),'quarantaine' => t('status.quarantaine')] as $key => $label): ?>
|
|
<option value="<?= h($key) ?>" <?= $room['status_code'] === $key ? 'selected' : '' ?>>
|
|
<?= h($label) ?></option><?php endforeach; ?></select></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('rooms.order')) ?></label><input
|
|
class="form-control" type="number" min="0" name="rooms[<?= (int)$room['id'] ?>][sort_order]"
|
|
value="<?= (int)$room['sort_order'] ?>"></div>
|
|
<div class="col-12"><label class="form-label"><?= h(t('rooms.boxes')) ?></label><textarea
|
|
class="form-control" rows="5" name="rooms[<?= (int)$room['id'] ?>][boxes]"
|
|
placeholder="<?= h(t('rooms.one_box_per_line')) ?>" data-line-maxlength="100"><?= h($boxNames) ?></textarea>
|
|
<div class="form-hint"><?= h(t('rooms.boxes_help')) ?></div>
|
|
</div>
|
|
<div class="col-12"><label class="form-check"><input class="form-check-input" type="checkbox"
|
|
name="rooms[<?= (int)$room['id'] ?>][bulk_validation]"
|
|
<?= $room['bulk_validation'] ? 'checked' : '' ?>><span
|
|
class="form-check-label"><?= h(t('rooms.bulk_validation')) ?></span></label></div>
|
|
<div class="col-12"><hr><div class="form-label"><?= h(t('rooms.admission_rules')) ?></div></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('animal.species')) ?></label><select class="form-select" name="rooms[<?= (int)$room['id'] ?>][allowed_species]"><option value=""><?= h(t('common.all')) ?></option><?php foreach ($species as $option): ?><option value="<?= h($option['code']) ?>" <?= ($room['allowed_species'] ?? '') === $option['code'] ? 'selected' : '' ?>><?= h($option['name']) ?></option><?php endforeach; ?></select></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('animal.sex')) ?></label><select class="form-select" name="rooms[<?= (int)$room['id'] ?>][allowed_sex]"><option value=""><?= h(t('common.all')) ?></option><option value="M" <?= ($room['allowed_sex'] ?? '') === 'M' ? 'selected' : '' ?>><?= h(t('sex.male')) ?></option><option value="F" <?= ($room['allowed_sex'] ?? '') === 'F' ? 'selected' : '' ?>><?= h(t('sex.female')) ?></option></select></div>
|
|
<div class="col-md-4"><label class="form-label">FIV</label><select class="form-select" name="rooms[<?= (int)$room['id'] ?>][required_fiv]"><option value="any"><?= h(t('common.all')) ?></option><option value="positive" <?= ($room['required_fiv'] ?? 'any') === 'positive' ? 'selected' : '' ?>><?= h(t('animals.test_positive')) ?></option><option value="negative" <?= ($room['required_fiv'] ?? 'any') === 'negative' ? 'selected' : '' ?>><?= h(t('animals.test_negative')) ?></option></select></div>
|
|
<div class="col-12"><label class="form-label"><?= h(t('rooms.care_periods')) ?></label><div class="d-flex flex-wrap gap-3"><?php foreach (ShelterRoomService::PERIODS as $period): ?><label class="form-check"><input class="form-check-input" type="checkbox" name="rooms[<?= (int)$room['id'] ?>][care_periods][]" value="<?= h($period) ?>" <?= in_array($period, ShelterRoomService::periods($room), true) ? 'checked' : '' ?>><span class="form-check-label"><?= h(t('care.' . $period)) ?></span></label><?php endforeach; ?></div></div>
|
|
</div>
|
|
</div>
|
|
</div><?php endforeach; ?>
|
|
<div class="col-12">
|
|
<div class="card border-primary">
|
|
<div class="card-header">
|
|
<h3 class="card-title"><?= h(t('rooms.add')) ?></h3>
|
|
</div>
|
|
<div class="card-body row g-3">
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('common.name')) ?></label><input
|
|
class="form-control" name="new_room[name]" maxlength="100"></div>
|
|
<div class="col-md-3"><label class="form-label"><?= h(t('rooms.type')) ?></label><select
|
|
class="form-select" name="new_room[room_type]">
|
|
<option value="collective"><?= h(t('rooms.collective')) ?></option>
|
|
<option value="boxes"><?= h(t('rooms.with_boxes')) ?></option>
|
|
</select></div>
|
|
<div class="col-md-3"><label class="form-label"><?= h(t('animal.status')) ?></label><select
|
|
class="form-select" name="new_room[status_code]">
|
|
<option value="refuge"><?= h(t('status.refuge')) ?></option>
|
|
<option value="soin"><?= h(t('status.soin')) ?></option>
|
|
<option value="quarantaine"><?= h(t('status.quarantaine')) ?></option>
|
|
</select></div>
|
|
<div class="col-md-2"><label class="form-label"><?= h(t('rooms.color')) ?></label><input
|
|
class="form-control form-control-color w-100" type="color" name="new_room[color]"
|
|
value="#6c757d"></div>
|
|
<div class="col-12"><label class="form-label"><?= h(t('rooms.boxes')) ?></label><textarea
|
|
class="form-control" name="new_room[boxes]" rows="3"
|
|
placeholder="<?= h(t('rooms.one_box_per_line')) ?>" data-line-maxlength="100"></textarea></div>
|
|
<div class="col-12"><label class="form-check"><input class="form-check-input" type="checkbox"
|
|
name="new_room[bulk_validation]"><span
|
|
class="form-check-label"><?= h(t('rooms.bulk_validation')) ?></span></label></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('animal.species')) ?></label><select class="form-select" name="new_room[allowed_species]"><option value=""><?= h(t('common.all')) ?></option><?php foreach ($species as $option): ?><option value="<?= h($option['code']) ?>"><?= h($option['name']) ?></option><?php endforeach; ?></select></div>
|
|
<div class="col-md-4"><label class="form-label"><?= h(t('animal.sex')) ?></label><select class="form-select" name="new_room[allowed_sex]"><option value=""><?= h(t('common.all')) ?></option><option value="M"><?= h(t('sex.male')) ?></option><option value="F"><?= h(t('sex.female')) ?></option></select></div>
|
|
<div class="col-md-4"><label class="form-label">FIV</label><select class="form-select" name="new_room[required_fiv]"><option value="any"><?= h(t('common.all')) ?></option><option value="positive"><?= h(t('animals.test_positive')) ?></option><option value="negative"><?= h(t('animals.test_negative')) ?></option></select></div>
|
|
<div class="col-12"><label class="form-label"><?= h(t('rooms.care_periods')) ?></label><div class="d-flex flex-wrap gap-3"><?php foreach (ShelterRoomService::PERIODS as $period): ?><label class="form-check"><input class="form-check-input" type="checkbox" name="new_room[care_periods][]" value="<?= h($period) ?>" <?= in_array($period, ['morning','evening'], true) ? 'checked' : '' ?>><span class="form-check-label"><?= h(t('care.' . $period)) ?></span></label><?php endforeach; ?></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mt-4 text-end"><button class="btn btn-primary"><?= h(t('common.save')) ?></button></div>
|
|
</form>
|