@extends('admin/layouts/default')
{{-- Page title --}}
@section('title')
Edit Editor Role
@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 Role</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/editor_role') }}">Assigned Role List</a></li>
        <li class="active">
            Edit Editor Role
        </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">
                    Edit Editor Role
                </h3>
            </div>
            <div class="panel-body">
                <div id="banner" class="panel">
                    @if ($errors->any())
                    @foreach ($errors->all() as $error)
                    <div class="text-danger">{{$error}}</div>
                    @endforeach
                    @endif
                    <div class="panel-body">
                        {!! Form::open(['url'=>'admin/editor_role/update', 'files'=>true]) !!}

                        @csrf()
                        <input type="hidden" name="ebm_id" value="{{$editor->ebm_id}}" />
                        <input type="hidden" name="editor_id" value="{{$editor->editor_id}}" />

                        <div class="form-group col-md-12">
                            <label for="e1" class="control-label">Name: </label>
                            <input type="text" class="form-control" name="name" value="{{$editor->fname.' '.$editor->mname.' '.$editor->lname}}" readonly>
                        </div>

                        <div class="form-group col-md-12">
                            <label class="control-label" for="select21">Journal: <span class="text-danger"> *</span></label>
                            <select class="form-control select2" id="journal_id" name="journal_id" required>
                                <option selected="true" value="" disabled="disabled" hidden>Select Journal</option>
                                @foreach($journal_list as $journal_lists)
                                <option value="{{$journal_lists->journal_id}}}" @if(isset($editor->journal_id) && $editor->journal_id == $journal_lists->journal_id) {{ 'selected' }} @endif>{{$journal_lists->title}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="form-group col-md-4">
                            <label class="control-label" for="select21">Role: <span class="text-danger"> *</span></label>
                            <select class="form-control select2" id="role_id" name="role_id" required onchange="toggleRegionDropdown()">
                                <option selected="true" value="" disabled="disabled" hidden>Select Role</option>
                                @foreach($role_list as $role)
                                <option value="{{$role->role_id}}" @if(isset($editor->ebm_role_id) && $editor->ebm_role_id == $role->role_id) {{ 'selected' }} @endif>{{$role->nicename}}</option>
                                @endforeach
                            </select>
                        </div>

                        <div class="form-group col-md-4" id="regionDropdown" style="display: none;">
                            <label class="control-label" for="select21">Region: <span class="text-danger"> *</span></label>
                            <select class="form-control select2" id="region_id" name="region_id">
                                <option selected="true" value="" disabled="disabled" hidden>Select Region</option>
                                @foreach($region_list as $region)
                                <option value="{{$region->region_id}}" @if(isset($editor->region_id) && $editor->region_id == $region->region_id) {{ 'selected' }} @endif>{{$region->name}}</option>
                                @endforeach
                            </select>
                        </div>
                        
                        <div class="form-group col-md-4" id="sectionInput">
                            <label for="e1" class="control-label">Section: </label>
                            <input type="text" class="form-control" name="section" id="section" value="{{$editor->section}}">
                        </div>

                        <div class="form-group col-md-4" style="margin-top: 30px;">
                            <span><input type="checkbox" name="c_ebm" value="{{$editor->conditional_ebm}}" {{ $editor->conditional_ebm == 'Y' ? 'checked' : null }}> Conditional EBM </span>
                            &nbsp;&nbsp;&nbsp;
                            <span><input type="checkbox" name="executive_ge" value="{{$editor->executive_ge}}" {{ $editor->executive_ge == 'Y' ? 'checked' : null }}> Executive Guest Editor</span>
                        </div>

                        <div class="form-group col-md-12">
                            <label for="e1" class="control-label">Section/Region: </label>
                            <input type="text" class="form-control" name="section_region" value="{{$editor->section_region}}">
                        </div>
                        <div class="form-group col-md-12">
                            <label for="e1" class="control-label">Acceptance Date: </label>
                            <input type="date" class="form-control" name="acceptance_date" value="{{$editor->acceptance_date}}">
                        </div>

                        <div class="form-group col-md-12">
                            <label for="e1" class="control-label">Acceptance Email Text: </label>
                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="acceptance_email">{{$editor->acceptance_email_text}}</textarea>
                        </div>

                        <div class="form-group col-md-12">
                            <label for="e1" class="control-label">Resign/Terminate Date: </label>
                            <input type="date" class="form-control" name="resign_date" value="{{$editor->resign_date}}">
                        </div>

                        <div class="form-group col-md-12">
                            <label for="e1" class="control-label">Rejection/Termination Email Text: </label>
                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="resign_email">{{$editor->resign_email_text}}</textarea>
                        </div>

                        <div class="form-group col-md-6 @if ($errors->has('cv_name')) has-error @endif">
                            <label for="e1" class="control-label">Upload CV: <span class="text-danger"> (Supported Format .doc, .docx, .pdf)</span></label>
                            @if($editor->cv_name == '') <span class="text-info">[No File Uploaded]</span> @else <strong><span class="text-info"> [{{$editor->cv_name}}]</span></strong>
                            @endif
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput">
                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                    <span class="fileinput-filename"></span>
                                </div>
                                <span class="input-group-addon btn btn-default btn-file">
                                    <span class="fileinput-new">Select file</span>
                                    <span class="fileinput-exists">Change</span>
                                    <input type="file" name="cv_name"></span>
                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                            </div>
                        </div>
                        <div class="form-group col-md-6 @if ($errors->has('accept_email')) has-error @endif">
                            <label for="e1" class="control-label">Upload Acceptance Email: <span class="text-danger"> (Supported Format .doc, .docx, .pdf)</span></label>
                            @if($editor->email_accp_name == '') <span class="text-info">[No File Uploaded]</span> @else <strong><span class="text-info"> [{{$editor->email_accp_name}}]</span></strong>
                            @endif
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput">
                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                    <span class="fileinput-filename"></span>
                                </div>
                                <span class="input-group-addon btn btn-default btn-file">
                                    <span class="fileinput-new">Select file</span>
                                    <span class="fileinput-exists">Change</span>
                                    <input type="file" name="accept_email"></span>
                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                            </div>
                        </div>

                        <div class="form-group col-md-6 @if ($errors->has('agreement_form')) has-error @endif">
                            <label for="e1" class="control-label">Upload Agreement Form: <span class="text-danger"> (Supported Format .doc, .docx, .pdf)</span></label>
                            @if($editor->agreement_form_name == '') <span class="text-info">[No File Uploaded]</span> @else <strong><span class="text-info"> [{{$editor->agreement_form_name}}]</span></strong>
                            @endif
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput">
                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                    <span class="fileinput-filename"></span>
                                </div>
                                <span class="input-group-addon btn btn-default btn-file">
                                    <span class="fileinput-new">Select file</span>
                                    <span class="fileinput-exists">Change</span>
                                    <input type="file" name="agreement_form"></span>
                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                            </div>
                        </div>
                        <div class="form-group col-md-6 @if ($errors->has('eic_approval')) has-error @endif">
                            <label for="e1" class="control-label">EIC's Approval: <span class="text-danger"> (Supported Format .doc, .docx, .pdf)</span></label>
                            @if($editor->eic_approval == '') <span class="text-info">[No File Uploaded]</span> @else <strong><span class="text-info"> [{{$editor->eic_approval}}]</span></strong>
                            @endif
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput">
                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                    <span class="fileinput-filename"></span>
                                </div>
                                <span class="input-group-addon btn btn-default btn-file">
                                    <span class="fileinput-new">Select file</span>
                                    <span class="fileinput-exists">Change</span>
                                    <input type="file" name="eic_approval"></span>
                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                            </div>
                        </div>

                        <div class="form-group col-md-12 @if ($errors->has('director_approval')) has-error @endif">
                            <label for="e1" class="control-label">Dr.Sahab Approval: <span class="text-danger"> (Supported Format .doc, .docx, .pdf)</span></label>
                            @if($editor->director_approval == '') <span class="text-info">[No File Uploaded]</span> @else <strong><span class="text-info"> [{{$editor->director_approval}}]</span></strong>
                            @endif
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput">
                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                    <span class="fileinput-filename"></span>
                                </div>
                                <span class="input-group-addon btn btn-default btn-file">
                                    <span class="fileinput-new">Select file</span>
                                    <span class="fileinput-exists">Change</span>
                                    <input type="file" name="director_approval"></span>
                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                            </div>
                        </div>

                        <div class="form-group col-md-6">
                            <label class="control-label" for="select21">Status: <span class="text-danger"> *</span></label>
                            <select class="form-control" name="status" required>
                                <option selected="true" value="" disabled="disabled" hidden>Select Status</option>
                                <option value="active" @if($editor->ebm_status=="active") selected @endif>Active</option>
                                <option value="resign" @if($editor->ebm_status=="resign") selected @endif>Resign</option>
                                <option value="terminate" @if($editor->ebm_status=="terminate") selected @endif>Terminate</option>
                            </select>
                        </div>
                        <div class="form-group col-md-6">
                            <label class="control-label" for="select21">Source: </label>
                            <select class="form-control" name="source">
                                <option selected="true" value="" disabled="disabled" hidden>Select Source</option>
                                <option value="EiC recommendation" @if($editor->source=="EiC recommendation") selected @endif>EIC recommendation</option>
                                <option value="EABM recommendation" @if($editor->source=="EABM recommendation") selected @endif>EABM recommendation</option>
                                <option value="solicitation" @if($editor->source=="solicitation") selected @endif>Solicitation</option>
                                <option value="website" @if($editor->source=="website") selected @endif>Website</option>
                                <option value="marketing" @if($editor->source=="marketing") selected @endif>Marketing</option>
                            </select>
                        </div>

                        <div class="form-group text-center col-md-12">
                            <button class="btn btn-primary text-center" type="submit">Submit</button>
                        </div>
                        {{ Form::close() }}
                    </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>
    $("#journal_id").select2({
        theme: "bootstrap",
        placeholder: "Select Journal",
        width: '100%',
        height: '50px'
    });
    $("#role_id").select2({
        theme: "bootstrap",
        placeholder: "Select Role",
        width: '100%',
        height: '50px'
    });
    $("#region_id").select2({
        theme: "bootstrap",
        placeholder: "Select Region",
        width: '100%',
        height: '50px'
    });
</script>
<script>
    function toggleRegionDropdown() {
        var roleDropdown = document.getElementById("role_id");
        var regionDropdown = document.getElementById("regionDropdown");

        if (roleDropdown.value === "4") {
            regionDropdown.style.display = "block";
        } else {
            regionDropdown.style.display = "none";
        }
    }

    // Initialize the "Region" dropdown when editing a record
    window.onload = function() {
        toggleRegionDropdown();
    };
</script>
@stop