【定期契約マスタ】【タグ発行キュー処理、履歴表示】画面修正
All checks were successful
Deploy main / deploy (push) Successful in 22s

This commit is contained in:
你的名字 2025-10-12 17:18:40 +09:00
parent c25833562c
commit d7b4e10459
3 changed files with 263 additions and 193 deletions

View File

@ -54,6 +54,10 @@ class TagissueController extends Controller
'user.user_regident_pre', 'user.user_regident_pre',
'user.user_regident_city', 'user.user_regident_city',
'user.user_regident_add', 'user.user_regident_add',
'user.user_relate_zip',
'user.user_relate_pre',
'user.user_relate_city',
'user.user_relate_add',
'operator_que.que_id', 'operator_que.que_id',
'operator_que.que_class', 'operator_que.que_class',
'operator_que.que_status' 'operator_que.que_status'
@ -125,9 +129,7 @@ class TagissueController extends Controller
{ {
$ids = $request->input('ids', []); // チェックされたuser_id配列 $ids = $request->input('ids', []); // チェックされたuser_id配列
$action = $request->input('action'); // 'to_issued' or 'to_unissued' $action = $request->input('action'); // 'to_issued' or 'to_unissued'
if (empty($ids) || !is_array($ids)) {
return back()->with('error', 'チェックボックスを選択してください。');
}
$operatorId = auth()->id(); $operatorId = auth()->id();
$now = now(); $now = now();
// 対象ユーザーのoperator_queを取得 // 対象ユーザーのoperator_queを取得

View File

@ -379,9 +379,7 @@
@endphp @endphp
<thead> <thead>
<tr> <tr>
<th class="text-right {{ $sortClass('contract_id') }}" sort="contract_id" style="white-space:nowrap;"> <th style="width:50px; text-align:right;"></th>
契約ID {!! $renderSortIcon('contract_id') !!}
</th>
{{-- 操作列(チェック+編集。背景色を付与) --}} {{-- 操作列(チェック+編集。背景色を付与) --}}
<th style="width:120px"> <th style="width:120px">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
@ -389,7 +387,9 @@
<span></span> <span></span>
</div> </div>
</th> </th>
<th class="text-right {{ $sortClass('contract_id') }}" sort="contract_id" style="white-space:nowrap;">
契約ID {!! $renderSortIcon('contract_id') !!}
</th>
{{-- 表頭(要件に合わせて網羅) --}} {{-- 表頭(要件に合わせて網羅) --}}
<th class="text-right {{ $sortClass('contract_qr_id') }}" sort="contract_qr_id"> <th class="text-right {{ $sortClass('contract_qr_id') }}" sort="contract_qr_id">
定期契約ID {!! $renderSortIcon('contract_qr_id') !!} 定期契約ID {!! $renderSortIcon('contract_qr_id') !!}
@ -523,8 +523,8 @@
@endphp @endphp
@foreach($list as $item) @foreach($list as $item)
<tr> <tr>
{{-- 先頭の並び替え列(行の contract_id を表示) --}}
<td class="text-right">{{ $item->contract_id }}</td> <td class="text-right">{{ $loop->iteration }}</td>
{{-- 操作列:チェック + 編集(背景色つき) --}} {{-- 操作列:チェック + 編集(背景色つき) --}}
<td class="op-cell"> <td class="op-cell">
@ -535,6 +535,8 @@
</div> </div>
</td> </td>
{{-- 先頭の並び替え列(行の contract_id を表示) --}}
<td class="text-right">{{ $item->contract_id }}</td>
{{-- データ列 --}} {{-- データ列 --}}
<td class="text-right">{{ $item->contract_qr_id }}</td> <td class="text-right">{{ $item->contract_qr_id }}</td>
<td>{{ $item->old_contract_id ?? '' }}</td> <td>{{ $item->old_contract_id ?? '' }}</td>

View File

@ -23,10 +23,11 @@
</nav> </nav>
</div> </div>
<!-- 絞り込み --> <!-- 絞り込みヘッダー -->
<div class="card mb-3"> <div class="card mb-3">
<div class="card-body"> <div class="card-body py-2">
<!-- 1行目:印刷処理 -->
{{-- 印刷処理 --}}
<div class="row mb-2"> <div class="row mb-2">
<div class="col-md-12 font-weight-bold mb-1">印刷処理</div> <div class="col-md-12 font-weight-bold mb-1">印刷処理</div>
<div class="col-md-12"> <div class="col-md-12">
@ -34,73 +35,45 @@
<div class="col-md-2 mb-1"> <div class="col-md-2 mb-1">
<button type="button" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2" <button type="button" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;" onclick="handlePrintLabels()">タグ発送宛名印刷</button> style="font-size:0.85rem;" onclick="handlePrintLabels()">タグ発送宛名印刷</button>
<script>
function handlePrintLabels() {
var checkboxes = document.querySelectorAll('input[name="ids[]"]:checked');
if (checkboxes.length === 0) {
alert('1件以上選択してください。');
return;
}
if (confirm('タグ発送用宛名を印刷してよろしいですか?')) {
// 送信用form生成
var form = document.createElement('form');
form.method = 'POST';
form.action = '/tagissue/print-unissued-labels';
form.target = '_blank';
// CSRF
var csrf = document.createElement('input');
csrf.type = 'hidden';
csrf.name = '_token';
csrf.value = '{{ csrf_token() }}';
form.appendChild(csrf);
// ids
checkboxes.forEach(function(cb) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'ids[]';
input.value = cb.value;
form.appendChild(input);
});
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
}
</script>
</div>
<div class="col-md-10 mb-1"></div>
</div> </div>
</div> </div>
</div> </div>
<!-- 2行目:絞り込みフィルター --> </div>
{{-- 種別フィルター --}}
<div class="row mb-2"> <div class="row mb-2">
<div class="col-md-12 font-weight-bold mb-1">絞り込みフィルター</div> <div class="col-md-12 font-weight-bold mb-1">種別フィルター</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="row g-1"> <div class="row g-1">
<div class="col-md-2 mb-1"> <div class="col-md-2 mb-1">
<form method="GET" style="display:inline;"> <form method="GET">
@if(request('filter_type') == 'unissued_toggle') @if(request('filter_type') == 'unissued_toggle')
<button type="submit" class="btn btn-warning btn-xs w-100 py-1 px-2" style="font-size:0.85rem;">タグ未発送解除</button> <button type="submit" class="btn btn-warning btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;">タグ未発送解除</button>
@else @else
<input type="hidden" name="filter_type" value="unissued_toggle"> <input type="hidden" name="filter_type" value="unissued_toggle">
<button type="submit" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2" style="font-size:0.85rem;">タグ発送未発送</button> <button type="submit" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;">タグ発送未発送</button>
@endif @endif
</form> </form>
</div> </div>
<div class="col-md-2 mb-1"> <div class="col-md-2 mb-1">
<form method="GET" style="display:inline;"> <form method="GET">
@if(request('filter_type') == 'issued_toggle') @if(request('filter_type') == 'issued_toggle')
<button type="submit" class="btn btn-warning btn-xs w-100 py-1 px-2" style="font-size:0.85rem;">タグ発送済み解除</button> <button type="submit" class="btn btn-warning btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;">タグ発送済み解除</button>
@else @else
<input type="hidden" name="filter_type" value="issued_toggle"> <input type="hidden" name="filter_type" value="issued_toggle">
<button type="submit" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2" style="font-size:0.85rem;">タグ発送済み</button> <button type="submit" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;">タグ発送済み</button>
@endif @endif
</form> </form>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- 3行目:タグシリアルフィルター -->
{{-- タグシリアルフィルター --}}
<div class="row mb-2"> <div class="row mb-2">
<div class="col-md-12 font-weight-bold mb-1">タグシリアルフィルター</div> <div class="col-md-12 font-weight-bold mb-1">タグシリアルフィルター</div>
<div class="col-md-12"> <div class="col-md-12">
@ -108,28 +81,39 @@
<div class="row align-items-center g-1"> <div class="row align-items-center g-1">
<div class="col-auto font-weight-bold" style="padding-right:4px;">タグシリアル</div> <div class="col-auto font-weight-bold" style="padding-right:4px;">タグシリアル</div>
<div class="col-auto" style="min-width:140px;"> <div class="col-auto" style="min-width:140px;">
<input type="text" name="tag_serial" value="{{ request('tag_serial') }}" class="form-control form-control-sm" style="font-size:0.85rem; padding:2px 6px;" placeholder="キーワード…"> <input type="text" name="tag_serial" value="{{ request('tag_serial') }}"
class="form-control form-control-sm" style="font-size:0.85rem; padding:2px 6px;"
placeholder="キーワード…">
</div> </div>
<div class="col-auto font-weight-bold" style="padding-right:4px; padding-left:8px;">タグシリアル64進</div> <div class="col-auto font-weight-bold" style="padding-right:4px; padding-left:8px;">
タグシリアル64進</div>
<div class="col-auto" style="min-width:140px;"> <div class="col-auto" style="min-width:140px;">
<input type="text" name="tag_serial_64" value="{{ request('tag_serial_64') }}" class="form-control form-control-sm" style="font-size:0.85rem; padding:2px 6px;" placeholder="キーワード…"> <input type="text" name="tag_serial_64" value="{{ request('tag_serial_64') }}"
class="form-control form-control-sm" style="font-size:0.85rem; padding:2px 6px;"
placeholder="キーワード…">
</div> </div>
<div class="col-auto text-end" style="padding-left:8px;"> <div class="col-auto text-end" style="padding-left:8px;">
<button type="submit" class="btn btn-default btn-xs py-1 px-2 me-1" style="font-size:0.85rem; min-width:60px;">絞り込み</button> <button type="submit" class="btn btn-default btn-xs py-1 px-2 me-1"
<a href="{{ route('tagissue') }}" class="btn btn-default btn-xs py-1 px-2" style="font-size:0.85rem; min-width:60px;">全表示</a> style="font-size:0.85rem; min-width:60px;">絞り込み</button>
<a href="{{ route('tagissue') }}" class="btn btn-default btn-xs py-1 px-2"
style="font-size:0.85rem; min-width:60px;">全表示</a>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<!-- 4行目:タグ発送ステータス変更 -->
{{-- タグ発送ステータス変更 --}}
<div class="row mb-2"> <div class="row mb-2">
<div class="col-md-12 font-weight-bold mb-1">タグ発送ステータス変更</div> <div class="col-md-12 font-weight-bold mb-1">タグ発送ステータス変更</div>
<div class="col-md-12"> <div class="col-md-12">
{{-- form 不包含表格 --}}
<form id="statusForm" method="POST" action="{{ route('tagissue.status') }}"> <form id="statusForm" method="POST" action="{{ route('tagissue.status') }}">
@csrf @csrf
<input type="hidden" name="action" id="statusAction" value=""> <input type="hidden" name="action" id="statusAction" value="">
<div class="row g-1"> </form>
<div class="row g-1 mb-2">
<div class="col-md-2 mb-1"> <div class="col-md-2 mb-1">
<button type="button" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2" <button type="button" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;" onclick="handleStatusChange('to_issued')">タグ発送済み</button> style="font-size:0.85rem;" onclick="handleStatusChange('to_issued')">タグ発送済み</button>
@ -138,25 +122,44 @@
<button type="button" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2" <button type="button" class="btn btn-outline-secondary btn-xs w-100 py-1 px-2"
style="font-size:0.85rem;" onclick="handleStatusChange('to_unissued')">タグ未発送</button> style="font-size:0.85rem;" onclick="handleStatusChange('to_unissued')">タグ未発送</button>
</div> </div>
<div class="col-md-8 mb-1"></div>
</div> </div>
</div>
</div>
</div>
</div>
{{-- 表格区域 --}}
<div class="mt-2"> <div class="mt-2">
<div class="d-flex justify-content-end mb-2">
<div class="ms-auto">
{{ $users->appends(request()->except('page'))->links('pagination') }}
</div>
</div>
<div style="overflow-x: auto;"> <div style="overflow-x: auto;">
<table class="table table-bordered dataTable text-nowrap"> <table class="table table-bordered dataTable text-nowrap">
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th style="width:40px;background-color:"><input type="checkbox" onclick="document.querySelectorAll('input[name=\'ids[]\']').forEach(cb => cb.checked = this.checked);"></th> <th style="width:40px;">
<th class="sorting {{ ($sort=='que_id') ? ($sortType=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="que_id" style="color:#212529;cursor:pointer;"><span>キューID</span></th> <input type="checkbox"
<th class="sorting {{ ($sort=='user_tag_serial') ? ($sortType=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="user_tag_serial" style="color:#212529;cursor:pointer;"><span>タグシリアル</span></th> onclick="document.querySelectorAll('input[name=\'ids[]\']').forEach(cb => cb.checked = this.checked);">
<th class="sorting {{ ($sort=='user_tag_serial_64') ? ($sortType=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="user_tag_serial_64" style="color:#212529;cursor:pointer;"><span>タグシリアル64進</span></th> </th>
<th class="sorting {{ ($sort=='user_tag_issue') ? ($sortType=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="user_tag_issue" style="color:#212529;cursor:pointer;"><span>タグ発送ステータス</span></th> <th sort="que_id">キューID</th>
<th class="sorting {{ ($sort=='user_name') ? ($sortType=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="user_name" style="color:#212529;cursor:pointer;"><span>利用者名</span></th> <th sort="user_tag_serial">タグシリアル</th>
<th><span>携帯電話番号</span></th> <th sort="user_tag_serial_64">タグシリアル64進</th>
<th><span>自宅電話番号</span></th> <th sort="user_tag_issue">タグ発送ステータス</th>
<th><span>居住所:郵便番号</span></th> <th sort="user_name">利用者名</th>
<th><span>居住所:都道府県</span></th> <th>携帯電話番号</th>
<th><span>居住所:市区郡</span></th> <th>自宅電話番号</th>
<th><span>居住所:住所</span></th> <th>居住所:郵便番号</th>
<th>居住所:都道府県</th>
<th>居住所:市区群</th>
<th>居住所:住所</th>
<th>関連住所:郵便番号</th>
<th>関連住所:都道府県</th>
<th>関連住所:市区群</th>
<th>関連住所:住所</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -175,10 +178,10 @@
<td> <td>
@if(!empty($user->user_seq)) @if(!empty($user->user_seq))
<a href="{{ route('users_edit', ['seq' => $user->user_seq]) }}" target="_blank"> <a href="{{ route('users_edit', ['seq' => $user->user_seq]) }}" target="_blank">
{{ $user->user_name }} {{ $user->user_id }}: {{ $user->user_name }}
</a> </a>
@else @else
{{ $user->user_name }} {{ $user->user_id }}: {{ $user->user_name }}
@endif @endif
</td> </td>
<td>{{ $user->user_mobile }}</td> <td>{{ $user->user_mobile }}</td>
@ -187,29 +190,64 @@
<td>{{ $user->user_regident_pre }}</td> <td>{{ $user->user_regident_pre }}</td>
<td>{{ $user->user_regident_city }}</td> <td>{{ $user->user_regident_city }}</td>
<td>{{ $user->user_regident_add }}</td> <td>{{ $user->user_regident_add }}</td>
<td>{{ $user->user_relate_zip }}</td>
<td>{{ $user->user_relate_pre }}</td>
<td>{{ $user->user_relate_city }}</td>
<td>{{ $user->user_relate_add }}</td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="d-flex align-items-center mb-2">
<div class="ms-auto">
{{ $users->appends(request()->except('page'))->links('pagination') }}
</div> </div>
</div> </div>
</div>
</form> {{-- 印刷処理用 JS --}}
<script> <script>
function handleStatusChange(actionType) { // タグ発送宛名印刷
var form = document.getElementById('statusForm'); function handlePrintLabels() {
document.getElementById('statusAction').value = actionType;
var checkboxes = document.querySelectorAll('input[name="ids[]"]:checked'); var checkboxes = document.querySelectorAll('input[name="ids[]"]:checked');
if (checkboxes.length === 0) { if (checkboxes.length === 0) {
alert('1件以上選択してください。'); alert('1件以上選択してください。');
return; return;
} }
if (confirm('タグ発送用宛名を印刷してよろしいですか?')) {
var form = document.createElement('form');
form.method = 'POST';
form.action = '/tagissue/print-unissued-labels';
form.target = '_blank';
var csrf = document.createElement('input');
csrf.type = 'hidden';
csrf.name = '_token';
csrf.value = '{{ csrf_token() }}';
form.appendChild(csrf);
checkboxes.forEach(function (cb) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'ids[]';
input.value = cb.value;
form.appendChild(input);
});
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
}
// ステータス変更処理
function handleStatusChange(actionType) {
var checkboxes = document.querySelectorAll('input[name="ids[]"]:checked');
if (checkboxes.length === 0) {
$.alert({
title: '選択エラー',
content: '1件以上選択してください。'
});
return;
}
var ids = Array.from(checkboxes).map(cb => cb.value); var ids = Array.from(checkboxes).map(cb => cb.value);
var ajaxType = (actionType === 'to_issued') ? 'issued' : 'unissued'; var ajaxType = (actionType === 'to_issued') ? 'issued' : 'unissued';
fetch('/tagissue/check-status', { fetch('/tagissue/check-status', {
method: 'POST', method: 'POST',
headers: { headers: {
@ -221,46 +259,74 @@
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (ajaxType === 'issued' && data.alreadyIssued.length > 0) { if (ajaxType === 'issued' && data.alreadyIssued.length > 0) {
alert('以下のユーザーはすでにタグ発送済みです:\n' + data.alreadyIssued.join('\n')); $.alert({
title: '確認エラー',
content: '以下のユーザーはすでにタグ発送済みです:<br>' + data.alreadyIssued.join('<br>')
});
return; return;
} }
if (ajaxType === 'unissued' && data.alreadyUnissued && data.alreadyUnissued.length > 0) { if (ajaxType === 'unissued' && data.alreadyUnissued && data.alreadyUnissued.length > 0) {
alert('以下のユーザーはすでにタグ未発送です:\n' + data.alreadyUnissued.join('\n')); $.alert({
title: '確認エラー',
content: '以下のユーザーはすでにタグ未発送です:<br>' + data.alreadyUnissued.join('<br>')
});
return; return;
} }
var confirmMsg = (ajaxType === 'issued') ? 'ステータスをタグ発送済に変更してよろしいですか?' : 'ステータスをタグ未発送に変更してよろしいですか?';
if (confirm(confirmMsg)) { var confirmMsg = (ajaxType === 'issued')
? 'ステータスをタグ発送済に変更してよろしいですか?'
: 'ステータスをタグ未発送に変更してよろしいですか?';
$.confirm({
title: '確認ダイアログ',
content: confirmMsg,
buttons: {
はい: {
text: 'はい',
btnClass: 'btn-primary',
keys: ['enter'],
action: function () {
var form = document.getElementById('statusForm');
// 古い input 清除
form.querySelectorAll('input[name="ids[]"]').forEach(e => e.remove());
// 动态附加选中 ID
ids.forEach(id => {
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'ids[]';
input.value = id;
form.appendChild(input);
});
document.getElementById('statusAction').value = actionType;
form.submit(); form.submit();
} }
},
いいえ: function () { }
}
});
}) })
.catch(() => { .catch(() => {
alert('ステータス確認に失敗しました。'); $.alert({
title: '通信エラー',
content: 'ステータス確認に失敗しました。'
});
}); });
} }
</script>
</div> // ソート挙動
</div> document.addEventListener('DOMContentLoaded', function () {
</div> document.querySelectorAll('th[sort]').forEach(function (th) {
</div> th.addEventListener('click', function () {
</div>
<script>
// ソート挙動
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('th.sorting').forEach(function(th) {
th.addEventListener('click', function() {
var sort = th.getAttribute('sort'); var sort = th.getAttribute('sort');
var currentSort = new URLSearchParams(window.location.search).get('sort');
var currentType = new URLSearchParams(window.location.search).get('sort_type');
var nextType = 'asc';
if (currentSort === sort) {
nextType = (currentType === 'asc') ? 'desc' : 'asc';
}
var params = new URLSearchParams(window.location.search); var params = new URLSearchParams(window.location.search);
var currentSort = params.get('sort');
var currentType = params.get('sort_type');
var nextType = (currentSort === sort && currentType === 'asc') ? 'desc' : 'asc';
params.set('sort', sort); params.set('sort', sort);
params.set('sort_type', nextType); params.set('sort_type', nextType);
window.location.search = params.toString(); window.location.search = params.toString();
}); });
}); });
}); });
</script> </script>
@endsection @endsection