@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
Editorial Board Member
@parent
@stop

{{-- page level styles --}}
@section('header_styles')
<link href="{{ asset('assets/css/pages/tables.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('assets/vendors/select2/css/select2.min.css') }}" type="text/css" rel="stylesheet">
<link href="{{ asset('assets/vendors/select2/css/select2-bootstrap.css') }}" rel="stylesheet">
<!-- end of page level css-->
@stop

{{-- Page content --}}
@section('content')
<style>
    .ebm_dropdown.open .dropdown-menu {
        height: auto !important;
        display: block;
        background: white !important;
    }

    .ebm_dropdown .dropdown-menu li a,
    .ebm_dropdown .dropdown-menu li button {
        background: #434343 !important;
        border-bottom: 1px dashed #d2d2d2;
        color: #fff;
        width: 100%;
        text-align: left;
        font-weight: bold;
        font-size: 16px;
        padding: 8px 16px;
        transition: .3s all ease-in-out;
    }
    .ebm_dropdown .dropdown-menu li a:hover, .ebm_dropdown .dropdown-menu li button:hover{
        background-color: #000 !important;
    }
    .ebm_dropdown .border-bottom-custom{
        border-bottom: 3px solid #fff !important;
    }
</style>
<section class="content-header">
    <!--section starts-->
    <h1>Editorial Board Member</h1>
    <ol class="breadcrumb">
        <li>
            <a href="{{ route('admin.dashboard') }}">
                <i class="livicon" data-name="home" data-size="18" data-loop="true"></i>
                Dashboard
            </a>
        </li>
        <li class="active">Editorial Board Member List</li>
    </ol>
</section>
<!--section ends-->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="portlet box primary">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="livicon" data-name="responsive" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                        Editorial Board Member List
                    </div>
                    @if($createPermission)
                    <a class="btn btn-sm btn-default button-alignment pull-right mb-1" title="Add New Editor" href="{{ route('editorial_board_member.create') }}"><span class="glyphicon glyphicon-plus"></span> New</a>
                    @endif
                </div>
                <div class="portlet-body table-responsive">
                    @if ($message = Session::get('success'))
                    <div class="alert alert-success alert-dismissable">
                        <p>{{ $message }}</p>
                    </div>
                    @endif
                    @if ($message = Session::get('error'))
                    <div class="alert alert-danger alert-dismissable">
                        <p>{{ $message }}</p>
                    </div>
                    @endif
                </div>

                <div class="portlet-body table-responsive" style="min-height:80vh;">
                    <form action="{{ route('editorial_board_member.index') }}" method="Get" id="article_frm" enctype="multipart/form-data">

                        <div class="form-row">
                            <div class="form-group col-md-12">
                                <label class="control-label" for="select21">Journal:</label>
                                <select class="form-control select2" id="journal_id" name="journal_id">
                                    <option selected="true" value="" disabled="disabled" hidden>Select Journal</option>
                                    @foreach($journal_search as $journal_lists)
                                    <option value="{{$journal_lists->journal_id}}" @isset($param) @if($param['journal_id']==$journal_lists->journal_id) selected @endif @endisset>{{$journal_lists->title}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group col-md-6">
                                <label class="control-label" for="select21">Country:</label>
                                <select class="form-control select2" id="country_id" name="country_id">
                                    <option selected="true" value="" disabled="disabled" hidden>Select Country</option>
                                    @foreach($country_search as $country)
                                    <option value="{{$country->printable_name}}" @isset($param) @if($param['country']==$country->printable_name) selected @endif @endisset>{{$country->printable_name}}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="form-group col-md-6">
                                <label class="control-label" for="select21">Role:</label>
                                <select class="form-control select2" id="role_id" name="role_id">
                                    <option selected="true" value="" disabled="disabled" hidden>Select Role</option>
                                    @foreach($ebm_role_search as $ebm)
                                    <option value="{{$ebm->role_id}}" @isset($param) @if($param['role_id']==$ebm->role_id) selected @endif @endisset>{{$ebm->nicename}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group col-md-4">
                                <label class="control-label" for="select21">Name:</label>
                                <input type="text" name="name" class="form-control" placeholder="Search by Name..." value="{{$param['name']}}" />
                            </div>

                            <div class="form-group col-md-4">
                                <label class="control-label" for="select21">Email:</label>
                                <input type="text" name="email" class="form-control" placeholder="Search by Email..." value="{{$param['email']}}" />
                            </div>

                            <div class="form-group col-md-4">
                                <label class="control-label" for="select21">Keyword:</label>
                                <input type="text" name="keyword" class="form-control" placeholder="Search by keyword..." value="{{$param['keyword']}}" />
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group col-md-12">
                                <button type="submit" class="btn btn-primary" name="frm_search" value="true">
                                    <span class="glyphicon glyphicon-search"></span> Search
                                </button>
                                <a href="{{route('editorial_board_member.index')}}" class="btn btn-default">
                                    <span class="glyphicon glyphicon-repeat"></span>&nbsp;Reset</a>
                                <button type="submit" class="btn btn-success float-right" name="export" value="true">
                                    <span class="glyphicon glyphicon-export"></span> Export
                                </button>
                            </div>
                        </div>

                    </form>
                    <table class="table table-striped table-bordered">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Degree</th>
                                <th>Titles</th>
                                <th>Email</th>
                                <th>H-Index</th>
                                <th>City</th>
                                <th>Country</th>
                                <th>Phone</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (count($editors_list) > 0)
                            @foreach ($editors_list as $editor)
                            <tr>
                                <td>{{$editor->fname.' '.$editor->mname.' '.$editor->lname}}</td>
                                <td>{{$editor->degree}}</td>
                                <td>{{$editor->titles}}</td>
                                <td>{{$editor->email}}</td>
                                <td>{{$editor->h_index}}</td>
                                <td>{{$editor->city}}</td>
                                <td>{{$editor->country}}</td>
                                <td>{{$editor->phone}}</td>
                                <td>
                                    @if ($editor->status == "A")
                                    <span class="label label-success">{{"Active"}}</span>
                                    @elseif ($editor->status == "B")
                                    <span class="label label-danger">{{"Block"}}</span>
                                    @endif
                                </td>
                                <td>
                                    <div class="dropup ebm_dropdown">
                                        <button class="btn btn-info dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            Select Action
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
                                            <li>
                                                <a href="{{ route('editorial_board_member.edit',$editor->editor_id) }}">Edit Editor</a>
                                            </li>
                                            <li>
                                                <a href="#" type="button" title="Delete Editor" data-toggle="modal" data-target="#{{$editor->editor_id}}">Delete Editor</a>
                                            </li>

                                            {{ Form::open(array('url' => 'admin/editor_role/add')) }}
                                            @csrf()
                                            <li>
                                                <input type="hidden" name="editor_id" value="{{$editor->editor_id}}" />
                                                <input type="hidden" name="name" value="{{$editor->fname.' '.$editor->mname.' '.$editor->lname}}" />

                                                <button class="" style="background-color:#009688;" title="Assign Role" type="submit" name="btn_add">
                                                    Assign Role
                                                </button>
                                            </li>
                                            {{ Form::close() }}

                                            {{ Form::open(array('url' => 'admin/editor_role/list')) }}
                                            @csrf()
                                            <li>
                                                <input type="hidden" name="editor_id" value="{{$editor->editor_id}}" />
                                                <button class="border-bottom-custom" title="Assigned Role List">
                                                    Assigned Role List
                                                </button>
                                            </li>
                                            {{ Form::close() }}

                                            {{ Form::open(array('url' => 'admin/editor_role/toggle-status')) }}
                                            @csrf()

                                            <input type="hidden" name="editor_id" value="{{$editor->editor_id}}" />
                                            <li>
                                                <button class="" title="Active" type="submit" name="toggle" value="active">
                                                    Active
                                                </button>
                                            </li>
                                            <li>
                                                <button type="submit" class="" title="Block" name="toggle" value="block">
                                                    Block
                                                </button>
                                            </li>
                                            {{ Form::close() }}
                                        </ul>
                                    </div>

                                    <!-- Modal -->
                                    <div class="modal fade" id="{{$editor->editor_id}}" role="dialog">
                                        <div class="modal-dialog">

                                            <!-- Modal content-->
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h3 class="modal-title text-danger">Confirmation</h3>
                                                </div>
                                                <div class="modal-body">
                                                    <p><strong>Are you sure you want to delete this editor?</strong></p>
                                                </div>
                                                <div class="modal-footer">
                                                    {{ Form::open([ 'method'  => 'delete', 'route' => [ 'editorial_board_member.destroy', $editor->editor_id] ]) }}
                                                    {{ Form::hidden('id', $editor->editor_id) }}
                                                    {{ Form::submit('Delete', ['class' => 'btn btn-danger']) }}
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                    {{ Form::close() }}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- End Modal -->
                                    
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="10">
                                    <center>Empty</center>
                                </td>
                            </tr>
                            @endif
                        </tbody>
                    </table>
                    @if (count($editors_list) > 0)
                    <center>{{ $editors_list->appends(request()->input())->links() }}</center>
                    @endif
                </div>
            </div>
        </div>
    </div>
</section>

@stop
{{-- page level scripts --}}
@section('footer_scripts')
<script src="{!! asset('assets/vendors/select2/js/select2.js') !!}"></script>
<script src="{!! asset('js/filter.js') !!}"></script>
<script>
    $("#journal_id").select2({
        theme: "bootstrap",
        placeholder: "Select Journal",
        width: '100%',
        height: '50px'
    });
    $("#country_id").select2({
        theme: "bootstrap",
        placeholder: "Select Country",
        width: '100%',
        height: '50px'
    });
    $("#role_id").select2({
        theme: "bootstrap",
        placeholder: "Select Role",
        width: '100%',
        height: '50px'
    });
</script>
@stop