<?php for($i = 1; $i < 5; $i++): ?>
    <?php
        $path = 'path' . $i;
        $label = 'label' . $i;
        $checked = 'checked' . $i;
    ?>
    <?php if(isset($emr->$path)): ?>
        <div class="col-8 mt-3">
            <input class="emr form-check-input" id="emr<?php echo e($i); ?>" group="<?php echo e($i); ?>"
                <?php if(@$emr->$checked): echo 'checked'; endif; ?> type="checkbox">
            &emsp;
            <label for="emr<?php echo e($i); ?>"><?php echo @$emr->$label; ?></label>
        </div>
        <div class="emrsuccess" id="emrsuccess<?php echo e($i); ?>" style="display: none">
            <button class="btn btn-success btn-status-vna btn-sm fw-bold">Success</button>
        </div>
        <div class="emrunsuccess" id="emrunsuccess<?php echo e($i); ?>" style="display: none">
            <button class="btn btn-danger btn-sm fw-bold">Not success</button>
        </div>
    <?php endif; ?>
<?php endfor; ?>

<script>
    $(document).ready(function() {
        $("#confirm_sendto").click(function() {
            $(".emrsuccess").hide();
            $(".emrunsuccess").hide();
            $(".emr:checked").each(function() {
                var group = $(this).attr("group");
                $.post("<?php echo e(url('api/sendto')); ?>", {
                    event: "emr2dir",
                    cid: "<?php echo e($cid); ?>",
                    group: group,
                }, function(d, s) {
                    let obj = JSON.parse(d);
                    if (obj.status == "success") {
                        $("#emrsuccess" + group).show();
                    } else {
                        $("#emrunsuccess" + group).show();
                    }
                    console.log(d);
                });
            });
        });
    });
</script>
<?php /**PATH D:\laragon\htdocs\screening\resources\views/reportendocapture/component/feature/emr.blade.php ENDPATH**/ ?>