46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?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
|
||
}
|
||
?>
|