krgm.so-manager-dev.com/resources/views/admin/psection/list.blade.php

115 lines
4.9 KiB
PHP

@extends('layouts.app')
@section('title', '車種区分マスタ')
@section('content')
{{-- コンテンツヘッダー(パンくず) --}}
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-lg-6">
<h1 class="m-0 text-dark">車種区分マスタ</h1>
</div>
<div class="col-lg-6">
<ol class="breadcrumb float-sm-right text-sm">
<li class="breadcrumb-item"><a href="{{ url('/home') }}">ホーム</a></li>
<li class="breadcrumb-item active">車種区分マスタ</li>
</ol>
</div>
</div>
</div>
</div>
<section class="content">
<div class="container-fluid">
{{-- アクションボタン --}}
<div class="mb-3">
<a href="{{ route('psection_add') }}" class="btn btn-sm btn-default">新規</a>
<button type="submit" form="deleteForm" class="btn btn-sm btn-default ml-2"
onclick="return confirm('選択した区分を削除しますか?');">削除</button>
</div>
{{-- ページネーション --}}
<div class="d-flex justify-content-end mb-3">
{{ $list->appends([
'sort' => $sort ?? '',
'sort_type' => $sort_type ?? ''
])->links('pagination') }}
</div>
@if ($list->count() > 0)
<form id="deleteForm" method="POST" action="{{ route('psection_delete') }}">
@csrf
<div class="table-responsive">
<table class="table table-bordered dataTable text-nowrap">
<thead class="thead-light">
<tr>
{{-- 統合列:チェック + 編集 --}}
<th style="width:140px;">
<input type="checkbox" onclick="$('input[name*=\'pk\']').prop('checked', this.checked);">
<span class="text-muted" style="font-weight:normal;"></span>
</th>
{{-- ソート対象列 --}}
<th class="sorting {{ ($sort=='psection_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}"
sort="psection_id">
<span>車種区分ID</span>
</th>
<th class="sorting {{ ($sort=='psection_subject') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}"
sort="psection_subject">
<span>車種区分名</span>
</th>
</tr>
</thead>
<tbody class="bg-white">
@foreach ($list as $item)
<tr>
{{-- 統合セル:チェック + 編集 --}}
<td style="background: #faebd7;">
<input type="checkbox" name="pk[]" value="{{ $item->psection_id }}">
<a href="{{ route('psection_edit', ['id' => $item->psection_id]) }}"
class="btn btn-sm btn-default ml10">編集</a>
</td>
{{-- データ列 --}}
<td style="text-align:right;">{{ $item->psection_id }}</td>
<td>{{ $item->psection_subject }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</form>
@else
{{-- データ無し表示 --}}
<div class="alert alert-info mt-4">表示するデータがありません。</div>
@endif
</div>
</section>
{{-- ソート用スクリプト --}}
<script>
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll("th.sorting, th.sorting_asc, th.sorting_desc").forEach(function(th) {
th.addEventListener("click", function() {
const sort = this.getAttribute("sort");
let sortType = "{{ $sort_type }}";
if ("{{ $sort }}" === sort) {
sortType = (sortType === "asc") ? "desc" : "asc";
} else {
sortType = "asc";
}
const url = new URL(window.location.href);
url.searchParams.set("sort", sort);
url.searchParams.set("sort_type", sortType);
window.location.href = url.toString();
});
});
});
</script>
@endsection