Compare commits
No commits in common. "73ebe11e77f29599d722eda0ab262fe13c43bd51" and "0b449c4c60ea5a37a9d0f76db43d4400122a6fbd" have entirely different histories.
73ebe11e77
...
0b449c4c60
@ -4,7 +4,6 @@ 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;
|
||||||
@ -15,8 +14,6 @@ use function base_path;
|
|||||||
|
|
||||||
class ReceiptController extends Controller
|
class ReceiptController extends Controller
|
||||||
{
|
{
|
||||||
use AuthenticatesUser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 領収書宛名入力画面を表示する。
|
* 領収書宛名入力画面を表示する。
|
||||||
* 契約IDに基づき、領収書宛名入力フォームを表示する。
|
* 契約IDに基づき、領収書宛名入力フォームを表示する。
|
||||||
@ -27,12 +24,13 @@ class ReceiptController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function input(string $management_code, string $contract_id): mixed
|
public function input(string $management_code, string $contract_id): mixed
|
||||||
{
|
{
|
||||||
if ($redirect = $this->handleSessionExpired('領収書宛名入力', false)) {
|
|
||||||
return $redirect;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ヘッダー表示のためユーザー名取得
|
|
||||||
$user_id = session('user_id');
|
$user_id = session('user_id');
|
||||||
|
if (!$user_id) {
|
||||||
|
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
||||||
|
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 領収書宛名入力画面アクセス");
|
||||||
|
return redirect()->guest('/login');
|
||||||
|
}
|
||||||
|
// ヘッダー表示のためユーザー名取得
|
||||||
$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');
|
||||||
@ -72,11 +70,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
|
||||||
{
|
{
|
||||||
if ($redirect = $this->handleSessionExpired('領収書宛名入力', false)) {
|
|
||||||
return $redirect;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_id = session('user_id');
|
$user_id = session('user_id');
|
||||||
|
if (!$user_id) {
|
||||||
|
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
||||||
|
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 領収書発行");
|
||||||
|
return redirect('/login');
|
||||||
|
}
|
||||||
|
|
||||||
// 既存レコードがある場合、再発行を促す
|
// 既存レコードがある場合、再発行を促す
|
||||||
$exists = DB::table('inv_publish')->where('contract_id', $contract_id)->exists();
|
$exists = DB::table('inv_publish')->where('contract_id', $contract_id)->exists();
|
||||||
@ -149,11 +148,12 @@ 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 {
|
||||||
if ($redirect = $this->handleSessionExpired('領収書ダウンロード', false)) {
|
|
||||||
return $redirect;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_id = session('user_id');
|
$user_id = session('user_id');
|
||||||
|
if (!$user_id) {
|
||||||
|
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
||||||
|
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 領収書ダウンロード");
|
||||||
|
return redirect('/login');
|
||||||
|
}
|
||||||
$management = session('management');
|
$management = session('management');
|
||||||
$management_id = $management->management_id;
|
$management_id = $management->management_id;
|
||||||
|
|
||||||
@ -179,23 +179,24 @@ class ReceiptController extends Controller
|
|||||||
->where('management_id', $management_id)
|
->where('management_id', $management_id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// 社員側の社判画像を参照するため、シンボリックリンクを作成 (company_image_path が存在する場合のみ)
|
$krgmStoragePath = config('app.krgm_storage_path');
|
||||||
if (!empty($inv_setting->company_image_path)) {
|
$linkPath = public_path('other-storage');
|
||||||
$krgmStoragePath = config('app.krgm_storage_path');
|
if (!file_exists($krgmStoragePath)) {
|
||||||
$linkPath = public_path('other-storage');
|
\Log::error('KRGM path not found: ' . $krgmStoragePath);
|
||||||
if (!file_exists($krgmStoragePath)) {
|
abort(404, '画像パスが見つかりません。');
|
||||||
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " 社判画像保存フォルダ発見不可: " . $krgmStoragePath . ", user_id=" . $user_id . ", contract_id=" . $contract_id);
|
}
|
||||||
throw new \Exception();
|
if (!file_exists($linkPath)) {
|
||||||
}
|
$result = symlink($krgmStoragePath, $linkPath);
|
||||||
if (!file_exists($linkPath)) {
|
\Log::info('Symlink result: ' . ($result ? 'success' : 'failed'));
|
||||||
$result = symlink($krgmStoragePath, $linkPath);
|
if (!$result) {
|
||||||
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 社判画像参照リンク作成。結果: " . ($result ? '成功' : '失敗') . ", user_id=" . $user_id . ", contract_id=" . $contract_id);
|
\Log::error('Symlink failed');
|
||||||
if (!$result) {
|
abort(500, 'リンク作成失敗');
|
||||||
\Log::error("[ERROR] " . now()->format('Y-m-d H:i:s') . " 社判画像参照リンク作成失敗。user_id=" . $user_id . ", contract_id=" . $contract_id);
|
|
||||||
throw new \Exception();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!file_exists($linkPath)) {
|
||||||
|
symlink($krgmStoragePath, $linkPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ダウンロード回数をカウントアップ
|
// ダウンロード回数をカウントアップ
|
||||||
DB::table('inv_publish')
|
DB::table('inv_publish')
|
||||||
@ -243,7 +244,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,7 +4,6 @@ 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;
|
||||||
@ -13,7 +12,6 @@ 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');
|
||||||
@ -91,12 +89,13 @@ class RegularContractController extends Controller
|
|||||||
* @param Request $request 受信したHTTPリクエスト
|
* @param Request $request 受信したHTTPリクエスト
|
||||||
* @return mixed ビュー応答またはリダイレクト
|
* @return mixed ビュー応答またはリダイレクト
|
||||||
*/
|
*/
|
||||||
if ($redirect = $this->handleSessionExpired('定期契約履歴確認')) {
|
|
||||||
return $redirect;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ヘッダー表示のためユーザー名取得
|
|
||||||
$user_id = session('user_id');
|
$user_id = session('user_id');
|
||||||
|
if (!$user_id) {
|
||||||
|
// 未認証アクセス(セッション切れ)を追跡するため、INFOログで記録
|
||||||
|
\Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 未認証ユーザーによるアクセス(セッション切れ): 定期契約履歴確認画面アクセス");
|
||||||
|
return redirect()->guest('/login');
|
||||||
|
}
|
||||||
|
// ヘッダー表示のためユーザー名取得
|
||||||
$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,6 +6,8 @@ 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
|
||||||
{
|
{
|
||||||
@ -15,10 +17,10 @@ class ManagementMiddleware
|
|||||||
*
|
*
|
||||||
* @param Request $request 受信したHTTPリクエスト
|
* @param Request $request 受信したHTTPリクエスト
|
||||||
* @param Closure $next 次のミドルウェア処理
|
* @param Closure $next 次のミドルウェア処理
|
||||||
* @return mixed 次の処理のレスポンス
|
* @return Response 次の処理のレスポンス
|
||||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException 運営元コードが見つからない場合
|
* @throws \Symfony\Component\HttpKernel\Exception\HttpException 運営元コードが見つからない場合
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): mixed
|
public function handle(Request $request, Closure $next): Response|RedirectResponse
|
||||||
{
|
{
|
||||||
// マルチテナント対応のため、URLの最初のセグメントを運営元コードとして扱う
|
// マルチテナント対応のため、URLの最初のセグメントを運営元コードとして扱う
|
||||||
$path = $request->getPathInfo(); // パス全体を取得
|
$path = $request->getPathInfo(); // パス全体を取得
|
||||||
|
|||||||
@ -1,48 +0,0 @@
|
|||||||
<?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,16 +123,6 @@ 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.general_footer')
|
@include('partials.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', ['management_code' => $management_code]) }}" target="_blank">このページの使い方</a></li>
|
<li class="nav-item"><a class="nav-link" href="{{ route('swo16_1') }}" 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 }}@if(!empty($inv_setting->bldg)){{ $inv_setting->bldg }}@endif
|
{{ $inv_setting->adrs ?? '' }}<br>
|
||||||
<br>適格事業者番号:{{ $inv_setting->t_number ?? '' }}<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