krgm.so-manager-dev.com/resources/views/admin/prices/list.blade.php
kin.rinzen e8f9c35efb
All checks were successful
Deploy main / deploy (push) Successful in 26s
駐輪場所、料金マスタのソート機能の実装と画面表示の修正
2025-09-10 14:08:22 +09:00

178 lines
9.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@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="{{route('home')}}">ホーム</a></li>
<li class="breadcrumb-item active">{{__('駐輪場所、料金マスタ')}}</li>
</ol>
</div>
</div>
</div>
</div>
{{-- メインコンテンツ --}}
<section class="content">
<div class="container-fluid">
{{-- 並び替え用 hidden --}}
<form action="{{ route('prices') }}" method="POST" id="list-form">
@csrf
<input type="hidden" name="sort" value="{{ $sort ?? '' }}">
<input type="hidden" name="sort_type" value="{{ $sort_type ?? '' }}">
</form>
{{-- 各種アクションボタン群 --}}
<div class="container-fluid mb20">
<button type="button" class="btn btn-sm btn-default mr10"
onclick="location.href='{{ route('price_add') }}'">新規</button>
<button type="submit" class="btn btn-sm btn-default mr10" form="form_delete" name="delete" id="delete"
onclick="return confirm('選択した項目を削除しますか?');">削除</button>
<button type="submit" class="btn btn-sm btn-default mr10" name="export_csv" id="export_csv"
action="{{route('prices_export')}}">CSV出力</button>
<button type="submit" class="btn btn-sm btn-default mr10" name="import_csv" id="import_csv"
action="{{route('prices_import')}}">インポート</button>
<button type="button" class="btn btn-sm btn-default mr10"
onclick="location.href='{{ route('prices_export') }}'">エクスポート</button>
</div>
<div class="d-flex justify-content-end">
{{ $list->appends(['sort' => $sort ?? '', 'sort_type' => $sort_type ?? ''])->links('pagination') }}
</div>
{{-- フラッシュメッセージ --}}
<div class="form col-lg-12">
@if(Session::has('success'))
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('success') }}
</div>
@elseif(Session::has('error'))
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-ban"></i> {{__('誤差')}}:</h4>
{!! Session::get('error') !!}
</div>
@elseif(isset($errorMsg))
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-ban"></i> {{__('誤差')}}:</h4>
{!! $errorMsg !!}
</div>
@endif
</div>
{{-- 一覧市区マスタ準拠1枚テーブル先頭が「チェック編集」統合列 --}}
<form action="{{route('prices_delete')}}" method="post" id="form_delete">
@csrf
<!-- ここから単一テーブル構成 ----------------------------------------- -->
<div class="col-lg-12 mb20">
<div class="table-responsive">
<form action="{{ route('prices_delete') }}" method="POST" id="form_delete">
@csrf
<table class="table table-bordered dataTable text-nowrap">
<thead class="thead-light">
<tr>
{{-- チェック + 編集 用の1列 --}}
<th style="width:140px;" class="text-left">
<input type="checkbox" onclick="$('input[name*=\'pk\']').prop('checked', this.checked);">
</th>
{{-- ソート対象列 --}}
<th class="sorting {{ ($sort=='price_parkplaceid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="price_parkplaceid">
<span>駐輪場所ID</span>
</th>
<th class="sorting {{ ($sort=='park_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="park_id">
<span>駐輪場ID</span>
</th>
{{-- ソート不要 --}}
<th><span>商品名</span></th>
<th><span>期間</span></th>
<th><span>利用者分類ID</span></th>
<th><span>駐輪料金(税込)</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=='price_ptypeid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="price_ptypeid">
<span>駐輪分類</span>
</th>
<th class="sorting {{ ($sort=='pplace_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="pplace_id">
<span>駐車車室ID</span>
</th>
</tr>
</thead>
<tbody class="bg-white">
@foreach($list as $item)
<tr>
{{-- 同じセル内に チェック + 編集ボタン --}}
<td class="align-middle" style="background-color:#faebd7;">
<div class="d-flex align-items-center">
<input type="checkbox" class="m-0 checkbox" name="pk[]" value="{{ $item->price_parkplaceid }}">
<a href="{{ route('price_edit', ['id' => $item->price_parkplaceid]) }}" class="btn btn-sm btn-default ml10">編集</a>
</div>
</td>
{{-- データ列 --}}
<td class="sm-item text-left align-middle">{{ $item->price_parkplaceid }}</td>
<td class="sm-item text-left align-middle">{{ $item->park_id }}</td>
<td class="sm-item text-left align-middle">{{ $item->prine_name }}</td>
<td class="sm-item text-left align-middle">{{ $item->price_month }}</td>
<td class="sm-item text-left align-middle">{{ $item->user_categoryid }}</td>
<td class="sm-item text-left align-middle">{{ $item->price }}</td>
<td class="sm-item text-left align-middle">{{ $item->psection_id }}</td>
<td class="sm-item text-left align-middle">{{ $item->price_ptypeid }}</td>
<td class="sm-item text-left align-middle">{{ $item->pplace_id }}</td>
</tr>
@endforeach
</tbody>
</table>
</form>
</div>
</div>
<!-- 単一テーブル構成ここまで ----------------------------------------- -->
</form>
</div>
</section>
{{-- 全選択/全解除name="pk[]" を対象) --}}
<script>
document.getElementById('checkbox_all')?.addEventListener('change', function(e){
document.querySelectorAll('input[name="pk[]"]').forEach(function(el){
el.checked = e.target.checked;
});
});
</script>
@endsection
@section('scripts')
<script>
$(function(){
$('.sorting').click(function(){
let sort = $(this).attr('sort');
let currentSort = $('input[name="sort"]').val();
let currentType = $('input[name="sort_type"]').val();
let newType = 'asc';
if (sort === currentSort) {
newType = (currentType === 'asc') ? 'desc' : 'asc';
}
$('input[name="sort"]').val(sort);
$('input[name="sort_type"]').val(newType);
$('#list-form').submit();
});
});
</script>
@endsection