@extends('admin.layouts.main', [
    'scripts' => [
        path_asset('path.backoffice.js_path') . '/view/member/member-list.js'
    ]
])

@section('content')
    <h1>Member List</h1>
    <div id="members">
        @if($canInsert)
            <button type="button" data-toggle="tooltip" data-placement="right" class="btn btn-default command-add list-add-btn" title="{{ Lang::get('backend.new_member') }}">
                <span class="icon glyphicon glyphicon-plus"></span>
            </button>
        @endif
        <div class="list-filters-container">
            <label for="" class="list-filters-label">Filters:</label>
            <div class="list-filters">
                <div class="list-filter">
                    @php
                        $types = [
                            '' => 'Filter by Type',
                            'noType' => 'No Type',
                            'regular' => 'Regular',
                            'associate' => 'Associate',
                        ]
                    @endphp
                    {!! Form::select('type_filter', $types, null, array(
                        'id' => 'type_id_input',
                        'class' => 'form-control' )) !!}
                </div>
                <div class="list-filter">
                    @php
                        $status = [
                            '' => 'Filter by Status',
                            'active' => 'Active',
                            'inactive' => 'Inactive',
                        ]
                    @endphp
                    {!! Form::select('status_filter', $status, null, array(
                        'id' => 'status_id_input',
                        'class' => 'form-control' )) !!}
                </div>
                <div class="list-filter">
                    @php
                        $commEmpty = [
                            0 => 'Filter by Committees',
                        ];
                        $committeesArray = array_merge($commEmpty, $committees);
                    @endphp
                    {!! Form::select('committees_filter', $committeesArray, null, array(
                        'id' => 'committees_id_input',
                        'class' => 'form-control' )) !!}
                </div>
                <div class="list-filter">
                    @php
                        $wgEmpty = [
                            0 => 'Filter by WG / TF',
                        ];
                        $wg = array_merge($wgEmpty, $workGroups);
                    @endphp
                    {!! Form::select('wg_filter', $wg, null, array(
                        'id' => 'wg_id_input',
                        'class' => 'form-control' )) !!}
                </div>
                <div class="list-filter form-group">
                    <div class="form-check">
                        @php
                            $optionsArr = ['id' => 'legal-committee', 'class' => 'form-check-input', 'data-role' => 'legal-committee'];
                        @endphp
                        {{ Form::checkbox('legal_committee', '1', null, $optionsArr) }}
                        <label class="form-check-label" for="legal-committee">
                            Legal Committee
                        </label>
                    </div>
                    <div class="form-check">
                        @php
                            $optionsArr = ['id' => 'legal-opinions', 'class' => 'form-check-input', 'data-role' => 'legal-opinions'];
                        @endphp
                        {{ Form::checkbox('legal_opinions', '1', null, $optionsArr) }}
                        <label class="form-check-label" for="legal-opinions">
                            Legal Opinions
                        </label>
                    </div>
                </div>
                <button type="button" data-toggle="tooltip" class="btn btn-default command-export list-export-btn" title="Export to Excel">
                    <span class="icon glyphicon glyphicon-export"></span>
                </button>
            </div>
        </div>

        <table id="grid" class="table table-condensed table-hover table-striped">
            <thead>
                <tr>
                    <th data-column-id="id" data-type="numeric" data-identifier="true">ID</th>
                    <th data-column-id="name" data-order="asc">Company Name</th>
                    <th data-column-id="country" data-sortable="false">Country</th>
                    <th data-column-id="created_at" data-order="asc">Date created</th>
                    <th data-column-id="notes" data-sortable="false">Notes</th>
                    <th data-column-id="committees" data-sortable="false">Com / TF / WG</th>
                    <th data-column-id="users" data-formatter="users" data-type="numeric" data-sortable="false">Users</th>
                    <th data-column-id="state" data-sortable="false">State</th>
                    <th data-column-id="types" data-sortable="false">Types</th>
                    <th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ trans('backend.actions') }}</th>
                </tr>
            </thead>
        </table>
    </div>
    <script>
        $(function() {
            var manageMembersView = new Eae.View.BackendMemberList({
                el : $('#members'),
                userId : {{ $loggedUser->id }},
                canInsert: 'true'
            });
        });
    </script>
@stop
