@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="media align-items-center font-weight-bold py-3 mb-2">
                {{-- <img src="assets/img/avatars/1.png" alt="" class="ui-w-50 rounded-circle"> --}}
                <div class="media-body ml-3">
                    Willkommen zurück, {{$user->account->first_name}}!
                    <div class="text-muted text-tiny mt-1"><small class="font-weight-normal">Heute ist {{__('cal.weekdays.'.$now->format('l'))}}, {{$now->format('j')}}. {{__('cal.months.'.$now->format('F'))}} {{$now->format('Y')}}</small></div>
                </div>
            </h4>

            <hr class="container-m-nx mt-0 mb-4">

            <div class="row">
                @if($user->active == 1)
                    @if($user->payment_account && $user->daysActiveAccount() <= config('mivita.remind_first_days'))
                        <div class="d-flex col-xl-12 align-items-stretch">
                            <!-- SHOP -->
                            <div class="card w-100 mb-4">
                                <h5 class="card-header">
                                    {{__('membership.home_hl') }}
                                </h5>
                                <div class="card-body">
                                        @if($user->daysActiveAccount() <= 0)
                                            @if($user->isActiveAccount())
                                                <h5 class="alert badge-danger">{{__('membership.home_copy_alert_35')}}</h5>
                                                <p>{{__('membership.home_copy_last_35', ['days'=>$user->daysActiveAccount(), 'datetime'=>$user->getPaymentAccountDateFormat()])}}</p>
                                            @else
                                                {{-- 35, 36 --}}
                                                @if($user->daysActiveAccount() == 0)
                                                <h5 class="alert badge-danger">{{__('membership.home_copy_alert_36_today', ['datetime'=>$user->getPaymentAccountDateFormat()])}}</h5>
                                                @else
                                                <h5 class="alert badge-danger">{{__('membership.home_copy_alert_36', ['days'=>$user->daysActiveAccount()*-1, 'datetime'=>$user->getPaymentAccountDateFormat()])}}</h5>
                                            @endif
                                                @if($user->payment_account && $user->isAboOption())
                                                {{ __('membership.home_copy_SEPA_36', ['price'=> 'von '.$user->payment_order_product->getFormattedPrice().' EUR', 'pay_date'=>Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y')]) }}
                                                <hr>
                                                @endif

                                                <p>{{__('membership.home_copy_last_36', ['days'=>$user->daysActiveAccount(), 'datetime'=>$user->getPaymentAccountDateFormat()])}}</p>
                                            @endif
                                        @elseif($user->daysActiveAccount() < config('mivita.remind_last_days') )
                                            {{-- 33 --}}
                                            <h5 class="alert badge-warning">{{ __('membership.home_copy_alert_31', ['datetime'=>$user->getPaymentAccountDateFormat()]) }}</h5>
                                            <p>{{__('membership.home_copy_last_34', ['days'=>$user->daysActiveAccount(), 'datetime'=>$user->getPaymentAccountDateFormat()])}}</p>
                                        @elseif($user->daysActiveAccount() < config('mivita.remind_sec_days'))
                                            {{-- 33 --}}
                                            <h5 class="alert badge-warning">{{ __('membership.home_copy_alert_31', ['datetime'=>$user->getPaymentAccountDateFormat()]) }}</h5>
                                            @if($user->payment_account && $user->isAboOption())
                                                @if($user->daysActiveAccount() < config('mivita.abo_booking_days') )
                                                    <p>{{ __('membership.home_copy_SEPA_33', ['price'=> 'von '.$user->payment_order_product->getFormattedPrice().' EUR', 'pay_date'=>Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y')]) }}</p>
                                                @else
                                                    <p>{{ __('membership.home_copy_SEPA_32', ['price'=> 'von '.$user->payment_order_product->getFormattedPrice().' EUR', 'pay_date'=>Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y')]) }}</p>
                                                @endif
                                                <hr>
                                            @endif
                                            <p>{{__('membership.home_copy_last_33', ['days'=>$user->daysActiveAccount()])}}</p>
                                        @else
                                            {{-- 32 / 31 --}}
                                            <h5 class="alert badge-default">{{ __('membership.home_copy_alert_31', ['datetime'=>$user->getPaymentAccountDateFormat()]) }}</h5>
                                            @if($user->payment_account && $user->isAboOption())
                                                {{ __('membership.home_copy_SEPA_32', ['price'=> 'von '.$user->payment_order_product->getFormattedPrice().' EUR', 'pay_date'=>Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y')]) }}
                                                <hr>
                                            @endif
                                            <p>{{__('membership.home_copy_last_31', ['days'=>$user->daysActiveAccount()])}}</p>

                                        @endif
                                </div>
                                <div class="card-footer py-3">
                                    <a href="{{route('user_membership')}}" class="btn btn-info mb-3"><i class="ion ion-ios-refresh text-default mr-1"></i> Mitgliedschaft jetzt hier verwalten</a>
                                </div>
                            </div>
                            <!-- / SHOP -->
                        </div>
                    @endif
                @endif

                {{-- <div class="d-flex col-xl-6 align-items-stretch">
                   <!-- Stats + Links -->
                  <div class="card d-flex w-100 mb-4">
                       <div class="row no-gutters row-bordered h-100">
                           <div class="d-flex col-sm-6 col-md-4 col-lg-6 align-items-center">

                               <a href="javascript:void(0)" class="card-body media align-items-center text-body">
                                   <i class="lnr lnr-chart-bars display-4 d-block text-primary"></i>
                                   <span class="media-body d-block ml-3">
                                   <span class="text-big font-weight-bolder">$1,342.11</span><br>
                                   <small class="">Umsatz diesen Monat</small>
                                </span>
                               </a>

                           </div>
                           <div class="d-flex col-sm-6 col-md-4 col-lg-6 align-items-center">

                               <a href="javascript:void(0)" class="card-body media align-items-center text-body">
                                   <i class="lnr lnr-hourglass display-4 d-block text-primary"></i>
                                   <span class="media-body d-block ml-3">
                                       <span class="text-big"><span class="font-weight-bolder">152</span> Working Hours</span><br>
                                       <small class="">Umsatz dieses Jahr</small>
                                   </span>
                               </a>

                           </div>
                           <div class="d-flex col-sm-6 col-md-4 col-lg-6 align-items-center">
                               <a href="javascript:void(0)" class="card-body media align-items-center text-body">
                                   <i class="lnr lnr-checkmark-circle display-4 d-block text-primary"></i>
                                   <span class="media-body d-block ml-3">
                                       <span class="text-big"><span class="font-weight-bolder">54</span> Tasks</span><br>
                                        <small class="">Punkte</small>
                                   </span>
                               </a>

                           </div>
                           <div class="d-flex col-sm-6 col-md-4 col-lg-6 align-items-center">
                               <a href="javascript:void(0)" class="card-body media align-items-center text-body">
                                   <i class="lnr lnr-license display-4 d-block text-primary"></i>
                                   <span class="media-body d-block ml-3">
                                       <span class="text-big"><span class="font-weight-bolder">6</span> Projects</span><br>
                                       <small class="">Verkäufe</small>
                                   </span>
                               </a>

                           </div>
                       </div>
                   </div>
                   <!-- / Stats + Links -->
               </div>   --}}

                <div class="d-flex col-xl-6 align-items-stretch">
                    <!-- SHOP -->
                    <div class="card w-100 mb-4">
                        <h5 class="card-header with-elements">
                            <div class="card-header-title">{{__('Mitgliedschaft') }}</div>
                        </h5>
                        <div class="card-body">

                            @if($user->isActiveAccount() )
                                <div class="badge btn-success p-2">
                                    <i class="ion ion-md-checkmark-circle-outline text-white"></i>
                                    <strong>{{__('Vertriebspartner-Mitgliedschaft aktiv')}}</strong> {{__('bis zum:')}} <strong></strong>{{ $user->getPaymentAccountDateFormat() }}</div>
                            @else
                                <div class="badge badge-danger p-2">
                                    <i class="ion ion-md-close-circle-outline text-white"></i>
                                    <strong>{{__('Vertriebspartner-Account inaktiv')}} </strong>
                                    @if($user->payment_account)
                                        {{__('abgelaufen am')}}: <strong></strong>{{ $user->getPaymentAccountDateFormat() }}
                                    @endif
                                </div>
                            @endif
                            <div class="clearfix mb-2"></div>
                            @if($user->isActiveShop())
                                <div class="badge btn-success p-2">
                                    <i class="ion ion-md-checkmark-circle-outline text-white"></i>
                                    <strong>{{__('Vertriebspartner-Online-Shop aktiv')}}</strong> {{__('bis zum')}}: <strong></strong>{{ $user->getPaymentShopDateFormat() }}</div>
                            @else
                                <div class="badge badge-danger p-2">
                                    <i class="ion ion-md-close-circle-outline text-white"></i>
                                    <strong>{{__('Vertriebspartner-Shop inaktiv')}}</strong>
                                    @if($user->payment_shop)
                                        {{__('abgelaufen am')}}: <strong></strong>{{ $user->getPaymentShopDateFormat() }}
                                    @endif
                                </div>
                            @endif
                        </div>
                        <div class="card-footer py-3">
                            <a href="{{route('user_membership')}}" class="btn btn-secondary"><i class="ion ion-ios-people text-default mr-1"></i>  {{__('Mitgliedschaft verwalten')}}</a>
                        </div>
                    </div>
                    <!-- / SHOP -->

                </div>

                <div class="d-flex col-xl-6 align-items-stretch">
                    <!-- SHOP -->
                    <div class="card w-100 mb-4">
                        <h5 class="card-header with-elements">
                            <div class="card-header-title">{{__('Your Shop') }}</div>
                        </h5>
                        <div class="card-body">

                            @if($user->isActiveAccount())
                                @if($user->isActiveShop())
                                    @if($user->shop)
                                        <p><span class="ion ion-md-checkmark-circle-outline  text-primary"></span>
                                            <strong>{{__('open since')}}</strong> {{__('at')}} {{ $user->shop->getActiveDateFormat() }}</p>
                                        @if($user->shop->active)
                                            <p><span class="ion ion-md-checkmark-circle-outline text-primary"></span>
                                                <strong>{{__('Status')}}</strong> {{ __('active') }}</p>
                                        @else
                                            <p><span class="ion ion-md-close-circle-outline text-danger"></span>
                                                <strong>{{__('Status')}}</strong> {{ __('inactive') }}</p>
                                        @endif
                                    @else
                                        <a href="{{route('user_shop')}}" class="btn btn-secondary">{{__('open your shop')}}</a>
                                    @endif
                                @else
                                    <p><span class="ion ion-md-close-circle-outline  text-danger"></span>
                                        <strong>{{__('Shop nicht gebucht')}}</strong></p>
                                @endif
                            @endif
                        </div>
                        @if($user->isActiveShop())
                        <div class="card-footer py-3">
                            <a href="{{route('user_shop')}}" class="btn btn-secondary"><i class="ion ion-ios-basket text-default mr-1"></i>  {{__('settings your shop')}}</a>
                        </div>
                        @endif
                    </div>
                    <!-- / SHOP -->

                </div>

                <div class="col-xl-5">
                    <!-- Tasks -->
                    <div class="card mb-4">
                        <h5 class="card-header with-elements">
                            <div class="card-header-title">{{__('Activities') }}</div>
                        </h5>
                        <div class="card-body">
                            @if($user->active == 1)
                                @if($user->files->count())
                                    @foreach($user->files()->whereIdentifier('contract')->get() as $file)
                                        <a class="btn btn-secondary btn-block mb-3" href="{{ route('storage_file', [$file->id, 'user']) }}" target="_blank"><i class="ion ion-ios-download text-default mr-1"></i> MIVITA_Vertriebspartnervertrag.pdf</a>
                                        <hr class="mb-3">
                                    @endforeach
                                @endif
                                <p><span class="ion ion-md-checkmark-circle-outline  text-primary"></span>
                                    <strong>{{__('Daten vollständig, freigeschaltet')}}</strong> {{__('at')}}: {{ $user->getActiveDateFormat() }}</p>
                            @endif
                            @if($user->account_id)
                                @if($user->active == 1)
                                    @if($user->agreement)
                                        <p><span class="ion ion-md-checkmark-circle-outline text-primary"></span>
                                            <strong>{{__('Einverständniserklärung')}}</strong> {{__('at')}}: {{ $user->getAgreementFormat() }}
                                        </p>
                                    @else
                                        <p><span class="ion ion-md-close-circle-outline text-danger"></span>
                                            <strong>{{__('Einverständniserklärung')}}</strong> {{ __('nicht akzeptiert') }}</p>
                                    @endif
                                @endif
                                @if($user->account->data_protection)
                                    <p><span class="ion ion-md-checkmark-circle-outline  text-primary"></span>
                                        <strong>{{__('Privacy policy approved')}}</strong> {{__('at')}}: {{ $user->account->getDataProtectionFormat() }}
                                    </p>
                                @endif
                            @endif
                            @if($user->confirmed == 1)
                                <p><span class="ion ion-md-checkmark-circle-outline  text-primary"></span>
                                    <strong>{{__('E-Mail verified')}}</strong> {{__('at')}}: {{ $user->getConfirmationDateFormat() }}</p>
                            @endif
                        </div>
                    </div>
                    <!-- / Tasks -->

                </div>
                <div class="col-xl-7">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="card mb-4">
                                <h5 class="card-header with-elements">
                                    <div class="card-header-title">{{__('Daten') }}</div>
                                </h5>
                                <div class="card-body">
                                    @if($user->active == 1)
                                        <p>{{__('Ändere Deine persönlichen Datan.')}}</p>
                                        <a href="{{ route('user_edit') }}" class="btn btn-secondary"><i class="ion ion-ios-contact text-default mr-1"></i> {{ __('Adjust data') }}</a>
                                    @endif
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6">
                            <div class="card mb-4">
                                <h5 class="card-header with-elements">
                                    <div class="card-header-title">{{ __('Sicherheit') }}</div>
                                </h5>
                                <div class="card-body">
                                    @if($user->active == 1)
                                        @if(!$user->isPasswort())
                                            <p>{{__('Assign a password for your account.')}}</p>
                                            <a href="{{route('user_update_password_first')}}" class="btn btn-submit"><i class="ion ion-ios-lock text-default mr-1"></i>  {{__('Create Password')}}</a>
                                        @else
                                            <p>{{__('Ändere Dein persönliches Passwort.')}}</p>
                                            <a href="{{route('user_update_password')}}" class="btn btn-secondary"><i class="ion ion-ios-lock text-default mr-1"></i>  {{__('Change password')}}</a>
                                        @endif
                                    @endif
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6">
                            <div class="card mb-4">
                                <h5 class="card-header with-elements">
                                    <div class="card-header-title">{{ __('Anmeldung') }}</div>
                                </h5>
                                <div class="card-body">
                                    @if($user->active == 1)
                                        <p>{{__('Ändere Deine E-Mail Adresse.')}}</p>
                                        <a href="{{route('user_update_email')}}" class="btn btn-secondary"><i class="ion ion-ios-mail text-default mr-1"></i> {{__('Change E-Mail')}}</a>
                                    @endif

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

                        <div class="col-md-6">
                            <div class="card mb-4">
                                <h5 class="card-header with-elements">
                                    <div class="card-header-title">{{ __('Logout') }}</div>
                                </h5>
                                <div class="card-body">
                                    <p>Abmelden und bis bald.</p></o>
                                    <a href="{{route('logout')}}" class="btn btn-primary"><i class="ion ion-ios-log-out text-default mr-1"></i> {{ __('Logout') }}</a>
                                </div>
                            </div>
                        </div>

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

            <hr class="container-m-nx mt-0 mb-4">
@endsection
