Compare commits
11 Commits
0b449c4c60
...
73ebe11e77
| Author | SHA1 | Date | |
|---|---|---|---|
| 73ebe11e77 | |||
| a27ac445c5 | |||
| c728744d9e | |||
| dbfd55908e | |||
| 35ba5ccf78 | |||
| 1e30943b38 | |||
| 22283f957b | |||
| 3a8e6c81f4 | |||
| ac7f6c9ad7 | |||
| babf9abd15 | |||
| 2c6bdf7868 |
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Traits\AuthenticatesUser;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@ -14,6 +15,8 @@ use function base_path;
|
|||||||
|
|
||||||
class ReceiptController extends Controller
|
class ReceiptController extends Controller
|
||||||
{
|
{
|
||||||
|
use AuthenticatesUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 領収書宛名入力画面を表示する。
|
* 領収書宛名入力画面を表示する。
|
||||||
* 契約IDに基づき、領収書宛名入力フォームを表示する。
|
* 契約IDに基づき、領収書宛名入力フォームを表示する。
|
||||||
@ -24,13 +27,12 @@ class ReceiptController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function input(string $management_code, string $contract_id): mixed
|
public function input(string $management_code, string $contract_id): mixed
|
||||||
{
|
{
|
||||||
$user_id = session('user_id');
|
if ($redirect = $this->handleSessionExpired('領収書宛名入力', false)) {
|
||||||
if (!$user_id) {
|
return $redirect;
|
||||||
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
|
||||||
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 領収書宛名入力画面アクセス");
|
|
||||||
return redirect()->guest('/login');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ヘッダー表示のためユーザー名取得
|
// ヘッダー表示のためユーザー名取得
|
||||||
|
$user_id = session('user_id');
|
||||||
$user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
|
$user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
|
||||||
|
|
||||||
$management = session('management');
|
$management = session('management');
|
||||||
@ -70,13 +72,12 @@ class ReceiptController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function issue(Request $request, string $management_code, string $contract_id): mixed
|
public function issue(Request $request, string $management_code, string $contract_id): mixed
|
||||||
{
|
{
|
||||||
$user_id = session('user_id');
|
if ($redirect = $this->handleSessionExpired('領収書宛名入力', false)) {
|
||||||
if (!$user_id) {
|
return $redirect;
|
||||||
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
|
||||||
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 領収書発行");
|
|
||||||
return redirect('/login');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user_id = session('user_id');
|
||||||
|
|
||||||
// 既存レコードがある場合、再発行を促す
|
// 既存レコードがある場合、再発行を促す
|
||||||
$exists = DB::table('inv_publish')->where('contract_id', $contract_id)->exists();
|
$exists = DB::table('inv_publish')->where('contract_id', $contract_id)->exists();
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
@ -148,12 +149,11 @@ class ReceiptController extends Controller
|
|||||||
public function download(string $management_code, string $contract_id, bool $is_reissue = true): mixed
|
public function download(string $management_code, string $contract_id, bool $is_reissue = true): mixed
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user_id = session('user_id');
|
if ($redirect = $this->handleSessionExpired('領収書ダウンロード', false)) {
|
||||||
if (!$user_id) {
|
return $redirect;
|
||||||
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
|
||||||
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 領収書ダウンロード");
|
|
||||||
return redirect('/login');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user_id = session('user_id');
|
||||||
$management = session('management');
|
$management = session('management');
|
||||||
$management_id = $management->management_id;
|
$management_id = $management->management_id;
|
||||||
|
|
||||||
@ -179,25 +179,24 @@ class ReceiptController extends Controller
|
|||||||
->where('management_id', $management_id)
|
->where('management_id', $management_id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
// 社員側の社判画像を参照するため、シンボリックリンクを作成 (company_image_path が存在する場合のみ)
|
||||||
|
if (!empty($inv_setting->company_image_path)) {
|
||||||
$krgmStoragePath = config('app.krgm_storage_path');
|
$krgmStoragePath = config('app.krgm_storage_path');
|
||||||
$linkPath = public_path('other-storage');
|
$linkPath = public_path('other-storage');
|
||||||
if (!file_exists($krgmStoragePath)) {
|
if (!file_exists($krgmStoragePath)) {
|
||||||
\Log::error('KRGM path not found: ' . $krgmStoragePath);
|
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " 社判画像保存フォルダ発見不可: " . $krgmStoragePath . ", user_id=" . $user_id . ", contract_id=" . $contract_id);
|
||||||
abort(404, '画像パスが見つかりません。');
|
throw new \Exception();
|
||||||
}
|
}
|
||||||
if (!file_exists($linkPath)) {
|
if (!file_exists($linkPath)) {
|
||||||
$result = symlink($krgmStoragePath, $linkPath);
|
$result = symlink($krgmStoragePath, $linkPath);
|
||||||
\Log::info('Symlink result: ' . ($result ? 'success' : 'failed'));
|
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 社判画像参照リンク作成。結果: " . ($result ? '成功' : '失敗') . ", user_id=" . $user_id . ", contract_id=" . $contract_id);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
\Log::error('Symlink failed');
|
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " 社判画像参照リンク作成失敗。user_id=" . $user_id . ", contract_id=" . $contract_id);
|
||||||
abort(500, 'リンク作成失敗');
|
throw new \Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!file_exists($linkPath)) {
|
|
||||||
symlink($krgmStoragePath, $linkPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ダウンロード回数をカウントアップ
|
// ダウンロード回数をカウントアップ
|
||||||
DB::table('inv_publish')
|
DB::table('inv_publish')
|
||||||
->where('contract_id', $contract_id)
|
->where('contract_id', $contract_id)
|
||||||
@ -244,7 +243,7 @@ class ReceiptController extends Controller
|
|||||||
->header('Content-Disposition', 'attachment; filename="receipt_' . $contract_id . '.pdf"');
|
->header('Content-Disposition', 'attachment; filename="receipt_' . $contract_id . '.pdf"');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// PDF生成エラーを記録
|
// PDF生成エラーを記録
|
||||||
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " PDFダウンロードエラー: user_id=" . $user_id . ", contract_id=" . $contract_id . ", error=" . $e->getMessage());
|
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " 領収書PDFダウンロードエラー: user_id=" . $user_id . ", contract_id=" . $contract_id . ", error=" . $e->getMessage());
|
||||||
abort(500, '領収書ダウンロードに失敗しました。');
|
abort(500, '領収書ダウンロードに失敗しました。');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Traits\AuthenticatesUser;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
@ -12,6 +13,7 @@ use Carbon\Carbon;
|
|||||||
|
|
||||||
class RegularContractController extends Controller
|
class RegularContractController extends Controller
|
||||||
{
|
{
|
||||||
|
use AuthenticatesUser;
|
||||||
public function showInfo(Request $request)
|
public function showInfo(Request $request)
|
||||||
{
|
{
|
||||||
$user_id = session('user_id');
|
$user_id = session('user_id');
|
||||||
@ -89,13 +91,12 @@ class RegularContractController extends Controller
|
|||||||
* @param Request $request 受信したHTTPリクエスト
|
* @param Request $request 受信したHTTPリクエスト
|
||||||
* @return mixed ビュー応答またはリダイレクト
|
* @return mixed ビュー応答またはリダイレクト
|
||||||
*/
|
*/
|
||||||
$user_id = session('user_id');
|
if ($redirect = $this->handleSessionExpired('定期契約履歴確認')) {
|
||||||
if (!$user_id) {
|
return $redirect;
|
||||||
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
|
||||||
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 定期契約履歴確認画面アクセス");
|
|
||||||
return redirect()->guest('/login');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ヘッダー表示のためユーザー名取得
|
// ヘッダー表示のためユーザー名取得
|
||||||
|
$user_id = session('user_id');
|
||||||
$user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
|
$user_name = DB::table('user')->where('user_id', $user_id)->value('user_name');
|
||||||
|
|
||||||
// マルチテナント対応のため、運営元コード、IDを取得
|
// マルチテナント対応のため、運営元コード、IDを取得
|
||||||
|
|||||||
@ -6,8 +6,6 @@ use Closure;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
|
|
||||||
class ManagementMiddleware
|
class ManagementMiddleware
|
||||||
{
|
{
|
||||||
@ -17,10 +15,10 @@ class ManagementMiddleware
|
|||||||
*
|
*
|
||||||
* @param Request $request 受信したHTTPリクエスト
|
* @param Request $request 受信したHTTPリクエスト
|
||||||
* @param Closure $next 次のミドルウェア処理
|
* @param Closure $next 次のミドルウェア処理
|
||||||
* @return Response 次の処理のレスポンス
|
* @return mixed 次の処理のレスポンス
|
||||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException 運営元コードが見つからない場合
|
* @throws \Symfony\Component\HttpKernel\Exception\HttpException 運営元コードが見つからない場合
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response|RedirectResponse
|
public function handle(Request $request, Closure $next): mixed
|
||||||
{
|
{
|
||||||
// マルチテナント対応のため、URLの最初のセグメントを運営元コードとして扱う
|
// マルチテナント対応のため、URLの最初のセグメントを運営元コードとして扱う
|
||||||
$path = $request->getPathInfo(); // パス全体を取得
|
$path = $request->getPathInfo(); // パス全体を取得
|
||||||
|
|||||||
48
app/Http/Traits/AuthenticatesUser.php
Normal file
48
app/Http/Traits/AuthenticatesUser.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Traits;
|
||||||
|
|
||||||
|
trait AuthenticatesUser
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* セッション切れ時のログインリダイレクト(マルチテナント対応)
|
||||||
|
*
|
||||||
|
* @param string|null $screenName ログに記録する画面名
|
||||||
|
* @param bool $saveIntended ログイン後に元のURLに戻るか(true: 戻る, false: マイページ)
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|null
|
||||||
|
*/
|
||||||
|
protected function handleSessionExpired(?string $screenName = null, bool $saveIntended = true)
|
||||||
|
{
|
||||||
|
$userId = session('user_id');
|
||||||
|
|
||||||
|
if ($userId) {
|
||||||
|
return null; // 認証済み
|
||||||
|
}
|
||||||
|
|
||||||
|
// 運営元コード取得
|
||||||
|
$management = session('management');
|
||||||
|
$managementCode = $management->management_code ?? request()->segment(1);
|
||||||
|
|
||||||
|
if (!$managementCode) {
|
||||||
|
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " 運営元取得失敗 url=" . request()->fullUrl());
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ログ記録
|
||||||
|
$logMessage = "[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーアクセス(セッション切れ)";
|
||||||
|
if ($screenName) {
|
||||||
|
$logMessage .= " {$screenName}画面";
|
||||||
|
}
|
||||||
|
$logMessage .= " management_code=" . $managementCode;
|
||||||
|
\Log::info($logMessage);
|
||||||
|
|
||||||
|
if ($saveIntended) {
|
||||||
|
// ログイン後に元の画面に戻る
|
||||||
|
return redirect()->guest(route('swo8_1', ['management_code' => $managementCode]));
|
||||||
|
} else {
|
||||||
|
// ログイン後はマイページトップへ
|
||||||
|
session()->forget('url.intended');
|
||||||
|
return redirect()->route('swo8_1', ['management_code' => $managementCode]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -123,6 +123,16 @@ return [
|
|||||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| KRGM Storage Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is the path to the KRGM storage directory for accessing images
|
||||||
|
| from the other project via symbolic link.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
'krgm_storage_path' => env('KRGM_STORAGE_PATH'),
|
'krgm_storage_path' => env('KRGM_STORAGE_PATH'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
@yield('content')
|
@yield('content')
|
||||||
</main>
|
</main>
|
||||||
{{-- フッター --}}
|
{{-- フッター --}}
|
||||||
@include('partials.footer')
|
@include('partials.general_footer')
|
||||||
</div>
|
</div>
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script src="{{ asset('assets/js/vendor/popper.min.js') }}"></script>
|
<script src="{{ asset('assets/js/vendor/popper.min.js') }}"></script>
|
||||||
|
|||||||
@ -25,7 +25,7 @@ $management_code = $management ? $management->management_code : '';
|
|||||||
<li class="nav-item {{ $active_menu == 'SWC-8-1' ? 'active' : '' }}"><a class="nav-link" href="{{ route('regular_contract.create', ['management_code' => $management_code]) }}">新規定期契約</a></li>
|
<li class="nav-item {{ $active_menu == 'SWC-8-1' ? 'active' : '' }}"><a class="nav-link" href="{{ route('regular_contract.create', ['management_code' => $management_code]) }}">新規定期契約</a></li>
|
||||||
<li class="nav-item {{ $active_menu == 'SWC-11-1' ? 'active' : '' }}"><a class="nav-link" href="{{ route('park_waitlist.index', ['management_code' => $management_code]) }}">空き待ち状況確認</a></li>
|
<li class="nav-item {{ $active_menu == 'SWC-11-1' ? 'active' : '' }}"><a class="nav-link" href="{{ route('park_waitlist.index', ['management_code' => $management_code]) }}">空き待ち状況確認</a></li>
|
||||||
<li class="nav-item {{ $active_menu == 'SWC-10-1' ? 'active' : '' }}"><a class="nav-link" href="{{ route('park_search', ['management_code' => $management_code]) }}">駐輪場検索</a></li>
|
<li class="nav-item {{ $active_menu == 'SWC-10-1' ? 'active' : '' }}"><a class="nav-link" href="{{ route('park_search', ['management_code' => $management_code]) }}">駐輪場検索</a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="{{ route('swo16_1') }}" target="_blank">このページの使い方</a></li>
|
<li class="nav-item"><a class="nav-link" href="{{ route('swo16_1', ['management_code' => $management_code]) }}" target="_blank">このページの使い方</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@ -122,9 +122,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<div class="company">
|
<div class="company">
|
||||||
<span style="font-size:20px; font-weight:bold;">{{ $inv_setting->t_name ?? '' }}</span><br>
|
<span style="font-size:20px; font-weight:bold;">{{ $inv_setting->t_name ?? '' }}</span><br>
|
||||||
{{ $inv_setting->zipcode ?? '' }}<br>
|
〒{{ $inv_setting->zipcode }}<br>
|
||||||
{{ $inv_setting->adrs ?? '' }}<br>
|
{{ $inv_setting->adrs }}@if(!empty($inv_setting->bldg)){{ $inv_setting->bldg }}@endif
|
||||||
適格事業者番号:{{ $inv_setting->t_number ?? '' }}<br>
|
<br>適格事業者番号:{{ $inv_setting->t_number ?? '' }}<br>
|
||||||
@if(!empty($inv_setting->tel_num))
|
@if(!empty($inv_setting->tel_num))
|
||||||
TEL:{{ $inv_setting->tel_num}}<br>
|
TEL:{{ $inv_setting->tel_num}}<br>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user