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

<script type="text/javascript">
	var path = '{$path|$data|escape:'htmlall':'UTF-8'}';
	var id_language = Number({$defaultFormLanguage|$data|escape:'htmlall':'UTF-8'});
	var iso = "{$iso|escape:'UTF-8'}";
	var languages = new Array();
	
	{foreach from=$languages key=k item=language}
	languages[{$k|escape:'UTF-8'}] = {
		id_lang: {$language.id_lang|$data|escape:'htmlall':'UTF-8'},
		iso_code: "{$language.iso_code|$data|escape:'htmlall':'UTF-8'}",
		name: "{$language.name|$data|escape:'htmlall':'UTF-8'}"
	};
	{/foreach}
	{if $psversion16}
		var psversion16 = true;
	{else}
		var psversion16 = false;
	{/if}
</script>

<div class="toolbar-placeholder">
	<div class="toolbarBox">
		<ul class="cc_button">
			<li>
				<a id="desc-configuration-save" class="toolbar_btn" href="#" title="{l s='Save' mod='blockreinsurancecustom'}">
					<span class="process-icon-save"></span>
					<div class="locked">{l s='Save' mod='blockreinsurancecustom'}</div>
				</a>
			</li>
			<li>
				<a class="toolbar_btn" href="{$back_link|$data|escape:'htmlall':'UTF-8'}" title="{l s='Back to list' mod='blockreinsurancecustom'}">
					<span class="process-icon-back"></span>
					<div class="locked">{l s='Back to list' mod='blockreinsurancecustom'}</div>
				</a>
			</li>
		</ul>
		<div class="pageTitle">
			<h3>
				<span style="font-weight: normal;" id="current_obj">
					<span class="breadcrumb item-0">{$display_name|$data|escape:'htmlall':'UTF-8'}</span>
				</span>
			</h3>
		</div>
	</div>
</div>
<div class="leadin"></div>
<form action="" id="{$module_name|$data|escape:'htmlall':'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" />
	<fieldset>
		<legend><img src="{$path|$data|escape:'htmlall':'UTF-8'}img/add.gif" alt="{if $action_form == 'add'}{l s='Add a reinsurance block' mod='blockreinsurancecustom'}{else}{l s='Update a reinsurance block' mod='blockreinsurancecustom'}{/if}" />{if $action_form == 'add'}{l s='Add a reinsurance block' mod='blockreinsurancecustom'}{else}{l s='Update a reinsurance block' mod='blockreinsurancecustom'}{/if}</legend>
		
		<div class="form-group">
			<label for="icon">
				{l s='Icon' mod='blockreinsurancecustom'}
			</label>
			<div class="margin-form">
				<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'}" style="height:17px;margin-top:-5px;">
					<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 class="form-group">
			<label>{l s='Text' mod='blockreinsurancecustom'}</label>
			<div class="margin-form translatable">
				{foreach from=$languages item=language}
					<div class="lang_{$language.id_lang|escape:'UTF-8'}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if};float:left;">
						<textarea name="text_{$language.id_lang}" class="rte autoload_rte textarea-autosize" rows="10" cols="40">{$fields_value['text'][$language.id_lang]|$data|escape:'htmlall':'UTF-8'}</textarea>
					</div>
				{/foreach}
				<script type="text/javascript">
					displayFlags(languages, {$defaultFormLanguage|$data|escape:'htmlall':'UTF-8'}, 1);
				</script>
			</div>
			<div class="clear"></div>
		</div>
		<br />
		<div class="form-group">
			<label>{l s='Link' mod='blockreinsurancecustom'}</label>
			<div class="margin-form translatable">
				{foreach from=$languages item=language}
					<div class="lang_{$language.id_lang|$data|escape:'htmlall':'UTF-8'}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if};float:left;">
						<input type="text" name="link_{$language.id_lang}" value="{$fields_value['link'][$language.id_lang]|escape:'html':'UTF-8'}" />
					</div>
				{/foreach}
				<script type="text/javascript">
					displayFlags(languages, {$defaultFormLanguage|$data|escape:'htmlall':'UTF-8'}, 1);
				</script>
			</div>
			<div class="clear"></div>
		</div>
		<br />
		<label>{l s='New window' mod='blockreinsurancecustom'}</label>
		<div class="margin-form" style="padding-top:3px;">
			<input type="radio" value="1" {if $fields_value['new_window']}checked="checked"{/if} id="new_window_on" name="new_window">
			<label class="t" for="new_window_on">
				<img title="{l s='Yes' mod='blockreinsurancecustom'}" alt="{l s='Yes' mod='blockreinsurancecustom'}" src="../img/admin/enabled.gif">
			</label>
			<input type="radio" value="0" {if !$fields_value['new_window']}checked="checked"{/if} id="new_window_off" name="new_window">
			<label class="t" for="new_window_off">
				<img title="{l s='No' mod='blockreinsurancecustom'}" alt="{l s='No' mod='blockreinsurancecustom'}" src="../img/admin/disabled.gif">
			</label>
		</div>

		<div class="clear"></div>
		<div class="margin-form">
			<input type="submit" id="{$module_name|$data|escape:'htmlall':'UTF-8'}_form_submit_btn" class="button" name="saveblockreinsurance" value="Sauvegarder" style="display:none;">
		</div>
		<div id="selectIcon" style="display:none;">
			<table>
				{assign var=j value=1}
				{foreach $icon_list as $icon}
					
					{if $j == 1}
						<tr>
					{/if}
					
					<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>
	</fieldset>
</form>
<script type="text/javascript">
	var titleDial = '{l s='Choose an icon' mod='blockreinsurancecustom'}';
	
	$(document).ready(function(){
		$('#desc-configuration-save').click(function(e) {
			e.preventDefault();
			$('#{$module_name|$data|escape:'htmlall':'UTF-8'}_form').submit();
		});
		
		// 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>		