This commit is contained in:
parent
e41309ca4c
commit
f547220af5
@ -23,13 +23,52 @@ class UsersController
|
||||
$row->usertype_subject1 ?? '',
|
||||
$row->usertype_subject2 ?? '',
|
||||
$row->usertype_subject3 ?? '',
|
||||
])->filter(fn ($v) => $v !== '')->implode('/');
|
||||
])->filter(fn($v) => $v !== '')->implode('/');
|
||||
|
||||
return [$row->user_categoryid => $label !== '' ? $label : (string) $row->user_categoryid];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用者分類1(一覧絞り込み用)
|
||||
*/
|
||||
private function buildCategory1Options()
|
||||
{
|
||||
return DB::table('regular_contract')
|
||||
->join('usertype', 'regular_contract.user_categoryid', '=', 'usertype.user_categoryid')
|
||||
->whereNotNull('usertype.usertype_subject1')
|
||||
->distinct()
|
||||
->orderBy('usertype.usertype_subject1')
|
||||
->pluck('usertype.usertype_subject1');
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用者分類2(一覧絞り込み用)
|
||||
*/
|
||||
private function buildCategory2Options()
|
||||
{
|
||||
return DB::table('regular_contract')
|
||||
->join('usertype', 'regular_contract.user_categoryid', '=', 'usertype.user_categoryid')
|
||||
->whereNotNull('usertype.usertype_subject2')
|
||||
->distinct()
|
||||
->orderBy('usertype.usertype_subject2')
|
||||
->pluck('usertype.usertype_subject2');
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用者分類3(一覧絞り込み用)
|
||||
*/
|
||||
private function buildCategory3Options()
|
||||
{
|
||||
return DB::table('regular_contract')
|
||||
->join('usertype', 'regular_contract.user_categoryid', '=', 'usertype.user_categoryid')
|
||||
->whereNotNull('usertype.usertype_subject3')
|
||||
->distinct()
|
||||
->orderBy('usertype.usertype_subject3')
|
||||
->pluck('usertype.usertype_subject3');
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用者一覧
|
||||
* - テーブル名: user
|
||||
@ -81,7 +120,9 @@ class UsersController
|
||||
$phone = trim((string) $request->input('phone', '')); // 携帯/自宅の両方対象
|
||||
$crime = trim((string) $request->input('crime', '')); // 防犯登録番号(暫定: qr_code)
|
||||
$email = trim((string) $request->input('email', ''));
|
||||
$user_categoryid = (string) $request->input('user_categoryid', '');
|
||||
$user_category1 = trim((string) $request->input('user_category1', ''));
|
||||
$user_category2 = trim((string) $request->input('user_category2', ''));
|
||||
$user_category3 = trim((string) $request->input('user_category3', ''));
|
||||
$tag_qr_flag = (string) $request->input('tag_qr_flag', ''); // 0=タグ / 1=QR
|
||||
$quit_flag = (string) $request->input('quit_flag', ''); // 0=いいえ / 1=はい
|
||||
$quit_from = (string) $request->input('quit_from', ''); // YYYY-MM-DD
|
||||
@ -120,8 +161,18 @@ class UsersController
|
||||
$query->where('user.user_primemail', 'like', "%{$email}%");
|
||||
|
||||
// ▼ セレクト/ラジオ('' 以外なら適用。'0' も通す)
|
||||
if ($user_categoryid !== '')
|
||||
$query->where('user.user_categoryid', $user_categoryid);
|
||||
if ($user_category1 !== '') {
|
||||
$query->where('usertype.usertype_subject1', $user_category1);
|
||||
}
|
||||
|
||||
if ($user_category2 !== '') {
|
||||
$query->where('usertype.usertype_subject2', $user_category2);
|
||||
}
|
||||
|
||||
if ($user_category3 !== '') {
|
||||
$query->where('usertype.usertype_subject3', $user_category3);
|
||||
}
|
||||
|
||||
if ($tag_qr_flag !== '')
|
||||
$query->where('user.tag_qr_flag', (int) $tag_qr_flag);
|
||||
if ($quit_flag !== '')
|
||||
@ -134,7 +185,7 @@ class UsersController
|
||||
$query->where('user.user_quitday', '<=', $quit_to);
|
||||
|
||||
// ▼ 並び & ページング
|
||||
$list = $query->orderBy("user.{$sort}", $sortType)->paginate(20);
|
||||
$list = $query->orderBy("user.{$sort}", $sortType)->paginate(50);
|
||||
|
||||
// ▼ 画面に渡す(フォーム再描画用に絞り込み値も)
|
||||
return view('admin.users.list', [
|
||||
@ -149,12 +200,16 @@ class UsersController
|
||||
'phone' => $phone,
|
||||
'crime' => $crime,
|
||||
'email' => $email,
|
||||
'user_categoryid' => $user_categoryid,
|
||||
'tag_qr_flag' => $tag_qr_flag,
|
||||
'quit_flag' => $quit_flag,
|
||||
'quit_from' => $quit_from,
|
||||
'quit_to' => $quit_to,
|
||||
'categoryOptions' => $this->buildCategoryOptions(),
|
||||
'user_category1' => $user_category1,
|
||||
'user_category2' => $user_category2,
|
||||
'user_category3' => $user_category3,
|
||||
'category1Options' => $this->buildCategory1Options(),
|
||||
'category2Options' => $this->buildCategory2Options(),
|
||||
'category3Options' => $this->buildCategory3Options(),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -186,9 +241,19 @@ class UsersController
|
||||
$q->where('user_primemail', 'like', "%{$v}%");
|
||||
|
||||
// ▼ セレクト/ラジオ('' だけスキップ。'0' は適用)
|
||||
$val = (string) $request->input('user_categoryid', '');
|
||||
if ($val !== '')
|
||||
$q->where('user_categoryid', $val);
|
||||
$q->leftJoin('usertype', 'user.user_categoryid', '=', 'usertype.user_categoryid');
|
||||
|
||||
if (($v = trim((string) $request->input('user_category1', ''))) !== '') {
|
||||
$q->where('usertype.usertype_subject1', $v);
|
||||
}
|
||||
|
||||
if (($v = trim((string) $request->input('user_category2', ''))) !== '') {
|
||||
$q->where('usertype.usertype_subject2', $v);
|
||||
}
|
||||
|
||||
if (($v = trim((string) $request->input('user_category3', ''))) !== '') {
|
||||
$q->where('usertype.usertype_subject3', $v);
|
||||
}
|
||||
|
||||
$val = (string) $request->input('tag_qr_flag', '');
|
||||
if ($val !== '')
|
||||
@ -375,8 +440,8 @@ class UsersController
|
||||
|
||||
$categoryOptions = $this->buildCategoryOptions();
|
||||
|
||||
// ▼ 退会処理専用(hiddenフィールド quit_action があれば退会処理)
|
||||
if ($request->has('quit_action')) {
|
||||
// ▼ 退会処理専用(hiddenフィールド quit_action があれば退会処理)
|
||||
if ($request->has('quit_action')) {
|
||||
DB::table('user')->where('user_seq', $seq)->update([
|
||||
'user_quit_flag' => 1,
|
||||
'user_quitday' => now()->format('Y-m-d'),
|
||||
@ -387,7 +452,7 @@ if ($request->has('quit_action')) {
|
||||
return redirect()
|
||||
->route('users_edit', ['seq' => $seq])
|
||||
->with('status', '退会処理が完了しました。');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($request->isMethod('get')) {
|
||||
|
||||
@ -24,7 +24,10 @@
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"app/Helpers/ListQueryHelper.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
||||
@ -502,9 +502,7 @@
|
||||
|
||||
{{-- 削除ボタン(別フォームを呼び出す) --}}
|
||||
<button type="button" class="btn btn-danger ml-2" id="delete_edit">削除</button>
|
||||
|
||||
<a href="{{ route('users') }}" class="btn btn-secondary ml-2">戻る</a>
|
||||
|
||||
<a href="{{ route('users', keepUserListQuery()) }}" class="btn btn-secondary ml-2">戻る</a>
|
||||
@if ($isEdit && $hasDeleteRoute)
|
||||
<button type="button" class="btn btn-warning ml-2" id="quitForm">退会</button>
|
||||
@endif
|
||||
|
||||
@ -524,7 +524,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success register">登録</button>
|
||||
<a href="{{ route('users') }}" class="btn btn-secondary ml-2">戻る</a>
|
||||
<a href="{{ route('users', keepUserListQuery()) }}"class="btn btn-secondary">戻る</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -10,21 +10,6 @@
|
||||
$curDir = 'desc';
|
||||
}
|
||||
|
||||
$queryBase = collect([
|
||||
'user_id' => $user_id ?? null,
|
||||
'user_categoryid' => $user_categoryid ?? null,
|
||||
'user_tag_serial' => $user_tag_serial ?? null,
|
||||
'quit_flag' => $quit_flag ?? null,
|
||||
'user_phonetic' => $user_phonetic ?? null,
|
||||
'phone' => $phone ?? null,
|
||||
'email' => $email ?? null,
|
||||
'tag_qr_flag' => $tag_qr_flag ?? null,
|
||||
'quit_from' => $quit_from ?? null,
|
||||
'quit_to' => $quit_to ?? null,
|
||||
])->filter(function ($value) {
|
||||
return !is_null($value) && $value !== '';
|
||||
})->all();
|
||||
|
||||
$thClass = function (string $key) use ($curSort, $curDir) {
|
||||
if ($curSort !== $key) {
|
||||
return 'sorting';
|
||||
@ -32,9 +17,12 @@
|
||||
return $curDir === 'asc' ? 'sorting_asc' : 'sorting_desc';
|
||||
};
|
||||
|
||||
$urlFor = function (string $key) use ($curSort, $curDir, $queryBase) {
|
||||
$urlFor = function (string $key) use ($curSort, $curDir) {
|
||||
$next = ($curSort === $key && $curDir === 'asc') ? 'desc' : 'asc';
|
||||
return route('users', array_merge($queryBase, ['sort' => $key, 'dir' => $next]));
|
||||
return route('users', keepUserListQuery([
|
||||
'sort' => $key,
|
||||
'dir' => $next,
|
||||
]));
|
||||
};
|
||||
@endphp
|
||||
{{-- ▼ コンテンツヘッダー(パンくず) --}}
|
||||
@ -100,18 +88,42 @@
|
||||
value="{{ $user_id ?? '' }}" placeholder="利用者ID">
|
||||
</div>
|
||||
|
||||
{{-- 分類名1 --}}
|
||||
<div class="form-group d-flex align-items-center mb-2">
|
||||
<label class="filter-label">利用者分類</label>
|
||||
<select class="form-control filter-input" name="user_categoryid">
|
||||
<label class="filter-label">分類名1</label>
|
||||
<select class="form-control filter-input" name="user_category1">
|
||||
<option value="">全て</option>
|
||||
@if(!empty($categoryOptions))
|
||||
@foreach($categoryOptions as $val => $label)
|
||||
<option value="{{ $val }}" @if(($user_categoryid ?? '') == (string) $val) selected
|
||||
@endif>
|
||||
{{ $label }}
|
||||
@foreach($category1Options as $val)
|
||||
<option value="{{ $val }}" @selected(($user_category1 ?? '') === $val)>
|
||||
{{ $val }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- 分類名2 --}}
|
||||
<div class="form-group d-flex align-items-center mb-2">
|
||||
<label class="filter-label">分類名2</label>
|
||||
<select class="form-control filter-input" name="user_category2">
|
||||
<option value="">全て</option>
|
||||
@foreach($category2Options as $val)
|
||||
<option value="{{ $val }}" @selected(($user_category2 ?? '') === $val)>
|
||||
{{ $val }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- 分類名3 --}}
|
||||
<div class="form-group d-flex align-items-center mb-2">
|
||||
<label class="filter-label">分類名3</label>
|
||||
<select class="form-control filter-input" name="user_category3">
|
||||
<option value="">全て</option>
|
||||
@foreach($category3Options as $val)
|
||||
<option value="{{ $val }}" @selected(($user_category3 ?? '') === $val)>
|
||||
{{ $val }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -248,13 +260,13 @@
|
||||
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<div>
|
||||
<a href="{{ route('users_add') }}" class="btn btn-primary">新規</a>
|
||||
<a href="{{ route('users_add', keepUserListQuery()) }}"class="btn btn-primary">新規</a>
|
||||
{{-- ▼ クリックで隠しフォーム送信 --}}
|
||||
<button type="button" class="btn btn-outline-success"
|
||||
onclick="document.getElementById('csvForm').submit();">CSV出力</button>
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
{{ $list->appends(request()->except('page'))->links('pagination') }}
|
||||
{{ $list->appends(keepUserListQuery())->links('pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -271,7 +283,9 @@
|
||||
<a href="{{ $urlFor('user_id') }}" class="header-link">利用者ID</a>
|
||||
</th>
|
||||
<th style="width:110px;">タグ/QRフラグ</th>
|
||||
<th style="width:140px;">利用者分類ID</th>
|
||||
<th style="width:140px;">利用者分類1</th>
|
||||
<th style="width:140px;">利用者分類2</th>
|
||||
<th style="width:140px;">利用者分類3</th>
|
||||
<th style="width:160px;">利用者名</th>
|
||||
<th style="width:160px;" class="{{ $thClass('user_phonetic') }}">
|
||||
<a href="{{ $urlFor('user_phonetic') }}" class="header-link">フリガナ</a>
|
||||
@ -309,16 +323,22 @@
|
||||
@endphp
|
||||
<tr>
|
||||
{{-- 利用者ID(リンク) --}}
|
||||
<td class="text-nowrap"><a href="{{ $userEditUrl }}">{{ $item->user_id }}
|
||||
{{ $item->user_name }}</a></td>
|
||||
<td class="text-nowrap">
|
||||
<a href="{{ route('users_edit',array_merge(['seq' => $item->user_seq], keepUserListQuery())) }}">
|
||||
{{ $item->user_id }} {{ $item->user_name }}
|
||||
</a>
|
||||
</td>
|
||||
{{-- タグ/QR --}}
|
||||
<td>{{ $item->tag_qr_flag ? 'QR' : 'タグ' }}</td>
|
||||
{{-- 利用者分類ID/氏名/フリガナ --}}
|
||||
<td>{{ $categoryDisplay ?: $item->user_categoryid }}</td>
|
||||
<td>{{ $item->usertype_subject1 }}</td>
|
||||
<td>{{ $item->usertype_subject2 }}</td>
|
||||
<td>{{ $item->usertype_subject3 }}</td>
|
||||
<td>{{ $item->user_name }}</td>
|
||||
<td>{{ $item->user_phonetic }}</td>
|
||||
{{-- 生年月日/年齢 --}}
|
||||
<td class="text-right">{{ $item->user_birthdate ? \Illuminate\Support\Str::limit($item->user_birthdate, 10, '') : '' }}
|
||||
<td class="text-right">
|
||||
{{ $item->user_birthdate ? \Illuminate\Support\Str::limit($item->user_birthdate, 10, '') : '' }}
|
||||
</td>
|
||||
<td class="text-right">{{ $item->user_age }}</td>
|
||||
{{-- 連絡先 --}}
|
||||
@ -328,7 +348,8 @@
|
||||
{{-- 本人確認(書類/チェック/日時) --}}
|
||||
<td>{{ __($item->user_idcard) }}</td>
|
||||
<td class="text-nowrap">{{ $chk === '1' ? '手動チェックOK' : '未チェック' }}</td>
|
||||
<td class="text-right">{{ $item->user_chk_day ? \Illuminate\Support\Str::limit($item->user_chk_day, 10, '') : '' }}
|
||||
<td class="text-right">
|
||||
{{ $item->user_chk_day ? \Illuminate\Support\Str::limit($item->user_chk_day, 10, '') : '' }}
|
||||
</td>
|
||||
{{-- 退会 --}}
|
||||
<td>{{ $item->user_quit_flag ? 'はい' : 'いいえ' }}</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user