<{include file="file:admin_style.css"}>
<div class="adminnavi">
	<a href="./index.php"><{$smarty.const._MI_USER_NAME}></a>&raquo;&raquo;
	<a href="./index.php?action=UserValueSetList"><{$smarty.const._AD_USER_LANG_USER_VALUE_SET_LIST}></a>&raquo;&raquo;
	<span class="adminnaviTitle"><{$smarty.const._AD_USER_LANG_USER_VALUE_SET_EDIT}></span>
</div>

<p><h3><{$smarty.const._AD_USER_LANG_USER_VALUE_SET_EDIT}></h3></p>
<p style="color:blue">&nbsp;&nbsp;&nbsp;<{$smarty.const._AD_USER_LANG_USER_VALUE_SET_EDIT_DESC}></p>
<br />
<br />

<script type="text/javascript" charset="utf-8">
var userEdit = new UserEdit.edit('<{$xoops_url}>', '<{$dirname}>', 'admin_value_set_form','');
jQuery.noConflict();
jQuery(function(){
	userEdit.sortable();
	jQuery('.<{$dirname}>_sortable tbody').bind('sortstop',function(event, ui){
		var formobj = jQuery('#<{$dirname}>_admin_value_set_form');
		formobj.attr('action', 'index.php?action=UserValueSetEdit&mode=6');
		formobj.submit();
	});
	jQuery('#<{$dirname}>_admin_value_set_form a[rel^="prettyPopin"],:button[rel^="prettyPopin"]').prettyPopin({
		width : 400, /* false/integer */
		height: 400, /* false/integer */
		opacity: 0.5, /* value from 0 to 1 */
		animationSpeed: '0', /*
		slow/medium/fast/integer */
		close : false, /* true/false */
		followScroll: false, /* true/false */
		loader_path: '../images/loader.gif', /* path to your loading image */
		callback: user_callback
	});
});
function user_callback(id,value){
	var form = jQuery('#<{$dirname}>_admin_value_set_form');
	if (value!=4){
		//add,edit
		var select_name_db = jQuery('#<{$dirname}>_select_name_db').val();
		form.attr('action', 'index.php?action=UserValueSetEdit&mode=' + value + '=' + select_name_db);
	}else{
		//delete
		form.attr('action', 'index.php?action=UserValueSetDelete&title_id='+id);
	}
	form.submit();	
}
function user_admin_value_set_submit(mode){
	var form = jQuery('#<{$dirname}>_admin_value_set_form');
	form.attr('action', 'index.php?action=UserValueSetEdit&mode='+mode);
	form.submit();
	return false;
}
function user_admin_value_set_link() {
	if (jQuery('#<{$dirname}>_mode').val() == 1) {
		var select_name_input = jQuery('#<{$dirname}>_select_name_input').val();
		var params = {mode:1,select_name:select_name_input};
		var str = jQuery.param(params);	
		var url = 'uservaluesetsub.php?' + str;
		jQuery('#<{$dirname}>_addbutton').attr('href',url);
	} else {
		var select_name_db = jQuery('#<{$dirname}>_select_name_db').val();
		var params = {mode:3,select_name:select_name_db};
		var str = jQuery.param(params);	
		var url = 'uservaluesetsub.php?' + str;
		jQuery('#<{$dirname}>_addbutton').attr('href',url);
	}
}
</script>

<{if $actionForm->hasError()}>
<div class="error">
<ul>
	<{foreach item=message from=$actionForm->getErrorMessages()}>
	<li><{$message|xoops_escape}></li>
	<{/foreach}>
</ul>
</div>
<{/if}>

<form id="<{$dirname}>_admin_value_set_form" name="<{$dirname}>_admin_value_set_form" action="index.php?action=UserValueSetEdit" method="post">
<{xoops_token form=$actionForm}> 
<{xoops_input type=hidden id=`$dirname`_mode name=mode value=$mode}>
<{if $mode == 2 && ($actionForm->get('select_name_db') eq '')}> 
<{xoops_input type=hidden id=`$dirname`_select_name_db name=select_name_db value=$actionForm->get('select_name_input')}>
<{else}>
<{xoops_input type=hidden id=`$dirname`_select_name_db name=select_name_db value=$actionForm->get('select_name_db')}>
<{/if}>
<p><{$smarty.const._AD_USER_LANG_USER_VALUE_SET_INFO}></p>
<{xoops_input type=text id=`$dirname`_select_name_input size=100 name=select_name_input value=$actionForm->get('select_name_input')}>
<{if $mode == 1 && ($actionForm->get('select_name_input') eq '' || $actionForm->hasError())}>
<input class="formButton" type="button" onclick="return user_admin_value_set_submit(1);" value="<{$smarty.const._AD_USER_LANG_NEXT}>"/>
<{elseif $mode !=1}>
<br />
<br />
<input class="formButton" type="button" onclick="return user_admin_value_set_submit(5);" value="<{$smarty.const._AD_USER_LANG_SAVE}>"/>
<{/if}>
<br />
<br />

<{if !empty($object)}>
<p>&raquo;<{$smarty.const._AD_USER_LANG_EDIT}></p>
<div class="<{$dirname}>_sortable">
<table class="outer">
	<thead>
	<tr>
		<th><{$smarty.const._AD_USER_LANG_CODE}></th>
		<th><{$smarty.const._AD_USER_LANG_NAME}></th>
		<th><{$smarty.const._AD_USER_LANG_CONTROL}></th>
	</tr>
	</thead>
	<tbody>
	<{foreach key=key item=obj from=$object}>
		<tr class="<{cycle values='odd,even'}>"> 
		<{xoops_input type=hidden name=display[] value=$obj->getShow('weight')}> 
		<{xoops_input type=hidden name=title_id[] value=$obj->getShow('title_id')}>
			<td class="<{$dirname}>_cursor"><{$obj->getShow('title_id')}></td>
      		<td class="<{$dirname}>_list_name"><{$obj->getShow('title')}></td>
     		<td class="<{$dirname}>_list_control">
       			<a rel="prettyPopin" href="uservaluesetsub.php?select_name=<{$obj->getShow('select_name')|xoops_escape|urlencode}>&amp;title_id=<{$obj->getShow('title_id')|xoops_escape|urlencode}>&amp;mode=2">
       			<img src="<{"icons/edit.png"|theme}>" alt="<{$smarty.const._EDIT}>" title="<{$smarty.const._EDIT}>" /></a>&nbsp;&nbsp;&nbsp;
       			<{if $canIdEdit[$key]}>
       			<a rel="prettyPopin" href="uservaluesetsub.php?select_name=<{$obj->getShow('select_name')|xoops_escape|urlencode}>&amp;title_id=<{$obj->getShow('title_id')|xoops_escape|urlencode}>&amp;mode=4">
       			<img src="<{"icons/delete.png"|theme}>" alt="<{$smarty.const._DELETE}>" title="<{$smarty.const._DELETE}>" /></a>
       			<{/if}>
      		</td>
       </tr>
	 <{/foreach}>
	 </tbody>
</table>
</div>
<{/if}>

<{if $actionForm->get('select_name_input') ne '' && !$actionForm->hasError()}>
	<{if empty($object)}>
		<p style="color:blue">&nbsp;&nbsp;&nbsp;<{$smarty.const._AD_USER_LANG_USER_VALUE_SET_EDIT_ATTENSION}></p>
	<{/if}>
	<p align="center">
	<input class="formButton" id="<{$dirname}>_addbutton" type="button" onclick="user_admin_value_set_link()" rel="prettyPopin" href="" value="<{$smarty.const._ADD}>"/>
<{else}>
	<p align="center">
<{/if}>
<input class="formButton" type="submit" value="<{$smarty.const._BACK}>" name="_form_control_cancel" />
</p>
</form>

