
<!-- banner page -->
<?php $__env->startSection('banner'); ?>
<img src="<?php echo e(asset('../storage/km/banner/'.$bannerPage)); ?>" class="img-fluid" width="100%">
<?php $__env->stopSection(); ?>
<!-- include -->
<?php $__env->startSection('leftmenuSub'); ?>
<?php echo $__env->make('layouts/partials/front/leftmenuSub', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>

<!-- content -->
<?php $__env->startSection('content'); ?>

<!-- menu serch filter -->
<div class="col-md-12">
    <?php echo $__env->make('layouts/partials/front/search', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
</div>
<div class="col-md-12">
    <div class="row">
        <div id="bladeSearch">
            <div class="row">
                <div class="col-md-3">
                    <?php echo $__env->yieldContent('leftmenuSub'); ?>
                </div>
                <div class="col-md-9">
                    <input type="hidden" id="expertId" name="expertId"
                        value="<?php echo e(config('constants.ID_clinic_expert')); ?>">
                    <input type="hidden" id="postId" name="postId" value="<?php echo e(config('constants.ID_clinic_QA')); ?>">
                    <input type="hidden" id="postDetail" name="postDetail" value="<?php echo e($detail); ?>">
                    <div class="row">
                        <div class="accordion" id="accordionContent1">
                            <div class="accordion-item">
                                <h2 class="accordion-header" id="headingOne">
                                    <button class="accordion-button" type="button" data-bs-toggle="collapse"
                                        data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                        <h5 id="topic"><?php echo e($nameMenu); ?></h5>
                                    </button>
                                </h2>
                                <div id="collapseOne" class="accordion-collapse collapse show"
                                    aria-labelledby="headingOne" data-bs-parent="#accordionContent1">
                                    <div class="accordion-body">

                                        <?php if($idMenu== config('constants.ID_clinic_expert')): ?>
                                        <div class="row" id="form_search">
                                            <div class="col-md-8">
                                                <div class="input-group mb-3">
                                                    <input type="hidden" id="id_main" name="id_main"
                                                        value="<?php echo e($idMenu); ?>">
                                                    <?php if($idSub == 0): ?>
                                                    <input type="hidden" id="id_search" name="id_search"
                                                        value="<?php echo e($idMenu); ?>">
                                                    <?php else: ?>
                                                    <input type="hidden" id="id_search" name="id_search"
                                                        value="<?php echo e($idSub); ?>">
                                                    <?php endif; ?>
                                                    <input id="input_search" type=" text" class="form-control"
                                                        placeholder="ค้นหาข้อมูล" aria-label="ค้นหาข้อมูล"
                                                        aria-describedby="button-addon2">
                                                    <button id="btn_search" class="btn btn-outline-secondary"
                                                        type="button" id="button-addon2">
                                                        <i class="fa fa-search"></i></button>
                                                </div>
                                            </div>
                                            <div class="col-md-4">
                                                <div class="mb-3 row">
                                                    <label class="col-md-4 col-form-label">เรียงตาม:</label>
                                                    <div class="col-md-8 col-form-label">
                                                        <div class="form-check form-check-inline">
                                                            <input class="form-check-input" type="radio"
                                                                name="radio_search"
                                                                value="option-new" checked>
                                                            <label class="form-check-label"
                                                                for="inlineRadio1">ล่าสุด</label>
                                                        </div>
                                                        <div class="form-check form-check-inline">
                                                            <input class="form-check-input" type="radio"
                                                                name="radio_search"
                                                                value="option-letters">
                                                            <label class="form-check-label"
                                                                for="inlineRadio2">ตัวอักษร</label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div id="blade">
                                            <!-- include -->
                                            <?php $__env->startSection('expert'); ?>
                                            <?php echo $__env->make('subpage/tableListExpert', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php $__env->stopSection(); ?>
                                            <?php echo $__env->yieldContent('expert'); ?>
                                        </div>
                                        <?php elseif($idMenu == config('constants.ID_clinic_QA')): ?>
                                        <div class="row" id="form_search">
                                            <div class="col-md-2">
                                                <div class="input-group mb-3">
                                                    <button id="btn_history" class="btn btn-warning" type="button">
                                                        <i class="far fa-clock"></i> จัดการกระทู้
                                                    </button>
                                                </div>
                                            </div>
                                            <div class="col-md-10">
                                                <div class="row" id="search-post">
                                                    <label class="col-md-2 col-form-label">เรียงตาม:</label>
                                                    <div class="col-md-10 col-form-label">
                                                        <div class="form-check form-check-inline">
                                                            <input class="form-check-input" type="radio"
                                                                name="inlineRadioOptions" value="option-newRelease"
                                                                checked>
                                                            <label class="form-check-label">New Release</label>
                                                        </div>
                                                        <div class="form-check form-check-inline">
                                                            <input class="form-check-input" type="radio"
                                                                name="inlineRadioOptions" value="option-mostViewed">
                                                            <label class="form-check-label">Most Viewed</label>
                                                        </div>
                                                        <div class="form-check form-check-inline">
                                                            <input class="form-check-input" type="radio"
                                                                name="inlineRadioOptions" value="option-mostCommented">
                                                            <label class="form-check-label">Most
                                                                Commented</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <input type="hidden" id="id_main" name="id_main" value="<?php echo e($idMenu); ?>">
                                                <?php if($idSub == 0): ?>
                                                <input type="hidden" id="id_search" name="id_search"
                                                    value="<?php echo e($idMenu); ?>">
                                                <?php else: ?>
                                                <input type="hidden" id="id_search" name="id_search" value="<?php echo e($idSub); ?>">
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div id="blade">
                                            <?php if($detail==0): ?>
                                            <!-- include -->
                                            <?php $__env->startSection('post'); ?>
                                            <?php echo $__env->make('subpage/tableListPost', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php $__env->stopSection(); ?>
                                            <?php echo $__env->yieldContent('post'); ?>
                                            <?php else: ?>
                                            <!-- include -->
                                            <?php $__env->startSection('detailPost'); ?>
                                            <?php echo $__env->make('subpage/detailPost', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                            <?php $__env->stopSection(); ?>
                                            <?php echo $__env->yieldContent('detailPost'); ?>
                                            <?php endif; ?>
                                        </div>
                                        <?php endif; ?>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
var expertId = $("#expertId").val();
var postId = $("#postId").val();
var postDetail = $("#postDetail").val();

if (postDetail == 1) {
    $('#search-post').css('display', 'none');
}

$('#form_search input').on('change', function() {
    var main = $("#id_main").val();
    var id = $("#id_search").val();
    var sortby = $("#form_search input[type='radio']:checked").val();
    var input = $('#input_search').val();
    // alert(id + "/" + sortby + "/" + input);
    // searchPage(id, sortby, input);
    if (main == expertId) {
        searchExpert(id, sortby, input);
    } else if (main == postId) {
        searchPost(id, sortby);
    }
});

$("#btn_search").click(function() {
    var main = $("#id_main").val();
    var id = $("#id_search").val();
    var sortby = $("#form_search input[type='radio']:checked").val();
    var input = $('#input_search').val();
    // alert(id + "/" + sortby + "/" + input);
    // searchPage(id, sortby, input);
    if (main == expertId) {
        searchExpert(id, sortby, input);
    } else if (main == postId) {
        searchPost(id, sortby);
    }
});

function searchExpert(id, sortby, input) {
    var form_data = new FormData();
    form_data.append('id', id);
    form_data.append('sortby', sortby);
    form_data.append('size', 5);
    form_data.append('input', input);
    form_data.append('url', '');

    var pathname = window.location.pathname;
    var pathArr = pathname.split("/");
    var len = pathArr.length;
    var urlpost = "";
    if (len == 4) {
        urlpost = "page/tableListExpert";
    } else {
        urlpost = "../page/tableListExpert";
    }

    $.ajax({
        type: "post",
        url: urlpost,
        data: form_data,
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        processData: false,
        contentType: false,
        cache: false,
        success: function(html) {
            window.scrollTo({
                top: 0,
                behavior: 'smooth'
            });
            $("#blade").empty();
            $('#blade').html(html);
        }
    });
}

function searchPost(id, sortby) {
    var form_data = new FormData();
    form_data.append('id', id);
    form_data.append('sortby', sortby);
    form_data.append('size', 5);
    form_data.append('url', '');

    var pathname = window.location.pathname;
    var pathArr = pathname.split("/");
    var len = pathArr.length;
    // alert(pathArr);
    var urlpost = "";
    if (len == 4) {
        urlpost = "page/tableListPost";
    } else if (len == 5) {
        urlpost = "../page/tableListPost";
    } else {
        urlpost = "../../page/tableListPost";
    }
    // alert(urlpost);
    $.ajax({
        type: "post",
        url: urlpost,
        data: form_data,
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        processData: false,
        contentType: false,
        cache: false,
        success: function(html) {
            window.scrollTo({
                top: 0,
                behavior: 'smooth'
            });
            $("#blade").empty();
            $('#blade').html(html);
        }
    });
}

$("#btn_history").click(function() {
    $(".loader").show();
    // location.href = '../posts';
    var pathname = window.location.pathname;
    var pathArr = pathname.split("/");
    var len = pathArr.length;
    var urlpost = "";
    if (len == 4) {
        urlpost = "posts";
    } else if (len == 5) {
        urlpost = "../posts";
    } else {
        urlpost = "../../posts";
    }

    location.href = urlpost;
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.front.mastermem', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/km-web/resources/views/frontOffice/clinic.blade.php ENDPATH**/ ?>