diff --git a/app/Http/Controllers/PrintStatementController.php b/app/Http/Controllers/PrintStatementController.php index 7b4657e..1049af9 100644 --- a/app/Http/Controllers/PrintStatementController.php +++ b/app/Http/Controllers/PrintStatementController.php @@ -141,7 +141,14 @@ try { $disk = Storage::disk('sftpStatement'); - $filePath = "{$statement->period_from}/Print/{$statement->branch_code}/{$statement->account_number}.pdf"; + $filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf"; + + // Log untuk debugging + Log::info('Checking SFTP file path', [ + 'file_path' => $filePath, + 'sftp_root' => config('filesystems.disks.sftpStatement.root'), + 'full_path' => config('filesystems.disks.sftpStatement.root') . '/' . $filePath + ]); if ($statement->is_period_range && $statement->period_to) { $periodFrom = Carbon::createFromFormat('Ym', $statement->period_from); @@ -152,7 +159,7 @@ for ($period = clone $periodFrom; $period->lte($periodTo); $period->addMonth()) { $periodFormatted = $period->format('Ym'); - $periodPath = $periodFormatted . "/Print/{$statement->branch_code}/{$statement->account_number}.pdf"; + $periodPath = $periodFormatted . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf"; if ($disk->exists($periodPath)) { $availablePeriods[] = $periodFormatted; @@ -274,7 +281,7 @@ // Generate or fetch the statement file $disk = Storage::disk('sftpStatement'); - $filePath = "{$statement->period_from}/Print/{$statement->branch_code}/{$statement->account_number}.pdf"; + $filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf"; if ($statement->is_period_range && $statement->period_to) { // Handle period range download (existing logic) @@ -480,7 +487,7 @@ try { $disk = Storage::disk('sftpStatement'); - $filePath = "{$statement->period_from}/Print/{$statement->branch_code}/{$statement->account_number}.pdf"; + $filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf"; if ($statement->is_period_range && $statement->period_to) { $periodFrom = Carbon::createFromFormat('Ym', $statement->period_from); @@ -492,7 +499,7 @@ for ($period = clone $periodFrom; $period->lte($periodTo); $period->addMonth()) { $periodFormatted = $period->format('Ym'); - $periodPath = $periodFormatted . "/Print/{$statement->branch_code}/{$statement->account_number}.pdf"; + $periodPath = $periodFormatted . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf"; if ($disk->exists($periodPath)) { $availablePeriods[] = $periodFormatted; @@ -517,7 +524,7 @@ if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) { // Add each available statement to the zip foreach ($availablePeriods as $period) { - $filePath = "{$period}/Print/{$statement->branch_code}/{$statement->account_number}.pdf"; + $filePath = "{$period}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf"; $localFilePath = storage_path("app/temp/{$statement->account_number}_{$period}.pdf"); // Download the file from SFTP to local storage temporarily