feat(webstatement): tambahkan fitur penggabungan dan proteksi file PDF
- Menambahkan command baru `webstatement:combine-pdf` melalui `CombinePdf` untuk menjalankan proses penggabungan file PDF. - Proses ini mencakup penggabungan file PDF dari folder r14 dan r23 berdasarkan periode tertentu. - File PDF yang dihasilkan juga dilindungi dengan password berbasis nomor rekening. - Membuat controller `CombinePdfController` dengan fungsi utama `combinePdfs` untuk mengontrol alur penggabungan file PDF: - Mendapatkan daftar akun yang relevan. - Mengecek file dari folder r14 dan r23 untuk setiap akun. - Melakukan logging saat file tidak ditemukan atau jika terdapat error dalam proses. - Mendaftarkan job `CombinePdfJob` untuk memproses file secara async. - Menambahkan job baru `CombinePdfJob`: - Menggunakan library `PDFMerger` untuk menggabungkan file. - Terapkan proteksi password menggunakan library `PDFPasswordProtect`. - Memastikan direktori output dibuat jika belum ada. - Melakukan logging saat proses berhasil maupun saat terjadi error. - Memperbarui `WebstatementServiceProvider`: - Mendaftarkan command baru ke dalam provider. - Menambahkan penjadwalan otomatis untuk menjalankan perintah `webstatement:combine-pdf` setiap hari pada pukul 09:30. - Logging hasil eksekusi ke file log `logs/combine-pdf.log`. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
47
app/Console/CombinePdf.php
Normal file
47
app/Console/CombinePdf.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Console;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Webstatement\Http\Controllers\CombinePdfController;
|
||||
|
||||
class CombinePdf extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webstatement:combine-pdf';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process combine pdf';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting combine pdf process...');
|
||||
$period = request()->set(['period' => $this->argument('period')]);
|
||||
try {
|
||||
$controller = app(CombinePdfController::class);
|
||||
$response = $controller->combinePdfs($period);
|
||||
|
||||
$responseData = json_decode($response->getContent(), true);
|
||||
$this->info($responseData['message'] ?? 'Process completed');
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (Exception $e) {
|
||||
$this->error('Error processing combine pdf: ' . $e->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user