@extends('layouts.app')
@section('content')
<link rel="stylesheet" href="{{ asset('css/nouislider.min.css') }}" />
<script src="{{ asset('js/nouislider.min.js') }}"></script>

<style>
    .text-success-light {
        color: #70bb70;
    }

    .form-group label {
        font-weight: 500;
    }

    .form-group label span {
        font-weight: 400;
    }

    .noUiSlider {
        margin: 58px 0;
        padding: 0 15px;
    }

    .notify.alert-warning {
        background-color: #f9f6ee;
        border-color: #ffecb5;
    }

    .notify i {
        font-size: 40px;
    }

    .checkbox label:after,
    .radio label:after {
        content: '';
        display: table;
        clear: both;
    }

    .checkbox .cr,
    .radio .cr {
        position: relative;
        display: inline-block;
        border: 1px solid #a9a9a9;
        border-radius: .25em;
        width: 1.3em;
        height: 1.3em;
        float: left;
        margin-right: .5em;
    }

    .radio .cr {
        border-radius: 50%;
    }

    .checkbox .cr .cr-icon,
    .radio .cr .cr-icon {
        position: absolute;
        font-size: .8em;
        line-height: 0;
        top: 50%;
        left: 13%;
    }

    .radio .cr .cr-icon {
        margin-left: 0.04em;
    }

    .checkbox label input[type="checkbox"],
    .radio label input[type="radio"] {
        display: none;
    }

    .checkbox label input[type="checkbox"]+.cr>.cr-icon,
    .radio label input[type="radio"]+.cr>.cr-icon {
        opacity: 0;
    }

    .checkbox label input[type="checkbox"]:checked+.cr>.cr-icon,
    .radio label input[type="radio"]:checked+.cr>.cr-icon {
        opacity: 1;
    }

    .checkbox label input[type="checkbox"]:disabled+.cr,
    .radio label input[type="radio"]:disabled+.cr {
        opacity: .5;
    }
</style>
<div class="bg-light">
    <div class="container pt-3">
        <nav class="mb-0">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{{ route('index') }}"><u>Home</u></a></li>
                <li class="breadcrumb-item active" aria-current="page">Hemorrhoid Treatment Survey</li>
            </ol>
        </nav>
    </div>
</div>
<div class="bg-grey py-5">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-7 text-center">
                <h5 class="subtitle">Hemorrhoid Treatment Survey</h5>
            </div>
        </div>
    </div>
</div>
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="container shadow p-4">
                <div class="row">
                    <div class="col-md-12">
                        <div class="notify alert alert-warning d-flex flex-column flex-md-row align-items-center" role="alert">
                            <i class="fa-duotone fa-circle-info fa-fw"></i>
                            <div class="ms-2 mt-2 mt-md-0">
                                <div>Are you a <b>gastroenterologist</b> who treats hemorrhoids?</div>
                                <div>Receive a <b>$50 Amazon Gift Card</b> to Take a 5 Minute Telephone Survey</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row justify-content-center">
                    @if (session('success'))
                    <div class="col-12">
                        <div class="alert alert-success" role="alert">
                            <h4 class="alert-heading">Thank you!</h4>
                            <p>We have received your form submission and will process it promptly.</p>
                        </div>
                    </div>
                    @else
                    <div id="surveyQuestionsComponent" class="col-md-12">
                        <form action="{{ route('submit-gi-survey-questions') }}" method="POST">
                            @csrf

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>Are you a gastroenterologist?</label>
                                        <div class="mt-1">
                                            <div class="radio mb-2">
                                                <label>
                                                    <input type="radio" name="are_you_a_gastroenterologist" v-model="form.are_you_a_gastroenterologist" value="YES">
                                                    <span class="cr"><i class="cr-icon fa fa-circle text-success-light"></i></span>
                                                    <span>Yes</span>
                                                </label>
                                            </div>
                                            <div class="radio mb-2">
                                                <label>
                                                    <input type="radio" name="are_you_a_gastroenterologist" v-model="form.are_you_a_gastroenterologist" value="NO">
                                                    <span class="cr"><i class="cr-icon fa fa-circle text-success-light"></i></span>
                                                    <span>No</span>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div v-if="form.are_you_a_gastroenterologist == 'NO'" class="form-group">
                                        <label>Your speciality?<sup class="text-danger">*</sup></label>
                                        <input type="text" class="form-control" name="your_specialty" value="{{ old('your_specialty') }}" required />
                                    </div>
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>How many patients per week, on average, do you see who have hemorrhoids?</label>
                                        <input type="number" class="form-control" name="number_of_patients_per_week" value="{{ old('number_of_patients_per_week') }}" />
                                    </div>
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>Do you currently perform rubber band ligation (RBL) for hemorrhoid treatment?</label>
                                        <div class="mt-1">
                                            <div class="radio mb-2">
                                                <label>
                                                    <input type="radio" name="performs_rubber_band_ligation" v-model="form.performs_rubber_band_ligation" value="YES">
                                                    <span class="cr"><i class="cr-icon fa fa-circle text-success-light"></i></span>
                                                    <span>Yes</span>
                                                </label>
                                            </div>
                                            <div class="radio mb-2">
                                                <label>
                                                    <input type="radio" name="performs_rubber_band_ligation" v-model="form.performs_rubber_band_ligation" value="NO">
                                                    <span class="cr"><i class="cr-icon fa fa-circle text-success-light"></i></span>
                                                    <span>No</span>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>What is the best phone number to reach you at to take a 5 minute telephone survey?<sup class="text-danger">*</sup></label>
                                        <input type="tel" class="form-control" name="phone_number" value="{{ old('phone_number') }}" required />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-12 question">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group mb-3">
                                                <label>Your First Name<sup class="text-danger">*</sup></label>
                                                <input type="text" class="form-control" name="first_name" value="{{ old('first_name') }}" required />
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group mb-3">
                                                <label>Your Last Name<sup class="text-danger">*</sup></label>
                                                <input type="text" class="form-control" name="last_name" value="{{ old('last_name') }}" required />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>What state do you practice in?</label>
                                        <select class="form-control" name="practice_address_state">
                                            <option value=""></option>
                                            @foreach(config('constants.us_states') as $stateKey => $stateLabel)
                                            <option value="{{ $stateKey }}" <?= old('practice_address_state') === $stateKey ? 'selected' : '' ?>>{{ $stateKey }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>Your email:<sup class="text-danger">*</sup></label>
                                        <input type="email" class="form-control" name="email" value="{{ old('email') }}" required />
                                        <small class="text-muted"><i class="fa-duotone fa-circle-info fa-fw"></i> We will use this email address to process your $50 Amazon gift card</small>
                                    </div>
                                </div>
                            </div>

                            <div class="row mb-3">
                                <div class="col-12 question">
                                    <div class="form-group">
                                        <label>Preferred time to call:</label>
                                        <div class="mb-3">
                                            <label class="me-3 text-muted">Day(s):</label>
                                            <div class="d-flex flex-column flex-md-row flex-wrap mt-1">
                                                <?php
                                                $preferred_days_to_call = [
                                                    'M',
                                                    'Tu',
                                                    'W',
                                                    'Th',
                                                    'F',
                                                    'Sa',
                                                    'Su'
                                                ];
                                                ?>
                                                @foreach($preferred_days_to_call as $day)
                                                <div class="checkbox me-3">
                                                    <label>
                                                        <input type="checkbox" name="preferred_day_to_call[]" value="{{ $day }}">
                                                        <span class="cr"><i class="cr-icon fa-duotone fa-check fa-fw text-success-light"></i></span>
                                                        <span>{{ $day }}</span>
                                                    </label>
                                                </div>
                                                @endforeach
                                            </div>
                                        </div>
                                        <div class="mb-3">
                                            <label class="me-3 text-muted">Time(s):</label>
                                            <div class="d-flex flex-column flex-md-row flex-wrap mt-1">
                                                <?php
                                                $preferred_time_to_call = [
                                                    '6-8 am',
                                                    '8-10 am',
                                                    '10-12 pm',
                                                    '12-2 pm',
                                                    '2-4 pm',
                                                    '4-6 pm',
                                                    '6-8 pm'
                                                ];
                                                ?>
                                                @foreach($preferred_time_to_call as $time)
                                                <div class="checkbox me-3">
                                                    <label>
                                                        <input type="checkbox" name="preferred_time_to_call[]" value="{{ $time }}">
                                                        <span class="cr"><i class="cr-icon fa-duotone fa-check fa-fw text-success-light"></i></span>
                                                        <span>{{ $time }}</span>
                                                    </label>
                                                </div>
                                                @endforeach
                                            </div>
                                            <div class="mt-3">
                                                <input type="text" class="form-control" name="any_other_special_time" value="{{ old('any_other_special_time') }}" placeholder="Any other special time" />
                                            </div>
                                            <small class="text-muted mt-1"><i class="fa-duotone fa-circle-info fa-fw"></i> Your local time</small>
                                        </div>
                                    </div>
                                </div>
                            </div>



                            <div class="row mt-3">
                                <div class="col-md-12">
                                    <div class="form-group mb-4">
                                        {!! htmlFormSnippet() !!}
                                        @error('g-recaptcha-response')
                                        <small class="text-danger"><i class="fas fa-exclamation-triangle mr-2"></i>Invalid</small>
                                        @enderror
                                    </div>
                                </div>
                                <div class="col-12">
                                    <button type="submit" class="btn btn-pry w-100 py-3">SUBMIT</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var surveyQuestionsComponent = new Vue({
        el: '#surveyQuestionsComponent',
        data: {
            form: {
                are_you_a_gastroenterologist: "{{ old('are_you_a_gastroenterologist') }}",
                performs_rubber_band_ligation: "{{ old('performs_rubber_band_ligation') }}"
            }
        },
        methods: {
            init: function() {}
        },
        mounted: function() {
            this.init();
        }
    });
</script>
@endsection