@extends('layouts.layout-2')

@section('content')
    <h4 class="font-weight-bold py-2 mb-2 d-flex justify-content-between align-items-center w-100 ">
        <div>{{ __('navigation.my_homeparty') }} / {{ $homeparty->name }} - {{ $homeparty->date }}</div>
        @if(!$homeparty->completed)
            <a href="{{route('user_homeparty_guest_detail', [$homeparty->id, 'new'])}}" class="btn btn-sm btn-secondary rounded-pill d-block float-right"><span class="ion ion-md-person-add"></span>&nbsp; Gast anlegen</a>
        @endif
    </h4>

    <div class="row">
        <div class="col-12">
            @php($g_count = 1)

            @foreach($homeparty->homeparty_users as $homeparty_user)
            <div class="card mb-3">
                <div class="card-body d-flex justify-content-between align-items-start pb-2">
                   
                    @if(!$homeparty->completed)
                    <div>
                        
                      
                            @if($homeparty_user->is_host)
                                <a href="{{route('user_homeparty_detail', [$homeparty->id, 13])}}" class="text-body text-big font-weight-semibold">
                                <span class="text-muted">Gastgeber:in </span>
                            @else
                                <a href="{{route('user_homeparty_guest_detail', [$homeparty->id, $homeparty_user->id])}}" class="text-body text-big font-weight-semibold">
                                <span class="text-muted">Gast {{$g_count++}} </span>

                            @endif
                            {{$homeparty_user->billing_firstname}} {{$homeparty_user->billing_lastname}}</a>
                                    
                        {{-- <span class="badge badge-success align-text-bottom ml-1">offen ...</span> --}}
                    </div>
                    <div>
                        @if($homeparty_user->is_host)
                        <a href="{{route('user_homeparty_detail', [$homeparty->id, 13])}}" class="btn btn-sm btn-secondary mr-2"><i class="fa fa-edit"></i> bearbeiten</a>
                        @else
                        <a href="{{route('user_homeparty_guest_detail', [$homeparty->id, $homeparty_user->id])}}" class="text-body text-big font-weight-semibold">
                        @endif
                        <div class="btn-group project-actions">
                            @if($homeparty_user->is_host)
                                <span class="ion ion-md-trash text-muted" data-toggle="tooltip" title="Gastgeber:in kann nicht gelsöcht werden"></span>
                            @else
                            <a href="{{ route('user_homeparty_delete', ['hpu', $homeparty->id, $homeparty_user->id]) }}"
                               class="" onclick="return confirm('Homeparty Gast wirklich löschen?');">
                                <span class="ion ion-md-trash text-danger"></span>
                            </a>
                            @endif
                        </div>
                    </div>
                    @else
                    <div>
                        
                        <div class="text-body text-big font-weight-semibold">
                            @if($homeparty_user->is_host)
                                <span class="text-muted">Gastgeber:in </span>
                            @else
                                <span class="text-muted">Gast {{$g_count++}} </span>
                            @endif
                            {{$homeparty_user->billing_firstname}} {{$homeparty_user->billing_lastname}}
                        </div>
                        {{-- <span class="badge badge-success align-text-bottom ml-1">offen ...</span> --}}
                    </div>
                    @endif
                 </div>
                 <div class="progress rounded-0" style="height: 2px;">
                     <div class="progress-bar" style="width: 100%;"></div>
                 </div>
                <div class="card-body pt-0 mt-2">
                    <div class="row">
                        <div class="col">
                            <div class="text-muted small">Adresse</div>
                            <div class="font-weight-bold">{{$homeparty_user->billing_address}}
                                {{$homeparty_user->billing_zipcode}}
                                {{$homeparty_user->city}}
                                @if($homeparty_user->billing_country_id){{ $homeparty_user->billing_country->getLocated() }}@endif
                            </div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">E-Telefon</div>
                            <div class="font-weight-bold">{{$homeparty_user->billing_phone}}</div>
                        </div>
                        <div class="col">
                            <div class="text-muted small">E-Mail</div>
                            <div class="font-weight-bold">{{$homeparty_user->billing_email}}</div>
                        </div>
                    </div>
                </div>

            </div>
            @endforeach

            @if(!$homeparty->completed)
            <div class="card">
                <div class="card-body py-3">
                    <div class="form-group mb-0">
                        <label  class="form-label">Einladungslink für Gäste <span class="text-muted"> (lass Deine Gäste ihre Daten selber ausfüllen)</span></label>
                        <div class="input-group">
                        <span class="input-group-prepend">
                        <button class="btn btn-sm btn-secondary" type="button" title="Kopiert!" data-clipboard-demo data-clipboard-target="#homeparty_link_{{$homeparty->id}}"><i class="ion ion-ios-copy"></i> Link kopieren</button>
                        </span>
                            <input type="text" class="form-control" name="homeparty_link_{{$homeparty->id}}" value="{{ $homeparty->getTokenLink() }}" id="homeparty_link_{{$homeparty->id}}" placeholder="">
                        </div>
                    </div>
                </div>
            </div>
            @endif
        </div>
    </div>
    <div class="text-left mt-3">
        @if(!$homeparty->completed)
        <a href="{{route('user_homeparty_detail', [$homeparty->id])}}" class="btn btn-sm btn-secondary mr-2 mb-2"><i class="ion ion-ios-cog"></i> Homparty verwalten</a>
        @endif
        <a href="{{route('user_homeparty_order', [$homeparty->id])}}" class="btn  btn-sm btn-secondary mr-2 mb-2"><i class="ion ion-md-basket"></i> Bestellung</a>
        <a href="{{route('user_homepartys')}}" class="btn btn-sm btn-default mb-2">zurück zur Übersicht</a>
    </div>


<script>
    $( document ).ready(function() {
        var clipboardDemos = new ClipboardJS('[data-clipboard-demo]');
        clipboardDemos.on('success', function (e) {
            e.clearSelection();
            $(e.trigger).tooltip('enable').tooltip('show');
        });
        clipboardDemos.on('error', function (e) {
            console.error('Action:', e.action);
            console.error('Trigger:', e.trigger);
        });

        $('button[data-clipboard-demo]').on('mouseout', function () {
            $(this).tooltip('disable');
        })
    });
</script>
@endsection
