@extends('admin/layouts/default')

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

{{-- page level styles --}}
@section('header_styles')
	<link href="{{ asset('assets/css/pages/tables.css') }}" rel="stylesheet" type="text/css" />
    <!-- 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="'+key+'" >'+value+'</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="'+key+'" >'+value+'</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">
								@if(isset($issue))
									<form action="{{ url('admin/metadata/article') }}" method="POST">
								@elseif(isset($ebook))
									<form action="{{ url('admin/metadata/ebook') }}" method="POST">
								@else
									<form action="{{ url('admin/metadata/issue') }}" method="POST">
								@endisset									@csrf
									<div class="my-3" id="e-book">

															@isset($issue)
                                                            <div class="form-group">
															
                                                                <label class="control-label" for="select21">Section: *</label>
                                                                
																<select class="form-control select2"  name="section_id" id="section_id">
																	<option title="Normal" value="0" selected="selected">Normal</option>
																	<option title="Epub Abstract" value="4">Epub Abstract</option>
																	<option title="Epub Full Text Article" value="1">Epub Full Text Article</option>
                                                                </select>
																
																<input type="hidden" id="link_id" name="link_id" value='edit'>
                                                            </div>
															@endisset
                                                          
															@isset($ebook)
																<div class="form-group">
																	<label class="control-label" for="">Ebook Title: *</label>
																	<select class="form-control select2"  name="ebook_id" id="ebook_id">
																	<option selected="true" disabled="disabled" hidden>Select Ebook</option>
																	
																		@foreach($ebook as $key => $value)
																			<option value="{{$key}}" @isset($param) @if($param['ebook_id'] == $key) selected @endif @endisset>{{$value}}</option>
																		@endforeach
																	
																	</select>
																</div>
															@else
																<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) @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>
															@endisset
															
															@isset($volume)
															<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 $key => $value)
																		<option value="{{$key}}"  @isset($param) @if($param['volume_id'] == $key) selected @endif @endisset>{{$value}}</option>
																	@endforeach
																
                                                                </select>
                                                            </div>
															@endisset

															
															@isset($issue)
																<div class="form-group">
																	<label class="control-label" for="">Issue Type: *</label>
																	<select class="form-control select2"  name="issue_id" id="issue_id">
																	<option selected="true" disabled="disabled" hidden>Select Issue</option>
																	
																		@foreach($issue as $key => $value)
																			<option value="{{$key}}" @isset($param) @if($param['issue_id'] == $key) selected @endif @endisset>{{$value}}</option>
																		@endforeach
																	
																	</select>
																</div>
															@endisset
															
															<input type="submit" class="btn btn-primary" value="Search">
									</div>
                                                <!--/.panel-body -->
									</form>
								</div>
									
								@isset($articles_list)
									@include('admin.metadata.articlelist')
								@endisset
								
								@isset($issue_list)
									@include('admin.metadata.issuelist')
								@endisset
								
								@isset($param)
									@isset($ebook)
										@include('admin.metadata.ebooklist')
									@endisset
								@endisset	
                               
                            </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>
@stop
