<script type="text/javascript">
	$(document).ready(function(){
		{{if isset( $smarty.get.activeTabId )}}$('ul.tab-headers li a[href="#{{$smarty.get.activeTabId}}"]').trigger('click');{{/if}}
	});
</script>

<div class="tabbed">
	<div class="clear"></div>
	<ul class="tab-headers">
		<li><a href="#values">{{$lang.Values}}</a></li>
		<li><a href="#columns">{{$lang.Columns}}</a></li>
	</ul>
	<h1>{{$lang.Adv_searcher}}</h1>
	<div class="tab" id="values">
		<h2>{{$lang.values}}</h2>
		<div id="value-delete-message"><p><span class="ui-icon ui-icon-alert"></span>Czy chcesz usunąć wybraną wartość? Informacje o wartości oraz wszystkich wartościach potomnych zostaną utracone bezpowrotnie!</p></div>

		<table id="advsearcher_list" class="list">
			{{if !empty( $aValue.iParentValue )}}
				<a href="?p=advsearcher-list&amp;iValue={{$aValue.iParentValue}}">{{$lang.Up}}</a>
			{{elseif isset( $aValue.iValue )}}
				<a href="?p=advsearcher-list">{{$lang.Up}}</a>
			{{/if}}
			<thead><tr><th class="left" colspan="3">{{if isset( $aValue.iValue )}}<form action="?p=advsearcher-value" method="post"><input type="hidden" name="iValue" value="{{$aValue.iValue}}" /><input type="hidden" name="iColumn" value="{{$aValue.iColumn}}" /> <label>{{$aColumnsNames[$aValue.iColumn].sName}}: <input type="text" name="sValue" value="{{$aValue.sValue}}" /></label> <label>{{$lang.Position}}: <input type="text" name="iPosition" value="{{$aValue.iPosition}}" /></label><input class="submit" type="submit" value="{{$lang.Save}}" /></form>{{else}}{{$lang.Adv_searcher}}{{/if}}</th></tr>
			{{if $aValue.bCanAdd}}
				<tr><th class="name">{{$lang.Name}}</th><th  class="position">{{$lang.Position}}</th><th class="actions">{{$lang.Actions}}</th></tr></thead>
				{{foreach from=$aValue.aChildren item=aSubValue}}
					<tr>
						<td class="name">{{$aSubValue.sValue}}</td>
						<td class="position">{{$aSubValue.iPosition}}</td>
						<td class="actions">
							<a href="?p=advsearcher-list&amp;iValue={{$aSubValue.iValue}}"><img src="templates/admin/images/ico/edit.png" alt="{{$lang.Edit}}"/></a>
							<a href="?p=advsearcher-delete&amp;iValue={{$aSubValue.iValue}}" class="value-delete"><img src="templates/admin/images/ico/delete.png" alt="{{$lang.Delete}}"/></a>
						</td>
					</tr>
				{{/foreach}}
				<tr><td class="left" colspan="3">
					<form action="?p=advsearcher-value" method="post">
						{{$lang.Add}}: <input type="hidden" name="iParentValue" value="{{$aValue.iValue}}" /><input type="hidden" name="iColumn" value="{{$aValue.iAddColumn}}" /><label>{{$aColumnsNames[$aValue.iAddColumn].sName}}: <input type="text" name="sValue" value="" /></label> <label>{{$lang.Position}}: <input type="text" name="iPosition" value="0" /></label><input class="new_element" type="submit" value="{{$lang.Add}}" />
					</form>
				</td></tr>
			{{/if}}
		</table>
	</div>
	<div class="tab" id="columns">
		<div id="column-delete-message"><p><span class="ui-icon ui-icon-alert"></span>Czy chcesz usunąć wybraną kolumnę? Informacje o kolumnie oraz jej wartościach zostaną utracone bezpowrotnie!</p></div>

		<form action="" method="post" id="advsearcher_columns">
		<fieldset>
		<table class="list">
		<thead>
			<tr><th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th class="actions">{{$lang.Actions}}</th></tr>
		</thead>
		{{foreach from=$aColumns item=aColumn}}
			<tr><td class="id">{{$aColumn.iColumn}}</td><td class="name"><input type="text" name="aColumnsNames[{{$aColumn.iColumn}}]" value="{{$aColumn.sName}}" /></td><td class="actions">{{if $aColumn@last}}<a href="?p=advsearcher-column_delete" class="column-delete"><img src="templates/admin/images/ico/delete.png" alt="{{$lang.Delete}}"/></a>{{/if}}</td></tr>
		{{/foreach}}
			<tr><td class="left" colspan="3">Dodaj kolumnę: <input type="text" name="sNewColumn" /><input type="submit" class="new_element" value="{{$lang.Save}}" name="sOption" /></td></tr>
		</table>
		</fieldset>
		</form>
	</div>
</div>
<div class="clear"></div>