+ availability
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<div>
|
||||
<h1>Отели</h1>
|
||||
|
||||
<a href="{{ route('admin.hotels.create') }}" class="btn" style="display: inline-block; margin-bottom: 20px;">Добавить отель</a>
|
||||
<a href="{{ route('admin.hotels.create') }}" class="btn">Добавить отель</a>
|
||||
|
||||
@if($hotels->isEmpty())
|
||||
<p>Нет отелей.</p>
|
||||
@@ -25,14 +25,20 @@
|
||||
<td>{{ $hotel->address ?? '-' }}</td>
|
||||
<td>{{ $hotel->phone ?? '-' }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.hotels.edit', $hotel) }}" class="btn" style="background: #6c757d; margin-right: 6px;">Редактировать</a>
|
||||
<a href="{{ route('admin.hotels.edit', $hotel) }}" class="btn" style="margin-right: 5px;">
|
||||
Редактировать
|
||||
</a>
|
||||
<form action="{{ route('admin.hotels.destroy', $hotel) }}" method="POST" style="display: inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn" style="background: #aaa;" onclick="return confirm('Удалить отель?')">
|
||||
<button type="submit" class="btn btn-danger" style="margin-right: 5px;" onclick="return confirm('Удалить отель?')">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
<!-- Кнопка шахматки -->
|
||||
<button type="button" class="btn btn-secondary open-calendar-modal" data-hotel-id="{{ $hotel->id }}">
|
||||
Календарь
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -40,4 +46,43 @@
|
||||
</table>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Модальное окно для шахматки -->
|
||||
<div id="calendarModal" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:1000;">
|
||||
<div style="background:white;margin:50px auto;padding:25px;border-radius:8px;max-width:800px;box-shadow:0 4px 20px rgba(0,0,0,0.3);">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;">
|
||||
<h2>Доступные даты: <span id="modalHotelName"></span></h2>
|
||||
<button id="closeCalendarModal" style="background:none;border:none;font-size:1.5rem;cursor:pointer;">×</button>
|
||||
</div>
|
||||
<div id="calendarModalContent">Загрузка...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const modal = document.getElementById('calendarModal');
|
||||
const closeModalBtn = document.getElementById('closeCalendarModal');
|
||||
|
||||
document.querySelectorAll('.open-calendar-modal').forEach(button => {
|
||||
button.addEventListener('click', async function () {
|
||||
const hotelId = this.dataset.hotelId;
|
||||
const hotelName = this.closest('tr').querySelector('td:first-child').textContent;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/admin/hotels/${hotelId}/calendar`, {
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||
});
|
||||
document.getElementById('modalHotelName').textContent = hotelName;
|
||||
document.getElementById('calendarModalContent').innerHTML = await response.text();
|
||||
modal.style.display = 'block';
|
||||
} catch (e) {
|
||||
alert('Ошибка загрузки шахматки');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
closeModalBtn.onclick = () => modal.style.display = 'none';
|
||||
window.onclick = (e) => { if (e.target === modal) modal.style.display = 'none'; };
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user