<script type="text/javascript" src="##JS_PATH##libsext/js/reorder.js"></script>
<script type="text/javascript" src="##JS_PATH##libsext/js/table_dnd.js"></script>
{literal}
<style type="text/css">
.class1{
background:#3366FF;
}
.showDragHandle{
background:#FF0000;
cursor:move;
}
.altbox .content table tr.even td {background: #fff;}
</style>
{/literal}
{if $sm.res}
<div class="box box-75 altbox">
<div class="boxin">
<div class="header">
<h3>Config Settings</h3><input id="collapse" type="button" class="button" value="Expand All"/>
{capture name=links}
<a class="button" href="javascript:void(0);" onclick="addNew('##LBL_ADMIN_SITE_URL##index.php/page-setting-choice-add-ce-0');">Add new</a>
<span id="chk_unchk"><a class="button" href="javascript:void(0);" onclick="checkAll(1);">Check All</a></span>
<!--<a class="button" href="javascript:void(0);" onclick="checkAll(0);">Uncheck All</a>-->
<a class="button" href="javascript:void(0);" onclick="deleteKey('##LBL_ADMIN_SITE_URL##index.php/page-setting-choice-delete_config-ce-0');">Delete</a>
{/capture}
{$smarty.capture.links}
</div>
<div style="margin-bottom:10px;">
{section name=setting loop=$sm.res}
{assign var=x value=$sm.res[setting]}
{if $sm.res[setting.index_prev].name != $x.name}
<div class="div_head">
<div class="fl"><b class="sign" style="font-size:16px; margin-left:5px">+</b></div>
<div class="fl"><b> {$x.name}</b></div>
</div>
<div class="content table_margin" style="display:none">
<!--<form action="##LBL_ADMIN_SITE_URL##index.php/page-setting-choice-update_config" name="setting_{$x.name}" method="post">-->
{literal}
<script type="text/javascript">
$(document).ready(function(){
var curl='##LBL_ADMIN_SITE_URL##index.php/setting/reorder?tab=';
{/literal}
new callreorder("tab{$x.name}","dragHandle",curl,"showDragHandle","class1");
{literal}
});
</script>
{/literal}
<div class="fr" style="margin-top:10px;margin-right:5px">
<a href="javascript:void(0);" onclick="addNew('##LBL_ADMIN_SITE_URL##index.php/page-setting-choice-add-id_config-{$x.id_config}-ce-0');">Add new</a>
</div>
<form action="javascript:void(0);" id="setting_{$x.name}" name="setting_{$x.name}" method="post" onsubmit="updateConfig('##LBL_ADMIN_SITE_URL##index.php/page-setting-choice-update_config','{$x.name}')">
<input type="hidden" name="sectype" value="{$x.name}" />
<table align="center" id="tab{$x.name}">
{/if}
<tr class="nodrag" id={$x.id_config}>
<td class="dragHandle"></td>
<td width="100px" class="ttop"><input type="checkbox" value="{$x.id_config}" class="chkbox" id="id_chk{$x.id_config}" /> <a href="javascript:void(0);" onclick="edit_config_key('{$x.id_config}');">{$x.ckey}</a></td>
<td class="ttop"> <!--input type="hidden" name="{$x.name}[{$x.ckey}][{$x.id_config}]" value="{$x.id_config}"/> -->
{assign var=f_key value=","|explode:$x.f_key}
{assign var=f_value value=","|explode:$x.f_value}
{assign var=name_field value=$x.name|cat:'['|cat:$x.id_config|cat:']'|cat:'['|cat:$x.id_config|cat:']'}
{if $x.f_type=='radio'}
{html_radios name=$name_field values=$f_key output=$f_value selected=$x.value}
{elseif $x.f_type=='checkbox'}
{assign var=x_value value=","|explode:$x.value}
{html_checkboxes name=$name_field values=$f_key output=$f_value selected=$x_value}
{elseif $x.f_type=='dropdown'}
<select name="{$name_field}">
{html_options values=$f_key output=$f_value selected=$x.value}
</select>
{else}
<input type="text" name="{$name_field}" value="{$x.value}" />
{/if}
</td>
<td><textarea name="{$x.name}[{$x.id_config}][comment]" style="background:none; width:300px">{$x.comment}</textarea></td>
</tr>
{if $sm.res[setting.index_next].name != $x.name}
<tr>
<td colspan="3" class="tr">
<input class="button" type="submit" value="Update" name="submit" />
</td>
</tr>
</table>
</form>
</div>
{/if}
{/section}
</div>
<div class="header">
{$smarty.capture.links}
</div>
</div>
</div>
{else}
<center><b>No records found</b></center>
{/if}
{literal}
<script type="text/javascript">
function addNew(url){
$.fancybox.showActivity();
$.post(url,function(response){
//$.fancybox(response,{centerOnScroll:true,hideOnOverlayClick:false});
show_fancybox(response);
});
}
function updateConfig(url,id){
var fval=$("#setting_"+id).serialize();
url+="-ce-0?"+fval;
$.post(url,function(response){
showmsg('',"Successfully Updated");//showmsg('divid','error message');
if(id=="ADMIN_THEME")
window.location.href=response;
});
}
function checkAll(c){
$('.chkbox').each(function(){
if(c){
$(this).attr('checked','checked');
$("#chk_unchk").html('<a class="button" href="javascript:void(0);" onclick="checkAll(0);">Uncheck All</a>');
}else{
$(this).removeAttr('checked');
$("#chk_unchk").html('<a class="button" href="javascript:void(0);" onclick="checkAll(1);">Check All</a>');
}
});
var txt=$('#collapse').attr('value');
if(txt=='Expand All'){
$('.table_margin').slideDown(1000);
$('#collapse').attr('value','Collapse All');
$('.sign').html('-');
}else if(txt=='Collapse All' && !c){
$('.table_margin').slideUp(1000);
$('#collapse').attr('value','Expand All');
$('.sign').html('+');
}
}
function deleteKey(url){
var keys='';
$('.chkbox').each(function(){
if($(this).is(':checked'))
keys +=$(this).val()+",";
});
if(!keys){
alert("Please choose records to delete.");
return false;
}else{
var c=confirm("Do you really want to delete selected records?");
if(!c)
return false;
}
$.post(url,{'keys':keys}, function(res){
window.location.href=res;
});
}
function edit_config_key(id_config) {
var url = "##LBL_ADMIN_SITE_URL##index.php";
$.fancybox.showActivity();
$.post(url,{"page":"setting","choice":"edit",ce:0,id_config:id_config},function(res){
//$.fancybox(res);
show_fancybox(res);
});
}
$('.div_head').click(function(){
var txt=$('.sign',this).html();
if(txt=='-'){
$(this).next('.table_margin').slideUp('slow');
$('.sign',this).html('+');
$('#collapse').attr('value','Expand All');
}else if(txt=='+'){
$(this).next('.table_margin').slideDown('slow');
$('.sign',this).html('-');
$('#collapse').attr('value','Collapse All');
}
});
$('#collapse').click(function(){
var txt=$('#collapse').attr('value');
if(txt=='Collapse All'){
$('.table_margin').slideUp(1000);
$('#collapse').attr('value','Expand All');
$('.sign').html('+');
}else if(txt=='Expand All'){
$('.table_margin').slideDown(1000);
$('#collapse').attr('value','Collapse All');
$('.sign').html('-');
}
});
</script>
{/literal}