Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||
use Modules\Lpj\Models\PemilikJaminan;
|
||||
use ZipArchive;
|
||||
|
||||
class DokumenJaminanController extends Controller
|
||||
{
|
||||
@@ -274,6 +275,45 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function bulkDownload()
|
||||
{
|
||||
$dokumenIds = request()->get('jaminan'); // Expecting an array of dokumen_jaminan_id
|
||||
$documents = DetailDokumenJaminan::where('dokumen_jaminan_id', $dokumenIds)->get();
|
||||
if ($documents->isEmpty()) {
|
||||
return redirect()->back()->with('error', 'No documents found for the provided IDs.');
|
||||
}
|
||||
|
||||
$zip = new ZipArchive;
|
||||
$zipFileName = 'documents_jaminan_' . $dokumenIds . '.zip';
|
||||
$zipFilePath = storage_path('app/public/' . $zipFileName);
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) {
|
||||
foreach ($documents as $document) {
|
||||
$filePath = storage_path('app/public/' . $document->dokumen_jaminan);
|
||||
if (file_exists($filePath)) {
|
||||
$zip->addFile($filePath, basename($filePath));
|
||||
} else {
|
||||
// Log or display an error message for missing files
|
||||
return redirect()->back()->with('error', 'File not found: ' . $filePath);
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
if (!file_exists($zipFilePath)) {
|
||||
return redirect()->back()->with('error', 'Failed to create ZIP file.');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Failed to create ZIP file.');
|
||||
}
|
||||
|
||||
return response()->download($zipFilePath, $zipFileName, [
|
||||
'Content-Type' => 'application/zip',
|
||||
'Content-Disposition' => 'attachment; filename="' . $zipFileName . '"',
|
||||
'Content-Length' => filesize($zipFilePath),
|
||||
])->deleteFileAfterSend(false);
|
||||
}
|
||||
|
||||
|
||||
public function download()
|
||||
{
|
||||
$dokumen = request()->get('dokumen');
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
'branch_id' => 'required|exists:branches,id',
|
||||
'tujuan_penilaian_id' => 'required|exists:tujuan_penilaian,id',
|
||||
'debiture_id' => 'required|exists:debitures,id',
|
||||
'status' => 'required|string|default:order',
|
||||
'status' => 'required|string',
|
||||
'jenis_fasilitas_kredit_id' => 'required|exists:jenis_fasilitas_kredit,id',
|
||||
'nilai_plafond_id' => 'required|exists:nilai_plafond,id',
|
||||
'status_bayar' => 'required|string',
|
||||
|
||||
Reference in New Issue
Block a user