{* Block Reinsurance Custom Prestashop module
 * Copyright 2014, Prestaddons
 * Author: Prestaddons
 * Website: http://www.prestaddons.fr
 *}

<script type="text/javascript">
	var path = '{$path|escape:'UTF-8'}';
	{if $psversion16}
		var psversion16 = true;
	{else}
		var psversion16 = false;
	{/if}
</script>
<form action="" id="{$table|escape:'UTF-8'}_form" method="post" class="form-horizontal">
	<input type="hidden" value="1" name="saveblockreinsurancecustom" />
	<input type="hidden" value="{$id_reinsurance_custom|escape:'html':'UTF-8'}" id="id_reinsurance_custom" name="id_reinsurance_custom" />
	<div class="panel">
		<h3><i class="icon-plus-sign-alt">&nbsp;</i>{if $action_form == 'add'}{l s='Add a reinsurance block' mod='blockreinsurancecustom'}{else}{l s='Update a reinsurance block' mod='blockreinsurancecustom'}{/if}</h3>
		
		<div class="form-wrapper">
			<div class="form-group">
				<label class="control-label col-lg-3" for="icon">
					{l s='Icon' mod='blockreinsurancecustom'}
				</label>
				<div class="col-lg-9">
					<div class="form-group">
						<div class="col-sm-6">
							<div class="dummyfile input-group">
								<span class="input-group-addon"><i class="icon" data-icon="{if $fields_value['icon_name'] != ''}&#x{$fields_value['icon_name']}{/if}"></i></span>
								<input type="text" readonly="" name="icon_name" id="icon-name" value="{$fields_value['icon_name']|escape:'html':'UTF-8'}">
								<span class="input-group-btn">
									<button class="btn btn-default" name="submitAddAttachments" type="button" id="icon-selectbutton">
										<i class="icon-folder-open"></i> {l s='Choose an icon' mod='blockreinsurancecustom'}
									</button>
								</span>
							</div>
						</div>
					</div>
				</div>
			</div>
									
			<div class="form-group">
				<label class="control-label col-lg-3">{l s='Text' mod='blockreinsurancecustom'}</label>
				<div class="col-lg-9">
					{assign var=use_textarea_autosize value=true}
					{foreach $languages as $language}
						{if $languages|count > 1}
						<div class="form-group translatable-field lang-{$language.id_lang}" {if $language.id_lang != $defaultFormLanguage}style="display:none;"{/if}>
							<div class="col-lg-9">
						{/if}
						
						<textarea name="text_{$language.id_lang}" class="rte autoload_rte textarea-autosize" >{$fields_value['text'][$language.id_lang]|escape:'html':'UTF-8'}</textarea>
						
						{if $languages|count > 1}	
							</div>
							<div class="col-lg-2">
								<button type="button" class="btn btn-default dropdown-toggle" tabindex="-1" data-toggle="dropdown">
									{$language.iso_code|escape:html:'UTF-8'}
									<span class="caret"></span>
								</button>
								<ul class="dropdown-menu">
									{foreach from=$languages item=language}
									<li>
										<a href="javascript:hideOtherLanguage({$language.id_lang|escape:html:'UTF-8'});" tabindex="-1">{$language.name|escape:html:'UTF-8'}</a>
									</li>
									{/foreach}
								</ul>
							</div>
						</div>
						{/if}
					{/foreach}
				</div>
				
				<div class="form-group">
				<label class="control-label col-lg-3">{l s='Link' mod='blockreinsurancecustom'}</label>
				<div class="col-lg-9">
					{foreach $languages as $language}
						{if $languages|count > 1}
						<div class="form-group translatable-field lang-{$language.id_lang}" {if $language.id_lang != $defaultFormLanguage}style="display:none;"{/if}>
							<div class="col-lg-9">
						{/if}
						<div class="input-group">
							<span class="input-group-addon"><i class="icon icon-link"></i></span>
							<input type="text" name="link_{$language.id_lang}" value="{$fields_value['link'][$language.id_lang]|escape:'html':'UTF-8'}" placeholder="http://www.example.com"/>
						</div>
						{if $languages|count > 1}	
							</div>
							<div class="col-lg-2">
								<button type="button" class="btn btn-default dropdown-toggle" tabindex="-1" data-toggle="dropdown">
									{$language.iso_code|escape:html:'UTF-8'}
									<span class="caret"></span>
								</button>
								<ul class="dropdown-menu">
									{foreach from=$languages item=language}
									<li>
										<a href="javascript:hideOtherLanguage({$language.id_lang|escape:html:'UTF-8'});" tabindex="-1">{$language.name|escape:html:'UTF-8'}</a>
									</li>
									{/foreach}
								</ul>
							</div>
						</div>
						{/if}
					{/foreach}
				</div>
				
				<div class="form-group">
					<label class="control-label col-lg-3">{l s='New window' mod='blockreinsurancecustom'}</label>
					<div class="col-lg-9 ">
						<span class="switch prestashop-switch fixed-width-lg">
							<input type="radio" value="1" {if $fields_value['new_window']}checked="checked"{/if} id="new_window_on" name="new_window">
							<label for="new_window_on">{l s='Yes' mod='blockreinsurancecustom'}</label>
							<input type="radio" value="0" {if !$fields_value['new_window']}checked="checked"{/if} id="new_window_off" name="new_window">
							<label for="new_window_off">{l s='No' mod='blockreinsurancecustom'}</label>
							<a class="slide-button btn"></a>
						</span>
					</div>
				</div>
				
			</div>
		</div>
		<div id="selectIcon" style="display:none;">
			<table>
				{assign var=j value=1}
				{foreach $icon_list as $icon}
					
					{if $j == 1}
						<tr>
					{/if}
					
					{*if <td><span data-icon=""></span></td>*}
					<td><i class="icon" data-icon="&#x{$icon|escape:html:'UTF-8'}" data-icon-font="{$icon|escape:html:'UTF-8'}"></i></td>
					
					{if ($j == 20)}
						</tr>
						{assign var=j value=0}
					{/if}
					
					{math assign=j equation="x + y" x=$j y=1}
				{/foreach}
			</table>
		</div>
		<div class="panel-footer">
			<a class="btn btn-default" href="{$back_link|escape:'UTF-8'}"><i class="process-icon-back"></i>{l s='Back to list' mod='blockreinsurancecustom'}</a>
			<button class="btn btn-default pull-right" name="submitBlockreinsurancecustom" type="submit"><i class="process-icon-save"></i>{l s='Save' mod='blockreinsurancecustom'}</button>
		</div>
	</div>
</form>
		
<script type="text/javascript">
	var titleDial = '{l s='Choose an icon' mod='blockreinsurancecustom'}';
	
	$(document).ready(function(){
		
		// Gestion des icones
		$("#selectIcon").dialog({
			height: 500,
			width: 700,
			title: titleDial
		});

		$("#selectIcon").dialog("close");
		$("#icon-selectbutton, #icon-name").click(function() {
			$("#selectIcon").dialog("open");
		});

		$("#selectIcon td").click(function() {
			$("#icon-name").val($(this).children('i').attr('data-icon-font'));
			$("#icon-name").prev('span').html($(this).html());
			$("#selectIcon").dialog("close");
		});

	});
</script>