@extends('template.'.config('settings.template').'.content.master')
@section('head')
<link rel="stylesheet" href="{{ asset('template/css/intlTelInput.min.css') }}">
@stop
@section('content')
<link rel="stylesheet" href="{{ asset('template/css/pages/news.css') }}">
<span id="database" data-new-id="{{$content->id}}" data-new-url="{{route_content($content)}}" data-new-title="{{$content->title}}" data-new-date="{{date('Y-m-d h:i:s', strtotime($content->created_at))}}" data-author-url="{{route('users.show', [$content->user->slug])}}" data-author-name="{{$content->user->name}}" data-author-image="{{$content->user->gravatar()}}"></span>
<div class="container">
    <!-- Modal -->
    @isset($form)
        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Bewerbung: {{$content->title}}</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <?php
                        $form = \App\Models\Form::find(1); // ID FORM DATABASE
                        ?>
                        <style>
                            label {
                                padding-bottom: 4px;
                            }
                        </style>
                        <form method="post" action="{{ route('send-form', [$form->id]) }}" id="formPost" enctype="multipart/form-data" autocomplete="on">
                            @csrf
                            <input type="hidden" name="nach_title" value="{{ $content->title }}" />
                            <input type="hidden" name="email_to" value="{{ $content->user->email }}" />
                            <div class="form-group" style="margin-bottom: 25px; display: block;">
                                <label for="field8">Anrede: <span style="color: red">*</span></label>
                                <select class="form-select" aria-label="Anrede" id="field8" name="fields[8]" required>
                                    <option selected disabled>Bitte wählen</option>
                                    <option value="Herr">Herr</option>
                                    <option value="Frau">Frau</option>
                                    <option value="Divers">Divers</option>
                                    <option value="keine Angabe">keine Angabe</option>
                                </select>
                            </div>
                            <div class="form-group" style="margin-bottom: 25px; display: block;">
                                <label for="field1">Vorname Nachname: <span style="color: red">*</span></label>
                                <input type="text" class="form-control" id="field1" name="fields[1]" placeholder="Max Mustermann" required>
                            </div>
                            <div class="form-group" style="margin-bottom: 25px; display: block;">
                                <label for="field7">E-Mail: <span style="color: red">*</span></label>
                                <br>
                                <input type="email" class="form-control" id="field7" name="fields[7]" placeholder="max.mustermann@example.de" required>
                            </div>
                            <div class="form-group" style="margin-bottom: 25px; display: block;">
                                <label for="field2">Telefon:</label>
                                <br>
                                <input type="tel" class="form-control phone" id="field2" name="fields[2]">
                            </div>
                            <div class="form-group" style="margin-bottom: 25px;">
                                <label for="field5">Möglichkeit zum Upload eines Lebenslaufs:</label>
                                <label for="field5" style="font-size: 11px; font-family: initial;">
                                    Maximal 4MB. Dateiformate: .pdf, .doc, .txt, .jpg, .png.
                                </label>
                                <input accept=".txt,.pdf,.doc,.jpg,.png" type="file" name="fields[5]" id="field5" placeholder="Anhänge" style="height: 125px;border: 1px dashed #e7cf84;background-color: #fff3cd6b; padding-left: 30px; padding-top: 50px; width: 100%;">
                            </div>
                            <div class="form-group d-none">
                                <label for="field3">Job</label>
                                <input type="text" class="form-control" id="field3" name="fields[3]" required value="{{$content->title}}">
                            </div>
                            <div class="form-group d-none">
                                <label for="field4">Firma</label>
                                <input type="text" class="form-control" id="field4" name="fields[4]" required value="{{$content->user->name}}">
                            </div>
                            <div class="mb-3 form-check">
                                <input type="checkbox" class="form-check-input" id="exampleCheck1" required>
                                <label class="form-check-label" for="exampleCheck1" style="font-size: 11px; font-family: initial;">
                                    Ich stimme zu, dass die oben erhobenen Daten verarbeitet und zur Weiterleitung an {{$content->user->name}} genutzt werden dürfen.
                                    Ich bestätige, dass ich mit den <a href="{{url('/datenschutz')}}" style="color:#f49c35; text-decoration: underline" target="_blank">Datenschutzerklärung</a> einverstanden bin.
                                    Ich kann meine Einwilligung selbstverständlich jederzeit widerrufen.
                                </label>
                            </div>

                            <span style="color: red" style="font-size: 11px;">*</span> <i style="font-size: 11px; font-family: initial;">Pflichtfeld</i>


                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-success">
                            Bewerbung abschicken <i class="fal fa-envelope"></i>
                        </button>

                    </div>
                    </form>
                </div>
            </div>
        </div>
    @endisset


    @if(session()->has('success'))
    <br>
    <br>
    <div class="alert alert-success">
        Bewerbung erfolgreich übermittelt!
    </div>
    <script>
        fbq('track', 'SubmitApplication');
        gtag('event', 'Application submitted', {
            'event_category': '{{$content->title}}'
        });
        gtag('event', 'Application submitted', {
            'event_category': '{{$content->title}}',
            'event_label': '-'
        });
    </script>
    @endif
    <div class="row" style="padding-top:20px;">
        <div class="col-12 col-md-9 hidden-md text-center">{{$content->user->name}} sucht zur Anstellung einen / eine:
            <br>
        </div>
    </div>
    <div class="row" style="padding-top:20px; padding-bottom: 20px;">

        <div class="col-3 col-md-1 d-flex align-items-center">

            <img src="{{ $content->user->gravatar() }}" class="rounded border img-fluid" alt="Logo {{$content->user->name}}">

        </div>
        <div class="col-9 col-md-11 d-flex align-items-center">
            <h1 class="h2">{{$content->title}}</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-6 text-muted small">
            Veröffentlicht: {{date('d.m.Y', strtotime($content->created_at))}}
        </div>

    </div>
    <div class="row">

        <div class="col-12 col-lg-9">

            @if ($content->image)
            <br>
            <img src="{{ asset('uploads/' . $content->image) }}" class="img-fluid">
            <br>
            @endif
            <br>
            <div class="row">




                <div class="col-12">
                    <br>
                    <svg style="width: 14px; fill: #d0504f" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
                        <!-- Font Awesome Pro 5.15.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) -->
                        <path d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0z" />
                    </svg>
                    92714 Pleystein
                </div>
            </div>

            <style>
                h2 {
                    font-size: 1.4rem;
                    padding-top: 55px;
                }
                h5 {
                    font-size: 0.9rem;
                }
            </style>
            <div class="row">
                <div class="col-12">
                    <h2 class="h4">Stellenbeschreibung</h2>
                    {!! isset($content->data_fields['stellenbeschreibung']) ? $content->data_fields['stellenbeschreibung'] : 'keine Angaben' !!}
                </div>
                <div class="col-12">
                    <h2 class="h4">Ihre Qualifikationen</h2>
                    {!! isset($content->data_fields['bewerberqualifikation']) ? $content->data_fields['bewerberqualifikation'] : 'keine Angaben' !!}
                </div>
                <div class="col-12">
                    <h2 class="h4">{{$content->user->name}} als Arbeitgeber</h2>
                    {!! isset($content->data_fields['wir_als_arbeitgeber']) ? $content->data_fields['wir_als_arbeitgeber'] : 'keine Angaben' !!}
                </div>
                @isset ($content->data_fields['bewerbunginfo'])
                <div class="col-12">
                    <h2 class="h4">Infos zur Bewerbung</h2>
                    {!! isset($content->data_fields['bewerbunginfo']) ? $content->data_fields['bewerbunginfo'] : 'keine Angaben' !!}
                </div>
                @endisset
            </div>
            <br>
            <br>

                    <a class="btn btn-lg btn-success" href="{{url('/kontakt')}}">
                        <svg style="fill: currentColor; width: 20px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M528 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm0 400H303.2c.9-4.5.8 3.6.8-22.4 0-31.8-30.1-57.6-67.2-57.6-10.8 0-18.7 8-44.8 8-26.9 0-33.4-8-44.8-8-37.1 0-67.2 25.8-67.2 57.6 0 26-.2 17.9.8 22.4H48V144h480v288zm-168-80h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8H360c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8zm0-64h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8H360c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8zm0-64h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8H360c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8zm-168 96c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64z"/></svg>
                        Jetzt online Bewerbung einreichen
                    </a>
                    <br>
                    <small class="text-muted" style="margin-left: 115px;">1 min Bewerbung</small>


            <br>
            <br>
            <br>
        </div>

    </div>
</div>

@stop
@section('scripts')
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
    const shareData = {
        title: "{{ $content->title }}",
        text: 'Text',
        url: window.location.href,
    }
</script>
<script src="{{ asset('template/js/pages/news/methods.js') }}"></script>
<script src="{{ asset('template/js/pages/news/events.js') }}"></script>
<script src="{{ asset('template/js/pages/news/script.js') }}"></script>
<script src="{{ asset('system/js/intlTelInput.min.js') }}"></script>
<script>
    var input = document.querySelector(".phone");
    var iti = window.intlTelInput(input, {
        initialCountry: "de",
        geoIpLookup: function(callback) {
            $.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) {
                var countryCode = (resp && resp.country) ? resp.country : "us";
                callback(countryCode);
            });
        },
        utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.11/js/utils.min.js",
        // any initialisation options go here
    });
    $("#formPost").submit(function() {
        if (iti.isValidNumber() == false) {
            alert('Telefonnummer nicht gültig!');
            return false;
        }
        return true;
    });
</script>
@stop