@extends('layouts.layout-2')

@section('content')

    @if ($errors->any())
        <div class="row">
            <div class="col-sm-12">
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    @endif


    <h4 class="font-weight-bold mb-4">
       Export VP
    </h4>

    {!! Form::open(['action' => url()->current(), 'class' => '']) !!}
    <div class="card mb-4">
        @if(count($values)>0)

            <div class="card-body">
                <button type="submit" name="action" value="export_vp" class="btn btn-primary"><i class="ion"></i> als CSV exportieren</button>
    
                <div class="card-datatable table-responsive">
                    <table class="table table-striped table-bordered">
                        <thead>
                        <tr>
                            <th style="max-width: 60px;">ID</th>
                            <th>Email</th>
                            <th>Firma</th>
                            <th>Anrede</th>
                            <th>Vorname</th>
                            <th>Nachname</th>
                            <th>Mitglied</th>
                            <th>Bis</th>

                        </tr>
                        </thead>
                        <tbody>
                        @foreach($values as $user)
                        @if($user->account)
                           <tr>
                               <td>{{$user->id}}</td>
                               <td>{{$user->email}}</td>
                               <td>{{$user->account->company}}</td>
                               <td>{{$user->account->salutation == 'mr' ? 'Herr' : 'Frau' }}</td>
                               <td>{{$user->account->first_name}}</td>
                               <td>{{$user->account->last_name}}</td>
                               <td>{{ $user->payment_account ? ($user->isActiveAccount() ? 'JA' : 'Abgelaufen') : "Nein"}}</td>
                               <td>{{ $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-"}}</td>
                           </tr>
                           @endif
                        @endforeach
                        </tbody>
                    </table>
                <!-- Controls -->
                </div>
            </div>
        @endif

    </div>
    {!! Form::close() !!}

@endsection

