168 lines
7.6 KiB
PHP
168 lines
7.6 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="{{ route('home') }}">ホーム</a></li>
|
||
<!-- <li class="breadcrumb-item"><a href="javascript:void(0);">[東京都|〇〇駐輪場]</a></li> -->
|
||
<li class="breadcrumb-item active">{{ __('デバイス管理マスタ') }}</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<section class="content">
|
||
<div class="container-fluid">
|
||
|
||
{{-- ソート用フォーム --}}
|
||
<form action="{{ route('devices') }}" method="post" id="list-form" class="d-none">
|
||
@csrf
|
||
<input type="hidden" name="sort" id="sort" value="{{ $sort }}">
|
||
<input type="hidden" name="sort_type" id="sort_type" value="{{ $sort_type }}">
|
||
</form>
|
||
|
||
<!-- ツールバー -->
|
||
<div class="container-fluid mb20 d-flex justify-content-between align-items-center">
|
||
<div>
|
||
<button type="button" class="btn btn-sm btn-default mr10" onclick="location.href='{{ route('devices_add') }}'">{{ __('新規') }}</button>
|
||
<button type="button" class="btn btn-sm btn-default mr10" id="delete">{{ __('削除') }}</button>
|
||
</div>
|
||
<div>
|
||
{{ $list->appends(['sort'=>$sort,'sort_type'=>$sort_type])->links('pagination') }}
|
||
</div>
|
||
</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>
|
||
|
||
{{-- 単一テーブル --}}
|
||
<div class="col-lg-12 mb20">
|
||
<div class="table-responsive">
|
||
<form action="{{ route('devices_delete') }}" method="post" id="form_delete">
|
||
@csrf
|
||
@php
|
||
$TYPE = [1=>'サーバー', 2=>'プリンタ', 3=>'その他'];
|
||
$WORK = ['1'=>'稼働', '0'=>'停止', 1=>'稼働', 0=>'停止'];
|
||
@endphp
|
||
|
||
<table class="table table-bordered dataTable text-nowrap">
|
||
<thead>
|
||
<tr>
|
||
<th style="width:120px;" class="text-left">
|
||
<input type="checkbox" onclick="$('input[name*=\'pk\']').prop('checked', this.checked);">
|
||
</th>
|
||
<th class="sorting @if($sort=='device_id'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-right"
|
||
sort="device_id"><span>{{ __('デバイスID') }}</span></th>
|
||
<th class="sorting @if($sort=='park_id'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-left"
|
||
sort="park_id"><span>{{ __('駐輪場ID') }}</span></th>
|
||
<th class="sorting @if($sort=='device_type'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-left"
|
||
sort="device_type"><span>{{ __('デバイス種別') }}</span></th>
|
||
<th class="text-left"><span>{{ __('デバイス名') }}</span></th>
|
||
<th class="text-left"><span>{{ __('識別子') }}</span></th>
|
||
<th class="text-left"><span>{{ __('稼働/停止') }}</span></th>
|
||
<th class="sorting @if($sort=='device_workstart'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-right"
|
||
sort="device_workstart"><span>{{ __('稼働開始日') }}</span></th>
|
||
<th class="sorting @if($sort=='device_replace'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-right"
|
||
sort="device_replace"><span>{{ __('リプレース予約日') }}</span></th>
|
||
<th class="text-left"><span>{{ __('備考') }}</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->device_id }}">
|
||
<a href="{{ route('devices_edit', ['id' => $item->device_id]) }}" class="btn btn-sm btn-default ml-2">{{ __('編集') }}</a>
|
||
</div>
|
||
</td>
|
||
|
||
<td class="sm-item text-right">{{ $item->device_id }}</td>
|
||
<td class="sm-item text-left">
|
||
{{ $item->park_id }}
|
||
@if($item->relationLoaded('park') && $item->park)
|
||
: {{ $item->park->park_name ?? '' }}
|
||
@endif
|
||
</td>
|
||
<td class="sm-item text-left">{{ $TYPE[$item->device_type] ?? $item->device_type }}</td>
|
||
<td class="sm-item text-left">{{ $item->device_subject }}</td>
|
||
<td class="sm-item text-left">{{ $item->device_identifier }}</td>
|
||
<td class="sm-item text-left">{{ $WORK[$item->device_work] ?? $item->device_work }}</td>
|
||
<td class="sm-item text-right">{{ optional($item->device_workstart)->format('Y/m/d') }}</td>
|
||
<td class="sm-item text-right">{{ optional($item->device_replace)->format('Y/m/d') }}</td>
|
||
<td class="sm-item text-left">{{ $item->device_remarks }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</section>
|
||
|
||
@push('scripts')
|
||
<script>
|
||
// ソート
|
||
document.querySelectorAll('th.sorting').forEach(th => {
|
||
th.addEventListener('click', function() {
|
||
const form = document.getElementById('list-form');
|
||
const current = "{{ $sort ?? '' }}";
|
||
const currentType = "{{ $sort_type ?? '' }}";
|
||
const nextCol = this.getAttribute('sort');
|
||
let nextType = 'asc';
|
||
if (current === nextCol) {
|
||
nextType = (currentType === 'asc') ? 'desc' : 'asc';
|
||
}
|
||
form.querySelector('[name=sort]').value = nextCol;
|
||
form.querySelector('[name=sort_type]').value = nextType;
|
||
form.submit();
|
||
});
|
||
});
|
||
|
||
// 全選択
|
||
document.getElementById('checkbox_all')?.addEventListener('change', function(e){
|
||
document.querySelectorAll('.checkbox').forEach(cb => cb.checked = e.target.checked);
|
||
});
|
||
|
||
// 削除確認
|
||
document.getElementById('delete')?.addEventListener('click', function(){
|
||
const anyChecked = Array.from(document.querySelectorAll('.checkbox')).some(cb => cb.checked);
|
||
if (!anyChecked) {
|
||
alert('削除対象が選択されていません。');
|
||
return;
|
||
}
|
||
if (confirm('削除してよろしいですか?')) {
|
||
document.getElementById('form_delete').submit();
|
||
}
|
||
});
|
||
</script>
|
||
@endpush
|
||
@endsection
|