@extends('admin/layouts/default')
{{-- Page title --}}
@section('title')
Article List
@parent
@stop
{{-- page level styles --}}
@section('header_styles')
<!--page level 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>article</h1>
    <ol class="breadcrumb">
        <li>
            <a href="{{ route('admin.dashboard') }}">
            <i class="livicon" data-name="home" data-size="18" data-loop="true"></i>
            Dashboard
            </a>
        </li>
        <li class="active">article List</li>
    </ol>
</section>
<!--section ends-->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN SAMPLE TABLE PORTLET-->
            <div class="portlet box primary">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="livicon" data-name="responsive" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                        article List 
                    </div>                    <a class="btn btn-sm btn-default button-alignment pull-right mb-1" title="Add article" href="{{ URL::to('admin/articles/add') }}">
                    <span class="glyphicon glyphicon-plus"></span> New</a>
                </div>
                <div class="portlet-body table-responsive">                   <form action="{{ route('articles.index') }}" method="Get"  id="article_frm" enctype="multipart/form-data">
				   
                        <div class="form-group col-md-6">
                            <label class="control-label" for="select21">Article Title</label>
                            <input type="text" id="title_search" name="title_search" value="{{$param['title_search']}}" class="form-control" placeholder="Search by article title...">
                        </div>

                        <div class="form-group col-md-3">
                            <label class="control-label" for="select21">Article Doi</label>
                            <input type="text" id="doi_search" name="doi_search" value="{{$param['doi_search']}}" class="form-control" placeholder="Search by article doi...">
                        </div>

                        <div class="form-group col-md-3">
                            <label class="control-label" for="select21">Article Type </label>
                            <select name="article_type" id="article_type"  class="form-control select2">
                               <option title="All" value="7" @isset($param) @if($param['article_type'] == 7) {{ 'selected' }}
                                    @endif @endisset>All</option>
                               <option title="Normal" value="0"
                              @isset($param) @if($param['article_type'] == 0) {{ 'selected' }}
                                    @endif @endisset>Normal</option>
                               <option title="Epub Abstract Ahead of Print" value="4"
                             @isset($param) @if($param['article_type'] == 4) {{ 'selected' }}
                                    @endif @endisset>Epub Abstract Ahead of Print</option>
                               <option title="Epub Full Text Article" value="1"
                             @isset($param) @if($param['article_type'] == 1) {{ 'selected' }}
                                    @endif @endisset>Epub Full Text Article</option>
                               <option title="Quick Track" value="2"
                              @isset($param) @if($param['article_type'] == 2) {{ 'selected' }}
                                    @endif @endisset>Quick Track</option>
                               <option title="Express Track" value="3"
                              @isset($param) @if($param['article_type'] == 3) {{ 'selected' }}
                                    @endif @endisset>Express Track</option>
                               <option title="Supplementary" value="5"
                              @isset($param) @if($param['article_type'] == 5) {{ 'selected' }}
                                    @endif @endisset>Supplementary</option>
                            </select>
                        </div>
                        <div class="form-group col-md-6">
    						@include('search.journal_search')
                        </div>
                        <div class="form-group col-md-3">
    						@include('search.volume_search')
                        </div>
                        <div class="form-group col-md-3">
    						@include('search.issue_search')
                        </div>
						
						<div class="form-group col-md-12">
							<button type="submit" class="btn btn-primary" name="frm_search" value ="true">
								<span class="glyphicon glyphicon-search"></span>  Search
							</button>							<a href="{{ URL::to('admin/articles') }}"  id="btn_reset" class="btn btn-default">Reset</a>
						</div>
                        
						
                    </form>
                    <br>
                    <table class="table table-striped table-bordered" id="article_table">
                        <thead>
                            <tr>
                                <th>Journal</th>
                                <th>Article Title</th>
                                <th width="100">Created</th>
                                <th width="180px" class="numeric">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (count($article_list) > 0)
                            @foreach($article_list as $key => $value)
                            <tr>
                                <td>{{ $value->subtitle }}</td>
                                <td>{!! $value->title !!}</td>
                                <td>{{ strftime('%Y-%m-%d',$value->created) }}</td>
                                <td class="numeric">
                                    @if($editPermission)                                    <a href="{{ URL::to('admin/articles/' . $value->article_id. '/edit') }}" class="btn btn-primary btn-sm pull-left mb-1" target="_blank">
                                    <i class="livicon" data-name="pen" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i>
                                    
                                    </a>  
                                    @endif		
                                   
                                    @if($deletePermission)
                                    <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#{{ $value->article_id}}"><i class="livicon" data-name="trash" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i></button>
                                    <!-- Modal -->
                                    <div class="modal fade" id="{{ $value->article_id}}" role="dialog">
                                        <div class="modal-dialog">
                                            <!-- Modal content-->
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h4 class="modal-title">Warning</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <p>Do you really want to delete article: <b>{{ $value->title }}</b></p>
                                                </div>
                                                <div class="modal-footer">													                                                      {{ Form::open([ 'method'  => 'delete', 'route' => [ 'articles.destroy', $value->article_id] ]) }}
                                                    {{ Form::hidden('nid', $value->nid) }}
                                                    {{ Form::submit('Delete', ['class' => 'btn btn-danger']) }}
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                    {{ Form::close() }} 
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    @endif                                    <a href="{{ URL::to('/articles/' . $value->article_id ) }}" class="btn btn-success btn-sm pull-left mb-1" target="_blank">
                                    <i class="livicon" data-name="eye-open" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i>
                                    </a> 

                                    <a href="{{ URL::to('/admin/article_generate_sgml/' . $value->article_id ) }}" class="btn btn-link pull-left mb-1" target="_blank">
                                    Generate SGML
                                    </a> 
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="6">
                                    <center>Empty</center>
                                </td>
                            </tr>
                            @endif
                        </tbody>
                    </table>
                    @if (count($article_list) > 0)
                    <center>{{ $article_list->appends(request()->input())->links() }}</center>
                    @endif
                </div>
            </div>
            <!-- END SAMPLE TABLE PORTLET-->
        </div>
    </div>
</section>
@stop

{{-- page level scripts --}}
@section('footer_scripts')
<script src="{!! asset('assets/vendors/select2/js/select2.js') !!}"></script>    
<script src="{!! asset('js/filter.js') !!}"></script>
<script>

$(document).ready(function(){
    
    $('#journal_id').removeAttr('required');
    $('#volume_id').removeAttr('required');
    $('#issue_id').removeAttr('required');

    $("#journal_id").select2({
        theme:"bootstrap",
        placeholder:"Select Journal",
        width: '100%',
        height: '50px'
    });
    $("#volume_id").select2({
    	theme:"bootstrap",
    	placeholder:"Select Volume",
    	width: '100%',
    	height: '50px'
    });    		
    $("#issue_id").select2({
        theme:"bootstrap",
        placeholder:"Select Issue",
        width: '100%',
        height: '50px'
    });     
});    
</script>
@stop