<?php $__env->startSection('content'); ?>

    <div class="container mt-3">
        <?php if(session('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <?php echo e(session('success')); ?>

                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        <?php endif; ?>
        <?php if(session('error')): ?>
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <?php echo e(session('error')); ?>

                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        <?php endif; ?>
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        <h4 class="mb-0">Print Cases</h4>
                        <button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal"
                            data-bs-target="#exportPdfModal">export pdf</button>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>HN</th>
                                        <th>ชื่อ-นามสกุล</th>
                                        <th>วันที่</th>
                                        <th>แพทย์</th>
                                        <th>สถานะ</th>
                                        <th>จัดการ</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $tb_case; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $case): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($case['case_hn']); ?></td>
                                        <td><?php echo e($case['patientname']); ?></td>
                                        <td><?php echo e($case['appointment_date']); ?></td>
                                        <td><?php echo e($case['doctorname']); ?></td>
                                        <td><?php echo e($case['statusjob']); ?></td>
                                        <td>
                                            <a target="_blank" href="<?php echo e(url('printpdf/'.$case['_id'])); ?>" class="btn btn-primary btn-sm">พิมพ์</a>
                                            
                                        </td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-12 mt-4">
                <div class="card">
                    <div class="card-header">
                        <h4>รายการที่พิมพ์แล้ว <?php echo e(count($tb_caseyet)); ?></h4>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>HN</th>
                                        <th>ชื่อ-นามสกุล</th>
                                        <th>วันที่</th>
                                        <th>แพทย์</th>
                                        <th>สถานะ</th>
                                        <th>จัดการ</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $i = 0;
                                    ?>

                                    <?php $__currentLoopData = $tb_caseyet; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $case): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($i++); ?></td>
                                        <td><?php echo e($case['case_hn']); ?></td>
                                        <td><?php echo e($case['patientname']); ?></td>
                                        <td><?php echo e($case['appointment_date']); ?></td>
                                        <td><?php echo e($case['doctorname']); ?></td>
                                        <td><?php echo e($case['statusjob']); ?></td>
                                        <td>
                                            <a target="_blank" href="<?php echo e(url('printpdf/'.$case['_id'])); ?>" class="btn btn-success btn-sm">พิมพ์อีกครั้ง</a>
                                            
                                        </td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>


        </div>
    </div>

    <div class="modal fade" id="exportPdfModal" tabindex="-1" aria-labelledby="exportPdfModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <form action="<?php echo e(url('printpdf')); ?>" method="post" id="exportPdfForm">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" name="department" value="<?php echo e(@$department); ?>">
                    <input type="hidden" name="event" value="exportpdf">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exportPdfModalLabel">Export PDF</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <label for="export_date" class="form-label">เลือกวันที่ export</label>
                        <input type="date" class="form-control" name="export_date" id="export_date"
                            value="<?php echo e(date('Y-m-d')); ?>" required>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-light" data-bs-dismiss="modal">ยกเลิก</button>
                        <button type="submit" class="btn btn-primary">Export</button>
                    </div>
                </form>
            </div>
        </div>
    </div>


<script>
    // รีเฟรชหน้าอัตโนมัติทุก 20 วินาที
    setInterval(function() {
        location.reload();
    }, 20000);
</script>


    <script src="<?php echo e(url('public/js/jquery-3.6.0.min.js')); ?>"></script>
    <script src="<?php echo e(url('assets/js/bootstrap.bundle.min.js')); ?>"></script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('capture.layoutv6', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\htdocs\screening\resources\views/printpdf/index.blade.php ENDPATH**/ ?>