<!-- /.panel.panel-default -->
<div class="panel panel-default">
	<div class="panel-heading">
		<h4 class="panel-title">
			<a  data-toggle="collapse" href="#update_chapter_form">eBook Chapter</a>
		</h4>
	</div>
	<div class="panel-collapse collapse" id="update_chapter_form">
	{{ Form::model($selected_chapter, array('url' => array('admin/chapter',$selected_chapter->chapter_id),'files' => true, 'method' => 'PUT')) }}
		<div class="panel-body">
				<div class="form-group">
					<label for="select28" class="control-label">
						eBook: *
					</label>
				 <select id="ebook" name ="ebook" class="form-control " disabled>
					<option value="">Select eBooks...</option>
					 @foreach ($ebook as $ebooks)
						<option value="{{$ebooks->ebook_id}}"  @if(old('ebook_id') == $ebooks->ebook_id) {{ 'selected' }}
					@elseif(isset($selected_chapter->ebook_id) and ($selected_chapter->ebook_id == $ebooks->ebook_id))) {{ 'selected' }} @endif> {{$ebooks->title}}</option>
					@endforeach
					</select>
					<input type="hidden" name="ebook_id" value="{{$selected_chapter->ebook_id}}">
					<input type="hidden" id="ebook_volume_id" name="ebook_volume_id" value="{{$selected_chapter->ebook_volume_id}}">
					<input type="hidden" id="chapter_id" name="chapter_id" value="{{$selected_chapter->chapter_id}}">
					<input type="hidden" id="nid" name="nid" value="{{$selected_chapter->nid}}">
					<input type="hidden" id="link_id" name="link_id" value='edit'>
				</div>
				<div class="form-group">
				   
					@if(!empty($ebook_volume))
					<label for="e1" class="control-label">Volume: *</label>
					<select id="volume" name="volume" class="form-control " name="select_state" disabled>
						<option value="{{$ebook_volume->ebook_volume_id}}" title="{{$ebook_volume->select_ebook_type}}">{{$ebook_volume->volume_name}} - (Type {{$ebook_volume->select_ebook_type}})</option>
					</select>
					@else
					<div class="alert alert-danger">
					  <strong>Volume Missing!</strong> 
					</div>
					@endif
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Chapter Number: *</label>
					<input type="number" min="1" max="50" name="chapter_no" id="chapter_no" class="form-control input-md" placeholder="Chapter Number" required="required" value="{{ old('chapter_no', isset($selected_chapter->chapter_no) ? $selected_chapter->chapter_no : '') }}">
					<span id ="lbl_chapter" class="control-label"></span>
				</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="Text Here..." required="required" value="{{ old('title', isset($selected_chapter->title) ? $selected_chapter->title : '') }}">
				</div>
				
				@if(strtolower($ebook_volume->select_ebook_type) == 'video')
				<div class="form-group">
					<label for="e1" class="control-label">Video Url: </label>
					<span class="text-success"><a target="_blank"href="{{  url('chapter/video/'.$selected_chapter->nid) }}">{{  url('chapter/video/'.$selected_chapter->nid) }}</a></span>
				</div>
				@endif
				<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="DOI" value="{{ old('doi', isset($selected_chapter->doi) ? $selected_chapter->doi : '') }}">
					<p>Leave it blank to generate DOI automatically.</p>
				</div>
					<?php $abstract = htmlspecialchars_decode($selected_chapter->abstract); ?>
				<div class="form-group">
					<label for="e1" class="control-label">Abstract:</label>
					<textarea class="form-control editor-cls" id="abstract" name="abstract" placeholder="Please enter your message here..." rows="5">{{ old('abstract', isset($abstract) ? $abstract : '') }}</textarea>
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Keywords:</label>
					<input type="text" id="keywords" name="keywords" class="form-control input-md" id="keywords" placeholder="Please enter keywords" data-role="tagsinput"  value="{{ old('keywords', isset($selected_keywords) ? $selected_keywords : '') }}">
					<p>Place "," separated keywords.</p>
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Video Link:</label>
					<textarea class="form-control resize_vertical" id="video_link" name="video_link" placeholder="Please enter your message here..." rows="5">{{ old('video_link', isset($selected_chapter->video_link) ? $selected_chapter->video_link : '') }}</textarea>
				</div>
			   <div class="form-group">
					<label for="e1" class="control-label">First Page: *</label>
					<input type="text" name="first_page" id="first_page" class="form-control input-md" placeholder="First Page" required="required" value="{{ old('first_page', isset($selected_chapter->first_page) ? $selected_chapter->first_page : '') }}" onblur="javascript: CountPages()">
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Last Page: *</label>
					<input type="text" name="last_page" id="last_page" class="form-control input-md" placeholder="Last Page" required="required" value="{{ old('last_page', isset($selected_chapter->last_page) ? $selected_chapter->last_page : '') }}" onblur="javascript: CountPages()">
					<p>Last page should be greater than First page</p>
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Total Page Count:</label>
					<input type="text" name="page_count" id="page_count" class="form-control input-md" placeholder="Total Page Count" value="{{ old('page_count', isset($selected_chapter->page_count) ? $selected_chapter->page_count : '') }}">
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Is Packaged: *</label>
					<select id="e1" class="form-control select2" name="is_packaged">
						<option value="2" {{ old('is_packaged', $selected_chapter->is_packaged) == '2' ? 'selected' : '' }}>Packaging Not Required</option>
						<option title="Packaged" value="1" {{ old('is_packaged', $selected_chapter->is_packaged) == '1' ? 'selected' : '' }}>Packaged</option>
						<option title="Not Packaged" value="0" {{ old('is_packaged', $selected_chapter->is_packaged) == '0' ? 'selected' : '' }}>Not Packaged</option>
					</select>
				</div>
				<div class="form-group">
					<label for="e1" class="control-label">Chapter Uploaded: *</label>
					<select id="e1" class="form-control select2" name="is_uploaded">
						<option value="1" {{ old('is_uploaded', $selected_chapter->is_uploaded) == '1' ? 'selected' : '' }}>Yes</option>
						<option value="0" {{ old('is_uploaded', $selected_chapter->is_uploaded) == '0' ? 'selected' : '' }}>No</option>
					</select>
				</div>
				
				<div class="form-group text-right">
					{{ Form::submit('Update', array('class' => 'btn btn-primary','value' => 'submit' , 'name' => 'update_chapter_form' )) }}
				</div>
				
		</div>
		
		
		<!--/.panel-body -->
	</div>
	{{ Form::close() }}		
</div>
<!-- /#adjusthtml -->