@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
Add New Journal
@parent
@stop

{{-- page level styles --}}
@section('header_styles')
     @include('admin.layouts.css')
<link rel="stylesheet" href="{{ asset('assets/vendors/bootstrap-tagsinput/css/bootstrap-tagsinput.css') }}" />
<link rel="stylesheet" href="{{ asset('assets/vendors/bootstrap-tagsinput/css/app.css') }}" />
<script type="text/javascript" src="{!! asset('js/angular.js') !!}"></script>

<link href="{{ asset('assets/vendors/bootstrap3-wysihtml5-bower/css/bootstrap3-wysihtml5.min.css')}}" rel="stylesheet" media="screen" />
<link href="{{ asset('css/pages/editor.css') }}" rel="stylesheet" type="text/css" />


<script>

    var MAMP = MAMP || {};
    MAMP.Subapp = MAMP.Subapp || {};

    MAMP.Subapp.Admin = angular.module('MAMP.Subapp.Admin', []);

    MAMP.Subapp.Admin.config(function($interpolateProvider) 
    {
        $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
    });

</script>

@stop

{{-- Page content --}}
@section('content')
<section class="content-header">
                <!--section starts-->
                @if(isset($selected_journal->journal_id))<h1>Update Journal</h1>
                @else <h1>Add New Journal</h1>
                @endif
                <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/journals') }}">Journal List</a></li>
                    <li class="active">@if(isset($selected_journal->journal_id))Update Journal
                                        @else Add New Journal
                                        @endif
                    </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">
                    <i class="livicon" data-name="gear" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                    Options
                </h3>
                <!-- <span class="pull-right clickable">
                    <i class="glyphicon glyphicon-chevron-up"></i>
                </span> -->
            </div>
            <div class="panel-body">
                @if(isset($selected_journal->journal_id))
                <form name="first" method="post" action="{{ route('journals.update',$selected_journal->journal_id) }}" enctype="multipart/form-data"> @method('PUT')
                  <input type="hidden" name="journal_id" id="journal_id" value="{{$selected_journal->journal_id}}">
                  <input type="hidden" name="journal_nid" value="{{$selected_journal->nid}}">
                @else    
                <form name="first" method="post" action="{{ route('journals.store') }}" enctype="multipart/form-data">
                @endif
                    <input type="hidden" name="_token" value="<?=csrf_token()?>">
             @if ($errors->any())
                <div class="row">
                    <div class="col-md-9 col-lg-offset-3 col-md-offset-3 pd-r lert alert-danger">
                        <strong>Whoops!</strong> There were some problems with your input.<br>
                        <ul>
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                </div>
                @endif                    
                <div class="row acc-wizard">
                    <div class="col-md-3 pd-2">
                        <p class="mar-2">
                            Follow the steps below to add new journal.
                        </p>
                        <ol class="acc-wizard-sidebar">
                            <li class="acc-wizard-todo">
                                <a href="#journal">Journal</a>
                            </li>
                            @if(isset($selected_journal->journal_rental) &&  $selected_journal->journal_rental== 'Y')
                            <li class="acc-wizard-todo">
                                <a href="#rental">Journal  Rental</a>
                            </li>
                            @endif
                            <li class="acc-wizard-todo">
                                <a href="#management">Journal Management</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#socialmedialink">Social Media Links</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#meta">Meta Tags</a>
                            </li>
                            @if(!empty($selected_journal))
                            <li class="acc-wizard-todo">
                                <a href="#multi_lang">Multi-Language(s)</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#journal_section">Journal Section(s)</a>
                            </li>
                            @endif
                       </ol>
                    </div>
                    <div class="col-md-9 pd-r">
                        <div id="accordion-demo" class="panel-group" ng-app="MAMP.Subapp.Admin">

                            <!-- /.panel.panel-default -->
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#journal" data-parent="#accordion-demo" data-toggle="collapse">Journal</a>
                                    </h4>
                                </div>
                                <div id="journal" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <div class="form-group {{ $errors->first('pic_file', 'has-error') }}">
                                            <label for="pic" class="col-sm-4 control-label">Cover Image</label>
                                            <div class="col-sm-8">
                                                <div class="fileinput fileinput-new" data-provides="fileinput">
                                                    <div class="fileinput-new thumbnail" style="width: 150px; height: 150px;">
                                                    @if(isset($selected_journal->image_file_name) && (file_exists(config('constants.admin.root_path').'JOURNALS/BEN/'.$selected_journal->subtitle.'/'.$selected_journal->image_file_name)))

                                                        <img src="{{DisplayImage(config('constants.admin.root_path').'JOURNALS/BEN/'.$selected_journal->subtitle.'/'.$selected_journal->image_file_name)}}" 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="image_file_name" name="image_file_name" @if(!isset($selected_journal->image_file_name)) required="required" @endif value="{{ old('image_file_name',isset($selected_journal->image_file_name) ? $selected_journal->image_file_name : '') }}">
                                </span>
                                                        <a href="#" class="btn btn-danger fileinput-exists"
                                                           data-dismiss="fileinput">Remove</a>
                                                    </div>
                                                </div>
                                                <span class="help-block">{{ $errors->first('pic_file', ':message') }}</span>

                                     @if(isset($selected_journal->image_file_name) && $selected_journal->image_file_name != '')
                                        @if(file_exists(config('constants.admin.root_path').'JOURNALS/BEN/'.$selected_journal->subtitle.'/'.$selected_journal->image_file_name)) 
                                            <strong><span> {{$selected_journal->image_file_name}}</span></strong>  
                                            @if($user==1)
                                                <a href="{{ route('DeleteJournalFile', array('id' => $selected_journal->journal_id, 'file_type' => 'image_file_name')) }}">[remove]</a> 
                                            @endif  
                                        @endif
                                    @endif

                                            </div>
                                        </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Publisher</label>
                                                    <select id="e1" class="form-control select2" name="publisher_id">
                                                         @foreach ($publisher as $publisher)
                                                            <option value="{{$publisher->publisher_id}}" @if(old('publisher_id') == $publisher->publisher_id) {{ 'selected' }}
                                                            @elseif(isset($selected_journal->publisher_id) and ($selected_journal->publisher_id == $publisher->publisher_id))) {{ 'selected' }} @endif> {{$publisher->title}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Subject:</label>
                                                    <select id="multiselect4" multiple="multiple" class="form-control" name="subject_id[]">
                                                       @foreach ($subject as $key => $value)
                                                        <option value="{{$key}}" @if (old("subject_id")){{ (in_array($key, old("subject_id")) ? "selected":"") }}
                                                         @elseif(isset($journalsubject) and in_array($key, $journalsubject)) selected @endif>{{$value}}</option>
                                                        @endforeach
                                                    </select>
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('subject_id') }}</span>
                                                    </div>
                                                </div>

                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Indexing:</label>
                                                    <select id="indexing_id" multiple="multiple" class="form-control" name="index_id[]">
                                                       @foreach ($indexing as $key => $value)
                                                        <option value="{{$key}}" @if (old("index_id")){{ (in_array($key, old("index_id")) ? "selected":"") }}
                                                         @elseif(isset($journalindexing) and in_array($key, $journalindexing)) selected @endif>{{$value}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>

                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Disease:</label>
                                                    <select id="multiselect5" multiple="multiple" class="form-control" name="disease_id[]">
                                                         @foreach ($disease as $disease)
                                                            <option value="{{$disease->disease_id}}" @if (old("disease_id")){{ (in_array($disease->disease_id, old("disease_id")) ? "selected":"") }}
                                                         @elseif(isset($journaldisease) and in_array($disease->disease_id, $journaldisease)) selected @endif>{{$disease->disease_name}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Status: *</label>
                                                    <select id="e1" class="form-control select2" name="journal_status">
                                                        <option value="1" @if(old('journal_status') == 1) {{ 'selected' }}
                                                            @elseif(isset($selected_journal->journal_status) and ($selected_journal->journal_status == 1))) {{ 'selected' }} @endif>Continued</option>
                                                        <option value="2"  @if(old('journal_status') == 2) {{ 'selected' }}
                                                            @elseif(isset($selected_journal->journal_status) and ($selected_journal->journal_status == 2))) {{ 'selected' }} @endif>Discontinued</option>
                                                    </select>
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('journal_status') }}</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Journal Type: *</label>
                                                    <select id="e1" class="form-control select2" name="journal_type">
                                                         @foreach ($journal_type as $journal_type)
                                                            <option value="{{$journal_type->journal_type_id}}" @if(old('journal_type') == $journal_type->journal_type_id) {{ 'selected' }}
                                                            @elseif(isset($selected_journal->journal_type) and ($selected_journal->journal_type == $journal_type->journal_type_id))) {{ 'selected' }} @endif>{{$journal_type->type_name}}</option>
                                                        @endforeach
                                                    </select>
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('journal_type') }}</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Is Open Access: *</label>
                                                    <select id="e1" class="form-control select2" name="IsOpenAccess">
                                                            <option value="2" @if(old('IsOpenAccess') == 2) {{ 'selected' }}
                                                            @elseif(isset($selected_journal->IsOpenAccess) and ($selected_journal->IsOpenAccess == 2))) {{ 'selected' }} @endif>No</option>
                                                            <option value="1"  @if(old('IsOpenAccess') == 1) {{ 'selected' }}
                                                            @elseif(isset($selected_journal->IsOpenAccess) and ($selected_journal->IsOpenAccess == 1))) {{ 'selected' }} @endif>Yes</option>
                                                    </select>
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('IsOpenAccess') }}</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Title: *</label>
                                                    <input type="text" name="title" id="title" class="form-control input-md" placeholder="Title" value="{{ old("title", isset($selected_journal->title) ? $selected_journal->title : '') }}">
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('title') }}</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Sub-Title: *</label>
                                                    <input type="text" name="subtitle" id="subtitle" class="form-control input-md" value="{{ old("subtitle", isset($selected_journal->subtitle) ? $selected_journal->subtitle : '') }}" @if(isset($selected_journal->subtitle)) {{'readonly'}} @endif>
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('subtitle') }}</span>
                                                    </div>
                                                </div>
<!--                                                 <div class="form-group">
                                                    <label for="e1" class="control-label">TrendMD Journal ID:</label>
                                                    <input type="text" name="trendmd_id" id="trendmd_id" class="form-control input-md" value="{{ old("trendmd_id", isset($selected_journal->trendmd_id) ? $selected_journal->trendmd_id : '') }}">
                                                </div>
 -->                                                
                                                    <div class="form-group">
                                                    <label for="e1" class="control-label">Journal Email</label>
                                                    <input type="text" name="journal_email" id="journal_email" class="form-control input-md" placeholder="Journal Email" value="{{ old("journal_email", isset($selected_journal->journal_email) ? $selected_journal->journal_email : '') }}">
                                                </div>
                                                    <div class="form-group">
                                                    <label for="e1" class="control-label">DOI</label>
                                                    <input type="text" name="doi" id="doi" class="form-control input-md" placeholder="Journal DOI" maxlength="50" value="{{ old("doi", isset($selected_journal->doi) ? $selected_journal->doi : '') }}">
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Formerly Title</label>
                                                    <textarea class="form-control resize_vertical" id="signature" name="formerly_title" placeholder="Please enter your message here..." rows="5">{{ old("formerly_title", isset($selected_journal->formerly_title) ? $selected_journal->formerly_title : '') }}</textarea>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Impact Factor</label>
                                                    <input type="text" name="org_impact_factor" id="org_impact_factor" class="form-control input-md" placeholder="Impact Factor" value="{{ old("org_impact_factor", isset($selected_journal->org_impact_factor) ? $selected_journal->org_impact_factor : '') }}">
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">ISSN (Print)</label>
                                                    <input type="text" name="issn" id="issn" class="form-control input-md" placeholder="ISSN (Online)" value="{{ old("issn", isset($selected_journal->issn) ? $selected_journal->issn : '') }}">
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">ISSN (Online): *</label>
                                                    <input type="text" name="eissn" id="eissn" class="form-control input-md" value="{{ old("eissn", isset($selected_journal->eissn) ? $selected_journal->eissn : '') }}">
                                                    <div>
                                                        <span class="text-danger">{{ $errors->first('eissn') }}</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Price/Article</label>
                                                    <input type="text" name="price" id="price" class="form-control input-md" placeholder="Price/Article" value="{{ old("price", isset($selected_journal->price) ? $selected_journal->price : '') }}">
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Price/ePub-Article</label>
                                                    <input type="text" name="epub_price" id="epub_price" class="form-control input-md" placeholder="Price/ePub-Article" value="{{ old("epub_price", isset($selected_journal->epub_price) ? $selected_journal->epub_price : '') }}">
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Jounral Rental</label>
                                                    <select id="journal_rental" class="form-control select2" name="journal_rental">
                                                       <option title="NO" value=""        
                                                       @if(old('journal_rental') == "") {{ 'selected' }}
                                                            @elseif(isset($selected_journal->journal_rental) and ($selected_journal->journal_rental == ""))) {{ 'selected' }} @endif>NO</option>
                                                        <option title="YES" value="Y" 
                                                       @if(old('journal_rental') == "Y") {{ 'selected' }}
                                                            @elseif(isset($selected_journal->journal_rental) and ($selected_journal->journal_rental == "Y"))) {{ 'selected' }} @endif>YES</option>
                                                    </select>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Journal Signature:</label>
                                                    <textarea class="form-control resize_vertical" id="signature" name="signature" placeholder="Please enter your message here..." rows="5">{{ old("signature", isset($selected_journal->signature) ? $selected_journal->signature : '') }}</textarea>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Description:</label>
                                                    <textarea class="form-control resize_vertical" id="description" name="description" placeholder="Please enter your message here..." rows="5">{{ old("description", isset($selected_journal->description) ? $selected_journal->description : '') }}</textarea>
                                                </div>
                                            <div class="acc-wizard-step"></div>
                                    </div>
                                    <!--/.panel-body --> </div>
                                <!-- /#adjusthtml --> </div>
                            <!-- /.panel.panel-default -->
                            @if(isset($selected_journal->journal_id))
                            @if(isset($selected_journal->journal_rental) &&  $selected_journal->journal_rental== 'Y')
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a data-parent="#accordion-demo" data-toggle="collapse" href="#rental">Journal Rental</a>
                                    </h4>
                                </div>
                                
                                <div class="panel-collapse collapse" id="rental">
                                {{ Form::open( array('url' => '')) }}       
                                    <div class="panel-body">
                                        @include('admin.journal.rental')
                                    </div>
                                {{ Form::close() }}     
                                </div>
                            </div>
                            @endif

                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#management" data-parent="#accordion-demo" data-toggle="collapse">Journal Management</a>
                                    </h4>
                                </div>
                                <div id="management" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <label for="e1" class="control-label">Editorial Policy:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="editorial_policy" id="editorial_policy">{{ old("editorial_policy", isset($selected_journal->editorial_policy) ? $selected_journal->editorial_policy : '') }}</textarea>
                                        </div>
                                        <label for="e1" class="control-label">Guidlines For Reviewers:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="guideline_for_reviewers">{{ old("guideline_for_reviewers", isset($selected_journal->guideline_for_reviewers) ? $selected_journal->guideline_for_reviewers : '') }}</textarea>
                                        </div>
                                        <label for="e1" class="control-label">IFA:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="ifa">{{ old("ifa", isset($selected_journal->ifa) ? $selected_journal->ifa : '') }}</textarea>
                                        </div>
                                        <label for="e1" class="control-label">Aims &amp; Scope:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="aims_and_scope">{{ old("aims_and_scope", isset($selected_journal->aims_and_scope) ? $selected_journal->aims_and_scope : '') }}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label for="e1" class="control-label">Facebook Like API Code:</label>
                                            <textarea class="form-control resize_vertical" id="facebook_like_api_code" name="facebook_like_api_code" placeholder="Please enter your message here..." rows="5">{{ old("facebook_like_api_code", isset($selected_journal->facebook_like_api_code) ? $selected_journal->facebook_like_api_code : '') }}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label for="e1" class="control-label">JMS Link:</label>
                                            <input type="text" name="jms_link" id="jms_link" class="form-control input-md" value="{{ old("jms_link", isset($selected_journal->jms_link) ? $selected_journal->jms_link : '') }}">
                                        </div>
                                        <div class="form-group">
                                            <label for="e1" class="control-label">Impact Factor:</label>
                                            <textarea class="form-control resize_vertical" id="impact_factor" name="impact_factor" placeholder="Please enter your message here..." rows="5">{{ old("impact_factor", isset($selected_journal->impact_factor) ? $selected_journal->impact_factor : '') }}</textarea>
                                        </div>
                                        <label for="e1" class="control-label">Ranking and Category:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="ranking_and_category">{{ old("ranking_and_category", isset($selected_journal->ranking_and_category) ? $selected_journal->ranking_and_category : '') }}</textarea>
                                        </div>
                                        <label for="e1" class="control-label">EIC Detail:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="eic_detail">{{ old("eic_detail", isset($selected_journal->eic_detail) ? $selected_journal->eic_detail : '') }}</textarea>
                                        </div>

                                        <div class="form-group">
                                            <label class="control-label">Flyer Link:</label>

                                        @isset($selected_journal->flyer_link) @if($selected_journal->flyer_link == '') <span class="text-danger">No File Uploaded</span> @else <strong><span> {{$selected_journal->flyer_link}}</span></strong> 
                                            @if($user==1)
                                                <a href="{{ route('DeleteJournalFile', array('id' => $selected_journal->journal_id, 'file_type' => 'flyer_link')) }}">[remove]</a> 
                                            @endif  
                                        @endif @endisset
                                        
                                            <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="flyer_link"></span>
                                                    
                                                <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                                            </div>
                                            <p>E.g: filename.pdf</p>
                                        </div>


                                        <div class="form-group">
                                            <label for="e1" class="control-label">Jounal Banner:</label>
                                            <textarea class="form-control resize_vertical" id="journal_banner" name="journal_banner" placeholder="Please enter your message here..." rows="5">{{ old("journal_banner", isset($selected_journal->journal_banner) ? $selected_journal->journal_banner : '') }}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label for="e1" class="control-label">Left Panel:</label>
                                            <textarea class="form-control resize_vertical" id="left_panel" name="left_panel" placeholder="Please enter your message here..." rows="5">{{ old("left_panel", isset($selected_journal->left_panel) ? $selected_journal->left_panel : '') }}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label for="e1" class="control-label">Right Panel:</label>
                                            <textarea class="form-control resize_vertical" id="right_panel" name="right_panel" placeholder="Please enter your message here..." rows="5">{{ old("right_panel", isset($selected_journal->right_panel) ? $selected_journal->right_panel : '') }}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label for="e1" class="control-label">Journal Submenus:</label>
                                            <textarea class="form-control resize_vertical" id="journal_submenus" name="journal_submenus" placeholder="Please enter your message here..." rows="5">{{ old("journal_submenus", isset($selected_journal->journal_submenus) ? $selected_journal->journal_submenus : '') }}</textarea>
                                        </div>
                                    <div class="acc-wizard-step"></div>
                                    </div>
                                </div>
      <!-- /#adjusthtml --> </div>
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#socialmedialink" data-parent="#accordion-demo" data-toggle="collapse">Social Media Page Link</a>
                                    </h4>
                                </div>
                                <div id="socialmedialink" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <label for="e1" class="control-label">Source Name:</label>
                                        <div class='box-body box_content'>
                                            <input type="text" name="sourcename" id="sourcename" class="form-control input-md" placeholder="Source Name" value="">

                                        </div>
                                        <label for="e1" class="control-label">External Link:</label>
                                        <div class='box-body box_content'>
                                            <input type="text" name="externallink" id="externallink" class="form-control input-md" placeholder="External Link" value="">
                                        </div>
                                        <label for="e1" class="control-label">Icon Name:</label>
                                        <div class='box-body box_content'>
                                           <input type="text" name="iconname" id="iconname" class="form-control input-md" placeholder="E.g: filename.jpg/gif/png/jpeg" value="">
                                           
                                        </div>
                                        <label for="e1" class="control-label">External Icon URL:</label>
                                        <div class='box-body box_content'>
                                           <input type="text" name="externaliconURL" id="externaliconURL" class="form-control input-md" placeholder="External Icon URL" value="">
                                        </div>
                                        <br>
                                        <div class="box-body box_content">                                            
                                            <button onclick="javascript:Addlink();return false;" type="button" name="addlink" id="addlink" class=" btn btn-info btn-sm">Add Link</button>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label for="e1" class="control-label">Social Media Link(s):</label>
                                            <textarea readonly="readonly" class="form-control resize_vertical" id="socialmedialink" name="socialmedialink" placeholder="" rows="5">{{ old("socialmedialink", isset($selected_journal->social_media_link) ? $selected_journal->social_media_link : '') }}</textarea>
                                        </div>
                                        <br>
                                        <div class="box-body box_content pull-right">                                            
                                            <button onclick="javascript:ResetLink();return false;" type="button" name="addlink" id="addlink" class=" btn btn-info btn-sm">Reset</button>
                                        </div>
                                        <input type="hidden" name="hdnsocial" value="{{ old('socialmedialink', isset($selected_journal->social_media_link) ? $selected_journal->social_media_link : '') }}">
                                    <div class="acc-wizard-step"></div>
                                    </div>
                                </div>
      <!-- /#adjusthtml --> </div>
                            @include('admin.meta_tag.meta_tag')
                            @endif
                            <!-- multi language div -->
                            @if(!empty($selected_journal))
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#multi_lang" data-parent="#accordion-demo" data-toggle="collapse">Multi Language(s)</a>
                                    </h4>
                                </div>
                                
                                <div id="multi_lang" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <table class="table table-striped table-bordered">
                                            <tr>
                                                <th>#</th>
                                                <th>Language</th>
                                                <th>Title</th>
                                                <th>Action</th>
                                            </tr>
                                            <tbody>
                                                @if(!empty($mulLangdata))
                                                    @if(!$mulLangdata->isEmpty())
                                                        @php $cnt = 0; @endphp
                                                        @foreach($mulLangdata as $row)
                                                        <tr>
                                                            <td width="7%">{{++$cnt}}</td>
                                                            <td width="15%">{{$row->language_title}}</td>
                                                            <td width="60%">{{$row->title}}</td>
                                                            <td width="10%">
                                                                <button type="button" class="btn btn-sm btn-success" onclick="submit_multi_lang('edit','{{json_encode($row)}}')"><i class="livicon mt-2" data-name="pen" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i></button>

                                                                <button type="button" class="btn btn-sm btn-danger" onclick="submit_multi_lang('delete','{{$row->id}}')"><i class="livicon mt-2" data-name="trash" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i></button>
                                                            </td>
                                                        </tr>
                                                        @endforeach

                                                    @endif

                                                @endif
                                            </tbody>
                                        </table>


                                        <label for="e1" class="control-label">Language :</label>
                                        <div class='box-body box_content' id="language_id_div">
                                            <select class="form-control" id="language_id">
                                                <option value="" hidden="true">--Select Language--</option>
                                                @foreach($multilanguage as $row)
                                                    <option value="{{$row->language_id}}">{{$row->language_title}}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                        <br>
                                        @if(!empty($selected_journal))
                                        <input type="hidden" id="multilang_journal_id" value="{{$selected_journal->journal_id}}">
                                        @endif    
                                        <label for="e1" class="control-label">Title :</label>
                                        <div id="multi_lang_title_div" class='box-body box_content'>
                                            <input type="text" name="multi_lang_title" id="multi_lang_title" class="form-control input-md" placeholder="Enter journal title in selected language...." value="">
                                        </div>
                                        <br>
                                        <input type="hidden" id="multi_language_id">
                                        <div class="box-body box_content pull-center">                                            
                                            <button  type="button" onclick="submit_multi_lang('submit')"  class=" btn btn-info btn-sm" id="submit_btn">Add Title</button>
                                            <button  type="button" onclick="submit_multi_lang('update')" style="display: none;" class=" btn btn-info btn-sm" id="update_btn">Update Title</button>


                                        </div>
                                        
                                    <div class="acc-wizard-step"></div>
                                    </div>
                                </div>
                                
                            </div>
                            <!-- Journal Sections -->                            
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#journal_section" data-parent="#accordion-demo" data-toggle="collapse">Journal Sections(s)</a>
                                    </h4>
                                </div>
                                
                                <div id="journal_section" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <table class="table table-striped table-bordered">
                                            <tr>
                                                <th>#</th>
                                                <th>Title</th>
                                                <th>Description</th>
                                                <th>Status</th>
                                                <th>Action</th>
                                            </tr>
                                            <tbody>
                                                @if(!empty($journal_section))
                                                    @if(!$journal_section->isEmpty())
                                                        @php $cnt = 0; @endphp
                                                        @foreach($journal_section as $row)
                                                        <tr>
                                                            <td width="7%">{{++$cnt}}</td>
                                                            <td width="15%">{{$row->js_title}}</td>
                                                            <td width="60%">{!! html_entity_decode($row->js_description) !!}</td>
                                                            <td width="60%">@if($row->js_status == 1) Active @else Inactive @endif</td>
                                                            <td width="10%">
                                                                <button type="button" class="btn btn-sm btn-success" onclick="submit_journal_section('Edit','{{json_encode($row)}}')"><i class="livicon mt-2" data-name="pen" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i></button>

                                                                <button type="button" class="btn btn-sm btn-danger" onclick="submit_journal_section('Delete','{{$row->js_id}}')"><i class="livicon mt-2" data-name="trash" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i></button>
                                                            </td>
                                                        </tr>
                                                        @endforeach

                                                    @endif

                                                @endif
                                            </tbody>
                                        </table>


                                        @if(!empty($selected_journal))
                                        <input type="hidden" id="js_journal_id" value="{{$selected_journal->journal_id}}">
                                        @endif    
                                        <label for="e1" class="control-label">Title * :</label>
                                        <div id="js_title_div" class='box-body box_content'>
                                            <input type="text" name="js_title" id="js_title" class="form-control input-md" placeholder="Enter Section Title...." value="">
                                        </div>
                                        <br>
                                        <label for="e1" class="control-label">Description * :</label>
                                        <div id="js_description_div" class='box-body box_content'>
                                            <textarea name="js_description" id="js_description" class="textarea editor-cls" placeholder="Enter Section Description Title...."></textarea>
                                        </div>
                                        <br>
                                        <label for="e1" class="control-label">Aims &amp; Scope * :</label>
                                        <div id="js_aims_and_scope_div" class='box-body box_content'>
                                            <textarea name="js_aims_and_scope" id="js_aims_and_scope"  class="textarea editor-cls" placeholder="Enter Section Aims & Scope...."></textarea>
                                        </div>
                                        <br>
                                        <label for="e1" class="control-label">Status :</label>
                                        <div class='box-body box_content' id="js_published_div">
                                            <select class="form-control" name="js_status" id="js_status">
                                                <option value="1">Active</option>
                                                <option value="0">Inactive</option>
                                            </select>
                                        </div>
                                        <br>
                                        <input type="hidden" id="js_id">
                                        <div class="box-body box_content pull-center">                                            
                                            <button  type="button" onclick="submit_journal_section('Submit')"  class=" btn btn-info btn-sm" id="submit_js_btn">Add Journal Section</button>
                                            <button  type="button" onclick="submit_journal_section('Update')" style="display: none;" class=" btn btn-info btn-sm" id="update_js_btn">Update Title</button>


                                        </div>
                                        
                                    <div class="acc-wizard-step"></div>
                                    </div>
                                </div>
                                
                            </div>                            
                            @endif    


<!-- /.panel.panel-default --> </div>

                    <button class="btn btn-primary" type="submit">Save and continue</button>
                    </div>
                            
                </div>
            </form>
            </div>
        </div>

    </div>
    <!--main content ends--> </section>
            <!-- content --> 
    @stop

{{-- page level scripts --}}
@section('footer_scripts')

    @include('admin.layouts.js')
<script src="{{ asset('assets/vendors/bootstrap-tagsinput/js/bootstrap-tagsinput.js') }}"  type="text/javascript"></script>
<script src="{{ asset('assets/js/sweetalert.min.js') }}"></script>

<!-- Bootstrap WYSIHTML5 -->
<script src="{{ asset('assets/vendors/tinymce/tinymce.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/vendors/ckeditor/js/ckeditor.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/vendors/ckeditor/js/jquery.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/vendors/ckeditor/js/config.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/js/pages/editor1.js') }}"" type="text/javascript"></script>
<!-- end of page level js -->


<script type="text/javascript">

// reset all social media fields...
function ResetLink(){
    
        var sourcename = document.getElementsByName("sourcename")[0];
        var externallink = document.getElementsByName("externallink")[0];
        var iconname = document.getElementsByName("iconname")[0];
        var sourcelink = document.getElementsByName("socialmedialink")[0];
        var externalicon = document.getElementsByName("externaliconURL")[0];
        var ohdnsocial = document.getElementsByName("hdnsocial")[0];
        
        sourcename.value = "";
        externallink.value = ""; 
        iconname.value = "";  
        externalicon.value = "";
        sourcelink.value = "";
        ohdnsocial.value = null;
}

function Addlink(){

    var ohdnsocial = document.getElementsByName("hdnsocial")[0];
    var sourcename = document.getElementsByName("sourcename")[0];
    var externallink = document.getElementsByName("externallink")[0];
    var iconname = document.getElementsByName("iconname")[0];
    var sourcelink = document.getElementsByName("socialmedialink")[0];
    var externalicon = document.getElementsByName("externaliconURL")[0];
    icon_name_url = window.location.origin + "/images/socialmedia/";
    str_icon = iconname.value;
  
    if(sourcename.value =="" && externallink.value =="" && iconname.value =="" && externalicon.value ==""){
        
        alert("Enter Data into Fileds");
        return false;
    }
    
    
    // using either icon name or external icon url...
    if(iconname.value!="" && externalicon.value!=""){
        alert(" Enter Either Icon Name / External Icon URL");
        iconname.value = "";  
        externalicon.value = "";
        return false;
    }
    // regx for image name..
    if(str_icon!="")
    {
    if(!(/\b[A-Za-z0-9_.]+(.jpeg|.JPEG|.gif|.GIF|.png|.PNG|.jpg|.JPG)+/.test(str_icon)))  
    {  
        alert("You have entered an invalid image name!");
        iconname.value = "";  
        return false;   
    }
    }
   /// add values on social media link and empty source name, external link, icon name, external icon fields... 
    if((iconname.value!="" && externalicon.value=="") ||(externalicon.value!="" && iconname.value=="")){
        
    if(iconname.value!="" && externalicon.value==""){
        var icon_name_link = (icon_name_url+iconname.value);}
    
    if(externalicon.value!="" && iconname.value==""){
        var icon_name_link = externalicon.value; }
    }else{
        var icon_name_link = "";
    }
    ohdnsocial.value = ohdnsocial.value + sourcename.value + "^" + externallink.value + "^" + icon_name_link + "|";   
    
    sourcelink.value = sourcelink.value + sourcename.value + " " + externallink.value + " " + icon_name_link + "\n\r";
        
    sourcename.value = "";
    externallink.value = ""; 
    iconname.value = "";  
    externalicon.value = "";

}

function submit_multi_lang(form_action,jid='') {
    
    if(form_action == 'submit'){
        language_id = $("#language_id").val();
        multi_lang_title = $("#multi_lang_title").val();
        journal_id = $("#multilang_journal_id").val();

        if(multi_lang_title == ''){
            $("#multi_lang_title_div").addClass('has-error');
            return false;
        }else{
            $("#multi_lang_title_div").removeClass('has-error');
        }
        if(language_id == ''){
            $("#language_id_div").addClass('has-error');
            return false; 
        }else{
            $("#language_id_div").removeClass('has-error');
        }

        $.ajax({
          type:"post",
          url: "{{ url('admin/managemultilang')}}",
          data:{_token:"{{ csrf_token() }}",form_action:form_action,language_id:language_id,multi_lang_title:multi_lang_title,journal_id:journal_id},
          cache:false,
          dataType: "json",
          success:function(response)
          {
            location.reload();
          }
          
      });

    }else if(form_action == 'edit'){
        const obj = JSON.parse(jid);
       
        $("#language_id option").filter(function() {
          //may want to use $.trim in here
          return $(this).text() == obj.language_title;
        }).prop('selected', true);

        $("#multi_lang_title").val(obj.title);
        $("#multi_language_id").val(obj.id);
        $("#submit_btn").hide();
        $("#update_btn").show();

    }else if(form_action == 'update'){
        
        language_id = $("#language_id").val();
        multi_lang_title = $("#multi_lang_title").val();
        multi_language_id = $("#multi_language_id").val();

        if(multi_lang_title == ''){
            $("#multi_lang_title_div").addClass('has-error');
            return false;
        }else{
            $("#multi_lang_title_div").removeClass('has-error');
        }
        if(language_id == ''){
            $("#language_id_div").addClass('has-error');
            return false; 
        }else{
            $("#language_id_div").removeClass('has-error');
        }

        $.ajax({
              type:"post",
              url: "{{ url('admin/managemultilang')}}",
              data:{_token:"{{ csrf_token() }}",form_action:form_action,language_id:language_id,multi_lang_title:multi_lang_title,multi_language_id:multi_language_id},
              cache:false,
              dataType: "json",
              success:function(response)
              {
                location.reload();
              }
              
        });


    }else if(form_action == 'delete'){
        multi_language_id = $("#multi_language_id").val();
        swal({
                  title: `Are you sure you want to delete this record?`,
                  text: "If you delete this, it will be gone forever.",
                  icon: "warning",
                  buttons: true,
                  dangerMode: true,
              })
              .then((willDelete) => {
                if (willDelete) {
                  
                  $.ajax({
                          type:"post",
                          url: "{{ url('admin/managemultilang')}}",
                          data:{_token:"{{ csrf_token() }}",form_action:form_action,multi_language_id:jid},
                          cache:false,
                          dataType: "json",
                          success:function(response)
                          {
                            location.reload();
                          }
                          
                    });
                    


                }
              });



    }else{
        alert("Invalid action performed!!!");
    }
}


function submit_journal_section(form_action,jid='') {

    if(form_action == 'Submit')
    {
        journal_id          =   $("#js_journal_id").val();
        js_title            =   $("#js_title").val();
        js_description      =   $("#js_description").val();
        js_aims_and_scope   =   $("#js_aims_and_scope").val();
        js_status           =   $("#js_status").val();
        subtitle            =   $("#subtitle").val();

        if(js_title == ''){
            $("#js_title_div").addClass('has-error');
            return false;
        }else{
            $("#js_title_div").removeClass('has-error');
        }
        if(js_description == ''){
            $("#js_description").addClass('has-error');
            return false; 
        }else{
            $("#js_description_div").removeClass('has-error');
        }
        if(js_aims_and_scope == ''){
            $("#js_aims_and_scope_div").addClass('has-error');
            return false; 
        }else{
            $("#js_aims_and_scope_div").removeClass('has-error');
        }

        $.ajax({
          type:"post",
          url: "{{ url('admin/journalsection')}}",
          data:{_token:"{{ csrf_token() }}",form_action:form_action,journal_id:journal_id,js_title:js_title,js_description:js_description,js_aims_and_scope:js_aims_and_scope,js_status:js_status,subtitle:subtitle},
          cache:false,
          dataType: "json",
          success:function(response)
          { 
            location.reload();
          }
          
      });

    }
    else if(form_action == 'Edit')
    {
        const obj = JSON.parse(jid);

      var js_description = htmlUnescape(obj.js_description);
      var js_aims_and_scope = htmlUnescape(obj.js_aims_and_scope);

    //  console.log(js_description);
        
        $("#js_status option").filter(function() {
          //may want to use $.trim in here
          return $(this).text() == obj.js_status;
        }).prop('selected', true);

        $("#js_id").val(obj.js_id);
        $("#js_title").val(obj.js_title);
        $("#js_description").data("wysihtml5").editor.setValue(js_description);
        $("#js_aims_and_scope").data("wysihtml5").editor.setValue(js_aims_and_scope);        
        $("#js_status").val(obj.js_status);
        $("#submit_js_btn").hide();
        $("#update_js_btn").show();
    }
    else if(form_action == 'Update')
    {
        js_id               =   $("#js_id").val();
        js_title            =   $("#js_title").val();
        js_description      =   $("#js_description").val();
        js_aims_and_scope   =   $("#js_aims_and_scope").val();
        js_status           =   $("#js_status").val();

        if(js_title == ''){
            $("#js_title_div").addClass('has-error');
            return false;
        }else{
            $("#js_title_div").removeClass('has-error');
        }
        if(js_description == ''){
            $("#js_description_div").addClass('has-error');
            return false; 
        }else{
            $("#js_description_div").removeClass('has-error');
        }
        if(js_aims_and_scope == ''){
            $("#js_aims_and_scope_div").addClass('has-error');
            return false; 
        }else{
            $("#js_aims_and_scope_div").removeClass('has-error');
        }

        $.ajax({
              type:"post",
              url: "{{ url('admin/journalsection')}}",
              data:{_token:"{{ csrf_token() }}",form_action:form_action,js_id:js_id,js_title:js_title,js_description:js_description,js_aims_and_scope:js_aims_and_scope,js_status:js_status},
              cache:false,
              dataType: "json",
              success:function(response)
              {
                location.reload();
              }
              
        });


}
    else if(form_action == 'Delete')
    {
        swal({
                  title: `Are you sure you want to delete this record?`,
                  text: "If you delete this, it will be gone forever.",
                  icon: "warning",
                  buttons: true,
                  dangerMode: true,
              })
              .then((willDelete) => {
                if (willDelete) {
                  
                  $.ajax({
                          type:"post",
                          url: "{{ url('admin/journalsection')}}",
                          data:{_token:"{{ csrf_token() }}",form_action:form_action,js_id:jid},
                          cache:false,
                          dataType: "json",
                          success:function(response)
                          {
                            location.reload();
                          }
                          
                    });
                    


                }
              });



    }
    else
    {
        alert("Invalid action performed!!!");
    }
}

function htmlUnescape(str) {
  return str
      .replace(/&amp;/g, '&')
      .replace(/&quot;/g, '"')
      .replace(/&#39;/g, "'")
      .replace(/&lt;/g, '<')
      .replace(/&gt;/g, '>')
      .replace(/&#x2F/g, '/')
      .replace(/&#x3D;/g, '=')
      .replace(/&#x60;/g, '`');
}
</script>
<script src="{!! asset('assets/vendors/select2/js/select2.js') !!}"></script>
<script>
    $("#indexing_id").select2({
        theme: "bootstrap",
        width: '100%',
        height: '50px'
    });
</script>
@stop