
<!-- <?php $__env->startSection('title', 'Best Practice'); ?> -->
<!-- banner page -->
<?php $__env->startSection('banner'); ?>
<img src="<?php echo e(asset('../storage/km/banner/fguide.jpg')); ?>" class="img-fluid" width="100%">
<?php $__env->stopSection(); ?>

<!-- content -->
<?php $__env->startSection('content'); ?>
<div class="col-md-12" id="col">
    <div class="row">
        <?php if($manual['status'] == true): ?>
        <div class="accordion" id="accordionContent1">
            <div class="accordion-item">
                <h2 class="accordion-header" id="headingFour">
                    <button class="accordion-button" type="button" data-bs-toggle="collapse"
                        data-bs-target="#collapseFour" aria-expanded="true" aria-controls="collapseFour">
                        <h5>วีดีโอ</h5>
                    </button>
                </h2>
                <div id="collapseFour" class="accordion-collapse collapse show" aria-labelledby="headingFour">
                    <div class="accordion-body">
                        <div class="row">
                            <div class="table-responsive">
                                <table id="listvideo" class="table" style="width: 100%">
                                    <tbody>
                                        <tr>
                                            <?php if(count($manual['data']) > 0): ?>
                                            <?php ($video = 0); ?>
                                            <?php $__currentLoopData = $manual['data']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if($item['type'] == 2): ?>
                                            <?php ($video = $video + 1); ?>
                                            <td style="width: 20%; text-align: center; border-bottom-width: 0px">
                                                <div class="box">
                                                    <div class="box-body">
                                                        <iframe width="230" height="180" src="<?php echo e($item['name']); ?>"
                                                            title="YouTube video player" frameborder="0"
                                                            allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
                                                            allowfullscreen>
                                                        </iframe>
                                                    </div>
                                                </div>
                                            </td>
                                            <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                            <?php if($video == 0): ?>
                                            <td style="width: 100%; text-align: left; border-bottom-width: 0px">
                                                <p class="kitem-1">ไม่พบข้อมูล</p>
                                            </td>
                                            <?php elseif($video < 3): ?> <?php for($i=$video; $i < 5; $i++): ?> <td
                                                style="width: 20%; border-bottom-width: 0px">
                                                </td>
                                                <?php endfor; ?>
                                                <?php endif; ?>
                                                <?php else: ?>
                                                <td style="width: 100%; text-align: left; border-bottom-width: 0px">
                                                    <p class="kitem-1">ไม่พบข้อมูล</p>
                                                </td>
                                                <?php endif; ?>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="accordion" id="accordionContent2">
            <div class="accordion-item">
                <h2 class="accordion-header" id="headingFive">
                    <button class="accordion-button" type="button" data-bs-toggle="collapse"
                        data-bs-target="#collapseFive" aria-expanded="true" aria-controls="collapseFive">
                        <h5>ไฟล์เอกสาร</h5>
                    </button>
                </h2>
                <div id="collapseFive" class="accordion-collapse collapse show" aria-labelledby="headingFive">
                    <div class="accordion-body">
                        <div class="row">
                            <div class="table-responsive">
                                <table id="listfile" class="table" style="width: 100%">
                                    <tbody>
                                        <?php if(count($manual['data']) > 0): ?>
                                        <?php ($doc = 0); ?>
                                        <?php $__currentLoopData = $manual['data']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($item['type'] == 3): ?>
                                        <?php ($doc = $doc + 1); ?>
                                        <tr data-index="<?php echo e($item['name']); ?>" class="tr-hover" title="Download">
                                            <td style="width: 90%; text-align: left; border-bottom-width: 0px">
                                                <p class="kitem-1"><?php echo e($item['name']); ?></p>
                                            </td>
                                            <td style=" width: 10%; text-align: left; border-bottom-width: 0px">
                                                <a data-index="<?php echo e($item['id']); ?>"
                                                    href="<?php echo e(asset('../storage/km/manual/'.$item['name'])); ?>" download
                                                    class="kitem-1 p-hover" title="Download" hidden></a>
                                                <i class="fas fa-download kitem-1"></i>
                                                <span class="numDownload<?php echo e($item['id']); ?> kitem-1">
                                                    <?php echo e($item['download_count']); ?>

                                                </span>
                                            </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; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php else: ?>
        <p class="kitem-1">ไม่พบข้อมูล</p>
        <?php endif; ?>
    </div>
</div>
<script>
$("#listfile tbody tr").on("click", function(event) {
    // alert("listfile tbody tr");
    var link_url = $(this).find("td").find("a").attr('href');
    var id_url = $(this).find("td").find("a").attr('data-index');

    var link = document.createElement("a");
    link.setAttribute('download', name);
    link.href = link_url;
    document.body.appendChild(link);
    link.click();
    link.remove();

    $.ajax({
        type: "get",
        url: 'helper/countDownloadManual/' + id_url,
        dataType: 'json',
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        success: function(result) {
            // console.log(result);
            if (result.status == true) {
                $(".numDownload" + id_url).text(result.data);
            }
        }
    });
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.front.mastermem', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\km-web\resources\views/frontOffice/manual.blade.php ENDPATH**/ ?>