Files
citrus-cms/resources/views/admin-ajax/pdf/tp-creator-download-zip.blade.php
2026-04-28 21:15:09 +03:00

46 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$data = json_decode(post("lines"), true); // Gelen JSON verisini diziye çevir
$path = 'storage/documents/' . post("path");
$tempPath = 'storage/documents/temp_zip';
@mkdir($tempPath, 0777, true);
$date = date("d-m-Y H:i:s");
// Tek bir zip dosyası oluşturmak için hedef dosya adı
$allDirectories = [];
// Her bir test package numarası için klasörleri bul ve diziye ekle
$tpNos = [];
foreach ($data as $d) {
$tpNo = $d['test_package_number'];
$directories = glob("$path/*$tpNo*");
if (!empty($directories)) {
$allDirectories = array_merge($allDirectories, $directories);
$tpNos[] = $tpNo;
}
}
$total = count($tpNos);
$zip_file = "$tempPath/$total Test Packages - $date .zip";
// Eğer dizinler varsa zip işlemini başlat
if (!empty($allDirectories)) {
$dirPaths = implode(" ", array_map('escapeshellarg', $allDirectories)); // Dizinleri tek bir string yap
// Zip oluşturma komutunu çalıştır
$command = "zip -r '$zip_file' $dirPaths";
shell_exec($command);
?>
<a href="{{ url($zip_file) }}" class="btn btn-outline-primary mb-3"><i class="fa fa-file-pdf"></i> Download PDF ZIP</a>
<hr>
{{e2("Includes Test Packages")}} {{e2("Total")}}: {{$total}} 👇 <br>
@foreach($tpNos AS $tpNo)
<div class="badge badge-info">{{$tpNo}}</div>
@endforeach
<?php
}
?>