@extends('webprofile.backend.layouts.master')

@section('title')
  {{ $title }}
@stop

@section('assets')
<link rel="stylesheet" href="{!! asset('backend/assets/select2/select2.min.css') !!}">
<style media="screen">
  .tkh{
    color: black;
  }
</style>
@stop

@section('breadcrumbs')
<li><a href="{{ url('home') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.edit_post')</li>
@stop

@section('content')
<!-- page start-->
<div class="row">
  {!! Form::model($data, ['route' => ['posts.update', $data->id], 'method'=>'patch', 'files' => true]) !!}
  {!! csrf_field() !!}
	<div class="col-md-9">
	    <div class="panel panel-default">
	        <div class="panel-heading">
	            <h3 class="panel-title"><strong>@lang('label.edit')</strong> @lang('feature.post')</h3>
	        </div>
	        <div class="panel-body">
	            <div class="row">
					<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
						Bahasa Indonesia
					</div>
	                <div class="col-md-12">
	                    <div class="form-group @if ($errors->has('title')) has-error @endif">
	                        <div class="col-md-12">
	                          {{ Form::text('title', old('title'), array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;', 'required')) }}
	                          @if ($errors->has('title'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
	                          @endif
	                        </div>
	                    </div>
					</div>
					<div class="col-md-12">
							<div class="form-group @if ($errors->has('categories')) has-error @endif" style="margin-top: 5px;">
							<div class="col-md-12">
								{{ Form::select('categories', $categories, old('categories'), ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'categories', 'placeholder' => app('translator')->getFromJson('feature.category'), 'required']) }}
								@if ($errors->has('categories'))
								<label id="login-error" class="error" for="login">{{$errors->first('categories')}}</label>
								@endif
							</div>
							</div>
					</div>
					<div class="col-md-12" style="height:500px;">
	                    <div class="block">
	                    	{{ Form::textarea('content', null, array('id'=>'content')) }}
							{{ Form::hidden('manual', $manual, array('id'=>'manual')) }}
						</div>
	                </div>
	            </div>

				{{-- <div class="tabs">
					<ul class="nav nav-tabs" role="tablist">
						<li class="active"><a href="#inggris" role="tab" data-toggle="tab" aria-expanded="true">Inggris</a></li>
						<li class=""><a href="#jerman" role="tab" data-toggle="tab" aria-expanded="false">Jerman</a></li>
						<li class=""><a href="#arab" role="tab" data-toggle="tab" aria-expanded="false">Arab</a></li>
						<li class=""><a href="#cina" role="tab" data-toggle="tab" aria-expanded="false">Cina</a></li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane active" id="inggris">
							<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
								English Language
							</div>
							<div class="col-md-12">
								<div class="form-group @if ($errors->has('title')) has-error @endif">
									<div class="col-md-12">
									{{ Form::text('title_en', $data->rEn ? $data->rEn->title : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;', 'required')) }}
									@if ($errors->has('title'))
									<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
									@endif
									</div>
								</div>
							</div>
							<div class="col-md-12">
								<div class="block">
									{{ Form::textarea('content_en', $data->rEn ? $data->rEn->content : null, array('id'=>'content_en')) }}
								</div>
							</div>
						</div>
						<div class="tab-pane" id="jerman">
							<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
								deutsche Sprache
							</div>
							<div class="col-md-12">
								<div class="form-group @if ($errors->has('title')) has-error @endif">
									<div class="col-md-12">
									{{ Form::text('title_de', $data->rDe ? $data->rDe->title : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }}
									@if ($errors->has('title'))
									<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
									@endif
									</div>
								</div>
							</div>
							<div class="col-md-12">
								<div class="block">
									{{ Form::textarea('content_de', $data->rDe ? $data->rDe->content : null, array('id'=>'content_de')) }}
								</div>
							</div>
						</div>
						<div class="tab-pane" id="arab">
							<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
								اللغة العربية
							</div>
							<div class="col-md-12">
								<div class="form-group @if ($errors->has('title')) has-error @endif">
									<div class="col-md-12">
									{{ Form::text('title_sa', $data->rSa ? $data->rSa->title : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }}
									@if ($errors->has('title'))
									<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
									@endif
									</div>
								</div>
							</div>
							<div class="col-md-12">
								<div class="block">
									{{ Form::textarea('content_sa', $data->rSa ? $data->rSa->content : null, array('id'=>'content_sa')) }}
								</div>
							</div>
						</div>
						<div class="tab-pane" id="cina">
							<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
								中文
							</div>
							<div class="col-md-12">
								<div class="form-group @if ($errors->has('title')) has-error @endif">
									<div class="col-md-12">
									{{ Form::text('title_zh', $data->rZh ? $data->rZh->title : null, array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }}
									@if ($errors->has('title'))
									<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
									@endif
									</div>
								</div>
							</div>
							<div class="col-md-12">
								<div class="block">
									{{ Form::textarea('content_zh', $data->rZh ? $data->rZh->content : null, array('id'=>'content_zh')) }}
								</div>
							</div>
						</div>
					</div>
				</div> --}}
	        </div>
	    </div>
	</div>
	<div class="col-md-3">
	    <div class="panel panel-default">
	        <div class="panel-heading">
	            <h3 class="panel-title"><strong>@lang('label.publish')</strong></h3>
	            <ul class="panel-controls">
	                <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
	            </ul>
	        </div>
	        <div class="panel-body">
	            <div class="row">
	                <div class="col-md-12">
	                    <div class="form-group">
	                        <label class="col-md-3 col-xs-12 control-label">@lang('label.date')</label>
	                        <div class="col-md-12">
	                            <div class="input-group">
	                                {{ Form::text('post_date', $data->post_date, array('class' => 'form-control datepicker')) }}
	                            </div>
	                        </div>
	                    </div>
                    </div>
                    <div class="col-md-12">
	                    <div class="form-group" style="padding-top: 10px;">
                            <label class="col-md-2 control-label">@lang('label.status')</label>
                            <div class="col-md-6">
                                <center><label class="switch">
                                	{{ Form::checkbox('post_status', 1, true) }}
                                    <span></span>
                                </label></center>
                            </div>
                        </div>
	                </div>
	            </div>
	        </div>
	        <div class="panel-footer">
	        </div>
	    </div>
	</div>
	<div class="col-md-3">
	    <div class="panel panel-default">
	        <div class="panel-heading">
	            <h3 class="panel-title"><strong>@lang('label.cover_image')</strong></h3>
	            <ul class="panel-controls">
	                <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
	            </ul>
	        </div>
	        <div class="panel-body">
	            <div class="row">
	                <div class="col-md-12">
	                    <div class="form-group">
	                        <label class="col-md-2 control-label"></label>
	                        <div class="col-md-12">
	                          <center>
	                          	  <div class="form-group">
									@if ($data->thumbnail)
									@if ($setting['external_storage'] == 1)
									<img id="uploadPreview" style="width: 200px; height: 100%;" src="{{ $setting['url_static'] . '/' . $setting['directory'] . '/thumbnail/' . $data->thumbnail }}"><br>
									@else
									<img id="uploadPreview" style="width: 200px; height: 100%;" src="{{ url('/storage/thumbnail/' . $data->thumbnail) }}"><br>
									@endif
									@else
									<img id="uploadPreview" style="width: 200px; height: 100%;" src="https://statik.unesa.ac.id/profileunesa_konten_statik/images/preview.png"/><br>
									@endif
                  	            </div>
                  	            <div class="form-group">
                  	            	{{ Form::file('thumbnail', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>app('translator')->getFromJson('label.cover_image'), 'onchange'=>'PreviewImage();')) }}
								</div>
								<div class="form-group" style="padding-top: 10px;">
									<div class="col-md-12">
										<div class="form-group">
											<label style="vertical-align: middle;">@lang('label.show_in_post')</label>
											<label class="switch" style="vertical-align: middle;">
												{{ Form::checkbox('cover_status', 1, true) }}
												<span></span>
											</label>
										</div>
									</div>
								</div>
	                          </center>
	                        </div>
	                    </div>
	                </div>
	            </div>
	        </div>
	        <div class="panel-footer">
	        </div>
	    </div>
	</div>
	<div class="col-md-3">
	    <div class="panel panel-default">
	        <div class="panel-footer">
	            <button class="btn btn-info pull-right">@lang('label.save')</button>
	        </div>
	    </div>
	</div>
	<div class="col-md-12">
	    <div class="panel panel-default">
	        <div class="panel-heading">
	            <h3 class="panel-title">Keywords</h3>
	            <ul class="panel-controls">
	                <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
	            </ul>
	        </div>
	        <div class="panel-body">
	            <div class="row">
	                <div class="col-md-12">
	                    <div class="form-group @if ($errors->has('keys')) has-error @endif">
	                        <div class="col-md-12">
	                          {{ Form::text('keys', old('keys'), array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.keys'), 'style'=>'font-size: 14pt;')) }}
	                          @if ($errors->has('keys'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('keys')}}</label>
	                          @endif
	                        </div>
	                    </div>
					</div>
	            </div>
	        </div>
	        <div class="panel-footer">
	        </div>
	    </div>
	</div>
  {!! Form::close() !!}
</div>
<!-- page end-->
@stop

@section('script')
{!! Html::script('backend/assets/select2/select2.full.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('backend/js/plugins/summernote/summernote.js') !!}

<script type="text/javascript">
	function PreviewImage() {
		var oFReader = new FileReader();
		oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);

		oFReader.onload = function (oFREvent) {
		document.getElementById("uploadPreview").src = oFREvent.target.result;
		};
	};

	$(document).ready(function() {
		$('#content').summernote({
			height: 350
		});
		$('#content_en').summernote({
			height: 350
		});

		$('#content_de').summernote({
			height: 350
		});

		$('#content_sa').summernote({
			height: 350
		});

		$('#content_zh').summernote({
			height: 350
		});
	});

  	$('#categories').select2();
</script>
@stop
