<div id="admin_settings_main">
	<h1>Настройки модулей</h1>
	{if !$_cfg.core.separate_config}
		<ul class="nav nav-tabs">
			<li><a href="{url}" title="Настройки сайта"><img src="/skins/default/images/icons/settings.png" alt="Настройки сайта" /></a></li>
			<li class="active"><a href="{url action="modules"}" title="Настройки модулей"><img src="/skins/default/images/icons/module.png" alt="Настройки модулей" /></a></li>
		</ul>
	{/if}

	<form method="post" action="#"  style="margin-top: 10px;">
		<p><input type="hidden" name="token" value="{$_user->token}" /></p>
		<div id="accordian" >
			{foreach $modules as $module_id=>$module}
				<div class="panel panel-primary" {if !$module.config}style="display:none"{/if}>
					<div class="panel-heading">{$module.name|escape}</div>
					<div class="panel-body">
						{foreach $module.access as $permis=>$access}
							<input type="hidden" name="access[{$module_id}][{$permis}]" value="{$access.val}" /> 
						{/foreach}					
						<table class="table table-striped">
							{foreach $module.config as $conf=>$cfg}
								<tr>
									<td>
										{$cfg.title|escape}
										<small class="help-block">{$cfg.describe|escape}</small>
									</td>
									<td>
										{if $cfg.type=='integer' || $cfg.type=='string'}
											<input class="form-control" type="text" name="config[{$module_id}][{$conf}]" value="{$smarty.post.config.$module_id.$conf|default:$cfg.val|escape}" /> 
										{elseif $cfg.type=='password'}
											<input class="form-control" type="password" name="config[{$module_id}][{$conf}]" value="{$smarty.post.config.$module_id.$conf|default:$cfg.val|escape}" /> 
										{elseif $cfg.type=='select'}
											<select class="form-control" name="config[{$module_id}][{$conf}]">
												{html_options options=$module.values.$conf selected=$cfg.val}
											</select>
										{elseif $cfg.type=='boolean'}
											<input type="checkbox" name="config[{$module_id}][{$conf}]"{if $cfg.val} checked="checked"{/if} />
										{elseif $cfg.type=='select_multiple'}
											<select class="form-control" multiple="multiple" name="config[{$module_id}][{$conf}][]">
												{html_options options=$module.values.$conf selected=$cfg.val}
											</select>
										{/if}
									</td>
								</tr>	
							{/foreach}
							<tr>
								<td{if $module.config} colspan="2"{/if}>
									<input type="submit" class="btn btn-default" value="Сохранить" />
								</td>
							</tr>
						</table>
					</div>
				</div>
			{/foreach}
		</div>
	</form>

	<script type="text/javascript">
		$('#accordian').accordion({ header: 'div.panel-heading', autoheight: false, fillSpace:false, alwaysOpen: true });
	</script>
</div>