@extends('admin.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? '' }}</h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
            @if($provider ?? ''  && $provider->id)
                @method('PUT')
            @endif
            @CSRF

            <ul class="nav nav-tabs col-12" role="tablist">
                <li class="nav-item">
                    <a class="nav-link active" data-toggle="tab" href="#personal_info">{{ __('providers.personal_info') }}</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" data-toggle="tab" href="#badges">{{ __('providers.badges') }}</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" data-toggle="tab" href="#stats">{{ __('providers.stats') }}</a>
                </li>
            </ul>
              
            <!-- Tab panes -->
            <div class="tab-content col-12">
                <div class="tab-pane col-12 pt-5 active" id="personal_info">
                    <div class="row col-lg-12">
                        <div class="form-group col">
                            <label>{{ __('providers.name') }} </label>
                            <input type="text" class="form-control {{ $errors->has('name') ? 'is-invalid' : '' }}" name="name" placeholder="{{ __('providers.name') }}" value='{{ old("name", $provider->name ?? "") }}'/>
                        </div>

                        <div class="form-group col">
                            <label>{{ __('providers.email') }} </label>
                            <input type="text"  class="form-control {{ $errors->has('email') ? 'is-invalid' : '' }}" name="email" placeholder="{{ __('providers.email') }}" value='{{ old("email", $provider->email ?? null) }}'/>
                        </div>

                        <div class="form-group col">
                            <label>{{ __('providers.phone') }} </label>
                            <div class="input-group">
                                <input type="text" class="form-control {{ $errors->has('phone') ? 'is-invalid' : '' }}" name="phone" placeholder="{{ __('providers.phone') }}" value='{{ old("phone", $provider->phone ?? "") }}'/>
                            </div>
                        </div>
                    </div>

                    <div class="row col-lg-12">
                        <div class="form-group col">
                            <label>{{ __('providers.password') }} </label>
                            <input type="password" class="form-control {{ $errors->has('password') ? 'is-invalid' : '' }}" name="password" placeholder="{{ __('providers.password') }}" value='{{ old("password", "") }}'/>
                        </div>

                        <div class="form-group col">
                            <label>{{ __('providers.password_confirmation') }} </label>
                            <input type="password" class="form-control {{ $errors->has('password_confirmation') ? 'is-invalid' : '' }}" name="password_confirmation" placeholder="{{ __('providers.password_confirmation') }}" value='{{ old("password_confirmation", "") }}'/>
                        </div>
                    </div>
                    <div class="row col-lg-12">
                        <div class="form-group col">
                            <label>{{ __('providers.status') }} </label>
                            <select name="status" id="status" class="form-control">
                                @foreach (__('providers.statuses') as $status=>$label)
                                <option value="{{ $status }}" {{ $status == old("status", $provider->providerProfile->status ?? '') ? 'selected' : '' }}>{{ $label  }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="form-group col">
                            <label>{{ __('providers.photo') }} </label>
                            <input type="file" class="form-control {{ $errors->has('photo') ? 'is-invalid' : '' }}" name="photo" placeholder="{{ __('providers.photo') }}" value='{{ old('photo', '') }}' accept="image/*"/>
                            @if (($provider->photo ?? null) && ($provider->photo_url ?? null))
                                <a href="{{ $provider->photo_url }}" class="btn btn-primary" target="_new"><i class="fas fa-download"></i></a>
                            @endif
                        </div>
                    </div>
                </div>
                {{--  --}}
                <div class="tab-pane col-12 pt-5" id="badges">
                    <div class="custom-control custom-switch">
                        <input type="checkbox" class="custom-control-input" id="is_top" name="is_top" {{ old('is_top', $provider->providerProfile->is_top ?? 0) ? 'checked' : '' }}>
                        <label class="custom-control-label" for="is_top">{{ __('providers.badges_labels.top') }}</label>
                    </div>
                    <div class="custom-control custom-switch">
                        <input type="checkbox" class="custom-control-input" id="is_reliable" name="is_reliable" {{ old('is_reliable', $provider->providerProfile->is_reliable ?? 0) ? 'checked' : '' }}>
                        <label class="custom-control-label" for="is_reliable">{{ __('providers.badges_labels.reliable') }}</label>
                    </div>
                    <div class="custom-control custom-switch">
                        <input type="checkbox" class="custom-control-input" id="is_most_active" {{  $provider->is_most_active ?? 0 ? 'checked' : '' }} @disabled(true)>
                        <label class="custom-control-label" for="is_most_active">{{ __('providers.badges_labels.most_active_user_units_month') }}</label>
                    </div>
                </div>
                {{--  --}}

                <div class="tab-pane col-12 pt-5" id="stats">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>{{ __('providers.total_units') }}</th>
                                <th>{{ __('providers.total_sold_units') }}</th>
                                <th>{{ __('providers.total_visits') }}</th>
                            </tr>
                        </thead>
                        <tr>
                            <th>{{ $provider->total_units ?? 0 }}</th>
                            <th>{{ $provider->total_sold ?? 0 }}</th>
                            <th>{{ $provider->total_units_visits ?? 0 }}</th>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="text-center mt-5 col-12">
                <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
            </div>
        </form>
    </div>

@endsection


@section('inner_js')
@endsection