Merge pull request '駐輪場検索画面レイアウト調整' (#22) from main_higashide into main
All checks were successful
Deploy so-manager (auto) / deploy (push) Successful in 22s
All checks were successful
Deploy so-manager (auto) / deploy (push) Successful in 22s
Reviewed-on: #22
This commit is contained in:
commit
ada3971259
@ -51,100 +51,101 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<table id="searchTable" class="tablesorter table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="header">
|
||||
駐輪場名
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'park_ruby', 'order' => 'asc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-up-fill"></i></a>
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'park_ruby', 'order' => 'desc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-down-fill"></i></a>
|
||||
</th>
|
||||
<th class="header">
|
||||
市町村名
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'city_id', 'order' => 'asc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-up-fill"></i></a>
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'city_id', 'order' => 'desc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-down-fill"></i></a>
|
||||
</th>
|
||||
<th class="header">
|
||||
駅名
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'station_name_ruby', 'order' => 'asc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-up-fill"></i></a>
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'station_name_ruby', 'order' => 'desc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-down-fill"></i></a>
|
||||
</th>
|
||||
<th class="header">自転車</th>
|
||||
<th class="header">原付</th>
|
||||
<th class="header">自動二輪</th>
|
||||
<th class="header">自動車</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($parks_table as $row)
|
||||
<tr>
|
||||
<td><a href="javascript:void(0);" class="btn-popup text-primary" data-park-id="{{ $row->park_id }}">
|
||||
{{ $row->park_name }}
|
||||
</a></td>
|
||||
<td>{{ $row->city_name }}</td>
|
||||
<td>{{ $row->station_neighbor_station }}</td>
|
||||
{{-- 自転車・原付・自動二輪・自動車列 --}}
|
||||
@foreach(['自転車', '原付', '自動二輪', '自動車'] as $vehicle)
|
||||
<td>
|
||||
@php
|
||||
$zonesForType = ($zones[$row->park_id] ?? collect())->where('psection_subject', $vehicle);
|
||||
@endphp
|
||||
@forelse ($zonesForType as $zone)
|
||||
@php
|
||||
$reserveCount = ($reserve[$row->park_id] ?? collect())
|
||||
->where('psection_id', $zone->psection_id)
|
||||
->count();
|
||||
$vacancy = $zone->zone_tolerance - $zone->zone_number - $reserveCount;
|
||||
// 猶予期間判定
|
||||
$grace = $city_grace_periods[$row->city_id] ?? null;
|
||||
$now = \Carbon\Carbon::now();
|
||||
$inGrace = false;
|
||||
if ($grace && $grace->update_grace_period_start_date && $grace->update_grace_period_start_time && $grace->update_grace_period_end_date && $grace->update_grace_period_end_time) {
|
||||
$year = $now->year;
|
||||
$month = $now->month;
|
||||
$startDay = (int)$grace->update_grace_period_start_date;
|
||||
$endDay = (int)$grace->update_grace_period_end_date;
|
||||
if ($startDay > $endDay) {
|
||||
// 月またぎ
|
||||
// 前月の開始日~今月の終了日
|
||||
$prevMonth = $now->copy()->subMonth();
|
||||
$startPrev = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $prevMonth->year, $prevMonth->month, $startDay, $grace->update_grace_period_start_time));
|
||||
$endCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time));
|
||||
// 今月の開始日~翌月の終了日
|
||||
$startCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time));
|
||||
$nextMonth = $month == 12 ? 1 : $month + 1;
|
||||
$nextYear = $month == 12 ? $year + 1 : $year;
|
||||
$endNext = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $nextYear, $nextMonth, $endDay, $grace->update_grace_period_end_time));
|
||||
$inGrace = $now->between($startPrev, $endCurr) || $now->between($startCurr, $endNext);
|
||||
} else {
|
||||
// 同月
|
||||
$start = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time));
|
||||
$end = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time));
|
||||
$inGrace = $now->between($start, $end);
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
@if ($vacancy > 0 && $inGrace)
|
||||
<button class="btn btn-block btn-sm btn-outline-success btn_82-table btn-popup" data-park-id="{{ $row->park_id }}">定期契約</button>
|
||||
@elseif (!$inGrace)
|
||||
<button class="btn btn-block btn-sm btn-outline-danger btn_103-table btn-popup" data-park-id="{{ $row->park_id }}">販売期間外</button>
|
||||
@elseif ($vacancy <= 0 && $inGrace)
|
||||
<button class="btn btn-block btn-sm btn-outline-danger btn_103-table btn-popup" data-park-id="{{ $row->park_id }}">空き待ち申込</button>
|
||||
@endif
|
||||
@empty
|
||||
<span class="text-muted"></span>
|
||||
@endforelse
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="text-center">該当する駐輪場はありません。</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="overflow-x: auto; width: 100%;">
|
||||
<table id="searchTable" class="tablesorter table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="header">
|
||||
駐輪場名
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'park_ruby', 'order' => 'asc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-up-fill"></i></a>
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'park_ruby', 'order' => 'desc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-down-fill"></i></a>
|
||||
</th>
|
||||
<th class="header">
|
||||
市町村名
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'city_id', 'order' => 'asc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-up-fill"></i></a>
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'city_id', 'order' => 'desc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-down-fill"></i></a>
|
||||
</th>
|
||||
<th class="header">
|
||||
駅名
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'station_name_ruby', 'order' => 'asc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-up-fill"></i></a>
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'station_name_ruby', 'order' => 'desc', 'page' => 1]) }}" class="text-success"><i class="bi bi-caret-down-fill"></i></a>
|
||||
</th>
|
||||
<th class="header">自転車</th>
|
||||
<th class="header">原付</th>
|
||||
<th class="header">自動二輪</th>
|
||||
<th class="header">自動車</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($parks_table as $row)
|
||||
<tr>
|
||||
<td><a href="javascript:void(0);" class="btn-popup text-primary" data-park-id="{{ $row->park_id }}">
|
||||
{{ $row->park_name }}
|
||||
</a></td>
|
||||
<td>{{ $row->city_name }}</td>
|
||||
<td>{{ $row->station_neighbor_station }}</td>
|
||||
{{-- 自転車・原付・自動二輪・自動車列 --}}
|
||||
@foreach(['自転車', '原付', '自動二輪', '自動車'] as $vehicle)
|
||||
<td>
|
||||
@php
|
||||
$zonesForType = ($zones[$row->park_id] ?? collect())->where('psection_subject', $vehicle);
|
||||
@endphp
|
||||
@forelse ($zonesForType as $zone)
|
||||
@php
|
||||
$reserveCount = ($reserve[$row->park_id] ?? collect())
|
||||
->where('psection_id', $zone->psection_id)
|
||||
->count();
|
||||
$vacancy = $zone->zone_tolerance - $zone->zone_number - $reserveCount;
|
||||
// 猶予期間判定
|
||||
$grace = $city_grace_periods[$row->city_id] ?? null;
|
||||
$now = \Carbon\Carbon::now();
|
||||
$inGrace = false;
|
||||
if ($grace && $grace->update_grace_period_start_date && $grace->update_grace_period_start_time && $grace->update_grace_period_end_date && $grace->update_grace_period_end_time) {
|
||||
$year = $now->year;
|
||||
$month = $now->month;
|
||||
$startDay = (int)$grace->update_grace_period_start_date;
|
||||
$endDay = (int)$grace->update_grace_period_end_date;
|
||||
if ($startDay > $endDay) {
|
||||
// 月またぎ
|
||||
// 前月の開始日~今月の終了日
|
||||
$prevMonth = $now->copy()->subMonth();
|
||||
$startPrev = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $prevMonth->year, $prevMonth->month, $startDay, $grace->update_grace_period_start_time));
|
||||
$endCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time));
|
||||
// 今月の開始日~翌月の終了日
|
||||
$startCurr = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time));
|
||||
$nextMonth = $month == 12 ? 1 : $month + 1;
|
||||
$nextYear = $month == 12 ? $year + 1 : $year;
|
||||
$endNext = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $nextYear, $nextMonth, $endDay, $grace->update_grace_period_end_time));
|
||||
$inGrace = $now->between($startPrev, $endCurr) || $now->between($startCurr, $endNext);
|
||||
} else {
|
||||
// 同月
|
||||
$start = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $startDay, $grace->update_grace_period_start_time));
|
||||
$end = \Carbon\Carbon::createFromFormat('Y-m-d H:i', sprintf('%04d-%02d-%02d %s', $year, $month, $endDay, $grace->update_grace_period_end_time));
|
||||
$inGrace = $now->between($start, $end);
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
@if ($vacancy > 0 && $inGrace)
|
||||
<button class="btn btn-block btn-sm btn-outline-success btn_82-table btn-popup" data-park-id="{{ $row->park_id }}">定期契約</button>
|
||||
@elseif (!$inGrace)
|
||||
<button class="btn btn-block btn-sm btn-outline-danger btn_103-table btn-popup" data-park-id="{{ $row->park_id }}">販売期間外</button>
|
||||
@elseif ($vacancy <= 0 && $inGrace)
|
||||
<button class="btn btn-block btn-sm btn-outline-danger btn_103-table btn-popup" data-park-id="{{ $row->park_id }}">空き待ち申込</button>
|
||||
@endif
|
||||
@empty
|
||||
<span class="text-muted"></span>
|
||||
@endforelse
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="text-center">該当する駐輪場はありません。</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@php
|
||||
$totalPages = ceil($parks_table_total / $parks_table_perPage);
|
||||
$currentPage = $parks_table_page;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user