@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/pagewidgets?return='.$return, 'class'=>'form-horizontal 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-12">
						<fieldset class="sbox" style="border-top:0; border-radius: 5px;"><legend> Page Widgets</legend>
				<?php if( !isset($row['id']))  $row['id'] = null;   ?>
		<input  type='hidden' name='id' id='id' value='{{$row['id']}}' />
									
									  <div class="form-group depen- wrap-title  " >
										<label for="Title" class=" control-label col-md-3 text-left"> Title <span class="asterix"> * </span></label>
										
										
										<div class="col-md-9">
										  <?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 {{$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="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-subtitle  " >
										<label for="Subtitle" class=" control-label col-md-3 text-left"> Subtitle </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['subtitle']))  $row['subtitle'] = null;   ?>
		 <?php $val = json_decode($row['subtitle']); $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='#subtitle_{{$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 {{$is_first ? "active" : null}}' id='subtitle_{{$ilang}}_{{$curTime}}'>
				<input  type='text' name="subtitle[{{$ilang}}]" id='subtitle' value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}' 
						  placeholder='Subtitle - {{$ilang}}'     class='form-control input-sm ' />
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-for_page  " >
										<label for="Page" class=" control-label col-md-3 text-left"> Page <span class="asterix"> * </span></label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['for_page']))  $row['for_page'] = null;   ?>
		<?php $for_page = (isset($row['for_page'])) ? $row['for_page'] : null ; ?>
					
					<input type='radio' name='for_page' value ='homepage' required    @if( $for_page == 'homepage') checked="checked" @endif class='minimal-red' > Homepage 
					
					<input type='radio' name='for_page' value ='all_stores' required    @if( $for_page == 'all_stores') checked="checked" @endif class='minimal-red' > All_stores 
					
					<input type='radio' name='for_page' value ='store_category' required    @if( $for_page == 'store_category') checked="checked" @endif class='minimal-red' > Store_category 
					
					<input type='radio' name='for_page' value ='store' required    @if( $for_page == 'store') checked="checked" @endif class='minimal-red' > Store 
					
					<input type='radio' name='for_page' value ='category' required    @if( $for_page == 'category') checked="checked" @endif class='minimal-red' > Category 
					
					<input type='radio' name='for_page' value ='tag' required    @if( $for_page == 'tag') checked="checked" @endif class='minimal-red' > Tag 
					
					<input type='radio' name='for_page' value ='brand' required    @if( $for_page == 'brand') checked="checked" @endif class='minimal-red' > Brand  
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-widget_type  " >
										<label for="Type" class=" control-label col-md-3 text-left"> Type <span class="asterix"> * </span></label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['widget_type']))  $row['widget_type'] = null;   ?>
		 
					<?php $row['widget_type'] = trim($row['widget_type'],'[]'); ?>

					 <select name='widget_type' rows='5' id='widget_type' class='select2 ' required   data-parsley-maxlength=  ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> <?php if( !isset($row['widget_content']))  $row['widget_content'] = null;   ?>
		<input  type='hidden' name='widget_content' id='widget_content' value='{{$row['widget_content']}}' />
				<?php if( !isset($row['object_type']))  $row['object_type'] = null;   ?>
		<input  type='hidden' name='object_type' id='object_type' value='{{$row['object_type']}}' />
									
									  <div class="form-group depen- wrap-link  " >
										<label for="Hyperlink" class=" control-label col-md-3 text-left"> Hyperlink </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['link']))  $row['link'] = null;   ?>
		<input  type='text' name='link' id='link' value='{{ $row['link'] }}' 
						   data-parsley-maxlength="500"    class='form-control input-sm ' /> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-sort_order  " >
										<label for="Sequence - Sort " class=" control-label col-md-3 text-left"> Sequence - Sort  <span class="asterix"> * </span></label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['sort_order']))  $row['sort_order'] = null;   ?>
		<input  type='number' name='sort_order' id='sort_order' value='{{ $row['sort_order'] }}' 
						required   data-parsley-maxlength="11"    class='form-control is_number'  /> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-status  " >
										<label for="Enable" class=" control-label col-md-3 text-left"> Enable <span class="asterix"> * </span></label>
										
										
										<div class="col-md-9">
										  <?php if( strlen($row['status']) < 1 )  $row['status']  = '1'; 	  ?>
		<div class='switch-wrap'> <label class='switch'>
				    <input type='hidden' name='status' value ='0' />
					<input type='checkbox' name='status' value ='1' 
					@if($row['status']) checked @endif 
					 />   <span class="slider round"></span></label></div> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </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() { 
		
		
		
		$("#widget_type").jCombo("{!! url('/manage/pagewidgets/comboselect?filter=widget_types:code:name&values='.$row["widget_type"]) !!}",
		{  selected_value : '{{ $row["widget_type"] }}' });
		 		 

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