<{$formValidator_code}>
<script type="text/javascript">
  $(document).ready(function(){

    $(".act").change(function() {
      var this_op=$(this).val();
      var cate_id=$(this).attr("id");
      if(this_op=="rename"){
        $("#new_name_col"+cate_id).show();
        $("#move2"+cate_id).hide();
        $("#del_alert"+cate_id).hide();
        $("#set_assistant"+cate_id).hide();
      }else if(this_op=="delete" || this_op=="move"){
        $("#new_name_col"+cate_id).hide();
        $("#move2"+cate_id).show();
        $("#del_alert"+cate_id).hide();
        $("#set_assistant"+cate_id).hide();
      }else if(this_op=="del_all"){
        $("#new_name_col"+cate_id).hide();
        $("#move2"+cate_id).hide();
        $("#del_alert"+cate_id).show();
        $("#set_assistant"+cate_id).hide();
      }else if(this_op=="set_assistant"){
        $("#new_name_col"+cate_id).hide();
        $("#move2"+cate_id).hide();
        $("#del_alert"+cate_id).hide();
        $("#set_assistant"+cate_id).show();
      }else{
        $("#new_name_col"+cate_id).hide();
        $("#move2"+cate_id).hide();
        $("#del_alert"+cate_id).hide();
        $("#set_assistant"+cate_id).hide();
      }
    });
  });
</script>

<h1><a href="<{$plugin.url}>"><{$plugin.title}></a><{$smarty.const._MD_TCW_CATE_TOOLS}></h1>

<{if $cate_arr}>
  <form action="cate.php" method="post" id="myForm" enctype="multipart/form-data" class="form-horizontal" role="form">
    <{$cate_menu_form}>
    <hr>

    <{if $isMyWeb and $WebID}>
      <div class="form-group">
        <label class="col-md-2 control-label">
          <{$plugin.title}><{$smarty.const._MD_TCW_NEW_CATE}>
        </label>
        <div class="col-md-4">
          <input type="text" name="newCateName" id="newCateName" class="form-control">
        </div>
      </div>
    <{/if}>

    <{foreach from=$cate_opt_arr item=cate}>
      <!--<{$cate.CateName}>-->
      <div class="form-group">
        <label class="col-md-2 control-label">
          <{if $cate.assistant}>
            <i class="fa fa-male" alt="<{$cate.assistant.MemName}>" title="<{$cate.assistant.MemName}>"></i>
          <{/if}>
          <span class="label label-success"><{$cate.counter}></span>
          <a href="<{$ColName}>.php?WebID=<{$WebID}>&CateID=<{$cate.CateID}>"><{$cate.CateName}></a>
        </label>
        <div class="col-md-4">
          <select name="act[<{$cate.CateID}>]" id="<{$cate.CateID}>" class="form-control act">
            <option value=""><{$smarty.const._MD_TCW_CATE_NONE_OPT}></option>
            <option value="move"><{$smarty.const._MD_TCW_CATE_MOVE}></option>
            <option value="rename"><{$smarty.const._MD_TCW_CATE_MODIFY}></option>
            <option value="delete"><{$smarty.const._MD_TCW_DEL_CATE_MOVE_TO}></option>
            <option value="del_all"><{$smarty.const._MD_TCW_DEL_CATE_ALL}></option>
            <{if $plugin.assistant=='1'}>
            <option value="set_assistant"><{$smarty.const._MD_TCW_CATE_SET_ASSISTANT}></option>
            <{/if}>
          </select>
        </div>
        <div class="col-md-6">
          <input type="text" name="newName[<{$cate.CateID}>]" value="<{$cate.CateName}>" id="new_name_col<{$cate.CateID}>" class="validate[required] form-control new_name_col" style="display: none;">
          <select name="move2[<{$cate.CateID}>]" id="move2<{$cate.CateID}>" class="form-control move2" style="display: none;">
            <{foreach from=$cate_arr item=other}>
              <{if $other.CateID!=$cate.CateID}>
                <option value="<{$other.CateID}>"><{$other.CateName}></option>
              <{/if}>
            <{/foreach}>
          </select>
          <div id="del_alert<{$cate.CateID}>" class="del_alert" style="color: red; display: none;">
            <label class="checkbox">
              <input type="checkbox" name="alert[<{$cate.CateID}>]" value="yes">
              <{$smarty.const._MD_TCW_DEL_CATE_ALL_ALERT}>
            </label>
          </div>
          <select name="MemID[<{$cate.CateID}>]" id="set_assistant<{$cate.CateID}>" class="form-control set_assistant" style="display: none;">
            <{foreach from=$students item=mem}>
              <option value="<{$mem.MemID}>" <{if $cate.assistant.MemID==$mem.MemID}>selected<{/if}>><{$mem.CateName}>(<{$mem.MemSort}>)<{$mem.MemName}></option>
            <{/foreach}>
          </select>
        </div>
      </div>
    <{/foreach}>


    <div class="form-group">
      <div class="col-md-12 text-center">
        <input type="hidden" name="ColName" value="<{$ColName}>">
        <input type="hidden" name="WebID" value="<{$WebID}>">
        <input type="hidden" name="op" value="save_cate">
        <button type="submit" class="btn btn-primary"><{$smarty.const._TAD_SAVE}></button>
      </div>
    </div>
  </form>
<{else}>
  <div class="jumbotron">
    <h1><a href="<{$plugin.url}>"><{$plugin.title}></a><{$smarty.const._MD_TCW_CATE_NONE}></h1>
      <{if $isMyWeb and $WebID}>
        <form action="cate.php" method="post" id="myForm" enctype="multipart/form-data" class="form-horizontal" role="form">
          <div class="form-group">
            <label class="col-md-2 control-label">
              <{$smarty.const._MD_TCW_NEW_CATE}>
            </label>
            <div class="col-md-6">
              <input type="text" name="newCateName" id="newCateName" class="validate[required] form-control">
            </div>
            <div class="col-md-4">
              <input type="hidden" name="ColName" value="<{$ColName}>">
              <input type="hidden" name="WebID" value="<{$WebID}>">
              <input type="hidden" name="op" value="save_cate">
              <button type="submit" class="btn btn-primary"><{$smarty.const._TAD_SAVE}></button>
            </div>
          </div>
        </form>
      <{/if}>
  </div>
<{/if}>