@extends('admin/layouts/default')
{{-- Page title --}}
@section('title')
Edit Editor
@parent
@stop
{{-- page level styles --}}
@section('header_styles')
@include('admin.layouts.css')
<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')
<section class="content-header">
    <!--section starts-->
    <h1>Edit Editor</h1>
    <ol class="breadcrumb">
        <li>
            <a href="{{ route('admin.dashboard') }}">
                <i class="livicon" data-name="home" data-size="14" data-loop="true"></i>
                Dashboard
            </a>
        </li>
        <li><a href="{{ URL::to('admin/editorial_board_member') }}">Editorial Board Member List</a></li>
        <li class="active">
            Edit Editor
        </li>
    </ol>
</section>
<!--section ends-->
<section class="content paddingleft_right15">
    <!--main content-->
    <div class="row">
        <div class="panel panel-primary ">
            <div class="panel-heading">
                <h3 class="panel-title">
                    Editor Form
                </h3>
            </div>
            <div class="panel-body">
                <div id="banner" class="panel">
                    <div class="panel-body">
                        <form name="first" method="post" action="{{ route('editorial_board_member.update',$editor->editor_id) }}" enctype="multipart/form-data">@method('PUT')
                            <input type="hidden" name="_token" value="<?= csrf_token() ?>">
                            <input type="hidden" class="form-control" name="verification_id" value="{{$verification_id}}">

                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">First Name: </label>
                                <input type="text" class="form-control" name="fname" value="{{$editor->fname}}">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Middle Name: </label>
                                <input type="text" class="form-control" name="mname" value="{{$editor->mname}}">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Last Name: </label>
                                <input type="text" class="form-control" name="lname" value="{{$editor->lname}}">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Degree: </label>
                                <input type="text" class="form-control" name="degree" value="{{$editor->degree}}">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Title: </label>
                                <input type="text" class="form-control" name="titles" value="{{$editor->titles}}">
                            </div>

                            <div class="form-group col-md-6">
                                <label class="control-label" for="select21">Salutation: </label>
                                <select class="form-control select2" name="salutation">
                                    <option selected="true" value="" disabled="disabled" hidden>Select Salutation</option>
                                    <option value="dr" @if($editor->salutation=="dr") selected @endif>Dr.</option>
                                    <option value="prof" @if($editor->salutation=="prof") selected @endif>Prof.</option>
                                    <option value="mr" @if($editor->salutation=="mr") selected @endif>Mr.</option>
                                    <option value="mrs" @if($editor->salutation=="mrs") selected @endif>Mrs.</option>
                                    <option value="sir" @if($editor->salutation=="sir") selected @endif>Sir.</option>
                                </select>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="control-label" for="select21">Suffix: </label>
                                <select class="form-control select2" name="suffix">
                                    <option selected="true" value="" disabled="disabled" hidden>Select Suffix</option>
                                    <option value="jr" @if($editor->suffix=="jr") selected @endif>Jr.</option>
                                    <option value="sr" @if($editor->suffix=="sr") selected @endif>Sr.</option>
                                </select>
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Institute: </label>
                                <input type="text" class="form-control" name="institute" value="{{$editor->institute}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">University: </label>
                                <input type="text" class="form-control" name="university" value="{{$editor->university}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Pharmaceutical: </label>
                                <input type="text" class="form-control" name="pharmaceutical" value="{{$editor->pharmaceutical}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Other (if company): </label>
                                <input type="text" class="form-control" name="company" value="{{$editor->company}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Department: </label>
                                <input type="text" class="form-control" name="department" value="{{$editor->department}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Laboratory: </label>
                                <input type="text" class="form-control" name="laboratory" value="{{$editor->laboratory}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Library: </label>
                                <input type="text" class="form-control" name="library" value="{{$editor->library}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Field of Expertise <span class="text-danger">(Comma Seprated)</span> </label>
                                <input type="text" class="form-control" name="expertise" value="{{$editor->expertise}}">
                            </div>

                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">H-Index: </label>
                                <input type="text" class="form-control" name="h_index" value="{{$editor->h_index}}">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Orcid ID: </label>
                                <input type="text" class="form-control" name="orcid_id" value="{{$editor->orcid_id}}">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Researcher ID: </label>
                                <input type="text" class="form-control" name="researcher_id" value="{{$editor->researcher_id}}">
                            </div>

                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Research Gate: </label>
                                <input type="text" class="form-control" name="research_gate" value="{{$editor->research_gate}}">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Google Scholar: </label>
                                <input type="text" class="form-control" name="google_scholar" value="{{$editor->google_scholar}}">
                            </div>
                            <div class="form-group col-md-4">
                                <label for="e1" class="control-label">Scopus ID: </label>
                                <input type="text" class="form-control" name="scopus_id" value="{{$editor->scopus_id}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Address: </label>
                                <input type="text" class="form-control" name="address" value="{{$editor->address}}">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Email:<span class="text-danger"> *</span></label>
                                <input type="email" class="form-control" name="email" value="{{$editor->email}}" required>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Alt Email: <span class="text-danger">* (e.g:- email1, email2)</span></label>
                                <input type="text" class="form-control" name="alt_email" value="{{$editor->alt_email}}">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Postal Code: </label>
                                <input type="text" class="form-control" name="zip_code" value="{{$editor->zip_code}}">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">City: </label>
                                <input type="text" class="form-control" name="city" value="{{$editor->city}}">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Country: </label>
                                <select class="form-control select2" id="country-list" name="country" onchange="getCity(this.value);">
                                    <option selected="true" value="" disabled="disabled" hidden>Select Country</option>
                                    @foreach($country_list as $country)
                                    <option value="{{$country->printable_name}}" @if($country->printable_name==$editor->country) selected @endif>{{$country->printable_name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">State: </label>
                                <input type="text" class="form-control" name="state" value="{{$editor->state}}">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">City: </label>
                                <select class="form-control" id="city_list" name="editor_city" onchange="getInstitute(this.value);">
                                    <option selected="true" value="" disabled="disabled" hidden></option>
                                </select>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="e1" class="control-label">Institute: </label>
                                <select class="form-control" name="institution_id" id="institute_list" onload="getSaveCityAndInstitute();">
                                    <option selected="true" value="" disabled="disabled" hidden></option>
                                </select>
                            </div>

                            <div class="form-group col-md-3">
                                <label for="e1" class="control-label">Phone No: </label>
                                <input type="text" class="form-control" name="phone" value="{{$editor->phone}}">
                            </div>
                            <div class="form-group col-md-3">
                                <label for="e1" class="control-label">Mobile No: </label>
                                <input type="text" class="form-control" name="mobile" value="{{$editor->mobile}}">
                            </div>
                            <div class="form-group col-md-3">
                                <label for="e1" class="control-label">We Chat No: </label>
                                <input type="text" class="form-control" name="we_chat_number" value="{{$editor->we_chat_number}}">
                            </div>
                            <div class="form-group col-md-3">
                                <label for="e1" class="control-label">Fax: </label>
                                <input type="text" class="form-control" name="fax" value="{{$editor->fax}}">
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Website: </label>
                                <input type="text" class="form-control" name="url" value="{{$editor->url}}">
                            </div>

                            <div class="form-group col-md-12 row" style="margin-bottom: 0px;">
                                <label for="pic" class="control-label col-sm-4">Profile Picture: </label>
                                <div class="fileinput fileinput-new col-sm-8" data-provides="fileinput" style="margin-bottom: 0px;">
                                    <div class="fileinput-new thumbnail" style="width: 150px; height: 150px;">
                                        @if(isset($editor->profile_pic))
                                        <img src="{{DisplayImage(config('constants.admin.ebm_root_path').'ebm_pic/'.$editor->profile_pic)}}" class="img-responsive" />
                                        @else
                                        <img src="http://placehold.it/200x200" alt="profile pic">
                                        @endif
                                    </div>
                                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 150px; max-height: 150px;"></div>
                                    <div>
                                        <span class="btn btn-default btn-file">
                                            <span class="fileinput-new">Select image</span>
                                            <span class="fileinput-exists">Change</span>
                                            <input type="file" id="profile_pic" name="profile_pic" @if(!isset($editor->profile_pic)) @endif value="{{ old('profile_pic',isset($editor->profile_pic) ? $editor->profile_pic : '') }}">
                                        </span>
                                        <a href="#" class="btn btn-danger fileinput-exists" data-dismiss="fileinput">Remove</a>
                                    </div>
                                    @if(isset($editor->profile_pic) && $editor->profile_pic != '')
                                    <p class="m-t-10" style="margin-bottom: 0px;"><strong> {{$editor->profile_pic}}</strong></p>
                                    @endif
                                </div>
                            </div>

                            <div class="form-group col-md-12">
                                <label for="e1" class="control-label">Web Format: </label>
                                <textarea class="textarea editor-cls" placeholder="Place some text here" name="web_format">
                                    @if(!empty($editor->web_format))
                                    {{$editor->web_format}}
                                    @endif
                                </textarea>
                            </div>

                            <div class="form-group text-center col-md-12">
                                <button class="btn btn-primary text-center m-r-10" type="submit">Update</button>
                                <button class="btn btn-secondary" type="button" onclick="window.history.back();">Cancel</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    <!--main content ends-->
</section>
<!-- content -->
@stop

{{-- page level scripts --}}
@section('footer_scripts')
@include('admin.layouts.js')
<script src="{!! asset('assets/vendors/select2/js/select2.js') !!}"></script>
<script src="{!! asset('js/filter.js') !!}"></script>
<script>
    $("#country-list").select2({
        theme: "bootstrap",
        placeholder: "Select Country",
        width: '100%',
        height: '50px'
    });
</script>
<script>
    window.onload = function getSaveCityAndInstitute() {
        var country_name = $('#country-list').val();
        var city_name = "<?= $editor_city ?>";

        $.ajax({
            url: "{{ url('/get_city') }}" + '/' + country_name + '/' + city_name,
            method: "GET",
            success: function(data) {
                $('#city_list').html(data.output);

            }
        });

        var institute_name = "<?= $editor_institute_name ?>";

        $.ajax({
            url: "{{ url('/get_institute') }}" + '/' + country_name + '/' + city_name + '/' + institute_name,
            method: "GET",
            success: function(data) {
                $('#institute_list').html(data.output);
            }
        });

    }

    function getCity(country_name) {
        $.ajax({
            url: "{{ url('/get_city') }}" + '/' + country_name,
            type: "GET",
            success: function(data) {
                $('#city_list').html(data.output);
                $('#institute_list').html('<option value="0">Select Institute</option>');
            }
        });

    }

    function getInstitute(city_names) {
        var country_name = $('#country-list').val();
        var city_name = city_names;

        $.ajax({
            url: "{{ url('/get_institute') }}" + '/' + country_name + '/' + city_name,
            method: "GET",
            success: function(data) {
                $('#institute_list').html(data.output);

            }
        });

    }
</script>
@stop