@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
Issue MetaData
@parent
@stop

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

{{-- Page content --}}
@section('content')
<script type="text/javascript" src="{!! asset('js/jquery.min.js') !!}"></script>
<script>
$(function () 
{
		$("#section_id").change(function()
		{
			var section_id = $('#section_id').val();
			
			if (section_id == 0)
			{				
				$("#issue_id").removeAttr("disabled", "disabled");
			}			
			else
			{
				$("#issue_id").empty();
				$("#issue_id").attr("disabled", "disabled");
			}
		});

		$("#journal_id").change(function(){
		
			var link_id = $('#link_id').val();
			var journal_id = $('#journal_id').val();
			
			  $.ajax({
					type: "GET",
					url: '',
					data: {journal_id: journal_id},
					success: function( msg ) 
					{
						var data = msg['volume'];
						$('#volume_id').empty();						
							
						
						$.each(data, function(key,value) 
						{	
							$("#volume_id").append('<option selected="true" disabled="disabled" hidden>Select Volume</option>');
							$("#volume_id").append('<option value="'+value['volume_id']+'" >'+value['volume_name']+'</option>');
						});					
					}
				});						
		});
		
		$("#volume_id").change(function(){
					
			var volume_id = $('#volume_id').val();

			  $.ajax({
					type: "GET",
					url: '',
					data: {volume_id: volume_id},
					success: function( msg ) 
					{
						var data = msg['issues'];
						$('#issue_id').empty();						
						
						
						$.each(data, function(key,value) 
						{		
							var section_id = $('#section_id').val();							
							if (section_id == 0)
							{	
								$("#issue_id").append('<option selected="true" disabled="disabled" hidden>Select Issue</option>');
								$("#issue_id").append('<option value="'+value['issue_id']+'" >'+value['title']+'</option>');
							}
						});					
					}
				});						
		});
		
});
  
</script>

<section class="content-header">
    <!--section starts-->
    <h1>Filter</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">Filter 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>
                                    Filter List 
                                </div>							
                            </div>
							
                            <div class="portlet-body table-responsive">
							
							   <div class="panel-body">								
									<form action="{{ url('admin/metadata/issue') }}" method="POST">										@csrf
								
									<div class="my-3" id="e-book">

															
															
															<div class="form-group">
																<label class="control-label" for="select21">Journal: *</label>
																<select class="form-control select2"  name="journal_id" id="journal_id">
																<option selected="true" disabled="disabled" hidden>Select Journal</option>
																@isset($journal)
																	@foreach($journal as $key => $value)
																		<option value="{{$key}}"  @isset($param['journal_id']) @if($param['journal_id'] == $key) selected @endif @endisset>{{$value}}</option>
																	@endforeach
																@endisset
																</select>
																  <input type="hidden" id="link_id" name="link_id" value='edit'>
															</div>
															
															<div class="form-group">
                                                                <label class="control-label" for="select21">Volume: *</label>
                                                                <select class="form-control select2"  name="volume_id" id="volume_id">
																<option selected="true" disabled="disabled" hidden>Select Volume</option>
																
                                                                    @foreach($volume as $volume_value)
																		<option value="{{$volume_value->volume_id}}"  @isset($param) @if($param['volume_id'] == $volume_value->volume_id) selected @endif @endisset>{{$volume_value->volume_name}}</option>
																	@endforeach
																
                                                                </select>
                                                            </div>
															
															
															<input type="submit" class="btn btn-primary" value="Search">
									</div>
                                                <!--/.panel-body -->
									</form>
								</div>
									
								                        <!-- BEGIN SAMPLE TABLE PORTLET-->
                        <div class="portlet box primary">
                            <div class="portlet-body table-responsive">
                                <table class="table table-striped table-bordered" id="Issue_table">
                                    <thead>
                                        <tr>
                                            <th class="text-center" >Issues</th>
											<th class="text-center" >Date</th>
											<th class="text-center" >Metadata1</th>
											<th class="text-center" >Metadata2</th>
											<th class="text-center" >CrossRef</th>
											<th class="text-center" >Medline</th>
											<th class="text-center" >FIZ Autodoc</th>
											<th class="text-center" >Ex-Libras</th>
											<th class="text-center" >Medline</th>
											<th class="text-center" >Onix</th>
											<th class="text-center" >Nlst</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    @if($issue_list)
									@foreach($issue_list as $key => $value)
                                        <tr>
											<td class="text-center" >{{ $value->title }}</td>
											<td class="text-center" >{{ strftime("%d-%b-%Y",$value->created) }}</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/1') }}" >Generate Metadata</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/2') }}" >Generate Metadata2</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/3') }}" >Metadata</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/4') }}" >Linkout</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/5') }}" >Metadata</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/6') }}" >Metadata</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/7') }}" >Metadata</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/8') }}" >Metadata</a>  
											</td>
											<td class="text-center numeric" >
												<a href="{{ URL::to('admin/metadata/issue/' . $value->journal_id. '/' . $value->volume_id. '/' . $value->issue_id. '/9') }}" >Metadata</a>  
											</td>
                                        </tr>
										@endforeach
										@else
										<tr><td colspan="10" align="center"> --empty--</td></tr>
										@endif
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <!-- END SAMPLE TABLE PORTLET-->
                               
                            </div>							
                        </div>
                        <!-- END SAMPLE TABLE PORTLET-->
                    </div>
                </div>
            </section>

@stop

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