<?php 
if(file_exists('../../../'.$_REQUEST['tenant'].'/config.php')){require_once('../../../'.$_REQUEST['tenant'].'/config.php');}
if(file_exists('/config.php')){require_once('/config.php');}


$path='../../../'.TENANT_URL.'/output/reports/'.$_REQUEST['clientnumber'].'/';
$count=0;
$arrays=explode('|',$_REQUEST['defectList']);
$theZip=$_REQUEST['clientnumber'].'-defect_'.rand().'.zip';
$zip = new ZipArchive;
if ($zip->open($path.$theZip, ZipArchive::CREATE) === TRUE)
{
foreach($arrays as $a){
$items=explode('-',$a);
if(!empty($items[0])){
$zip->addFile($path.$items[0].'.pdf',$items[0].'.pdf');
$count++;
}
}
$zip->close();
echo $theZip.$_REQUEST['defectList'];
}
else{echo "error";}
?>