@extends('layouts.app')

@section('content')
<section class="page-header row">
	<h2> {{ $pageTitle }} </h2>
	<ol class="breadcrumb">
		<li><a href="{{ url('') }}"> Dashboard </a></li>
		<li><a href="{{ url('/manage/'.$pageModule) }}"> {{ $pageTitle }} </a></li>
		<li class="active"> Form  </li>		
	</ol>
</section>
<div class="page-content row">
	<div class="page-content-wrapper no-margin">
	
	{!! Form::open(array('url'=>'/manage/pages?return='.$return, 'class'=>'form-vertical validated','files' => true )) !!}
	<input type="hidden" name="status_type" value="{{ $pageTitle }}" />
	
		<div class="sbox-title clearfix">
			<div class="sbox-tools pull-right" >
				<a href="{{ url('/manage/'.$pageModule.'?return='.$return) }}" class="tips btn btn-sm "  title="{{ __('core.btn_back') }}" ><i class="fa  fa-times"></i></a> 
			</div>
			<div class="sbox-tools1 pull-left1" >
				<button name="apply" class="btn btn-sm btn-primary  "  title="{{ __('core.btn_back') }}" ><i class="fa  fa-check"></i> {{ __('core.sb_apply') }} </button>
				<button name="save" class="btn btn-sm btn-success"  title="{{ __('core.btn_back') }}" ><i class="fa  fa-paste"></i> {{ __('core.sb_save') }} </button> 
				<?php if($frontendSlug!='') {
				$fsconfig = explode('@',$frontendSlug);
				if( ($row[$fsconfig[1]]) ) 
				echo '<a  class="btn btn-sm btn-outline-primary" target="_blank"  title="FrontEnd" href="'. (config('website.cnf_appurl') .'/'.config('website.cnf_lang') . str_replace('//','/',('/'.$fsconfig[0].'/'.$row[$fsconfig[1]]))).'"><i class="fa  fa-desktop"></i> FrontEnd</a>';
				 } ?>
			</div>
		</div>	
		<div class="sbox1">
		<div class="sbox-content clearfix row">
		<div class="col-xs-12">
	<ul class="parsley-error-list">
		@foreach($errors->all() as $error)
			<li>{{ $error }}</li>
		@endforeach
	</ul>		

	<?php $curTime = time();?>

<div class="sbox1"><div class="col-md-6">
						<fieldset class="sbox" style="border-top:0; border-radius: 5px;"><legend> Page Information</legend>
				<?php if( !isset($row['pageID']))  $row['pageID'] = null;   ?>
		<input  type='hidden' name='pageID' id='pageID' value='{{$row['pageID']}}' />
									
									  <div class="form-group  depen-  wrap-title  " >
										<label for="ipt" class=" control-label "> Title  <span class="asterix"> * </span>  </label>
										
										
										  <?php if( !isset($row['title']))  $row['title'] = null;   ?>
		 <?php $val = json_decode($row['title']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#title_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}' id='title_{{$ilang}}_{{$curTime}}'>
				<input  type='text' name="title[{{$ilang}}]" id='title' value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}' 
						required  placeholder='Title - {{$ilang}}'     class='form-control input-sm ' />
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-slug  " >
										<label for="ipt" class=" control-label "> Slug    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Do not enter any special character or blank SPACE. Keep this value unique."><i class="fa fa-info-circle"></i></a>
										
										  <?php if( !isset($row['slug']))  $row['slug'] = null;   ?>
		<input  type='text' name='slug' id='slug' value='{{ $row['slug'] }}' 
						       class='form-control input-sm ' /> 						
									  </div> 					
									  <div class="form-group  depen-  wrap-h1_tag  " >
										<label for="ipt" class=" control-label "> H1 Tag    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Page title with SEO relavance"><i class="fa fa-info-circle"></i></a>
										
										  <?php if( !isset($row['h1_tag']))  $row['h1_tag'] = null;   ?>
		 <?php $val = json_decode($row['h1_tag']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#h1_tag_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}' id='h1_tag_{{$ilang}}_{{$curTime}}'>
				<input  type='text' name="h1_tag[{{$ilang}}]" id='h1_tag' value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}' 
						  placeholder='H1 Tag - {{$ilang}}'     class='form-control input-sm ' />
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-h2_tag  " >
										<label for="ipt" class=" control-label "> H2 Tag    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Page sub-title with SEO relavance"><i class="fa fa-info-circle"></i></a>
										
										  <?php if( !isset($row['h2_tag']))  $row['h2_tag'] = null;   ?>
		 <?php $val = json_decode($row['h2_tag']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#h2_tag_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}' id='h2_tag_{{$ilang}}_{{$curTime}}'>
				<input  type='text' name="h2_tag[{{$ilang}}]" id='h2_tag' value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}' 
						  placeholder='H2 Tag - {{$ilang}}'     class='form-control input-sm ' />
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-image  " >
										<label for="ipt" class=" control-label "> Image    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Feature image for the page, optional and applicable to specific page with the layout requirement."><i class="fa fa-info-circle"></i></a>
										
										  <?php if( !isset($row['image']))  $row['image'] = null;   ?>
		<input  type='hidden' name='image' id='image' value='{{ $row['image'] }}' class='image    form-control input-sm '    />

							
                <button class='btn btn-primary mr-5' data-type='mediaUpload' data-target='.image' type='button'>Choose file</button>
				<button class='btn btn-danger unUploadImage' data-type='mediaUnUpload' data-target='image' type='button'>Remove File</button>
            
			
							<div class='image_preview'></div>
							<div class='imagePreview'>
					 	<div class='img-preview'>
						{!! SiteHelpers::showUploadedFile($row['image'],'/uploads/images/page/') !!}
						
						</div>					
						</div>					
					 						
									  </div> 					
									  <div class="form-group  depen-  wrap-content  " >
										<label for="ipt" class=" control-label "> Content    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Content "><i class="fa fa-info-circle"></i></a>
										
										  <?php if( !isset($row['content']))  $row['content'] = null;   ?>
		 <?php $val = json_decode($row['content']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#content_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}' id='content_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="content[{{$ilang}}]" rows='5' id='content'   class='form-control editor input-sm '  
				             >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>
				
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> <?php if( !isset($row['filename']))  $row['filename'] = null;   ?>
		<input  type='hidden' name='filename' id='filename' value='{{$row['filename']}}' />
				<?php if( strlen($row['views']) < 1 )  $row['views']  = '0'; 	  ?>
		<input  type='hidden' name='views' id='views' value='{{$row['views']}}' />
				<?php if( !isset($row['ctrl_function']))  $row['ctrl_function'] = null;   ?>
		<input  type='hidden' name='ctrl_function' id='ctrl_function' value='{{$row['ctrl_function']}}' />
									
									  <div class="form-group  depen-  wrap-exclude_sitemap  " >
										<label for="ipt" class=" control-label "> Exclude Sitemap    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Switch On if you wish to exclude from Search Engine crawling."><i class="fa fa-info-circle"></i></a>
										
										  <?php if( strlen($row['exclude_sitemap']) < 1 )  $row['exclude_sitemap']  = '0'; 	  ?>
		<div class='switch-wrap'> <label class='switch'>
				    <input type='hidden' name='exclude_sitemap' value ='0' />
					<input type='checkbox' name='exclude_sitemap' value ='1' 
					@if($row['exclude_sitemap']) checked @endif 
					 />   <span class="slider round"></span></label></div> 						
									  </div> </fieldset>
			</div>
			
			<div class="col-md-6">
						<fieldset class="sbox" style="border-top:0; border-radius: 5px;"><legend> Additional Information</legend>
									
									  <div class="form-group  depen-  wrap-heading  " >
										<label for="ipt" class=" control-label "> Heading    </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Page heading"><i class="fa fa-info-circle"></i></a>
										
										  <?php if( !isset($row['heading']))  $row['heading'] = null;   ?>
		 <?php $val = json_decode($row['heading']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#heading_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}' id='heading_{{$ilang}}_{{$curTime}}'>
				<input  type='text' name="heading[{{$ilang}}]" id='heading' value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}' 
						  placeholder='Heading - {{$ilang}}'     class='form-control input-sm ' />
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-meta_title  " >
										<label for="ipt" class=" control-label "> Meta Title    </label>
										
										
										  <?php if( !isset($row['meta_title']))  $row['meta_title'] = null;   ?>
		 <?php $val = json_decode($row['meta_title']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#meta_title_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}' id='meta_title_{{$ilang}}_{{$curTime}}'>
				<input  type='text' name="meta_title[{{$ilang}}]" id='meta_title' value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}' 
						  placeholder='Meta Title - {{$ilang}}'     class='form-control input-sm ' />
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-meta_desc  " >
										<label for="ipt" class=" control-label "> Meta Description    </label>
										
										
										  <?php if( !isset($row['meta_desc']))  $row['meta_desc'] = null;   ?>
		 <?php $val = json_decode($row['meta_desc']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#meta_desc_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}' id='meta_desc_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="meta_desc[{{$ilang}}]" rows='5' id='meta_desc' class='form-control input-sm '  
				             >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>
				
				
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-metakey  " >
										<label for="ipt" class=" control-label "> Meta keywords    </label>
										
										
										  <?php if( !isset($row['metakey']))  $row['metakey'] = null;   ?>
		<input  type='text' name='metakey' id='metakey' value='{{ $row['metakey'] }}' 
						       class='form-control input-sm ' /> 						
									  </div> 					
									  <div class="form-group  depen-  wrap-footer_content  " >
										<label for="ipt" class=" control-label "> Footer Content    </label>
										
										
										  <?php if( !isset($row['footer_content']))  $row['footer_content'] = null;   ?>
		 <?php $val = json_decode($row['footer_content']); $is_first = true; ?>	
				<ul class='editor-nav nav nav-tabs'>

				@foreach(explode(',', config('website.cnf_langs')) as $ilang )<li class='{{$is_first ? "active" : null}} '><a  href='#footer_content_{{$ilang}}_{{$curTime}}' data-toggle='tab'>{{$ilang}}</a></li>
				<?php  $is_first = false;?>
				@endforeach </ul>
				
				<div class="tab-content ">
				<?php $is_first = true; ?>
				@foreach(explode(',', config('website.cnf_langs')) as $ilang )
				<div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}' id='footer_content_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="footer_content[{{$ilang}}]" rows='5' id='footer_content'   class='form-control editor input-sm '  
				             >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>
				
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 						
									  </div> 					
									  <div class="form-group  depen-  wrap-status  " >
										<label for="ipt" class=" control-label "> Status  <span class="asterix"> * </span>  </label>
										
										
										  <?php if( strlen($row['status']) < 1 )  $row['status']  = 'draft'; 	  ?>
		<?php $status = (isset($row['status'])) ? $row['status'] : null ; ?>
					
					<input type='radio' name='status' value ='publish' required    @if( $status == 'publish') checked="checked" @endif class='minimal-red' > Publish 
					
					<input type='radio' name='status' value ='draft' required    @if( $status == 'draft') checked="checked" @endif class='minimal-red' > Draft 
					
					<input type='radio' name='status' value ='trash' required    @if( $status == 'trash') checked="checked" @endif class='minimal-red' > Trash  						
									  </div> </fieldset>
			</div>
			
			
		</div>
		
		
</div>
</div>
</div>
@include('/manage/'.$pageModule.'/subform')

		
		
		<div class="sbox-title clearfix">
			<div class="sbox-tools pull-right" >
				<a href="{{ url('/manage/'.$pageModule.'?return='.$return) }}" class="tips btn btn-sm "  title="{{ __('core.btn_back') }}" ><i class="fa  fa-times"></i></a> 
			</div>
			<div class="sbox-tools pull-left" >
				<button name="apply" class=" btn btn-sm btn-primary  "  title="{{ __('core.btn_back') }}" ><i class="fa  fa-check"></i> {{ __('core.sb_apply') }} </button>
				<button name="save" class=" btn btn-sm btn-success"  title="{{ __('core.btn_back') }}" ><i class="fa  fa-paste"></i> {{ __('core.sb_save') }} </button> 
			</div>
		</div>	
		
	
	
	<input type="hidden" name="action_task" value="save" />
	{!! Form::close() !!}
	</div>
</div>		

	
		 
   <script type="text/javascript">
	$(document).ready(function() { 
		
		
		 		 

		$('.removeMultiFiles').on('click',function(){
			var removeUrl = '{{ url("pages/removefiles?file=")}}'+$(this).attr('url');
			$(this).parent().remove();
			$.get(removeUrl,function(response){});
			$(this).parent('div').empty();	
			return false;
		});		
		
	});
	</script>		 
@stop