【本人確認手動処理】本人確認チェックOK/本人確認チェックNG ボダン実装
All checks were successful
Deploy main / deploy (push) Successful in 22s

This commit is contained in:
你的名字 2025-09-29 15:47:02 +09:00
parent 98ea395e80
commit 4137794126
4 changed files with 171 additions and 49 deletions

View File

@ -14,14 +14,27 @@ class PersonalController extends Controller
*/
public function list(Request $request)
{
$query = User::query();
$query = User::query()
// 本人確認手動処理:未チェック(1) または 手動NG(4) または 自動チェックNG(5)
->whereIn('user_idcard_chk_flag', [1, 4, 5])
// 本人確認書類アップロード済み
->where(function($q) {
$q->whereNotNull('photo_filename1')
->orWhereNotNull('photo_filename2');
})
// usertypeテーブルとLEFT JOINで分類情報を取得
->leftJoin('usertype', 'user.user_categoryid', '=', 'usertype.user_categoryid')
->select('user.*',
'usertype.usertype_subject1',
'usertype.usertype_subject2',
'usertype.usertype_subject3');
if ($request->filled('user_id')) {
$query->where('user_id', $request->input('user_id'));
$query->where('user.user_id', $request->input('user_id'));
}
// データベースの物理順序(主キー昇順)で表示
$users = $query->paginate(20);
return view('admin.personal.list', [
'users' => $users,
'request' => $request,
@ -31,33 +44,121 @@ class PersonalController extends Controller
/**
* 本人確認手動処理 編集画面
*/
public function edit(Request $request, $id)
public function edit(Request $request, $seq)
{
// 利用者情報取得
$user = User::where('user_id', $id)->firstOrFail();
\Log::info('=== Personal Edit Method START ===', ['seq' => $seq, 'method' => $request->method()]);
// 利用者情報取得user_seqで検索
$user = User::where('user_seq', $seq)->firstOrFail();
\Log::info('User found:', [
'user_seq' => $user->user_seq,
'user_id' => $user->user_id,
'current_flag' => $user->user_idcard_chk_flag
]);
// 利用者分類マスタ取得(ラジオボタン用)
$usertypes = Usertype::orderBy('sort_order')->get();
// POST時の処理
if ($request->isMethod('post')) {
// 利用者分類IDの更新
\Log::info('=== FULL REQUEST DEBUG ===');
\Log::info('All request data:', $request->all());
\Log::info('=== Personal Edit POST Processing ===');
// 各フィールドの更新
$user->user_categoryid = $request->input('user_categoryid', $user->user_categoryid);
$user->user_regident_zip = $request->input('user_regident_zip', $user->user_regident_zip);
$user->user_regident_pre = $request->input('user_regident_pre', $user->user_regident_pre);
$user->user_regident_city = $request->input('user_regident_city', $user->user_regident_city);
$user->user_regident_add = $request->input('user_regident_add', $user->user_regident_add);
$user->user_relate_zip = $request->input('user_relate_zip', $user->user_relate_zip);
$user->user_relate_pre = $request->input('user_relate_pre', $user->user_relate_pre);
$user->user_relate_city = $request->input('user_relate_city', $user->user_relate_city);
$user->user_relate_add = $request->input('user_relate_add', $user->user_relate_add);
$user->user_remarks = $request->input('user_remarks', $user->user_remarks);
$user->user_idcard = $request->input('user_idcard', $user->user_idcard);
// 本人確認チェックOK/NG
if ($request->input('check') === 'ok') {
$user->user_idcard_chk_flag = 1;
} elseif ($request->input('check') === 'ng') {
$user->user_idcard_chk_flag = 0;
// 備考欄も更新NG理由
$user->user_remarks = $request->input('user_remarks', $user->user_remarks);
// 本人確認チェック処理(バックアップ値を優先使用)
$checkValue = $request->input('check') ?? $request->input('check_backup');
\Log::info('Check value received:', [
'check' => $request->input('check'),
'check_backup' => $request->input('check_backup'),
'final_value' => $checkValue,
'type' => gettype($checkValue)
]);
if ($checkValue === 'ok') {
$user->user_idcard_chk_flag = 3; // 手動チェックOK
$user->ope_id = auth()->user()->ope_id ?? auth()->id(); // 現在ログイン中の操作者ID
\Log::info('Setting user_idcard_chk_flag to 3 (手動チェックOK)');
\Log::info('Setting ope_id to current user:', ['ope_id' => $user->ope_id]);
} elseif ($checkValue === 'ng') {
$user->user_idcard_chk_flag = 4; // 手動チェックNG
$user->ope_id = auth()->user()->ope_id ?? auth()->id(); // 現在ログイン中の操作者ID
\Log::info('Setting user_idcard_chk_flag to 4 (手動チェックNG)');
\Log::info('Setting ope_id to current user:', ['ope_id' => $user->ope_id]);
} else {
\Log::warning('No valid check value received', [
'checkValue' => $checkValue,
'all_input' => $request->all()
]);
}
$user->save();
\Log::info('Before save:', [
'user_idcard_chk_flag' => $user->user_idcard_chk_flag,
'ope_id' => $user->ope_id,
'isDirty' => $user->isDirty(),
'getDirty' => $user->getDirty()
]);
return redirect()->route('personal')->with('success', '更新しました');
try {
$result = $user->save();
\Log::info('User saved successfully', [
'result' => $result,
'user_idcard_chk_flag' => $user->user_idcard_chk_flag
]);
// 保存結果の検証
$user->refresh(); // モデルデータをリフレッシュ
$savedUser = User::where('user_seq', $seq)->first();
\Log::info('Verification after save', [
'model_refresh' => $user->user_idcard_chk_flag,
'user_idcard_chk_flag' => $savedUser->user_idcard_chk_flag
]);
// データベース直接確認
$dbUser = \DB::table('user')->where('user_seq', $seq)->first();
\Log::info('DB direct check:', [
'user_idcard_chk_flag' => $dbUser->user_idcard_chk_flag ?? 'NOT_FOUND'
]);
} catch (\Exception $e) {
\Log::error('Save failed', [
'error' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine()
]);
return back()->withErrors('保存に失敗しました: ' . $e->getMessage());
}
\Log::info('=== POST Processing END ===');
// 成功メッセージ
$message = 'データを更新しました。';
if ($checkValue === 'ok') {
$message = '本人確認チェックOKで更新しました。';
} elseif ($checkValue === 'ng') {
$message = '本人確認チェックNGで更新しました。';
}
return redirect()->route('personal')->with('success', $message);
}
\Log::info('=== Personal Edit Method END (GET) ===');
return view('admin.personal.edit', [
'user' => $user,
'usertypes' => $usertypes,

View File

@ -22,7 +22,7 @@
<section class="content">
<div class="container-fluid">
<form method="POST" action="{{ route('personal_edit', ['id' => $user->user_id]) }}" enctype="multipart/form-data">
<form method="POST" action="{{ route('personal_edit', ['seq' => $user->user_seq]) }}" enctype="multipart/form-data">
@csrf
<div class="card mb-3">
@ -34,7 +34,7 @@
<div class="label-head">本人確認写真ファイル名1</div>
<div class="photo-box mx-auto">
@if($user->photo_filename1)
<img src="{{ asset('storage/photos/'.$user->photo_filename1) }}" alt="" class="img-fluid h-100 w-auto">
<img src="{{ asset('storage/photo/'.$user->photo_filename1) }}" alt="" class="img-fluid h-100 w-auto">
@endif
</div>
</div>
@ -42,7 +42,7 @@
<div class="label-head">本人確認写真ファイル名2</div>
<div class="photo-box mx-auto">
@if($user->photo_filename2)
<img src="{{ asset('storage/photos/'.$user->photo_filename2) }}" alt="" class="img-fluid h-100 w-auto">
<img src="{{ asset('storage/photo/'.$user->photo_filename2) }}" alt="" class="img-fluid h-100 w-auto">
@endif
</div>
</div>
@ -68,7 +68,9 @@
name="user_categoryid"
value="{{ $type->user_categoryid }}"
{{ (string)$user->user_categoryid === (string)$type->user_categoryid ? 'checked' : '' }}>
{{ $type->print_name }}
{{ $type->usertype_subject1 }}
@if($type->usertype_subject2)/{{ $type->usertype_subject2 }}@endif
@if($type->usertype_subject3)/{{ $type->usertype_subject3 }}@endif
</label>
@endforeach
</div>
@ -97,25 +99,25 @@
{{-- 居住所 --}}
<tr>
<th rowspan="2" class="align-middle">居住所</th>
<th class="sub">郵便番号</th><td>{{ $user->user_regident_zip }}</td>
<th class="sub">都道府県</th><td>{{ $user->user_regident_pre }}</td>
<th class="sub">郵便番号</th><td><input type="text" name="user_regident_zip" value="{{ $user->user_regident_zip }}" class="form-control form-control-sm"></td>
<th class="sub">都道府県</th><td><input type="text" name="user_regident_pre" value="{{ $user->user_regident_pre }}" class="form-control form-control-sm"></td>
<td></td>
</tr>
<tr>
<th class="sub">市区群</th><td>{{ $user->user_regident_city }}</td>
<th class="sub">住所</th><td colspan="2">{{ $user->user_regident_add }}</td>
<th class="sub">市区群</th><td><input type="text" name="user_regident_city" value="{{ $user->user_regident_city }}" class="form-control form-control-sm"></td>
<th class="sub">住所</th><td colspan="2"><input type="text" name="user_regident_add" value="{{ $user->user_regident_add }}" class="form-control form-control-sm"></td>
</tr>
{{-- 関連住所 --}}
<tr>
<th rowspan="2" class="align-middle">関連住所</th>
<th class="sub">郵便番号</th><td>{{ $user->user_relate_zip }}</td>
<th class="sub">都道府県</th><td>{{ $user->user_relate_pre }}</td>
<th class="sub">郵便番号</th><td><input type="text" name="user_relate_zip" value="{{ $user->user_relate_zip }}" class="form-control form-control-sm"></td>
<th class="sub">都道府県</th><td><input type="text" name="user_relate_pre" value="{{ $user->user_relate_pre }}" class="form-control form-control-sm"></td>
<td></td>
</tr>
<tr>
<th class="sub">市区群</th><td>{{ $user->user_relate_city }}</td>
<th class="sub">住所</th><td colspan="2">{{ $user->user_relate_add }}</td>
<th class="sub">市区群</th><td><input type="text" name="user_relate_city" value="{{ $user->user_relate_city }}" class="form-control form-control-sm"></td>
<th class="sub">住所</th><td colspan="2"><input type="text" name="user_relate_add" value="{{ $user->user_relate_add }}" class="form-control form-control-sm"></td>
</tr>
<tr>
@ -126,42 +128,55 @@
<tr>
<th>備考</th>
<td colspan="5">{{ $user->user_remarks }}</td>
<td colspan="5"><textarea name="user_remarks" class="form-control form-control-sm" rows="3">{{ $user->user_remarks }}</textarea></td>
</tr>
<tr>
<th>本人確認書類</th>
<td colspan="5">{{ $user->user_idcard }}</td>
<td colspan="5"><input type="text" name="user_idcard" value="{{ $user->user_idcard }}" class="form-control form-control-sm"></td>
</tr>
</tbody>
</table>
</div>
{{-- 注意文&アクション --}}
<div class="alert alert-info mb-3">
<div class="mb-3">
本人確認書類写真と登録情報を比較して問題なければ、「本人確認チェックOK」ボタンを押下してください。<br>
問題がある場合は「備考」にNG理由を記載のうえ、「本人確認チェックNG」ボタンを押下してください。
</div>
<div class="row">
<div class="col-md-6 mb-2 mb-md-0">
<button type="submit" name="check" value="ok" class="btn btn-success btn-block">
<button type="submit" name="check" value="ok" class="btn btn-success btn-block register" onclick="setCheckValue('ok')">
本人確認チェックOK
</button>
</div>
<div class="col-md-6">
<button type="submit" name="check" value="ng" class="btn btn-danger btn-block">
<button type="submit" name="check" value="ng" class="btn btn-danger btn-block register" onclick="setCheckValue('ng')">
本人確認チェックNG
</button>
</div>
</div>
{{-- 隐藏字段备份check值 --}}
{{-- check値のバックアップ用隠しフィールド --}}
<input type="hidden" name="check_backup" id="checkBackup" value="">
</div>
</div>
</form>
</div>
</section>
{{-- check値が隠しフィールドに保存されることを確保 --}}
<script>
// ボタンクリック時にcheck値を隠しフィールドに保存
function setCheckValue(value) {
document.getElementById('checkBackup').value = value;
console.log('Check value set to backup:', value);
}
</script>
{{-- 専用スタイル(目標画像の見た目に寄せる) --}}
<style>
.label-head{font-weight:600; margin-bottom:.25rem;}
@ -192,5 +207,8 @@
}
.info-table th.sub{background:#fffaf2;color:#555;font-weight:500;width:8rem;}
.info-table td{background:#fff;}
/* 郵便番号入力フィールドの幅調整 */
input[name="user_regident_zip"], input[name="user_relate_zip"] { width: 120px !important; }
</style>
@endsection

View File

@ -22,18 +22,6 @@
<section class="content">
<div class="container-fluid">
{{-- フィルター(必要なら追加) --}}
{{-- <form method="get" action="{{ route('personal') }}" class="mb-3">
<div class="form-row">
<div class="col-auto">
<input type="text" name="user_id" class="form-control" placeholder="利用者ID" value="{{ request('user_id') }}">
</div>
<div class="col-auto">
<button type="submit" class="btn btn-default">検索</button>
</div>
</div>
</form> --}}
<div class="card">
<div class="card-body table-responsive">
<table class="table table-bordered table-hover text-nowrap" style="min-width:1400px;">
@ -61,16 +49,21 @@
<th>卒業予定</th>
<th>備考</th>
<th>本人確認書類</th>
<th>確認状態</th>
</tr>
</thead>
<tbody>
@forelse($users as $user)
<tr>
<td style="background-color:#faebd7;">
<a href="{{ route('personal_edit', ['id' => $user->user_id]) }}" class="btn btn-sm btn-default">編集</a>
<a href="{{ route('personal_edit', ['seq' => $user->user_seq]) }}" class="btn btn-sm btn-default">編集</a>
</td>
<td>{{ $user->user_id }}</td>
<td>{{ $user->user_categoryid }}</td>
<td>
{{ $user->usertype_subject1 ?? '' }}
@if($user->usertype_subject2)/{{ $user->usertype_subject2 }}@endif
@if($user->usertype_subject3)/{{ $user->usertype_subject3 }}@endif
</td>
<td>{{ $user->user_name }}</td>
<td>{{ $user->user_phonetic }}</td>
<td>{{ $user->user_gender }}</td>
@ -90,10 +83,20 @@
<td>{{ $user->user_graduate }}</td>
<td>{{ $user->user_remarks }}</td>
<td>{{ $user->user_idcard }}</td>
<td>
@switch($user->user_idcard_chk_flag)
@case(1)<span class="badge badge-warning">未チェック</span>@break
@case(2)<span class="badge badge-success">自動OK</span>@break
@case(3)<span class="badge badge-primary">手動OK</span>@break
@case(4)<span class="badge badge-danger">手動NG</span>@break
@case(5)<span class="badge badge-secondary">自動NG</span>@break
@default<span class="badge badge-light">不明</span>
@endswitch
</td>
</tr>
@empty
<tr>
<td colspan="22" class="text-center text-muted">データがありません。</td>
<td colspan="23" class="text-center text-muted">データがありません。</td>
</tr>
@endforelse
</tbody>

View File

@ -261,7 +261,7 @@ Route::middleware('auth')->group(function () {
// 本人確認手動処理
Route::match(['get', 'post'], '/personal', [PersonalController::class, 'list'])->name('personal');
Route::match(['get', 'post'], '/personal/edit/{id}', [PersonalController::class, 'edit'])->name('personal_edit')->where(['id' => '[0-9]+']);
Route::match(['get', 'post'], '/personal/edit/{seq}', [PersonalController::class, 'edit'])->name('personal_edit')->where(['seq' => '[0-9]+']);
// 常時表示インフォメーション
Route::get('/information', [InformationController::class, 'list'])->name('information');