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

219 lines
9.1 KiB
PHP
Raw Permalink 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') }}">XX様info(ホーム)</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">
<button type="button" class="btn btn-sm btn-default mr10" onclick="location.href='{{ route('devices_add') }}'">{{ __('新規') }}</button>
<button type="submit" class="btn btn-sm btn-default mr10" form="form_delete">{{ __('削除') }}</button>
{{ $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>
<div class="col-lg-12 row sample03-wrapper no_padding_right mb20">
{{-- 左:チェック列+編集ボタン --}}
<div class="col-xl-2 col-lg-2 col-md-2 col-sm-3 col-xs-3 table_left">
<form action="{{ route('devices_delete') }}" method="post" id="form_delete">
@csrf
<table class="table dataTable">
<thead>
<tr><th><input type="checkbox" class="minimal m-0" id="checkbox_all"></th></tr>
</thead>
<tbody>
@foreach($list as $item)
<tr role="row">
<td>
<input type="checkbox" class="minimal m-0 checkbox" name="ids[]" value="{{ $item->device_id }}">
<div class="btn_action">
<a href="{{ route('devices_edit',['id'=>$item->device_id]) }}" class="btn btn-sm btn-default ml10">{{ __('編集') }}</a>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
<form id="form_import_export" method="post" enctype="multipart/form-data">@csrf</form>
</div>
{{-- 右:本体 --}}
<div class="col-lg-10 col-xl-10 col-md-10 col-sm-9 col-xs-9 table_right no_padding_right">
<div class="scroll">
@php
$TYPE = [1=>'サーバー',2=>'プリンタ',3=>'その他'];
$WORK = ['1'=>'稼働','0'=>'停止',1=>'稼働',0=>'停止'];
@endphp
<table class="table dataTable">
<thead>
<tr>
{{-- 1 デバイスID--}}
<th class="sorting @if($sort=='device_id'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-right"
sort="device_id"><span>{{ __('デバイスID') }}</span></th>
{{-- 2 駐輪場ID --}}
<th class="sorting @if($sort=='park_id'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-left"
sort="park_id"><span>{{ __('駐輪場ID') }}</span></th>
{{-- 3 デバイス種別--}}
<th class="sorting @if($sort=='device_type'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-left"
sort="device_type"><span>{{ __('デバイス種別') }}</span></th>
{{-- 4 デバイス名 --}}
<th class="text-left"><span>{{ __('デバイス名') }}</span></th>
{{-- 5 識別子 --}}
<th class="text-left"><span>{{ __('識別子') }}</span></th>
{{-- 6 稼働/停止 --}}
<th class="text-left"><span>{{ __('稼働/停止') }}</span></th>
{{-- 7 稼働開始日--}}
<th class="sorting @if($sort=='device_workstart'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-right"
sort="device_workstart"><span>{{ __('稼働開始日') }}</span></th>
{{-- 8 リプレース予約日 --}}
<th class="sorting @if($sort=='device_replace'){{ $sort_type=='asc'?'sorting_asc':'sorting_desc' }}@endif text-right"
sort="device_replace"><span>{{ __('リプレース予約日') }}</span></th>
{{-- 9 備考 --}}
<th class="text-left"><span>{{ __('備考') }}</span></th>
</tr>
</thead>
<tbody>
@foreach($list as $item)
<tr>
{{-- 1 デバイスID --}}
<td class="sm-item text-right">
<span>{{ mb_substr($item->device_id, 0, 10) }}</span>
</td>
{{-- 2 駐輪場ID駐輪場名 --}}
<td class="sm-item text-left">
<span>
{{ mb_substr($item->park_id, 0, 10) }}
@if($item->relationLoaded('park') && $item->park)
: {{ mb_substr($item->park->park_name ?? '', 0, 10) }}
@endif
</span>
</td>
{{-- 3 デバイス種別 --}}
<td class="sm-item text-left">
<span>{{ mb_substr($TYPE[$item->device_type] ?? (string)$item->device_type, 0, 10) }}</span>
</td>
{{-- 4 デバイス名 --}}
<td class="sm-item text-left">
<span>{{ mb_substr($item->device_subject, 0, 10) }}</span>
</td>
{{-- 5 識別子--}}
<td class="sm-item text-left">
<span>{{ mb_substr($item->device_identifier, 0, 10) }}</span>
</td>
{{-- 6 稼働/停止--}}
<td class="sm-item text-left">
<span>{{ $WORK[$item->device_work] ?? $item->device_work }}</span>
</td>
{{-- 7 稼働開始日 --}}
<td class="sm-item text-right">
@php
$ws = $item->device_workstart instanceof \Carbon\Carbon ? $item->device_workstart->format('Y/m/d') : ($item->device_workstart ? \Carbon\Carbon::parse($item->device_workstart)->format('Y/m/d') : '');
@endphp
<span>{{ $ws }}</span>
</td>
{{-- 8 リプレース予約日) --}}
<td class="sm-item text-right">
@php
$rp = $item->device_replace instanceof \Carbon\Carbon ? $item->device_replace->format('Y/m/d') : ($item->device_replace ? \Carbon\Carbon::parse($item->device_replace)->format('Y/m/d') : '');
@endphp
<span>{{ $rp }}</span>
</td>
{{-- 9 備考 --}}
<td class="sm-item text-left">
<span>{{ mb_substr($item->device_remarks, 0, 10) }}</span>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
@push('scripts')
<script>
document.querySelectorAll('th.sorting[sort]').forEach(function(th){
th.style.cursor = 'pointer';
th.addEventListener('click', function(){
var field = this.getAttribute('sort');
var cur = document.getElementById('sort').value;
var type = document.getElementById('sort_type').value || 'asc';
var next = (cur === field && type === 'asc') ? 'desc' : 'asc';
document.getElementById('sort').value = field;
document.getElementById('sort_type').value = next;
document.getElementById('list-form').submit();
});
});
document.getElementById('checkbox_all')?.addEventListener('change', function(e){
document.querySelectorAll('.checkbox').forEach(function(cb){ cb.checked = e.target.checked; });
});
</script>
@endpush
@endsection