@extends('backend.layouts.app')

@section('title', @$data['title'])

@section('content')
    {!! breadcrumb([
        'title' => @$data['title'],
        route('admin.dashboard') => _trans('common.Dashboard'),
        '#' => @$data['title'],
    ]) !!}

    <div class="card ot-card">
        <div class="card-body">
            <form method="POST" action="{{ route('user.permission_update', $data['show']->id) }}">
                @csrf
                @method('PATCH')

                <div class="row">
                    <div class="col-lg-12">
                        <div class="permission-data d-flex flex-wrap flex-sm-nowrap align-items-start gap-30">
                            @include('backend.user.employee.permissionTab.menu')
                            
                            <div class="permission-data tab-content" id="v-pills-tabContent">
                                @foreach ($data['permissions'] ?? [] as $attribute => $keywords)
                                    @include('backend.user.employee.permissionTab.permission', ['attribute' => $attribute, 'keywords' => $keywords, 'isFirstItem' => $loop->first ? true : false])
                                @endforeach
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-12">
                    <div class="col-md-12 text-right mt-3 mb-3 mr-5">
                        <div class="form-group d-flex justify-content-end">
                            @if (hasPermission('user_create'))
                                <button type="submit" class="btn btn-gradian">{{ _trans('common.Update') }}</button>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection

@section('script')
    <script src="{{ url('backend/js/pages/__profile.js') }}"></script>

    <script>
        function toggleCheckboxes(attributeId) {
            const isChecked = $('#' + attributeId).prop('checked');
            $('.' + attributeId + '-child').prop('checked', isChecked);
        }
    </script>
@endsection
