@extends('layout.app')
@section('title')
    <title>Contact Us</title>
    <meta name="description" content="If you have an enquiry regarding immigration to Australia, please fill out the enquiry form below and one of our migration agents will be in touch."/>
    <meta name="og:title" content="Contact Us"/>
    <meta name="og:image" content="{{url('frontend/images/contact-us-banner.png')}}"/>
@endsection
@section('content')

@php
          $msg = Session::get('msg') ?? null; 
        @endphp
    <section class="contact-us-section" style="background: url('frontend/images/contact-us-banner.png')">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
              <li class="breadcrumb-item"><a href="/">Home</a></li>
              <li class="breadcrumb-item active" aria-current="page">Contact Us</li>
            </ol>
        </nav>
        <div class="contact-banner-content">
            <h2>Contact us</h2>
        </div>
    </section>
    <section class="get-in-touch-section">
        <div class="get-in-card">
            <div class="row">
                <div class="col-md-5">
                    <div class="get-in-desc">
                        <div class="contact-icon">
                            <img src="{{url('frontend/icons/contact-icon.svg')}}" alt="">
                            <h5>Contact us</h5>
                        </div>
                        <h2>Get in touch with us</h2>
                        <p>If you have an enquiry regarding immigration to
                            Australia, please fill out the enquiry form below and
                            one of our migration agents will be in touch.
                        </p>
                        <div class="contact-desc">
                            @if(!is_null($phone))
                              <a href="tel: {{$phone->value}}" class="contact-phone">
                                <img src="{{url('frontend/icons/contact-call-icon.svg')}}" alt="">
                                <h5>{{$phone->value}}</h5>
                              </a>
                            @endif
                            @if(!is_null($email))
                              <a href="mailto: {{$email->value}}" class="contact-phone">
                                <img src="{{url('frontend/icons/contact-mail-icon.svg')}}" alt="">
                                <h5>{{$email->value}}</h5>
                              </a>
                            @endif
                            @if(!is_null($address))
                            <a href="https://goo.gl/maps/P4Y2PYGMpGa83L2R8" target="_blank" class="contact-phone">
                              <img src="{{url('frontend/icons/contact-location-icon.svg')}}" alt="">
                              <h5>{{$address->value}}</h5>
                            </a>
                            @endif
                          </div>
                    </div>
                </div>
                <div class="col-md-7">
                    <div class="contact-form">
                        <h2>Please fill-up the form</h2>
                        @include('errors.error')

                        <form action="{{route('send_contact_mail')}}" method = "post">
                            @csrf
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label for="">Full name</label>
                                        <input type="text" class="form-control" placeholder="Enter your full name" name="fullname" id="" value = "{{old('fullname')}}">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label for="">Email address</label>
                                        <input type="email" class="form-control" placeholder="Enter your email adress" name="email" id="" value = "{{old('email')}}">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label for="">Phone</label>
                                        <input type="text" class="form-control" placeholder="Enter your phone number" name="phone" id="" value = "{{old('phone')}}">
                                    </div>
                                </div>
                                <input type = "hidden" name = "check" value = "1"/>
                                <div class="col-md-6">
                                    <div class="mb-3">
                                        <label for="">Services</label>
                                        <select name="service_id" id="" class="form-select">
                                            <option hidden value = ''>Choose service</option>
                                            @foreach($services as $service)
                                             <option value="{{$service->id}}" class="aplus-display-select" {{old('service_id') == $service->id ? 'selected' : ''}}>{{$service->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    @php
                                        $code = Str::random(5);
                                    @endphp
                                <div class="mb-3">
                                    <label for="">Enter Captcha</label>
                                        <div class="contact-captcha">
                                            <div class="captcha-sec">
                                                <input id="captcha" type="text" name = "entered_captcha_code" class="form-control" placeholder="Enter Captcha as Shown" required>
                                                <input type = "hidden" id = "displayed_captcha_code" name = "displayed_captcha_code" value = "{{$code}}"/>
                                            </div>
                                            <div class="captch-field">
                                                <!-- name = "captcha_code" value = "{{$code}}" -->
                                                <input type = "text" id="captcha_code" readonly  name = "captcha_code" value = "{{$code}}"/>
                                                <a id = "refresh"><img src="{{url('frontend/icons/reset-icon.svg')}}" alt=""></a>
                                            </div>
                                        </div>
                                </div>
                                @if ($errors->has('captcha'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('captcha') }}</strong>
                                    </span>
                                @endif
                                </div>
                                <div class="col-md-12">
                                    <div class="mb-5">
                                        <label for="">Message</label>
                                        <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Write a message.." name="message">{{old('message')}}</textarea>
                                    </div>
                                </div>
                                <div class="submit-btn">
                                    <button type="submit">Send Message</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <section class="map-section">
        <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3312.5156265342534!2d151.20545281583023!3d-33.876371926884524!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6b12ae3d03e36c87%3A0xecb5377dac8c07a8!2s406%2F383%20Pitt%20St%2C%20Sydney%20NSW%202000%2C%20Australia!5e0!3m2!1sen!2snp!4v1671163675803!5m2!1sen!2snp" width="100%" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
    </section>

    @section('script')
    <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
        <script>

     var php_var = "<?php echo $msg; ?>";
        if(php_var.length !== 0){
              Swal.fire({
                  title: 'Submitted!!',
                  text: php_var,
                  icon: 'success'
              })
        }

            $('#refresh').click(function(event){
                event.preventDefault();
                $.ajax({
                    type:'GET',
                    url:'refreshcaptcha',
                    success:function(data){
                        document.getElementById('captcha_code').readOnly
                                        = false;
                        document.getElementById('captcha_code').value = (data.captcha_code);
                        document.getElementById('displayed_captcha_code').value = (data.captcha_code);
                        document.getElementById('captcha_code').readOnly
                                        = true;
                    }
                });
            });
</script>
    @endsection
@endsection