<div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne"
    data-bs-parent="#accordionContent1">
    <div class="accordion-body">
        <?php if($article['status'] == true): ?>
        <?php $__currentLoopData = $article['data']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ad): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="row mx-md-n5 margin-down">
            <div class="col-md-3">
                <img src="<?php echo e(asset('../storage/km/cover/cover.jpg')); ?>" class="img-fluid">
            </div>
            <div class="col-md-9">
                <h3 class="txtorange-1"><?php echo e($ad['name']); ?></h3>
                <div class="row">
                    <div class="col-sm-3">
                        <p class="kitem-1">
                            <i class="fas fa-user-alt"></i>
                            <strong>บรรณาธิการ:</strong>
                        </p>
                    </div>
                    <div class="col-sm-9">
                        <p class="kitem-1"><?php echo e($ad['author']); ?></p>
                    </div>
                    <div class="col-sm-3">
                        <p class="kitem-1">
                            <i class="fas fa-building"></i>
                            <strong>หน่วยงาน:</strong>
                        </p>
                    </div>
                    <div class="col-sm-9">
                        <p class="kitem-1"><?php echo e($ad['organization']['name']); ?></p>
                    </div>
                    <div class="col-sm-3">
                        <p class="kitem-1">
                            <i class="fas fa-calendar-alt"></i>
                            <strong>ปีที่จัดทำ:</strong>
                        </p>
                    </div>
                    <div class="col-sm-9">
                        <p class="kitem-1 year_format"><?php echo e($ad['year_of']); ?></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="accordion" id="accordionContent2">
            <div class="accordion-item">
                <h2 class="accordion-header" id="headingTwo">
                    <button class="accordion-button" type="button" data-bs-toggle="collapse"
                        data-bs-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
                        <h5>ไฟล์เอกสาร</h5>
                    </button>
                </h2>
                <div id="collapseTwo" class="accordion-collapse collapse show" aria-labelledby="headingTwo"
                    data-bs-parent="#accordionContent2">
                    <div class="accordion-body">
                        <div class="row">
                            <div class="table-responsive">
                                <table id="listallfile" class="table" style="width: 100%">
                                    <tbody>
                                    <?php if(session()->has('user')): ?>
                                        <?php if(count($ad['file']) > 0): ?>
                                        <?php ($doc = 0); ?>
                                        <?php $__currentLoopData = $ad['file']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $af): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($af['type'] == 3): ?>
                                        <?php ($doc = $doc + 1); ?>
                                        <tr data-index="<?php echo e($af['name']); ?>" class="tr-hover">
                                            <td style="width: 90%; text-align: left; border-bottom-width: 0px">
                                                <p class="kitem-1"><?php echo e($af['name']); ?></p>
                                            </td>
                                            <td style=" width: 10%; text-align: left; border-bottom-width: 0px">
                                                <a data-index="<?php echo e($af['id']); ?>"
                                                    href="<?php echo e(asset('../storage/km/articles/'.$af['name'])); ?>" download
                                                    class="kitem-1 p-hover" title="Download">
                                                    <i class="fas fa-download "></i>
                                                    <span class="numDownload<?php echo e($af['id']); ?>">
                                                        <?php echo e($af['download_count']); ?>

                                                    </span>
                                                </a>
                                            </td>
                                        </tr>
                                        <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($doc == 0): ?>
                                        <tr>
                                            <td style="width: 100%; text-align: left; border-bottom-width: 0px">
                                                <p class="kitem-1">ไม่พบข้อมูล</p>
                                            </td>
                                        </tr>
                                        <?php endif; ?>
                                        <?php else: ?>
                                        <tr>
                                            <td style="width: 100%; text-align: left; border-bottom-width: 0px">
                                                <p class="kitem-1">ไม่พบข้อมูล</p>
                                            </td>
                                        </tr>
                                        <?php endif; ?>
                                    <?php else: ?>
                                    <tr>
                                        <td style="width: 100%; text-align: left; border-bottom-width: 0px; color:red;">
                                            <p>สงวนสิทธิ์การใช้งานเฉพาะบุคลากรกรมทางหลวงเท่านั้น</p>
                                        </td>
                                    </tr>
                                    <?php endif; ?>                                        
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php else: ?>
        <p>ไม่พบข้อมูล</p>
        <?php endif; ?>
    </div>
</div>

<script>
$('.year_format').each(function(d) {
    $(this).html(moment($(this).html()).add(543, 'years').locale('th').format('YYYY'));
});
$('#listallfile tr td a').click(function() {
    // alert("The paragraph was clicked.");
    $id = $(this).data('index');
    // console.log($id);
    $.ajax({
        type: "get",
        url: '../helper/countDownload/' + $id,
        dataType: 'json',
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        success: function(result) {
            // console.log(result);
            if (result.status == true) {
                $(".numDownload" + $id).text(result.data);
            }
        }
    });
});
</script><?php /**PATH C:\xampp\htdocs\km-web\resources\views/subpage/listArticle.blade.php ENDPATH**/ ?>