<div class="card mb-2  border-primary">
    <h6 class="card-header  bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseCustomerBooking" aria-expanded="false" aria-controls="collapseCustomerBooking">
        <strong style="line-height: 1.6em">Anfragen
            <span class="badge badge-secondary">{{ $customer->leads->count()}} </span> |
        </strong>
        
        <strong style="line-height: 1.6em">Buchung
            <span class="badge badge-secondary">{{ $customer->bookings->count()}} </span> |
        </strong>

        <strong style="line-height: 1.6em">Gutscheine
            <span class="badge badge-secondary">{{ $customer->coupons->count()}} </span>
        </strong>
    </h6>
    
    <div class="collapse" id="collapseCustomerBooking">
        <div class="card-body">
            <div class="row">
                <div class="col-sm-12">
                    <table class="table table-striped table-sm">
                        <thead>
                        <tr>
                            <th style="max-width: 60px;">AnfrageID</th>
                            <th>{{__('Sachbearbeiter')}}</th>
                            <th>{{__('Status')}}</th>
                            <th>{{__('Anfrage-Datum')}}</th>
                        </tr>
                        </thead>
                        <tbody>
                            @if($customer->leads)
                            @foreach ($customer->leads as $lead)
                            <tr>
                                <td>
                                    <a href="{{ route('lead_detail', [$lead->id]) }}" class="btn icon-btn btn-sm btn-primary">
                                        <span class="fa fa-edit"></span>
                                    </a>
                                    {{  $lead->id }}
                                </td>
                                <td>
                                    @if($lead->sf_guard_user_id && $lead->sf_guard_user) 
                                        {{ $lead->sf_guard_user->first_name }} {{ $lead->sf_guard_user->last_name }}
                                    @endif
                                </td>
                                <td>
                                    {!! $lead->getStatusBadge() !!}
                                </td>
                                <td>
                                    {{ _format_date($lead->request_date) }}
                                </td>    
                            </tr>
                            @endforeach
                            @endif

                        </tbody>
                    </table>

                    <hr class="mt-3 mb-3">

                    <table class="table table-striped table-sm">
                        <thead>
                        <tr>
                            <th style="max-width: 60px;">BuchnungsID</th>
                            <th>{{__('Reiseland')}}</th>
                            <th>{{__('Programm')}}</th>
                            <th>{{__('Anreise')}}</th>
                            <th>{{__('Abreise')}}</th>
                            <th>{{__('Sachbearbeiter')}}</th>
                            <th>{{__('Status')}}</th>
                            <th>{{__('Datum')}}</th>
                        </tr>
                        </thead>
                        <tbody>
                            @if($customer->bookings)
                            @foreach ($customer->bookings as $booking)
                            <tr>
                                <td>
                                    <a href="{{ route('booking_detail', [$booking->id]) }}" class="btn icon-btn btn-sm btn-primary">
                                        <span class="fa fa-edit"></span>
                                    </a>
                                    {{  $booking->id }}
                                </td>
                                <td>
                                    @if($booking->travel_country_id && $booking->travel_country) 
                                        {{ $booking->travel_country->name }}
                                    @endif
                                </td>
                                <td>
                                    @if($booking->travelagenda_id && $booking->travel_agenda) 
                                        {{ $booking->travel_agenda->name }}
                                    @endif
                                </td>
                                <td>{{ _format_date($booking->start_date) }}</td>
                                <td>{{ _format_date($booking->end_date) }}</td>
                                <td>
                                    @if($booking->sf_guard_user_id && $booking->sf_guard_user) 
                                        {{ $booking->sf_guard_user->first_name }} {{ $booking->sf_guard_user->last_name }}
                                    @endif
                                </td>
                                <td>
                                    @if($booking->lead)
                                     {!! $booking->lead->getStatusBadge($booking) !!}
                                    @endif
                                </td>
                                <td>
                                    {{ _format_date($booking->booking_date) }}
                                </td>    
                            </tr>
                            @endforeach
                            @endif

                        </tbody>
                    </table>

                    <hr class="mt-3 mb-3">

                    <table class="table table-striped table-sm">
                        <thead>
                        <tr>
                            <th>{{__('Gutschein')}}</th>
                            <th>{{__('Wert')}}</th>
                            <th>{{__('Ausstellungsdatum')}}</th>
                            <th>{{__('Gültig bis')}}</th>
                            <th>{{__('Eingelöst')}}</th>
                            <th>{{__('#')}}</th>
                        </tr>
                        </thead>
                        <tbody>
                            @if($customer->coupons)
                            @foreach ($customer->coupons as $coupon)
                            <tr>
                                <td>
                                    <a href="{{ route('customer_file_show', ['coupon', $coupon->id]) }}" target="_blank" class="badge badge-md badge-warning">
                                    <i class="fa fa-file-pdf mr-1"></i> Gutschein {{$coupon->number}}
                                    </a>
                                </td>
                                <td>
                                    {{ \App\Services\Util::_number_format($coupon->value)}} &euro;
                                </td>
                                <td>
                                    {{\App\Services\Util::_format_date($coupon->issue_date, 'date')}}
                                </td>
                                <td>
                                    {{\App\Services\Util::_format_date($coupon->valid_date, 'date')}}
                                </td>
                                <td>
                                    @if($coupon->is_redeemed) 
                                        <i class="fa fa-check-circle text-success"></i> {{\App\Services\Util::_format_date($coupon->redeem_date, 'date')}}  
                                    @else 
                                        <i class="fa fa-times-circle text-danger"></i>
                                    @endif
                                </td>
                              
                                <td>
                                    <a href="{{ route('customer_file_show', ['coupon', $coupon->id, true]) }}" class="btn btn-xs btn-default"
                                        title="Download" data-placement="left" rel="tooltip">
                                         <i class="fa fa-download"></i>
                                     </a>
                                </td>   
                            </tr>
                            @endforeach
                            @endif

                        </tbody>
                    </table>

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