<?php $__env->startSection('title', 'EndoINDEX'); ?>

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

    <style>
        .btn-final {
            background: #3577F1;
            color: #fff;
        }

        .btn-final:hover {
            background: #2a56a8;
            color: #fff;
        }

        .text-red {
            color: #FF0000;
        }

        .icon-text {
            color: #299cdb;
        }

        .text-ALCENTER {
            margin-left: 0.8rem;
        }

        .pd-1 {
            padding-left: 1.5rem;
        }

        #switch_setting {
            cursor: pointer;
        }

        .form-check-input {
            border: 1px solid #000000 !important;
        }

        .form-check-input:disabled {
            opacity: 1 !important;
        }

        .btn-edit {
            background: #f7b84b;
            color: #ffffff;
            width: 80px;
        }

        .btn-edit:hover {
            background: #f7b84b;
            color: #ffffff;
            width: 80px;
        }

        /* .btn-position{
                position: absolute;
                left: 25em;
                top: 25em;
                z-index: 99999999;
            } */
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('title-left'); ?>
    <h4 class="mb-sm-0">REPORT</h4>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('title-right'); ?>
    <ol class="breadcrumb m-0">
        <li class="breadcrumb-item"><a href="javascript: void(0);">Cases List</a></li>
        <li class="breadcrumb-item active">Report</li>
    </ol>
<?php $__env->stopSection(); ?>







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

    
    <div class="row mt-13 ">
        <div class="col-lg  ">
            <?php
                if (isset($_GET['type'])) {
                    $type = '&type=' . $_GET['type'];
                } else {
                    $type = '';
                }
            ?>
            <div class="card">
                
                <div class="col-12" id="card_setting" style="display: none;">
                    <div class="row m-0">
                        <div class="col-12">
                            <div class="row">
                                <?php
                                    $swicth = 'EndoCAPTURE.superadmin.component.switch';
                                    $textbox = 'EndoCAPTURE.superadmin.component.textbox';
                                ?>
                                <?php $__env->startComponent($swicth, ['type' => 'admin', 'name' => 'PDF findding normal', 'id' => 'pdf_findding_normal']); ?>
                                <?php echo $__env->renderComponent(); ?>
                                <?php $__env->startComponent($textbox, ['type' => 'pdf', 'name' => 'PDF Folder HEAD Hospital', 'id' => 'pdf_folder_head']); ?>
                                <?php echo $__env->renderComponent(); ?>
                                <?php $__env->startComponent($textbox, ['type' => 'admin', 'name' => 'PDF Procedure pic', 'id' => 'pdf_procedure_pic']); ?>
                                <?php echo $__env->renderComponent(); ?>
                                <?php $__env->startComponent($textbox, ['type' => 'admin', 'name' => 'pdf_exit', 'id' => 'pdf_exit']); ?>
                                <?php echo $__env->renderComponent(); ?>

                                <?php $__env->startComponent($textbox, ['type' => 'pdf', 'name' => 'pdf_page_margin_top', 'id' => 'pdf_page_margin_top']); ?>
                                <?php echo $__env->renderComponent(); ?>
                                <?php $__env->startComponent($textbox, ['type' => 'pdf', 'name' => 'pdf_header_margin_top', 'id' => 'pdf_header_margin_top']); ?>
                                <?php echo $__env->renderComponent(); ?>
                                <?php $__env->startComponent($textbox, ['type' => 'pdf', 'name' => 'pdf_content_left_top', 'id' => 'pdf_content_left_top']); ?>
                                <?php echo $__env->renderComponent(); ?>
                                <?php $__env->startComponent($textbox, ['type' => 'pdf', 'name' => 'pdf_content_right_top', 'id' => 'pdf_content_right_top']); ?>
                                <?php echo $__env->renderComponent(); ?>

                                <div class="col-3">
                                    <h3>pdf_default&emsp;&nbsp;</h3>
                                </div>
                                <div class="col-1"></div>
                                <div class="col-6">
                                    <select id="pdf_default" class="form-control configtext">
                                        
                                        <option value="procedure" <?php if(@$config->pdf_default == 'procedure'): ?> selected <?php endif; ?>>
                                            procedure</option>
                                        <option value="case_largepicture" <?php if(@$config->pdf_default == 'case_largepicture'): ?> selected <?php endif; ?>>
                                            Large Picture</option>
                                        <option value="long_writing" <?php if(@$config->pdf_default == 'long_writing'): ?> selected <?php endif; ?>>
                                            long_writing</option>
                                        <option value="drawing" <?php if(@$config->pdf_default == 'drawing'): ?> selected <?php endif; ?>>drawing
                                        </option>
                                        <option value="long_image" <?php if(@$config->pdf_default == 'long_image'): ?> selected <?php endif; ?>>
                                            long_image</option>
                                        <option value="procedure_custom" <?php if(@$config->pdf_default == 'procedure_custom'): ?> selected <?php endif; ?>>
                                            procedure_custom</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php
                        $head_line = configTYPE('pdf', 'head_line');
                        $body_line = configTYPE('pdf', 'body_line');
                        $pagetwo = configTYPE('pdf', 'pagetwo');
                    ?>
                    <div class="row mt-2">
                        <div class="col-3 h3">Head special</div>
                        <div class="col-1"></div>
                        <div class="col-6"><input type="number" name="" id="head_line"
                                class="form-control config_type" config_type="pdf" value="<?php echo e($head_line); ?>"></div>
                    </div>
                    <div class="row mt-2">
                        <div class="col-3 h3">Line special</div>
                        <div class="col-1"></div>
                        <div class="col-6"><input type="number" name="" id="body_line"
                                class="form-control config_type" config_type="pdf" value="<?php echo e($body_line); ?>"></div>
                    </div>
                    <div class="row mt-2">
                        <div class="col-3 h3">Image Page 2</div>
                        <div class="col-1"></div>
                        <div class="col-6"><input type="number" name="" id="pagetwo"
                                class="form-control config_type" config_type="pdf" value="<?php echo e($pagetwo); ?>"></div>
                    </div>
                    <div class="row mb-3 mt-2">
                        <div class="col text-end">
                            <button class="btn btn-primary" id="open_file_location">Open File Location</button>
                            <a id="pdf_setting_save" class="btn btn-success">Save</a>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <div class="col-12 text-end">
                        <button class="btn btn-outline-primary btn-icon " style="display:none;" id="btn_printnursenote"><i
                                class=" ri-printer-fill"></i></button>
                    </div>
                    <iframe class="" id="iframepdf" src="<?php echo e(url("api/pdf/$cid")); ?>" width="100%"
                        height="1200"></iframe>
                </div>
            </div>
        </div>
        <div class="col-lg-3 hide-content">
            <div class="card ribbon-box">
                <div class="card-body px-0 py-1">
                    <div class="row m-0 py-0 mb-3">
                        <div class="col-lg-6 p-0 m-0">
                            <div class="ribbon ribbon-success round-shape">
                                <i class=" ri-file-paper-line
                                "></i>&ensp; Procedure
                            </div>
                        </div>
                        <div class="col-lg-6  text-end">
                            <span class="text-red h5">Patient ID :
                                <?php echo e(@$casetoday[0]['case_hn']); ?></span>
                        </div>
                    </div>

                    

                    <?php $__currentLoopData = $casetoday; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $in => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $data = (object) $data;
                            $folderdate = isset($data->appointment) ? explode(' ', $data->appointment)[0] : '';
                        ?>


                        <div class="row pt-2 m-0">
                            <div class="col-8">
                                <a class="form-check-label" href="<?php echo e(url("reportendocapture/$data->_id")); ?>">
                                    <div class="border p-2 mb-1">
                                        <input type="radio" class="form-check-input mt-1"
                                            id="procedureradio_<?php echo e(@$data->_id); ?>" name="radios1" disabled
                                             <?php if($id == $data->_id): ?> checked <?php endif; ?>>
                                        <span></span> &emsp;

                                        <?php echo e(@$data->procedurename); ?>

                                </a>
                            </div>
                        </div>
                        <?php
                            $statusvna = isset($data->vna) ? $data->vna : [];
                            $numpacs = 0;

                        ?>
                        <?php if(@$data->statuspacs[$numpacs]): ?>
                            <div class="col-auto p-0 m-0 align-self-center">
                                <i class="ri-checkbox-circle-fill ri-lg text-success"></i>
                            </div>
                        <?php else: ?>
                            <div class="col-auto p-0 m-0 align-self-center" style="visibility: hidden;">
                                <i class="ri-checkbox-circle-fill ri-lg text-success"></i>
                            </div>
                        <?php endif; ?>

                        <?php if(isset($statusvna[$numpacs])): ?>
                            <div class="col-auto p-0 m-0 align-self-center">
                                <i class="ri-checkbox-circle-fill ri-lg text-success"></i>
                            </div>
                        <?php else: ?>
                            <div class="col-auto p-0 m-0 align-self-center" style="visibility: hidden;">
                                <i class="ri-checkbox-circle-fill ri-lg text-success"></i>
                            </div>
                        <?php endif; ?>
                        <div class="col-2 text-nowrap">
                            <a href="<?php echo e(url("loadpic/$data->_id")); ?>" class="btn btn-loadicon btn-edit">
                                <i class="ri-edit-box-line"></i> Edit</a>
                        </div>

                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
        
        <div class="card ribbon-box mb-2">
            <div class="card-body">
                <div class="row px-0">
                    <div class="col-lg-6 mb-3 d-flex justify-content-between">
                        <div class="ribbon ribbon-success round-shape" id="switch_setting">
                            <i class="ri-file-list-3-line"></i>&ensp; Report
                        </div>

                        

                    </div>
                    <div class="col-lg-6 text-end ">
                        <?php if(@$feature->esign): ?>
                            <button id="signed_btn<?php echo e(@$in); ?>" data-index="<?php echo e(@$in); ?>" type="button"
                                class="btn btn-load btn-secondary signed_btn" data-caseid="<?php echo e(@$casedata->_id); ?>"
                                data-doctorname="<?php echo e(@$casedata->doctorname); ?>"
                                data-doctorid="<?php echo e(@$casedata->case_physicians01); ?>"
                                data-folderdate="<?php echo e(@$folderdate); ?>" data-caseuniq="<?php echo e(@$casedata->caseuniq); ?>"
                                data-comcreate="<?php echo e(@$casedata->comcreate); ?>" data-hn="<?php echo e(@$casedata->hn); ?>"
                                onclick="show_modal('signed_modal', 'signed_btn<?php echo e(@$in); ?>')"><i
                                    class="ri-ball-pen-fill"></i>E-Sign
                            </button>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="row m-0 ">
                    <div class="col">
                        <div class="border p-2 mt-3">
                            <input type="radio" class="form-check-input" id="pdf1" name="pdftype"
                                value="physician" checked
                                onclick="change_pdf('physician', '<?php echo e(Request::segment(2)); ?>')" />
                            <label class="form-check-label" for="pdf1">
                                &emsp; Physician Report
                            </label>

                            <div class="row ">
                                <div class="col-12 ms-4 pt-2 ">
                                    <div class="form-check mb-2">
                                        <input class="form-check-input pdf-type" data-type="case_normal" type="radio"
                                            name="flexRadioDefault" id="flexRadioDefault5" <?php if(@$casedata->pdftype == 'procedure' || @$config->pdf_default == 'procedure'): echo 'checked'; endif; ?>
                                            onclick="change_pdf('procedure')">
                                        <label class="form-check-label" for="flexRadioDefault5">
                                            Type 1 (8 pics Right)
                                        </label>
                                    </div>
                                    <div class="form-check mb-2">
                                        <input class="form-check-input pdf-type" data-type="largepicture" type="radio"
                                            name="flexRadioDefault" id="flexRadioDefault8" <?php if(@$casedata->pdftype == 'largepicture'  || @$config->pdf_default == 'largepicture'): echo 'checked'; endif; ?>
                                            onclick="change_pdf('largepicture')">
                                        <label class="form-check-label" for="flexRadioDefault8">
                                            Type 2 (Large Picture)
                                        </label>
                                    </div>
                                    <div class="form-check mb-2 pt-1">
                                        <input class="form-check-input pdf-type" data-type="case_writing" type="radio"
                                            name="flexRadioDefault" id="flexRadioDefault6" <?php if(@$casedata->pdftype == 'long_writing' || @$config->pdf_default == 'long_writing'): echo 'checked'; endif; ?>
                                            onclick="change_pdf('long_writing')">
                                        <label class="form-check-label" for="flexRadioDefault6">
                                            Type 3 (Long Writing)
                                        </label>
                                    </div>
                                    <div class="form-check mb-2 pt-1" onclick="change_pdf('drawing')">
                                        <input class="form-check-input pdf-type" data-type="drawing" type="radio"
                                            name="flexRadioDefault" <?php if(@$casedata->pdftype == 'drawing' || @$config->pdf_default == 'drawing'): echo 'checked'; endif; ?> id="flexRadioDefault7">
                                        <label class="form-check-label" for="flexRadioDefault7">
                                            Type 4 (Drawing Picture)
                                        </label>
                                    </div>
                                    <div class="form-check mb-2 pt-1" onclick="change_pdf('onlypicture')">
                                        <input class="form-check-input pdf-type" data-type="onlypicture" type="radio"
                                            name="flexRadioDefault" <?php if(@$casedata->pdftype == 'onlypicture'  || @$config->pdf_default == 'onlypicture'): echo 'checked'; endif; ?> id="flexRadioDefault10">
                                        <label class="form-check-label" for="flexRadioDefault10">
                                            Type 5 (Only Picture)
                                        </label>
                                    </div>
                                    <?php if(@$file_check_advance): ?>
                                    <div class="form-check mb-2 pt-1" onclick="change_pdf('procedure_custom')">
                                        <input class="form-check-input pdf-type" data-type="procedure_custom"
                                            type="radio" name="flexRadioDefault" <?php if(@$casedata->pdftype == 'procedure_custom' || @$config->pdf_default == 'procedure_custom'): echo 'checked'; endif; ?>
                                            id="flexRadioDefault20">
                                        <label class="form-check-label" for="flexRadioDefault20">
                                            Type 6 (Custom Procedure)
                                        </label>
                                    </div>
                                    <?php endif; ?>
                                    
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <?php if(@$feature->nursenote): ?>
                    <div class="row m-0 mt-2">
                        <div class="col">
                            <div class="border p-2">

                                <input type="radio" class="form-check-input" name="pdftype" value="nurse"
                                    id="pdf2" onclick="extra_pdf('nurse')" />

                                <label class="form-check-label" for="pdf2">
                                    &emsp; Nurse Report
                                </label>
                            </div>
                        </div>

                    </div>
                    <div class="row m-0 mt-2">
                        <div class="col">
                            <div class="border p-2">
                                <input type="radio" class="form-check-input" name="pdftype" id="pdf3"
                                    value="billing" onclick="extra_pdf('billing')" />
                                <label class="form-check-label" for="pdf3">
                                    &emsp; Billing Report
                                </label>
                            </div>
                        </div>

                    </div>
                    <div class="row m-0 mt-2">
                        <div class="col">
                            <div class="border p-2">
                                <input type="radio" name="pdftype" class="form-check-input" value="followup"
                                    id="pdf4" onclick="extra_pdf('followup')" />
                                <label class="form-check-label" for="pdf4">
                                    &emsp; Follow Up Report
                                </label>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>

            </div>
            <div class="col-12 m-0 p-0">
                <hr>
            </div>
            <div class="m-0">
                <div class="card-body pb-0 px-0">

                    <div class="row m-0 mb-1 px-3">
                        <div class="col-12 p-0">
                            
                            <h5> Send Report</h5>
                        </div>
                    </div>



                    <div class="col-12 mt-1 m-0 px-3">
                        <button id="btn_callmodalsendto" class="btn btn-primary btn-label waves-effect waves-light w-lg"
                            type="button">
                            <i class="bx bx-server label-icon align-middle fs-16 me-2"></i>
                            Send to
                        </button>


                        <script>
                            $("#btn_callmodalsendto").click(function() {
                                let txt_accessionno = $("#txt_accessionno").val();
                                if (txt_accessionno != "") {

                                    $("#modal_sendto").modal("show");
                                } else {
                                    alert("กรุณากรอก AccessionNUMBER");
                                }
                            });
                        </script>


                    </div>
                    <?php if(@$feature->ordata): ?>
                        <div class="col-12 m-0 p-0">
                            <hr>
                        </div>
                        <div class="row m-0 mb-1 px-3">
                            <div class="col-12 p-0">
                                
                                <h5> Send Data</h5>
                            </div>
                        </div>

                        <div class="col-12 mt-1 m-0 px-3">
                            <button id="btn_ordata_modal" class="btn btn-danger btn-label waves-effect waves-light w-lg">
                                <i class="bx bx-server label-icon align-middle fs-16 me-2"></i>
                                OR Data
                            </button>
                        </div>
                    <?php endif; ?>
                </div>
                <div class="col-12 m-0 p-0">
                    <hr>
                </div>


                <div class="row m-0">
                    <div class="col-12">
                        <h5>Edit Version</h5>
                    </div>
                    <?php
                        $case_pdfversion = isset($casedata->case_pdfversion) ? $casedata->case_pdfversion : [];
                        $hn = isset($casedata->hn) ? $casedata->hn : '';
                    ?>
                    <?php $__currentLoopData = $case_pdfversion; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pdf): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $when = isset($pdf['when']) ? explode(' ', $pdf['when'])[0] : '';
                            $pdfname = isset($pdf['pdf']) ? $pdf['pdf'] : '';
                        ?>
                        <div class="row m-0 mt-2">
                            <div class="col-4 m-0 p-0 text-muted">
                                Endocapture
                            </div>
                            <div class="col-5 text-muted">
                                <?php echo e(format_date($pdf['when'], 'd/m/Y H:i:s')); ?>

                            </div>
                            <div class="col-3 text-end">
                                <a href="<?php echo e(domainname("store/$hn/$folderdate/pdf/$pdfname")); ?>"
                                    class="text-primary text-decoration-underline" target="_blank">View</a>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <br>
        </div>
        <div class="col-12  ">
            <a href="<?php echo e(url('')); ?>" class="btn btn-load btn-success w-100">
                <i class="ri-list-check me-2"></i>
                Back to list
            </a>
        </div>
        <?php
            $pdf_type = @$_GET['type'];
            $app_url = url('');
            $pdf_url = "$app_url/api/pdf?id=$id+type=$pdf_type";
            // dd($pdf_type, $app_url, $pdf_url, $casedata);
        ?>
    </div>
    </div>
    <?php if(configTYPE('admin', 'system_ordata')): ?>
        <?php echo $__env->make('reportendocapture.component.ordata', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php endif; ?>

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


<?php $__env->startSection('modal'); ?>
    <?php echo $__env->make('reportendocapture.component.modal_vip', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_emr', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_modal_confirmsave', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_waitingcreatedicom', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_process', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_signed', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_sendto', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('reportendocapture.component.modal_loading', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

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

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

    <script>
        $(".mouse-enter").mouseover(function() {
            $(".hide-content").toggle(300);
        })
    </script>
    <script>
        function loadOtherPage(src) {
            console.log(src);
            $("<iframe>") // create a new iframe element
                .hide() // make it invisible
                .attr("src", "<?php echo e(url("note/paper/$id")); ?>") // point the iframe to the page you want to print
                .appendTo("body") // add iframe to the DOM to cause it to load the page
                .on('load', function() { // add an event listener to wait for the iframe to load
                    this.contentWindow.print();
                    setTimeout(() => {
                        $("#modal_loading").modal("hide"); // print the iframe content once it's loaded
                    }, 3000);
                });
        }

        $("#btn_printnursenote").click(function() {
            $("#modal_loading").modal("show");
            loadOtherPage("");
        });
    </script>






    <script>
        $("#open_file_location").click(function() {
            let folder = $("#pdf_folder_head").val();
            $.post("<?php echo e(url('api/case')); ?>", {
                event: "go2folder",
                folder: folder,
            }, function(data, status) {});
        })
    </script>


    <script>
        let pdf_setting = false;
        $("#switch_setting").click(function() {
            if (pdf_setting) {
                pdf_setting = false;
                $("#card_setting").slideUp(500);
            } else {
                pdf_setting = true;
                $("#card_setting").slideDown(500);
            }
        });
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $(".jsonboxSAVE").click(function() {
            var ele = $(this).attr("name");
            var elements = document.querySelectorAll('input[name="' + ele + '"]:checked');
            var checkedElements = Array.prototype.map.call(elements, function(el, i) {
                return el.value;
            });
            $.post("<?php echo e(url('api/case')); ?>", {
                event: "jsonboxSAVE",
                ele: ele,
                val: checkedElements,
                cid: "<?php echo e($cid); ?>"
            }, function(data, status) {});
        });


        $('#send_to_pac_btn').on('click', function() {
            var is_show = $('#pac_btn').css('display')
            if (is_show == 'block') {
                $('#pac_btn').css('display', 'none')
            } else {
                $('#pac_btn').css('display', 'block')
            }
        })



        $("#pdf_setting_save").click(function() {
            $.post("<?php echo e(url('superadmin')); ?>", {
                event: "clearview"
            }, function(d, s) {
                window.location.reload();
            });
        });



        $("#btn_esign").click(function() {
            $("#modal_emr").modal("show");
            $("#password_incorrect1").hide();
            $("#password_incorrect2").hide();
        });



        $("#create_sign").click(function() {
            var doctor_id = $("#doctor_id").val();
            var doctor_code = $("#doctor_code").val();
            setTimeout(() => {
                $.post('<?php echo e(url('reportendocapture')); ?>', {
                    event: "create_sign",
                    doctor_id: doctor_id,
                    doctor_code: doctor_code,
                    folderdate: '<?php echo e($folderdate); ?>',
                    cid: '<?php echo e($cid); ?>',
                    caseuniq: '<?php echo e($casedata->caseuniq); ?>',
                    comcreate: '<?php echo e($casedata->comcreate); ?>',
                    hn: '<?php echo e($casedata->case_hn); ?>'
                }, function(data, status) {
                    if (data == "success") {
                        location.reload();
                    } else {
                        $("#password_incorrect1").show();
                        $("#password_incorrect2").show();
                    }
                });
            }, 1000);
        });

        var pdftype = "";

        $('.btn-outline-success').click(function() {
            pdftype = $(this).attr('id');
            $('#modal_confirmsave').modal('show');
        });

        $('#btnYes').click(function() {
            window.location.replace("<?php echo e(url('')); ?>/reportendocapture/<?php echo e(Request::segment(2)); ?>?type=" +
                pdftype + "&savepdf=true");
        });


        $('#sendbilling').click(function() {
            var cid = $(this).attr('cid');
            $.post('<?php echo e(url('billing')); ?>', {
                event: "billing_file",
                cid: cid,
            }, function(data, status) {
                const obj = JSON.parse(data);
                if (obj.status == "success") {
                    alert("ส่งข้อมูลค่าใช้จ่าย สำเร็จ");
                } else {
                    alert("ส่งข้อมูลค่าใช้จ่าย ไม่สำเร็จ");
                }
                console.log(data);
            });
        });
    </script>
    <script>
        $(".config_type").focusout(function() {
            var value = $(this).val();
            var id = $(this).attr('id');
            var config_type = $(this).attr('config_type');
            $.post("<?php echo e(url('superadmin')); ?>", {
                event: "config_type",
                config_type: config_type,
                id: id,
                value: value,
            }, function(data, status) {});
        });

        $(".configtext").focusout(function() {
            var value = $(this).val();
            var id = $(this).attr('id');
            $.post("<?php echo e(url('jquery')); ?>", {
                event: "configtext",
                id: id,
                value: value,
            }, function(data, status) {});
        });

        $('.config_option').click(function() {
            var id = $(this).attr('id');
            var config_type = $(this).attr('config_type');
            var value = true;
            if ($(this).prop("checked") == false) {
                value = 'false';
            }
            $.post("<?php echo e(url('jquery')); ?>", {
                event: "configcheck",
                id: id,
                config_type: config_type,
                value: value,
            }, function(data, status) {
                console.log(data);
            });
        });
    </script>
    <script>
        <?php
            $comname = webconfig('com_name');
        ?>
        <?php if($comname != 'endocapture'): ?>
            <?php if(configTYPE('admin', 'system_semi')): ?>
                setInterval(function() {
                    $.post("<?php echo e(url('synchronize')); ?>", {},
                        function(data, status) {
                            console.log(data);
                            if (data == "true") {
                                location.reload();
                            }
                        });
                    console.log("Connect server success!!!");
                }, 10000);
            <?php endif; ?>
        <?php endif; ?>
    </script>



    <script>
        function show_modal(modal_id, btn_id) {
            var doctorname = $(`#${btn_id}`).data('doctorname')
            var doctor_id = $(`#${btn_id}`).data('doctorid')
            var cid = $(`#${btn_id}`).data('caseid')
            $(`#btn_id`).val(btn_id)
            $('#doctorname_txt').html(doctorname)
            $('#create_sign_btn').attr('href', `<?php echo e($url); ?>/esign/${doctor_id}?cid=${cid}`)
            var myModal = new bootstrap.Modal(document.getElementById(modal_id))
            myModal.show()
        }

        $("#autoesign").click(function() {
            $.post("<?php echo e(url('api/jquery')); ?>", {
                event: 'autoesign',
                cid: "<?php echo e($cid); ?>",
                doctor_id: "<?php echo e($casedata->case_physicians01); ?>"
            }, function(data, status) {
                console.log(doctor_id);
                if (data == "success") {
                    location.reload();
                } else {
                    alert("แพทย์ท่านนี้ไม่มีลายเซ็น")
                }
            });
        })





        $('#confirm_signed_btn').on('click', function() {
            // alert('Please');
            var btn_id = $(`#btn_id`).val()
            $.post("<?php echo e(url('api/jquery')); ?>", {
                event: 'create_sign',
                doctor_id: $(`#${btn_id}`).data('doctorid'),


                doctor_code: $('#user_code_inp').val(),


                folderdate: $(`#${btn_id}`).data('folderdate'),
                cid: $(`#${btn_id}`).data('caseid'),
                caseuniq: $(`#${btn_id}`).data('caseuniq'),
                comcreate: $(`#${btn_id}`).data('comcreate'),
                hn: $(`#${btn_id}`).data('hn')
            }, function(data, status) {
                if (data == "success") {
                    location.reload();
                } else {
                    $('#warning_msg').css('display', 'block')
                    $('#warning_msg').html(data)
                }
            });
        })

        $('#user_code_inp').on('input', function() {
            var inp_lg = $(this).val().length
            if (inp_lg > 0) {
                $('#confirm_signed_btn').prop('disabled', false)
                $('#warning_msg').css('display', 'none')
            } else {
                $('#confirm_signed_btn').prop('disabled', true)
            }
        })
    </script>



    <?php if(connectSERVER()): ?>
        
        <script src='http://<?php echo e(webconfig('server_name')); ?>:3000/socket.io/socket.io.js'></script>
        <script>
            var socketserver = io.connect('http://<?php echo e(webconfig('server_name')); ?>:3000');
            socketserver.emit('chat message', 'casemonitor');
        </script>
    <?php endif; ?>

    <script>
        //Semi
        setInterval(() => {
            $.post("<?php echo e(url('api/semi')); ?>", {
                event: "checktempin"
            }, function(d, s) {
                console.log(d);
            });
        }, 10000);
    </script>

    <script>
        function change_pdf(type) {

            $.post("<?php echo e(url('api/pdf')); ?>", {
                "event": "change_pdf",
                "cid": "<?php echo e($cid); ?>",
                "pdftype": type
            }, function(d, s) {
                $('#iframepdf').attr('src', "<?php echo e(url("api/pdf/$cid")); ?>");
            });




        }

        function extra_pdf(type) {
            if (type == 'lumina_report') {
                $('#iframepdf').attr('src', '<?php echo e(url("lumina/print/$id")); ?>');
            }
            if (type == 'nurse') {
                $("#btn_printnursenote").show();
                $("#photo_report").prop('checked', false);
                $("#report_sendto").prop('checked', false);
                $("#nurse_report").prop('checked', true);
                $('#iframepdf').attr('src', '<?php echo e(url("note/paper/$cid/edit")); ?>').css('width', '825px');
            }
            if (type == 'followup') {
                $('#iframepdf').attr('src', '<?php echo e(url("api/pdfnurse/$id/edit")); ?>')
            }
        }
    </script>
<?php $__env->stopSection(); ?>

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