@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();
	$switcher = [];
	?>

<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="For Page" class=" control-label col-md-3 text-left"> For Page <span class="asterix"> * </span></label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Page"><i class="fa fa-info-circle"></i></a>
										
										<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="Widget Type" class=" control-label col-md-3 text-left"> Widget Type <span class="asterix"> * </span></label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Type"><i class="fa fa-info-circle"></i></a>
										
										<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   ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  
										
										</div> 
										<?php  if( !isset($row['widget_content']))  $row['widget_content'] = null; 
												if($row['widget_type']) $switcher[$row['widget_type']]  = $row['widget_content']; ?>
										
									  <input  type='hidden' name='widget_content' id='widget_content' value='{{$row['widget_content']}}' />
									
									  <div class="form-group depen- wrap-object_type  hidden" >
										<label for="Object Type" class=" control-label col-md-3 text-left"> Object Type <span class="asterix"> * </span></label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['object_type']))  $row['object_type'] = null;   ?>
		<input  type='hidden' name='object_type' id='object_type' value='{{ $row['object_type'] }}' 
						required   data-parsley-maxlength="50"    class='form-control input-sm ' /> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-link  " >
										<label for="Link" class=" control-label col-md-3 text-left"> Link </label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Hyperlink"><i class="fa fa-info-circle"></i></a>
										
										<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="Sort Order" class=" control-label col-md-3 text-left"> Sort Order <span class="asterix"> * </span></label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Sequence - Sort "><i class="fa fa-info-circle"></i></a>
										
										<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="Status" class=" control-label col-md-3 text-left"> Status <span class="asterix"> * </span></label>
										<a class="adtip" data-toggle="tooltip" data-placement="bottom" title="Enable"><i class="fa fa-info-circle"></i></a>
										
										<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> 					
									
									  <div id="switcherWrapper">
									  <div class="form-group depen- wrap-stores  hidden" id="StoresGridWrapper">
										<label for="Stores" class=" control-label col-md-3 text-left"> Stores </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['stores']))  $row['stores'] = null;   ?>
		 
					<?php $row['stores'] = trim($row['stores'],'[]'); ?>

					 <select name='StoresGrid[]' multiple rows='5' id='stores' class='select2 '      ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-brands  hidden"  id="BrandsGridWrapper">
										<label for="Brands" class=" control-label col-md-3 text-left"> Brands </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['brands']))  $row['brands'] = null;   ?>
		 
					<?php $row['brands'] = trim($row['brands'],'[]'); ?>

					 <select name='BrandsGrid[]' multiple rows='5' id='brands' class='select2 '      ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-image  hidden"  id="PromoImageWrapper">
										<label for="Image" class=" control-label col-md-3 text-left"> Image </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($switcher['PromoImage']))  $switcher['PromoImage'] = null;   ?>
		<input  type='hidden' name='PromoImage' id='image' value='{{ $switcher['PromoImage'] }}' 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($switcher['PromoImage'],'') !!}
						
						</div>					
						</div>					
					 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-tags  hidden" id="TagListWrapper" >
										<label for="Tags" class=" control-label col-md-3 text-left"> Tags </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['tags']))  $row['tags'] = null;   ?>
		 
					<?php $row['tags'] = trim($row['tags'],'[]'); ?>

					 <select name='TagList[]' multiple rows='5' id='tags' class='select2 '      ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-pages  hidden" id="PageListWrapper">
										<label for="Pages" class=" control-label col-md-3 text-left"> Pages </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['pages']))  $row['pages'] = null;   ?>
		 
					<?php $row['pages'] = trim($row['pages'],'[]'); ?>

					 <select name='PageList[]' multiple rows='5' id='pages' class='select2 '      ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-store_cats  hidden" id="StoreCatListWrapper">
										<label for="Store Cats" class=" control-label col-md-3 text-left"> Store Cats </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['store_cats']))  $row['store_cats'] = null;   ?>
		 
					<?php $row['store_cats'] = trim($row['store_cats'],'[]'); ?>

					 <select name='StoreCatList[]' multiple rows='5' id='store_cats' class='select2 '      ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-full_html  hidden" id="HtmlBoxWrapper">
										<label for="Full Html" class=" control-label col-md-3 text-left"> Full Html </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($switcher['HtmlBox']))  $switcher['HtmlBox'] = null;   ?>
		 <?php $val = json_decode($switcher['HtmlBox']); $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='#full_html_{{$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='full_html_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="HtmlBox[{{$ilang}}]" rows='5' id='full_html'   class='form-control editor input-sm '  
				             >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>
				
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-text_content  hidden" id="TextBoxWrapper">
										<label for="Text Content" class=" control-label col-md-3 text-left"> Text Content </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($switcher['TextBox']))  $switcher['TextBox'] = null;   ?>
		 <?php $val = json_decode($switcher['TextBox']); $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='#text_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 {{$is_first ? "active" : null}}' id='text_content_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="TextBox[{{$ilang}}]" rows='5' id='text_content' class='form-control input-sm '  
				             >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>
				
				
						</div>
						<?php  $is_first = false;?>
						@endforeach
						</div>
						 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </div> 					
									  <div class="form-group depen- wrap-coupon_cats  hidden" id="CatListWrapper" >
										<label for="Coupon Cats" class=" control-label col-md-3 text-left"> Coupon Cats </label>
										
										
										<div class="col-md-9">
										  <?php if( !isset($row['coupon_cats']))  $row['coupon_cats'] = null;   ?>
		 
					<?php $row['coupon_cats'] = trim($row['coupon_cats'],'[]'); ?>

					 <select name='CatList[]' multiple rows='5' id='coupon_cats' class='select2 '      ></select> 
										 </div> 
										 <div class="col-md-2">
										 	
										 </div>
									  </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>		

	
@include('manage.'.$pageModule.'.widget-js')
  	 
@stop