<div>
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item mr-2 mb-2">
<a class="btn btn-primary active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">Входящее сканирование</a>
</li>
<li class="nav-item">
<a class="btn btn-primary" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">Исходящее сканирование</a>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
<table class="table table-striped table-bordered coolTable" style="table-layout: fixed">
<thead>
<tr>
<th scope="col">№ заказа</th>
<th scope="col">Дата сканирования</th>
</tr>
</thead>
<tbody>
<?foreach ($arResult['ITEMS'] as $item):?>
<tr>
<td><?=$item['ID']?></td>
<td><?=$item['SCANNING_DATE']?></td>
</tr>
<?endforeach;?>
</tbody>
</table>
</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
<ul>
<?PHP
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/upload/awb/' . $awb . '/';
$fileArray = array_diff(scandir($uploadDir, 1), array("inputScanning.json", "..", "."));
foreach ($fileArray as $filename)
echo "<li>$filename</li>";
?>
</ul>
<div id="out">
</div>
<table class="table table-striped table-bordered coolTable" style="table-layout: fixed">
<thead>
<tr>
<th scope="col">№ заказа</th>
<th scope="col">Дата сканирования</th>
<th scope="col">Пользователь</th>
</tr>
</thead>
<tbody>
<?foreach ($arResult['OUTPUT_SCAN'] as $outScan):?>
<?foreach ($outScan as $outRow):?>
<tr>
<td><?=$outRow['ID']?></td>
<td><?=$outRow['SCANNING_DATE']?></td>
<td><?=$outRow['USER']?></td>
</tr>
<?endforeach;?>
<?endforeach;?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(function(){
$("ul").on("click","li",function(e){
$.ajax({
url: "<?=$_SERVER['PHP_SELF']?>",
type: 'POST',
data: {
filename:$(this).html()
}
}).done(function(data){
$("#out").html("<pre>"+data+"</pre>");
})
});
})
</script>
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/upload/awb/' . $awb . '/';
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(file_exists($uploadDir."/".$_POST["filename"])){
echo file_get_contents($uploadDir."/".$_POST["filename"]);
die;
}
}
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/upload/awb/' . $awb . '/';
$fileArray = array_diff(scandir($uploadDir, 1), array("inputScanning.json", "..", "."));
$filePath = $uploadDir . $filename;
foreach ($fileArray as $filename){
$filePath = $uploadDir . $filename;
$dataFile = file_get_contents($filePath);
$resultScan = json_decode($dataFile, true);
$resultOut[] = $resultScan;
}
<table id="myTable" class="table table-bordered coolTable">
<tbody>
<? foreach ($arResult['OUTPUT'] as $message): ?>
<tr>
<td><?=$message['TIME']?></td>
<td><?=$message['MESSAGE']?></td>
<td>Тут типо ответил админ</td>
</tr>
<? endforeach; ?>
</tbody>
</table>