HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/sarvodayahospital/resources/views/pages/doctor-filter.blade.php
@extends('layouts.main')

@section('content')
    @php
        $searchstrings = [];
        if (request()->has('selectedDoctorT')) {
            $searchstrings[] = Request::get('selectedDoctorT');
        }
        if (request()->has('selectedSpecialityT')) {
            $searchstrings[] = Request::get('selectedSpecialityT');
        }
        $searchstring = array_filter($searchstrings, fn($value) => !is_null($value) && $value !== '');
    @endphp
    <section class="banner-sec relative">
        <div class="container">
            <div class="row justify-content-between align-items-center pb-4 pb-md-0">
                <div class="col-md-6">
                    <p class="fw-400 text-md-start text-center f-sm-18 mb-3 f-28  text-white banner-top-text">
                        Our Medical Experts are here for you.
                    </p>
                    <h2 class="text-white f-50  text-md-start text-center f-sm-24 fw-500 l-sm-19 mb-md-4 mb-3 banner-heading">
                        Get quality medical care and treatment with us.
                    </h2>
                    <p class="fw-400 text-md-start f-20 text-center f-sm-15 f-16 lh-19 text-white">
                        Find the required doctor and schedule your appointment now.
                    </p>
                </div>
                <div class="col-md-6 pt-md-5 text-md-end text-center">
                    <img class="img-fluid banner-img" src="{{ asset('img/doctors.png') }}"  alt="Sarvodaya doctors"/>
                </div>
            </div>
        </div>
    </section>

    <div class="pb-md-4 pt-md-0 py-3 tabbed-sec banner-points-box-sec absolute">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-md-10">
                    <div class="banner-points-box">
                        <form class="px-md-2 row px-4 align-items-center justify-content-center py-md-2 py-4"
                            id="call-back-form" method="GET" action="{{ route('make-an-appointment') }}">
                            <div class="col-md-4 pe-md-1">
                                <div class="input-group suggestion-search-box position-relative">
                                    <span class="input-group-text">
                                        <img src="{{ asset('img/user-blue.svg') }}"  alt="Sarvodaya search icon"/>
                                    </span>
                                    <input type="text" placeholder="Search for Doctor / Specialities"
                                        class="form-control search-doctor-input-h" id="query" autocomplete="off"
                                        value="" />
                                    <input type="hidden" name="doctor" id="selectedDoctor"
                                        value="{{ Request::get('doctor') ? Request::get('doctor') : '' }}">
                                    <input type="hidden" name="speciality" id="selectedSpeciality"
                                        value="{{ Request::get('speciality') }}">
                                    <input type="hidden" name="hospital" id="selectedHospital"
                                        value="{{ Request::get('hospital') }}">
                                    <input type="hidden" name="selectedDoctorT" id="selectedDoctorT"
                                        value="{{-- Request::get('selectedDoctorT') --}}">
                                    <input type="hidden" name="selectedSpecialityT" id="selectedSpecialityT"
                                        value="{{-- Request::get('selectedSpecialityT') --}}">
                                    <input type="hidden" name="selectedHospitals" id="selectedHospitals"
                                        value="{{-- Request::get('selectedHospitals') --}}">
                                    <input type="hidden" name="selectedHospitald" id="selectedHospitald"
                                        value="{{-- Request::get('selectedHospitald') --}}">
                                    <!-- Suggestion Search Box -->
                                    <div id="test1" style="display: none;">
                                        <div class="suggestion-box-wrapper suggestion1">
                                            <div class="suggestion-inner-content">
                                                <div id="suggestion-box-result" class="suggestion-box specialities">
                                                    <h6 id="doctorResult"
                                                        class="suggestion-total-count clrBlueDark f-16 fw-400 mb-2">Select
                                                        Doctor</h6>
                                                    <ul class="suggestion-listing doctorResult"></ul>
                                                    <h6 id="specialityResult"
                                                        class="suggestion-total-count clrBlueDark f-16 fw-400 mb-2 mt-1">
                                                        Select Speciality</h6>
                                                    <ul class="suggestion-listing specialityResult"></ul>
                                                </div>
                                            </div>
                                            {{-- <div class="apply-specialties-box d-flex align-items-center">
                                                <button id="apply-doc-spec" type="button"
                                                    class="btn btn-small btn-primary">Apply</button>
                                            </div> --}}
                                        </div>
                                    </div>
                                    <!-- Suggestion -->
                                    <input type="hidden" id="search-id" name="search-id" />
                                </div>
                            </div>
                            <div class="col-md-5 pe-md-1">
                                <div class="input-group suggestion-search-box position-relative location-suggestion-box">
                                    <span class="input-group-text">
                                        <img src="{{ asset('img/map-location.svg') }}" alt="Sarvodaya location marker"/>
                                    </span>
                                    <input type="text" placeholder="Select Location" class="form-control border-0"
                                        id="location" autocomplete="off" value="" />
                                    <!-- Suggestion Search Box -->
                                    <div class="suggestion-box-wrapper" id="locationResult">
                                        <div class="suggestion-inner-content ">
                                            <div class="suggestion-box specialities">
                                                <div class="d-flex justify-content-between align-items-center appy-btn-fix ">
                                                    <h6 class="suggestion-total-count clrBlueDark f-16 fw-400 mb-2"> Select Location</h6>
                                                    <div class="apply-specialties-box d-flex align-items-center">
                                                    <button type="button" class="btn btn-small btn-primary m-0"
                                                        id="apply-location">Apply
                                                    </button>
                                                </div>
                                                </div>
                                                <ul class="suggestion-listing">
                                                    @foreach ($hospitals as $hospital)
                                                        <li>
                                                            <input type="checkbox" id="location{{ $loop->index }}"
                                                                class="locationList"
                                                                data-location="{{ $hospital->HospitalShortName }}, {{ $hospital->Location }}"
                                                                value="{{ $hospital->Slug }}">
                                                            <label
                                                                for="location{{ $loop->index }}">{{ $hospital->HospitalShortName }},
                                                                {{ $hospital->Location }}</label>
                                                            <span class="checkmark-doctor-search"></span>
                                                        </li>
                                                    @endforeach
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- Suggestion -->
                                </div>
                            </div>
                            <div class="col-md-3 pe-md-1 ps-md-0 text-end">
                                <button type="submit" id="shree-map"
                                    class="btn rounded-pill text-white f-16 py-3 fw-500 bgBlueDark w-100 btn-block mt-3 mt-md-0 call-btn">
                                    Book Appointment
                                    <img class="d-inline-block ms-3" src="{{ asset('img/right-arrow.png') }}" alt="next-arrow" />
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- filter section -->
    <div class="filter-section pb-md-4">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-md-10">
                    <div class="show-result-wrapper mt-2 mt-md-0">
                        @php
                            $doctor = request('doctor');
                            $speciality = request('speciality');
                            $hospitals = request('hospital');
                            $explode = !is_null($hospitals) ? explode(',', $hospitals) : []
                        @endphp

                        <div class="clear-text-wrapper mb-3">
                            @if ($doctor != '' || $speciality != '' || count($explode) != 0)
                                {{-- <strong class="f-13">Filter: </strong> --}}
                            @endif

                            @if (count($explode))
                                @foreach ($explode as $sel_hospital)
                                    <a href="javascript:void(0)" class="my-2 f-12 no-underline me-3 rounded-pill bgBlueDark text-white p-1">
                                        <span class="me-1">{{ $sel_hospital }}</span>
                                        <i class="fa-solid fa-xmark"></i>
                                    </a>
                                @endforeach
                            @endif

                            @if ($doctor != '')
                                <a href="{{ request()->fullUrlWithQuery(['doctor' => '', 'speciality' => request('speciality'), 'hospital' => request('hospital')]) }}" class="my-2 f-12 no-underline me-3 rounded-pill bgBlueDark text-white p-1">
                                    <span class="me-1">{{ request('selectedDoctorT') }}</span>
                                    <i class="fa-solid fa-xmark"></i>
                                </a>
                            @endif

                            @if ($speciality)
                                <a href="{{ request()->fullUrlWithQuery(['doctor' => request('doctor'), 'speciality' => '', 'hospital' => request('hospital')]) }}" class="my-2 f-12 no-underline me-3 rounded-pill bgBlueDark text-white p-1">
                                    <span class="me-1">{{ request('selectedSpecialityT') }}</span>
                                    <i class="fa-solid fa-xmark"></i>
                                </a>
                            @endif

                        </div>

                        @if (count($filterDoctors))
                            <h4 class="clr5c fw-500 f-20 f-sm-18  mb-2 pb-1">
                                Available {{ \Illuminate\Support\Str::plural('Doctor', count($filterDoctors)) }}
                                ({{ count($filterDoctors) }})
                            </h4>
                            @foreach ($filterDoctors as $index => $doctor)
                                <div class="results-show-box mb-4">
                                    <div class="d-flex align-items-center">
                                        <div class="filter-show-img text-center">
                                            @if (!is_null($doctor->media))
                                                <img src="{{ $doctor->media->thumbnail_url }}" alt="{{ $doctor->AltInfo }}">
                                            @elseif($doctor->gender->Gender === 'Male')
                                                <img src="{{ asset('img/default-doctor-male.jpg') }}" alt="{{ $doctor->AltInfo }}">
                                            @else
                                                <img src="{{ asset('img/default-doctor-female.jpg') }}" alt="{{ $doctor->AltInfo }}">
                                            @endif
                                            <a href="{{ route('doctors.show', $doctor->Slug) }}"
                                                class="clrBlueDark f-sm-14 f-16 fw-500 no-underline d-block mt-3 text-md-center text-start"
                                                target="_blank">
                                                View Profile
                                            </a>
                                        </div>
                                        <div class="filter-result-dr-content ps-4 flex-grow-1 position-relative">
                                            <div class="d-flex justify-content-between">
                                                <div class="w-lg-70">
                                                    <h3 class="mb-0 clr5c fw-500 f-18 f-sm-16 mb-1">{{ $doctor->DoctorName }}</h3>
                                                    <p class="mb-0 f-16 clr8e f-sm-14">{{ $doctor->CurrentDesignation }}</p>
                                                </div>
                                            </div>
                                            <div class="appt-btn-sec">
                                                    <a href="javascript:void(0)" class="btn make-appointment-btn mt-2 float-btnn btn-grey-disabled">
                                                        @if(count(array_filter(explode(',', request('hospital')))) === 1) <i class="fa fa-spinner fa-spin"></i> @endif Book Appointment
                                                    </a>
                                            </div>
                                            <div class="d-none d-md-block">
                                                <hr class="filter-show-result-hr w-100" />
                                                <div class="d-flex align-items-center">
                                                    <h3 class="mb-0 clr5c fw-500 f-18">Select Location</h3>
                                                    <div class="validation__error"></div>
                                                </div>
                                                <ul class="mb-2 pt-0  f-16 filter-location-text mt-1 list-unstyled ps-0">
                                                    @php
                                                        $cache_hospital = $doctor->hospitals()->orderBy('weight', 'asc')->get();
                                                    @endphp
                                                    @foreach ($cache_hospital as $hospitalIndex => $hospital)
                                                        <li class="d-flex align-items-center">
                                                            <input type="radio" id="{{$hospital->Slug}}{{$index}}{{$doctor->id}}" class="hospital_checkbox me-2" name="sel_hospital{{ $index }}" value="{{ collect([
                                                                'doctor_id' => $doctor->id,
                                                                'doctor_person_id' => $doctor->PersonID,
                                                                'doctor' => $doctor->DoctorName,
                                                                'hospital' => $hospital->HospitalShortName. ', ' .$hospital->Location,
                                                                'hospital_num' => $hospital->LandlineNumber,
                                                                'enable_booking' => checkHospitalAppointmentEnable($hospital->id, $doctor->mednetInformation)
                                                                ]) }}" @if (hospitalExist($hospital->Slug, request('hospital'))) checked @endif>
                                                            <label for="{{$hospital->Slug}}{{$index}}{{$doctor->id}}">{{ $hospital->HospitalShortName }}, {{ $hospital->Location }}</label>
                                                            {{-- <label class="container-radio-custom">
                                                                {{ $hospital->HospitalShortName }}, {{ $hospital->Location }}
                                                                <input type="radio" class="hospital_checkbox" name="radio{{ $index }}" @if (hospitalExist($hospital->Slug, request('hospital'))) checked @endif value="{{ collect([
                                                                'doctor_id' => $doctor->id,
                                                                'doctor_person_id' => $doctor->PersonID,
                                                                'doctor' => $doctor->DoctorName,
                                                                'hospital' => $hospital->HospitalShortName. ', ' .$hospital->Location,
                                                                'hospital_num' => $hospital->LandlineNumber,
                                                                'enable_booking' => checkHospitalAppointmentEnable($hospital->id, $doctor->mednetInformation)
                                                                ]) }}">
                                                                <span class="checkmark-radio-custom"></span>
                                                            </label> --}}
                                                        </li>
                                                    @endforeach
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="d-block d-md-none">
                                        <hr class="filter-show-result-hr w-100" />
                                        <div class="d-flex align-items-center">
                                            <h3 class="mb-0 clr5c fw-500 f-16">Select Location</h3>
                                            <div class="validation__error"></div>
                                        </div>
                                        <ul class="mb-0 pt-0 f-14 filter-location-text mt-1 list-unstyled ps-0">
                                            @foreach ($cache_hospital as $hospital)
                                                <li class="d-flex align-items-center">
                                                    <input type="radio" id="mob{{$hospital->Slug}}{{$index}}{{$doctor->id}}" class="hospital_checkbox me-2" name="mob_sel_hospital{{ $index }}" value="{{ collect([
                                                        'doctor_id' => $doctor->id,
                                                        'doctor_person_id' => $doctor->PersonID,
                                                        'doctor' => $doctor->DoctorName,
                                                        'hospital' => $hospital->HospitalShortName. ', ' .$hospital->Location,
                                                        'hospital_num' => $hospital->LandlineNumber,
                                                        'enable_booking' => checkHospitalAppointmentEnable($hospital->id, $doctor->mednetInformation)
                                                        ]) }}" @if (hospitalExist($hospital->Slug, request('hospital'))) checked @endif>
                                                    <label for="mob{{$hospital->Slug}}{{$index}}{{$doctor->id}}">{{ $hospital->HospitalShortName }}, {{ $hospital->Location }}</label>
                                                    {{-- <label class="container-radio-custom">
                                                        {{ $hospital->HospitalShortName }}, {{ $hospital->Location }}
                                                        <input type="radio" class="hospital_checkbox" name="radio{{ $index }}" @if (hospitalExist($hospital->Slug, request('hospital'))) checked @endif value="{{ collect([
                                                        'doctor_id' => $doctor->id,
                                                        'doctor_person_id' => $doctor->PersonID,
                                                        'doctor' => $doctor->DoctorName,
                                                        'hospital' => $hospital->HospitalShortName. ', ' .$hospital->Location,
                                                        'hospital_num' => $hospital->LandlineNumber,
                                                        'enable_booking' => checkHospitalAppointmentEnable($hospital->id, $doctor->mednetInformation)
                                                        ]) }}">
                                                        <span class="checkmark-radio-custom"></span>
                                                    </label> --}}
                                                </li>
                                            @endforeach
                                        </ul>
                                    </div>
                                </div>
                            @endforeach
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>

    @include('partials.appointment-booking-popup-doctor-filter')
@stop

@section('javascript')
    <script>

        $(document).ready(function() {

            $('.btn-grey-disabled').click(function() {
                $(this).closest('.results-show-box').find('.validation__error').html('<small class="p-2 f-10 ms-2 bg-error"><i class="fa fa-exclamation-circle bg-red"></i> Please Select Hospital Location</small>');
            });

            setTimeout(function() {
                $('input:radio.hospital_checkbox:checked').each(function () {
                    let appt_json = JSON.parse($(this).val());
                    $(this).closest('.checkmark-radio-custom').css
                    if (appt_json.enable_booking === false) {
                        let buttonTxt = `<a href="javascript:void(0)"
                                class="btn make-appointment-btn mt-2 float-btnn"
                                data-bs-toggle="modal"
                                data-doctor-id="${appt_json.doctor_id}"
                                data-person-id="${appt_json.doctor_person_id}"
                                data-doctor-name="${appt_json.doctor}"
                                data-hospital-name="${appt_json.hospital}"
                                data-hospital-num="${appt_json.hospital_num}"
                                data-bs-target="#doctorAppointmentModalFilter">Book Appointment</a>`;
                        $(this).closest('.results-show-box').find('.appt-btn-sec').html(buttonTxt);
                    } else {
                        let buttonTxt = `<a href="/appointment-doctor-select/${appt_json.doctor_id}" class="btn make-appointment-btn float-btnn">Book Appointment</a>`;
                        $(this).closest('.results-show-box').find('.appt-btn-sec').html(buttonTxt);
                    }
                });
            }, 2000);

            $('.hospital_checkbox').change(function () {
                let appt_json = JSON.parse($(this).val());
                let $thisEle = $(this);

                $(this).closest('.results-show-box').find('.validation__error').html('');
                $(this).closest('.results-show-box').find('.appt-btn-sec').html(`<a href="javascript:void(0)" class="btn make-appointment-btn mt-2 float-btnn btn-grey-disabled"><i class="fa fa-spinner fa-spin"></i> Book Appointment</a>`);

                setTimeout(function() {
                    if (appt_json.enable_booking === false) {
                        let buttonTxt = `<a href="javascript:void(0)"
                            class="btn make-appointment-btn mt-2 float-btnn"
                            data-bs-toggle="modal"
                            data-doctor-id="${appt_json.doctor_id}"
                            data-person-id="${appt_json.doctor_person_id}"
                            data-doctor-name="${appt_json.doctor}"
                            data-hospital-name="${appt_json.hospital}"
                            data-hospital-num="${appt_json.hospital_num}"
                            data-bs-target="#doctorAppointmentModalFilter">Book Appointment</a>`;
                            $thisEle.closest('.results-show-box').find('.appt-btn-sec').html(buttonTxt);
                    } else {
                        let buttonTxt = `<a href="/appointment-doctor-select/${appt_json.doctor_id}" class="btn make-appointment-btn float-btnn">Book Appointment</a>`;
                        $thisEle.closest('.results-show-box').find('.appt-btn-sec').html(buttonTxt);
                    }
                }, 2000);
            });
        })

        function scrollBottom(scroll){
            $(window).scrollTop(scroll);
        }

        setTimeout(() => {
            scrollBottom(300);
            $('#query').focus();
        }, 500);

        function capitalizeFirstLetter(string) {
            return string.charAt(0).toUpperCase() + string.slice(1);
        }

        $(document).ready(function() {
            $(document).on('click', '.apply-specialties-box button', function(e) {
                e.preventDefault();
                $(this).parent().parent().hide();
            });

            let queryInputBoxSelector = $('#query');
            let locationBoxSelector = $('#locationResult');

            queryInputBoxSelector.on('focus', function() {
                if ($(this).val().length >= 3) {
                    $('#test1').show();
                }
                $('.suggestion1').show();
            });

            locationBoxSelector.hide();

            $('#location').on('click', function(e) {
                locationBoxSelector.show();
                $('#test1').hide();

            });

            queryInputBoxSelector.on('keyup', function() {
                if ($(this).val().length >= 3) {
                    let searchQuery = $(this).val();
                    let apiURL = `{{ route('search-doctors') }}`;
                    $('.doctorResult li').remove();
                    $.ajax({
                        url: apiURL,
                        dataType: "json",
                        type: "POST",
                        async: true,
                        data: {
                            searchQuery: searchQuery
                        },
                        success: function(response) {
                            let uniqueLocation = [];
                            $('.doctorResult li').remove();
                            $('.specialityResult li').remove();
                            $("#suggestion-box-result .doctorResult").html = '';
                            $("#suggestion-box-result .specialityResult").html = '';
                            if ((response.data).length <= 0) {
                                clearResult();
                            } else {
                                $.each(response.data, function(key, value) {
                                    uniqueLocation.push(value.locations);
                                    if (value.type == "doctor") {
                                        let responseHTML = `<li>
                                                <input type="radio" data-type="${value.type}" id="${value.id}" data-hospitals="${value.hslug}" class="checkboxResult" name="${value.type}" data-radio-value="${value.match}" value="${value.id}">
                                                <label for="${key}">${value.match}</label>
                                                <span class="float-end d-none">${capitalizeFirstLetter(value.type)}</span>
                                                <span class="checkmark-doctor-search"></span>
                                                </li>`;
                                        $("#suggestion-box-result .doctorResult")
                                            .append(
                                                responseHTML);
                                    }
                                    if (value.type == "speciality") {
                                        let responseHTML = `<li>
                                                <input type="radio" data-type="${value.type}" id="${value.id}" data-hospitals="${value.hslug}" class="checkboxResult" name="${value.type}" data-radio-value="${value.match}" value="${value.id}">
                                                <label for="${key}">${value.match}</label>
                                                <span class="float-end d-none">${capitalizeFirstLetter(value.type)}</span>
                                                <span class="checkmark-doctor-search"></span>
                                                </li>`;
                                        $("#suggestion-box-result .specialityResult")
                                            .append(responseHTML);
                                    }
                                });
                                if ($("#suggestion-box-result .specialityResult").html() ==
                                    '') {
                                    $('#specialityResult').hide();
                                } else {
                                    $('#specialityResult').show();
                                }
                                if ($("#suggestion-box-result .doctorResult").html() == '') {
                                    $('#doctorResult').hide();
                                } else {
                                    $('#doctorResult').show();
                                }
                                $('#test1').show();
                                let locations = Array.prototype.concat(...uniqueLocation)
                                    .filter(
                                        function(itm, i, a) {
                                            return i === a.indexOf(itm);
                                        });
                            }
                        },
                        error: function(error) {
                            console.log(error);
                        }
                    });
                } else {
                    clearResult();
                }
            })

            let setSelectedValue = [];
            let setSelectedDoctor = [];
            let setSelectedDoctorT = [];
            let setSelectedSpeciality = [];
            let setSelectedSpecialityT = [];

            $(document.body).on('click', '.checkboxResult', function() {
                if ($(this).is(':checked')) {
                    let currentElem = $(this).attr("data-type");
                    if (currentElem === 'speciality') {
                        $('#selectedSpeciality').val($(this).attr('value'));
                        $('#selectedSpecialityT').val($(this).attr('data-radio-value'));
                        $('#selectedHospitals').val($(this).attr('data-hospitals'));
                    }
                    if (currentElem === 'doctor') {
                        $('#selectedDoctor').val($(this).attr('value'));
                        $('#selectedDoctorT').val($(this).attr('data-radio-value'));
                        $('#selectedHospitald').val($(this).attr('data-hospitals'));
                    }
                    setSelectedValue = [];
                    if ($('#selectedDoctorT').val() != '') {
                        setSelectedValue.push($('#selectedDoctorT').val());
                    }
                    if ($('#selectedSpecialityT').val() != '') {
                        setSelectedValue.push($('#selectedSpecialityT').val());
                    }
                    $('#query').val(setSelectedValue.join(", "));
                    $('.suggestion-box-wrapper').css("display", "none");
                }
            });
        });

        $(document.body).on('click', '#apply-location', function() {
            setSelectedValue = [];
            setSelectedLocation = [];
            $('.locationList').each(function(e) {
                if ($(this).is(':checked')) {
                    setSelectedValue.push($(this).attr('value'));
                    setSelectedLocation.push($(this).attr('data-location'));
                }
            });
            $('#selectedHospital').val(setSelectedValue.toString());
            $('#location').val(setSelectedLocation.join(", "));
        });

        // $(document.body).on('click', '#apply-doc-spec', function() {
        //     setSelectedValue = [];
        //     if ($('#selectedDoctorT').val() != '') {
        //         setSelectedValue.push($('#selectedDoctorT').val());
        //     }
        //     if ($('#selectedSpecialityT').val() != '') {
        //         setSelectedValue.push($('#selectedSpecialityT').val());
        //     }
        //     $('#query').val(setSelectedValue.join(", "));
        // });
    </script>


    <script type="text/javascript">
        $('#search').on('keyup', function() {
            $value = $(this).val();
            $.ajax({
                type: 'get',
                url: '{{ route('search-home.show') }}',
                data: {
                    'search': $value
                },
                success: function(data) {
                    if (data !== '') {
                        $('.suggestion-box-wrapper').css("display", "block");
                        $('.suggestion-inner-content').html(data);
                    } else {
                        $('.suggestion-box-wrapper').css("display", "none");
                        $('.suggestion-inner-content').html(data);
                    }
                }
            });
        })
    </script>

    <script type="text/javascript">
        $.ajaxSetup({
            headers: {
                'csrftoken': '{{ csrf_token() }}'
            }
        });
    </script>

    <script type="text/javascript">
        function search(val) {
            $('#search-id').val(val);
            $('.suggestion-box-wrapper').css("display", "none");
            $('#search').val($('#' + val).text());
        }
    </script>

    <script>
        $(document).ready(function() {
            $(document).on('click', 'body', function(e) {
                if (($(e.target).is('#location')) || ($(e.target).is(
                        '.suggestion-listing [id^="location"]'))) {
                    let locs = [];
                    let locd = [];
                    if ($('#selectedHospitals').val() != '') {
                        locs = $('#selectedHospitals').val().split(',');
                    }
                    if ($('#selectedHospitald') != '') {
                        locd = $('#selectedHospitald').val().split(',');
                    }
                    let childloc = locs.concat(locd);

                    setSelectedValue = [];
                    setSelectedLocation = [];
                    $('.locationList').each(function(e) {
                        if ($(this).is(':checked')) {
                            setSelectedValue.push($(this).attr('value'));
                            setSelectedLocation.push($(this).attr('data-location'));
                        }
                    });
                    $('#selectedHospital').val(setSelectedValue.toString());
                    $('#location').val(setSelectedLocation.join(", "));

                    unique = new Set(childloc);
                    $('.locationList').each(function(e) {
                        $(this).parent().show();
                    });
                    if ((unique.size > 0) && (childloc != '') && ($('#query').val() != '')) {
                        $('.locationList').each(function(e) {
                            if (!inArray($(this).attr('value'), Array.from(unique))) {
                                $(this).parent().hide();
                            }
                        });
                    }
                    //pass
                } else {
                    $('#locationResult').css("display", "none");
                }
                if (($(e.target).is('.search-doctor-input-h')) || ($(e.target).is(
                        '.doctorResult li input')) || ($(e.target).is('.suggestion1'))  || ($(e.target).is('.apply-specialties-box'))) {
                } else {
                    $('.suggestion1').css("display", "none");
                }

            });
        });
        $(document).ready(function() {
            $('form#call-back-form').submit(function(e) {
                if (($('#query').val() != '') || ($('#location').val() != '')) {
                    form.submit();
                } else {
                    e.preventDefault();
                    return false;
                }
            });
        });

        function inArray(needle, haystack) {
            var length = haystack.length;
            for (var i = 0; i < length; i++) {
                if (haystack[i] == needle) return true;
            }
            return false;
        }
    </script>

    <script>
        function clearResult() {
            $('.doctorResult li').remove();
            $('.specialityResult li').remove();
            $("#suggestion-box-result .doctorResult").html = '';
            $("#suggestion-box-result .specialityResult").html = '';
            $('#test1').hide();
            $('#selectedSpeciality').val('');
            $('#selectedSpecialityT').val('');
            $('#selectedHospitals').val('');
            $('#selectedDoctor').val('');
            $('#selectedDoctorT').val('');
            $('#selectedHospitald').val('');
        }
    </script>
@endsection

@section('css')
    <style>
        .hospital_checkbox {
            accent-color: #008fc5;
        }

        .bg-error {
            background: #ffeeeb;
            color: black;
            border-radius: 5px;
            font-size: 10px;
        }

        .bg-red {
            color: red;
        }
        .btn-grey-disabled{
            border: unset !important;
        }
        .btn-grey-disabled, .btn-grey-disabled:hover {
            background: grey;
            color: white;
        }
        .container-radio-custom {
            display: block;
            position: relative;
            padding-left: 20px;
            cursor: pointer;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
        .container-radio-custom input {
            position: absolute;
            opacity: 0;
            cursor: pointer;
        }
        .checkmark-radio-custom {
            position: absolute;
            top: 5px;
            left: 0;
            height: 15px;
            width: 15px;
            background-color: #ffffff;
            border-radius: 50%;
            border: 1px solid #adadad;
        }
        .container-radio-custom input:checked ~ .checkmark-radio-custom {
            background-color: #fff;
        }
        .checkmark-radio-custom:after {
            content: "";
            position: absolute;
            display: none;
        }
        .container-radio-custom input:checked ~ .checkmark-radio-custom:after {
            display: block;
        }
        .container-radio-custom .checkmark-radio-custom:after {
            top: 1.4px;
            left: 1.4px;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #0091c6;
        }
        #locationResult {
            display: none;
        }
    </style>
@stop