diff --git a/app/Http/Controllers/ReceiptController.php b/app/Http/Controllers/ReceiptController.php index 919023a..f7778a4 100644 --- a/app/Http/Controllers/ReceiptController.php +++ b/app/Http/Controllers/ReceiptController.php @@ -179,24 +179,23 @@ class ReceiptController extends Controller ->where('management_id', $management_id) ->first(); - $krgmStoragePath = config('app.krgm_storage_path'); - $linkPath = public_path('other-storage'); - if (!file_exists($krgmStoragePath)) { - \Log::error('KRGM path not found: ' . $krgmStoragePath); - abort(404, '画像パスが見つかりません。'); - } - if (!file_exists($linkPath)) { - $result = symlink($krgmStoragePath, $linkPath); - \Log::info('Symlink result: ' . ($result ? 'success' : 'failed')); - if (!$result) { - \Log::error('Symlink failed'); - abort(500, 'リンク作成失敗'); + // 社員側の社判画像を参照するため、シンボリックリンクを作成 (company_image_path が存在する場合のみ) + if (!empty($inv_setting->company_image_path)) { + $krgmStoragePath = config('app.krgm_storage_path'); + $linkPath = public_path('other-storage'); + if (!file_exists($krgmStoragePath)) { + \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); + \Log::info("[INFO] " . now()->format('Y-m-d H:i:s') . " 社判画像参照リンク作成。結果: " . ($result ? '成功' : '失敗') . ", user_id=" . $user_id . ", contract_id=" . $contract_id); + if (!$result) { + \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') @@ -244,7 +243,7 @@ class ReceiptController extends Controller ->header('Content-Disposition', 'attachment; filename="receipt_' . $contract_id . '.pdf"'); } catch (\Exception $e) { // 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, '領収書ダウンロードに失敗しました。'); } } diff --git a/config/app.php b/config/app.php index 0767204..02cfcbf 100644 --- a/config/app.php +++ b/config/app.php @@ -123,6 +123,16 @@ return [ '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'), ]; diff --git a/resources/views/receipt/pdf.blade.php b/resources/views/receipt/pdf.blade.php index 7dfab4c..359bff4 100644 --- a/resources/views/receipt/pdf.blade.php +++ b/resources/views/receipt/pdf.blade.php @@ -122,9 +122,12 @@
{{ $inv_setting->t_name ?? '' }}
- {{ $inv_setting->zipcode ?? '' }}
- {{ $inv_setting->adrs ?? '' }}
- 適格事業者番号:{{ $inv_setting->t_number ?? '' }}
+ 〒{{ $inv_setting->zipcode }}
+ {{ $inv_setting->adrs }} + @if(!empty($inv_setting->bldg)) + {{ $inv_setting->bldg }} + @endif +
適格事業者番号:{{ $inv_setting->t_number ?? '' }}
@if(!empty($inv_setting->tel_num)) TEL:{{ $inv_setting->tel_num}}
@endif