<{include file="file:admin_header.html"}>
<script type="text/javascript" charset="utf-8">
var <{$dirname}>Edit = new XoonipsEdit.edit('<{$xoops_url}>', '<{$dirname}>', 'system_item_field_select_editform');
jQuery.noConflict();
jQuery(function(){
  <{$dirname}>Edit.sortable();
  jQuery('.<{$dirname}>_sortable tbody').bind('sortstop',function(event, ui){
    jQuery('#<{$dirname}>_system_item_field_select_edit_op').attr('value','save');
    jQuery('#<{$dirname}>_system_item_field_select_edit_mode').attr('value',6);
    jQuery('#<{$dirname}>_system_item_field_select_editform').submit();
  });
  jQuery('#<{$dirname}>_system_item_field_select_editform :button[rel^="prettyPopin"],a[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: xoonipsCallback
  });
});
function xoonipsCallback(id,mode){
  if (mode!=4){
    jQuery('#<{$dirname}>_system_item_field_select_edit_op').attr('value','save');
    jQuery('#<{$dirname}>_system_item_field_select_edit_mode').attr('value',mode);
  // delete mode
  } else {
    jQuery('#<{$dirname}>_system_item_field_select_edit_op').attr('value','delete');
    jQuery('#<{$dirname}>_system_item_field_select_edit_delete_id').attr('value',id);
  }
  jQuery('#<{$dirname}>_system_item_field_select_editform').submit();
  return false;
}
function action_submit(op,mode){
  jQuery('#<{$dirname}>_system_item_field_select_edit_op').attr('value',op);
  jQuery('#<{$dirname}>_system_item_field_select_edit_mode').attr('value',mode);
  jQuery('#<{$dirname}>_system_item_field_select_editform').submit();
}
function add_submit() {
  //add
  if (jQuery('#<{$dirname}>_system_item_field_select_edit_mode').val() == 1) {
    var name = jQuery('#<{$dirname}>_select_name').val();
    var params = {mode:1,select_name:name};
    var str = jQuery.param(params);  
    var url = '<{$smarty.const.XOOPS_MODULE_URL}>/<{$dirname}>/admin/system_itemfield_valuesetsub.php?' + str;
    jQuery('#<{$dirname}>_addbutton').attr('href',url);
  }else{       
    var name = jQuery('#<{$dirname}>_select_name_db').val();
    var params = {mode:3,select_name:name};
    var str = jQuery.param(params);  
    var url = '<{$smarty.const.XOOPS_MODULE_URL}>/<{$dirname}>/admin/system_itemfield_valuesetsub.php?' + str;
    jQuery('#<{$dirname}>_addbutton').attr('href',url);
  }
}
</script>
<form name="<{$dirname}>_system_item_field_select_editform" id="<{$dirname}>_system_item_field_select_editform" action="system_itemfield_select.php" method="post">
<input type="hidden" id="<{$dirname}>_system_item_field_select_edit_op" name="op" value="">
<input type="hidden" id="<{$dirname}>_system_item_field_select_edit_mode" name="mode" value="<{$mode}>"/> 
<input type="hidden" id="<{$dirname}>_system_item_field_select_edit_delete_id" name="delete_id" value=""> 
<input type="hidden" id="<{$dirname}>_select_name_db" name="select_name_db" value="<{$select_name_db}>"> 
<{$token_ticket}>
<input type="text" size="70" id="<{$dirname}>_select_name" name="select_name" value="<{$select_name|xoops_escape}>"></input>
<{if $mode <= 1 && ($select_name eq '' || !empty($errors))}>
<input class="formButton" type="button" onclick="return action_submit('edit',1);" value="<{$smarty.const._AM_XOONIPS_LABEL_NEXT}>"/>
<{elseif $mode > 1}>
<br />
<br />
<input class="formButton" type="button" onclick="return action_submit('save',5);" value="<{$smarty.const._AM_XOONIPS_LABEL_SAVE}>"/>
<{/if}>
<br />
<br />

<{if $mode == 2}>
  <br/><br/><br/><p>&raquo;<{$smarty.const._AM_XOONIPS_SYSTEM_VALUE_MODIFY_TITLE}></p>
  <div class="<{$dirname}>_sortable">
  <table width="100%" cellspacing="1" class="outer">
    <thead>
      <tr>
        <th><{$smarty.const._AM_XOONIPS_SYSTEM_VALUE_UID_TITLE}></th>
        <th><{$smarty.const._AM_XOONIPS_SYSTEM_VALUE_MODIFY_NAME}></th>
        <th><{$smarty.const._AM_XOONIPS_LABEL_ACTION}></th>
      </tr>
      </thead>
      <tbody>
      <{foreach item=obj from=$objects}>
      <tr class="<{cycle values='odd,even'}>"> 
        <td class="<{$dirname}>_cursor" width="9%"><{$obj.id|xoops_escape}></td>
        <td class="<{$dirname}>_list_title" width="78%"><{$obj.title|xoops_escape}><br />
        <input name="display_name[<{$obj.id|xoops_escape}>]" value="<{$obj.weight|xoops_escape}>" type="hidden"/>
          <input name="name" value="<{$obj.select_name|xoops_escape}>" type="hidden"/> 
            <input name="deletetitle" value="<{$obj.title|xoops_escape}>" type="hidden"/>                
        </td>
      <td class="<{$dirname}>_control" width="13%">
      <a rel="prettyPopin" href="<{$smarty.const.XOOPS_MODULE_URL}>/<{$dirname}>/admin/system_itemfield_valuesetsub.php?title_id=<{$obj.id|xoops_escape|urlencode}>&mode=2&select_name=<{$select_name|xoops_escape|urlencode}>">
      <img src="../images/icon_modify.png" alt="<{$smarty.const._AM_XOONIPS_LABEL_UPDATE}>" title="<{$smarty.const._AM_XOONIPS_LABEL_UPDATE}>" /></a>&nbsp;&nbsp;&nbsp;
      <{if $obj.canIdEdit}>
      <a rel="prettyPopin" href="<{$smarty.const.XOOPS_MODULE_URL}>/<{$dirname}>/admin/system_itemfield_valuesetsub.php?title_id=<{$obj.id|xoops_escape|urlencode}>&mode=4&select_name=<{$select_name|xoops_escape|urlencode}>">
      <img src="../images/icon_delete.png" alt="<{$smarty.const._AM_XOONIPS_LABEL_DELETE}>" title="<{$smarty.const._AM_XOONIPS_LABEL_DELETE}>"/></a>
      <{/if}>
        </td>
      </tr>
      <{/foreach}>
    </tbody>
  </table>
<{/if}>
<{if $select_name ne '' && empty($errors)}>
  <{if empty($objects)}>
    <p style="color:blue">&nbsp;&nbsp;&nbsp;<{$smarty.const._AM_XOONIPS_SYSTEM_VALUE_EDIT_ATTENTION}></p>
  <{/if}>
  <p align="center">
  <input class="formButton" id="<{$dirname}>_addbutton" type="button" onclick="add_submit()" rel="prettyPopin" href="" value="<{$smarty.const._ADD}>"/>
<{else}>
  <p align="center">
<{/if}>
<input class="formButton" type="button" value="<{$smarty.const._BACK}>" onclick=action_submit('back') />
</p>   
</form>
<{include file="file:admin_footer.html"}>
