
<input type="hidden" name="article_id" value="@isset($article->article_id) {{$article->article_id}} @endisset">

<!-- /.panel.panel-default -->
<div class="panel panel-default">
	<div class="panel-heading">
		<h4 class="panel-title">
			<a data-parent="#accordion-demo" data-toggle="collapse" href="#update_article_form">
			   Article
			</a>
		</h4>
	</div>
	<div class="panel-collapse collapse" id="update_article_form">
	{{ Form::model($article, array('url' => array('admin/articles',$article->article_id), 'id'=>"articleForm", 'files' => true, 'method' => 'PUT')) }}	


		<div class="panel-body">
		
				<div class="form-group">
				<label class="control-label" for="select21">Sections: *</label>
				<select name="is_epub" id="is_epub"  class="form-control select2" onchange="onchange_isEPUB();">
				   <option title="Normal" value="0"
				   @isset($article) @if($article->is_epub == 0) selected @endif @endisset>Normal</option>
				   <option title="Epub Abstract Ahead of Print" value="4"
				   @isset($article) @if($article->is_epub == 4) selected @endif @endisset>Epub Abstract Ahead of Print</option>
				   <option title="Epub Full Text Article" value="1"
				   @isset($article) @if($article->is_epub == 1) selected @endif @endisset>Epub Full Text Article</option>
				   <option title="Quick Track" value="2"
				   @isset($article) @if($article->is_epub == 2) selected @endif @endisset>Quick Track</option>
				   <option title="Express Track" value="3"
				   @isset($article) @if($article->is_epub == 3) selected @endif @endisset>Express Track</option>
				   <option title="Supplementary" value="5"
				   @isset($article) @if($article->is_epub == 5) selected @endif @endisset>Supplementary</option>
				</select>
				</div>
			  
					<div class="form-group">
						<label class="control-label" for="select21">Journal: *</label>
						
						<select class="form-control select2" id="journal_id" name="journal_id">
							@foreach($journal as $key => $value)
								<option value="{{$key}}"   @if(old('journal_id') == $key) {{ 'selected' }} @elseif($article->journal_id == $key) {{ 'selected' }} @endif>{{$value}}</option>
							@endforeach
						</select>

					</div>
			
					
					<div class="form-group">
						<label class="control-label" for="select21">
						   Volume: *
						</label>
						<select class="form-control select2"  name="volume_id" id="volume_id" @if($article->is_epub == 0 || $article->is_epub == 1 || $article->is_epub == 4) @else disabled="true" @endif >
						@if (!empty($volume_search))		
							@foreach($volume_search as $value)
								<option value="{{$value->volume_id}}"  {{ old('volume_id',$article->volume_id)==$value->volume_id ? 'selected' : ''  }}>{{$value->volume_name}}</option>
							@endforeach
						@endif	 			
						</select>
					</div>

					
					<div class="form-group">
					    <label class="control-label" for="select21">Issue:</label>
					    <select class="form-control select2" id="issue_id" name="issue_id"  @if($article->is_epub == 1 || $article->is_epub == 4) disabled="true" @else required="required" @endif>
					        <option selected="true" value="" disabled="disabled" hidden>Select Issue</option>
							@if (!empty($issue_search))		
					        @foreach($issue_search as $value)
					        <option value="{{$value->issue_id}}" {{ old('issue_id',$article->issue_id)==$value->issue_id ? 'selected' : ''  }}>{{$value->title}}</option>
					        @endforeach	
							@endif
					    </select>
					</div>

					<div class="form-group">
					    <label class="control-label" for="select21">Journal Section:</label>
						<select class="form-control select2"  name="section_id" id="section_id" @if($section_search->count() == 0) disabled="true" @else required="required" @endif>
						<option selected="true" disabled="disabled" hidden>Select Section</option>
							@if (!empty($section_search))
							 @foreach($section_search as $section)
								<option value="{{$section->js_id}}" 
								{{ old('section_id',$article->js_id)==$section->js_id ? 'selected' : ''  }}>{{$section->js_title}}</option>
							@endforeach
							@endif
						</select>
					</div>
					
					 <div class="form-group">
					 <label class="control-label" for="select21">JMS Ref No:</label>
					<input type="text" name="jms_ref_no"  class="form-control input-md" placeholder="JMS Ref No" value="{{ old('jms_ref_no', isset($article->jms_ref_no) ? $article->jms_ref_no : '') }}">
					</div>
					
				<div class="form-group @if ($errors->has('title')) has-error @endif ">
					<label  class="control-label">Title: *</label>
						<textarea class="form-control resize_vertical" required name="title" placeholder="Please enter text here..." rows="5" required="required">{{ old('title', isset($article->title) ? $article->title : '') }}</textarea>
				</div>
					
					<div class="form-group">
						<label  class="control-label">Article Number: *</label>
						<input id="article_no" type="number" class="form-control input-md" name="article_no" placeholder="Please enter text here..."  
						value="{{ old('article_no', isset($article->article_no) ? $article->article_no : '') }}">
					</div>
					
					<div class="form-group @if ($errors->has('article_type')) has-error @endif ">															
						<label class="control-label" for="select21">Article type: </label>
						<select class="form-control"  name="article_type" id="article_type">
						<option selected="true" disabled="disabled" hidden>Select Article Type</option>
						@isset($article_type)
							@foreach($article_type as $key=>$article_row)
								<option value="{{$article_row->art_type_id}}" 
								@if(old('article_type') == $article_row->art_type_id) {{ 'selected' }}
					@elseif(isset($article->art_type) && ($article->art_type == $article_row->art_type_id)) {{ 'selected' }} @endif>{{$article_row->type_name}}</option>
							@endforeach
						@endisset
						</select>
						
					</div>
					
					<div class="form-group">
					 <label class="control-label" for="select21">DOI:</label>
					<input type="text" name="doi"  class="form-control input-md" placeholder="DOI" value="{{ old('doi', isset($article->doi) ? $article->doi : '') }}" readonly>
					
					</div>
					
					<div class="form-group">
					 <label class="control-label" for="select21">eLocator:</label>
					<input type="text" name="elocator"  class="form-control input-md" placeholder="eLocator" value="{{ old('elocator', isset($article->elocator) ? $article->elocator : '') }}">
					
					</div>
					
					<div class="form-group">
					 <label class="control-label" for="select21">Citation:</label>
					<input type="text" name="citation"  class="form-control input-md" placeholder="Citation" value="{{ old('citation', isset($article->citation) ? $article->citation : 0) }}">
					</div>
					<?php $abstract = htmlspecialchars_decode($article->abstract); ?>
					
					<div class="form-group">
					<label  class="control-label">Abstract:</label>
					<textarea class="form-control " name="abstract" placeholder="Please enter text here..." rows="5">{{{ old('abstract', isset($abstract) ? $abstract : '') }}}</textarea>
					</div>
					
					<div class="form-group">
					<label  class="control-label">Animated Abstract:</label>
					<textarea class="form-control resize_vertical" name="animated_abstract" placeholder="Please enter text here..." rows="5">{{{ old('animated_abstract', isset($article->animated_abstract) ? $article->animated_abstract : '') }}}</textarea>
					</div>

					<div class="form-group">
					<label  class="control-label">Erratum In:</label>
					<textarea class="form-control resize_vertical" name="erratum_in" placeholder="Please enter text here..." rows="3">{{{ old('erratum_in', isset($article->erratum_in) ? $article->erratum_in : '') }}}</textarea>
					</div>
					
					<div class="form-group">
					<label  class="control-label">Erratum For:</label>
					<textarea class="form-control resize_vertical" name="erratum_for" placeholder="Please enter text here..." rows="3">{{{ old('erratum_for', isset($article->erratum_for) ? $article->erratum_for : '') }}}</textarea>
					</div>
					
					<div class="form-group">
					 <label class="control-label" for="select21">Podcast:</label>
					<input type="text" name="podcast"  class="form-control input-md" placeholder="Podcast" value="{{ old('podcast', isset($article->podcast) ? $article->podcast : '') }}">
					</div>
					
					<div class="form-group">
					 <label class="control-label" for="select21">Altmetric Score:</label>
					<input type="text" name="altmetric_score"  class="form-control input-md" placeholder="Altmetric Score" value="{{ old('altmetric_score', isset($article->altmetric_score) ? $article->altmetric_score : '') }}">
					</div>
					<div class="form-group">
					 <label class="control-label" for="select21">Altmetric URL:</label>
					<input type="text" name="altmetric_url"  class="form-control input-md" placeholder="Altmetric URL" value="{{ old('altmetric_url', isset($article->altmetric_url) ? $article->altmetric_url : '') }}">
					</div>
					<div class="form-group">
					 <label class="control-label" for="select21">KUDOS URL:</label>
					<input type="text" name="kudos_url"  class="form-control input-md" placeholder="KUDOS URL" value="{{ old('kudos_url', isset($article->kudos_url) ? $article->kudos_url : '') }}">
					</div>

					<div class="form-group col-md-3">
					 <label class="control-label" for="select21">Publish On Date:</label>
					<input type="date" name="publish_on"  class="form-control input-md" placeholder="Receive Date" value="{{ old('publish_on', isset($article->publish_on) && $article->publish_on != 0 ? date('Y-m-d', $article->publish_on) : '') }}" @php if(isset($article->is_epub) && $article->is_epub == 1 || $article->is_epub == 0) echo "disabled"; @endphp >
					</div>

					<div class="form-group col-md-3">
					 <label class="control-label" for="select21">Receive Date:</label>
					<input type="date" name="Received_date"  class="form-control input-md" placeholder="Receive Date" value="{{ old('Received_date', isset($article->receivedate) ? $article->receivedate : '') }}">
					</div>
					<div class="form-group  col-md-3">
					 <label class="control-label" for="select21">Revised Date:</label>
					<input type="date" name="Revised_date"  class="form-control input-md" placeholder="Revised Date" 
					value="{{ old('Revised_date', isset($article->revisedate) ? $article->revisedate : '') }}">
					</div>
					
					<div class="form-group  col-md-3">
					 <label class="control-label" for="select21">Accepted Date:</label>
					<input type="date" name="Accepted_date"  class="form-control input-md" placeholder="Accepted Date" 
					value="{{ old('Accepted_date', isset($article->acceptdate) ? $article->acceptdate : '') }}">
					</div>
					<br><br><br><br>
					<div class="form-group">
					 <label class="control-label" for="select21">PMID:</label>
					<input type="text" name="pm_id"  class="form-control input-md" placeholder="PMID" value="{{ old('pm_id', isset($article->pmid) ? $article->pmid : '') }}">
					</div>
					
					<div class="form-group">
					<label  class="control-label">Keywords:</label>
					<input name="keyword" type="text" data-role="tagsinput"  value="{{ old('keyword', isset($keyword) ? $keyword : '') }}" />
					</div>
			   
					<div class="form-group">
					 <label class="control-label" for="select21">First Page:</label>
					<input type="text" name="first_page" id="first_page"  class="form-control input-md" placeholder="First Page" onblur="javascript: CountPages()" value="{{ old('first_page', isset($article->first_page) ? $article->first_page : '') }}">
					</div>
					<div class="form-group">
					 <label class="control-label" for="select21">Last Page:</label>
					<input type="text" name="last_page" id="last_page"  class="form-control input-md" placeholder="Last Page" onblur="javascript: CountPages()" value="{{ old('last_page', isset($article->last_page) ? $article->last_page : '') }}">
					</div>
					<div class="form-group">
					 <label class="control-label" for="select21">Total Page Count:</label>
					<input type="text" id="page_count" name="page_count"  class="form-control input-md" placeholder="Total Page Count" value="{{ old('page_count', isset($article->page_count) ? $article->page_count : '') }}">
					</div>
					
					<div class="form-group @if ($errors->has('is_uploaded')) has-error @endif ">
						<label class="control-label" >Article Uploaded: *</label>
						<select class="form-control select2" name="is_uploaded" required="required">		
							<option title="NO" value="0" @if(old('is_uploaded') == 0) {{ 'selected' }}
					@elseif(isset($article->is_uploaded) and ($article->is_uploaded == 0))) {{ 'selected' }} @endif>NO</option>
							<option title="YES" value="1" 
							 @if(old('is_uploaded') == 1) {{ 'selected' }}
					@elseif(isset($article->is_uploaded) and ($article->is_uploaded == 1))) {{ 'selected' }} @endif>YES</option>
						</select>
					</div>
					
					<div class="form-group @if ($errors->has('article_status')) has-error @endif ">
						<label class="control-label" >Article Status: *</label>
						<select class="form-control select2" name="article_status" required="required">		
							<option title="Active" value="A" @if(old('article_status') == 'A') {{ 'selected' }}
					@elseif(isset($article->article_status) and ($article->article_status == 'A'))) {{ 'selected' }} @endif>Active</option>
							<option title="Withdrawal" value="W" 
							 @if(old('article_status') == 'W') {{ 'selected' }}
					@elseif(isset($article->article_status) and ($article->article_status == 'W'))) {{ 'selected' }} @endif>Withdrawal</option>
						</select>
					</div>
					
					<div class="form-group">
						<label class="control-label" >Is Editor Choice: *</label>
						<select class="form-control select2" name="is_editor_choice">
						   <option title="NO" value="N" 	   
						   @if(old('is_editor_choice') == 'N') {{ 'selected' }}
					@elseif(isset($article->is_editor_choice) and ($article->is_editor_choice == 'N'))) {{ 'selected' }} @endif>NO</option>
							<option title="YES" value="Y" 
							 @if(old('is_editor_choice') == 'Y') {{ 'selected' }}
					@elseif(isset($article->is_editor_choice) and ($article->is_editor_choice == 'Y'))) {{ 'selected' }} @endif>YES</option>
						</select>
					</div>
					
					<div class="form-group">
						<label class="control-label" >Is Most Popular:</label>
						<select class="form-control select2" name="is_popular">
						   <option title="NO" value="N" 
							 @if(old('is_popular') == 'N') {{ 'selected' }}
					@elseif(isset($article->is_popular) and ($article->is_popular == 'N'))) {{ 'selected' }} @endif>NO</option>
							<option title="YES" value="Y" 
							 @if(old('is_popular') == 'Y') {{ 'selected' }}
					@elseif(isset($article->is_popular) and ($article->is_popular == 'Y'))) {{ 'selected' }} @endif>YES</option>
						</select>
					</div>
					
					<div class="form-group">
						<label class="control-label" >Is Highlighted: *</label>
						<select class="form-control select2" name="is_highlighted" required="required">
						   <option title="NO" value="N" 
							 @if(old('is_highlighted') == 'N') {{ 'selected' }}
					@elseif(isset($article->is_highlighted) and ($article->is_highlighted == 'N'))) {{ 'selected' }} @endif>NO</option>
							<option title="YES" value="Y" 
							 @if(old('is_highlighted') == 'Y') {{ 'selected' }}
					@elseif(isset($article->is_highlighted) and ($article->is_highlighted == 'Y'))) {{ 'selected' }} @endif>YES</option>
						</select>
					</div>

				
				<div class="form-group">
					<label class="control-label" >Crossmark enabled: </label>
					<input type="text" name="crossmark_enabled"  class="form-control input-md" placeholder="Crossmark enabled" value="{{ old('crossmark_enabled', isset($article->crossmark_enabled) ? $article->crossmark_enabled : '') }}">
				</div>

				<div class="form-group">
					<label class="control-label" >Text mining URLs: </label>
					<input type="text" name="text_mining_urls"  class="form-control input-md" placeholder="Text mining URLs" value="{{ old('text_mining_urls', isset($article->text_mining_urls) ? $article->text_mining_urls : '') }}">
				</div>

				<div class="form-group">
					<label class="control-label" >License URLs: </label>
					<input type="text" name="license_urls"  class="form-control input-md" placeholder="License URLs" value="{{ old('license_urls', isset($article->license_urls) ? $article->license_urls : '') }}">
				</div>
					
					<div class="form-group text-right">
					{{ Form::submit('Update', array('class' => 'btn btn-primary','value' => 'submit' , 'name' => 'update_article_form' )) }}
					</div>
					
		
		<!--/.panel-body -->
	</div>
	{{ Form::close() }}		
</div>
	<!-- /#adjusthtml -->
	
</div>

<script type="text/javascript">
	
// $(function () {
		
	
// 		$("#volume_id").change(function(){
// 			var journal_id = $('#journal_id').val();
// 			var volume_id = $('#volume_id').val();

// 			  $.ajax({
// 					type: "GET",
// 					url: '',
// 					data: {volume_id: volume_id,ajx_search : true,article_exist : false},
// 					success: function( msg ) 
// 					{
						
// 						var data = msg['issues'];
// 						console.log(data);
// 						$('#issue_id').empty();						
// 							$("#issue_id").append('<option value="" >Select Issue</option>');
// 						$.each(data, function(key,value) 
// 						{							
// 							$("#issue_id").append('<option value="'+value['issue_id']+'" >'+value['title']+'</option>');
// 						});					
// 					}
// 				});						
// 			});	
// 		});	
</script>
