@extends('template.'.config('settings.template').'.content.master')
@section('content')


        <div class="row">
            <div id="header_static_city" style="background:url('{{ asset('uploads/categories/' . $categoryModel->image) }}'); background-size: cover; min-height:550px;">
                @if (\Route::currentRouteName() == 'welcome' or \Route::currentRouteName() == 'category.get' or \Route::currentRouteName() == 'author.get')
                    <a href="{{ url('/') }}" title="zur Startseite">
                        <img id="logo_new" alt="Das neue Jobportal für die Oberpfalz"
                             src="{{ asset('template/images/new_jobs_portal_logo.png') }}" >
                    </a>
                @else
                    <a href="{{ url('/') }}" title="zur Startseite">
                        <img id="logo_new" alt="Das neue Jobportal für die Oberpfalz"
                             src="{{ asset('template/images/logo-sm.png') }}" >
                    </a>
                @endif

                <div class="clearfix">

                    <div class="pull-right hidden-xs" id="header_static_links">

                        <img class="arrow pull-right" src="{{ asset('template/images/pfeil_grau.png') }}" alt="">

                    </div>
                </div>

                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>

                <div id="city_headline">
                    <h1>Die besten <strong>Arbeitsstellen</strong> in <strong>{{ $categoryModel->name }}</strong> auf jobs-oberpfalz.de</h1>
                    <h2>Jetzt Traumjob finden und direkt online bewerben.</h2>
                </div>

            </div> <!-- header_static -->
        </div>





        <div class="row" id="employers-home">
            <div class="col-xs-12">
                <h1>Jobs in  <strong>{{ $categoryModel->name }}</strong></h1>
                <br>
                @if (isset($categoryModel))
                    {{ $categoryModel->description }}
                @endif
                <br>
                <br>
                <hr>

            </div>

            <div class="col-sm-12">
                <h2 style="text-align: left">Top <strong>Arbeitgeber</strong> mit offenen <strong>Arbeitsstellen in {{ $categoryModel->name }}</strong></h2>
                <br><br>
            </div>

            <div class="row">

                <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/personalleasing-puran-gmbh">
                        <img src="https://www.jobs-oberpfalz.de/uploads/profile/2.png"
                             class="img-responsive center-block">
                    </a>

                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/personalleasing-puran-gmbh">PersonalLeasing Puran GmbH</a>
                </div>


                @if (\Request::is('schwandorf'))
                    <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/horsch-maschinen-gmbh">
                            <img src="https://www.jobs-oberpfalz.de/uploads/profile/5.png"
                                 class="img-responsive center-block">
                        </a>

                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/horsch-maschinen-gmbh">HORSCH Maschinen GmbH</a>
                    </div>

                    <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/dr-loew">
                            <img src="https://www.jobs-oberpfalz.de/uploads/profile/6.png"
                                 class="img-responsive center-block">
                        </a>

                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/dr-loew">Dr. Löw</a>
                    </div>
                @endif

                @if (\Request::is('regensburg'))
                    <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/horsch-maschinen-gmbh">
                            <img src="https://www.jobs-oberpfalz.de/uploads/profile/5.png"
                                 class="img-responsive center-block">
                        </a>

                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/horsch-maschinen-gmbh">HORSCH Maschinen GmbH</a>
                    </div>
                @endif

                @if (\Request::is('vohenstrauss'))
                <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/areya-webservices">
                        <img src="https://www.jobs-oberpfalz.de/uploads/profile/1.png"
                             class="img-responsive center-block">
                    </a>

                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/areya-webservices">Areya Webservices GmbH</a>
                </div>

                <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/envea-gmbh">
                        <img src="https://www.jobs-oberpfalz.de/uploads/profile/51.jpg"
                             class="img-responsive center-block">
                    </a>

                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/envea-gmbh">ENVEA GmbH</a>
                </div>

                <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/wohnen-am-kreuzberg">
                        <img src="https://www.jobs-oberpfalz.de/uploads/profile/3.png"
                             class="img-responsive center-block">
                    </a>

                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/wohnen-am-kreuzberg">Wohnen am Kreuzberg</a>
                </div>

                <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/psz-electronic-gmbh">
                        <img src="https://www.jobs-oberpfalz.de/uploads/profile/98.jpg"
                             class="img-responsive center-block">
                    </a>

                    <a href="https://www.jobs-oberpfalz.de/arbeitgeber/psz-electronic-gmbh">PSZ electronic GmbH</a>
                </div>
                @endif

                @if (\Request::is('eschenbach'))
                    <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/kerafol-keramische-folien-gmbh-co-kg">
                            <img src="https://www.jobs-oberpfalz.de/uploads/profile/70.jpg"
                                 class="img-responsive center-block">
                        </a>

                        <a href="https://www.jobs-oberpfalz.de/arbeitgeber/kerafol-keramische-folien-gmbh-co-kg">KERAFOL Keramische Folien</a>
                    </div>
                @endif

                @if (\Request::is('weiden'))
                        <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                            <a href="https://www.jobs-oberpfalz.de/arbeitgeber/richard-rank">
                                <img src="https://www.jobs-oberpfalz.de/uploads/profile/65.png"
                                     class="img-responsive center-block">
                            </a>

                            <a href="https://www.jobs-oberpfalz.de/arbeitgeber/richard-rank">Richrd Rank</a>
                        </div>

                        <div class="col-xs-4 col-lg-2 logos" style="padding-bottom: 60px; text-align: center">
                            <a href="https://www.jobs-oberpfalz.de/arbeitgeber/ows-service-fur-schienenfahrzeuge-gmbh">
                                <img src="https://www.jobs-oberpfalz.de/uploads/profile/67.jpg"
                                     class="img-responsive center-block">
                            </a>

                            <a href="https://www.jobs-oberpfalz.de/arbeitgeber/ows-service-fur-schienenfahrzeuge-gmbh">OWS Service für Schienenfahrzeuge</a>
                        </div>


                @endif







            </div>
        </div>


        <div class="row">
            <div id="latest_jobs" class="col-lg-12">


                <h2>Aktuelle <strong>Jobangebote in {{ $categoryModel->name }}</strong></h2>

                <div class="table-responsive">
                    <table class="table table-striped" id="new_jobs_table">
                        <thead>
                        <tr class="headline">
                            <th colspan="2">Arbeitgeber</th>
                            <th>Jobbeschreibung</th>
                            <th>Ort</th>
                            <th style="min-width:100px;" class="hidden-xs hidden-sm">Datum</th>
                        </tr>
                        </thead>
                        <tbody>

                        @foreach($nachrichten as $nach)
                            <tr>

                                <td class="company_image">
                                    <a href="{{ route('author.get', [$nach->user->slug]) }}">
                                        <img src="{{ $nach->user->gravatar() }}" class="rounded-circle" title="{{ $nach->user->name }}" style="min-width: 70">
                                    </a>
                                </td>
                                <td>

                                    <a href="{{ route('author.get', [$nach->user->slug]) }}">
                                        {{ $nach->user->name }}
                                    </a>
                                </td>

                                <td>
                                    <a href="{{ route_content($nach) }}">
                                        {{$nach->title}}
                                    </a>
                                </td>
                                <td>{{ $nach->category->name}}</td>
                                <td class="hidden-xs hidden-sm">{{date('d.m.Y', strtotime($nach->created_at))}}</td>
                                <td>
                                    <a class="btn btn-primary" href="{{ route_content($nach) }}">Job ansehen <i class="fal fa-chevron-right"></i></a>
                                </td>
                            </tr>

                        @endforeach

                        </tbody>
                    </table>
                </div>

            </div>
        </div>

        <div class="row">
            <div class="col-xs-12">
                <h2>Jobsuche auf der Landkarte</h2>

            </div>
            <div id="map-canvas" style="height:500px;width:100%;"></div>
        </div>
@stop

@section('scripts')
    <script>
        function initMap() {
            $.ajax({
                url: '{{ route('location.category', $categoryModel->slug) }}',
                type: "GET",
                dataType: "json",
                success: function (data) {
                    var dados = data.data;

                    if (dados.length != 0) {
                        const map = new google.maps.Map(document.getElementById("map-canvas"), {
                            zoom: 10,
                            //center: { lat: -25.363, lng: 131.044 },
                        });

                        var markers = data.lg;
                        var bounds = new google.maps.LatLngBounds();
                        for (var i = 0; i < markers.length; i++) {
                            bounds.extend(markers[i]);
                        }

                        google.maps.event.addListener(map, 'zoom_changed', function() {
                            zoomChangeBoundsListener =
                                google.maps.event.addListener(map, 'bounds_changed', function(event) {
                                    if (this.getZoom() > 15 && this.initialZoom == true) {
                                        // Change max/min zoom here
                                        this.setZoom(15);
                                        this.initialZoom = false;
                                    }
                                    google.maps.event.removeListener(zoomChangeBoundsListener);
                                });
                        });
                        map.initialZoom = true;
                        map.fitBounds(bounds);

                        $.each(dados, function(propName, propVal) {
                            var marker = new google.maps.Marker({
                                position: { lat: parseFloat(propVal.lat), lng: parseFloat(propVal.lng) },
                                map,
                                link: propVal.url,
                            });
                            new google.maps.event.addListener(marker, "click", function () {

                                window.open(this.link,"_blank");
                            });
                        });
                    }
                }
            });
        }
    </script>

    <script src="https://maps.googleapis.com/maps/api/js?key={{ env('MAPS_API_KEY', 'AIzaSyAQj1N9Mj-OzOiUjt5QUDRkcDonXz4O85A') }}&callback=initMap&libraries=&v=weekly" defer></script>

@stop