<{$bootstrap}>
<{$toolbar}>

<{if $up_power}>

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

    //***目錄排序****
    $("#dir_sort").sortable({opacity: 0.6, cursor: "move", update: function() {
        var order = $(this).sortable('serialize');
        $.post('save_dir_sort.php', order, function(theResponse){
            $('#save_msg').html(theResponse);
        });
    }
    });


    //***檔案排序****
    $("#sort").sortable({opacity: 0.6, cursor: "move", update: function() {
        var order = $(this).sortable('serialize');
        $.post('save_file_sort.php', order, function(theResponse){
            $('#save_msg').html(theResponse);
        });
    }
    });

    $("#clickAll").click(function() {
      if($("#clickAll").attr("checked")){
        $(".u<{$cat_sn}>").each(function() {
        $(this).attr("checked", true);
        });
      }else{
       $(".u<{$cat_sn}>").each(function() {
           $(this).attr("checked", false);
       });
      }
    });


  });

  function delete_catalog_func(cat_sn,of_cat_sn){
    var sure = window.confirm("<{$smarty.const._MD_TADUP_DEL_CONFIRM}>");
    if (!sure)	return;
    location.href="index.php?op=delete_catalog&cat_sn=" + cat_sn + "&of_cat_sn=" + of_cat_sn;
  }

  function delete_file_func(cfsn,of_cat_sn){
    var sure = window.confirm("<{$smarty.const._TAD_DEL_CONFIRM}>");
    if (!sure)	return;
    location.href="index.php?op=del_file&cfsn=" + cfsn + "&of_cat_sn=" + of_cat_sn;
  }

  </script>
<{/if}>

<div id="save_msg" style="float:right"></div>

<{$jqueryui}>


<{$path}>

<div style="clear:both"></div>

<{if $cat_desc}>
  <div class="well"><{$cat_desc}></div>
<{/if}>




<form action="index.php" method="POST" enctype="multipart/form-data">
  <{if $folder_list or $files_list}>

    <{if $list_mode=="more"}>
      <{$FooTableJS}>
      <table class="footable" id="filetbl">
        <thead>
          <tr class="success">
            <th data-class="expand">
              <label class="checkbox inline">
              <input type="checkbox" id="clickAll"> <{$smarty.const._MD_TADUP_FILE_NAME}>
              </label>
            </th>
            <th data-hide="phone" style="text-align:center;" nowrap>
              <{$smarty.const._MD_TADUP_FILE_DATE}>
            </th>
            <th data-hide="phone" style="text-align:center;" nowrap>
              <{$smarty.const._MD_TADUP_FILE_SIZE}>
            </th>
            <th data-hide="phone" style="text-align:center;" nowrap>
              <{$smarty.const._MD_TADUP_FILE_COUNTER}>
            </th>

            <{if $only_show_desc!="1"}>
              <th data-hide="phone"><{$smarty.const._MD_TADUP_FILE_DESC}></th>
            <{/if}>

            <{if $up_power}>
              <th data-hide="phone" style="text-align:center;">
                <{$smarty.const._TAD_FUNCTION}>
              </th>
            <{/if}>
          </tr>
        </thead>
    <{else}>
      <div class="row-fluid">
    <{/if}>


    <{if $folder_list}>
      <{if $list_mode=="icon"}>
        <ul id="dir_sort" style="display:inline">
        <{foreach from=$folder_list item=folder}>
          <li id="tr_<{$folder.cat_sn}>" style="display:inline;margin:2px;width:<{$icon_width}>;height:130px;float:left;">
            <a href="index.php?of_cat_sn=<{$folder.cat_sn}>" style="display:block;height:64px;overflow:hidden;margin:0px auto;text-align:center">
            <img src="images/folder<{$folder.lock}>.gif">
            </a>
            <div style="overflow: hidden;width:100%;height:50px;text-align:center;">
              <a href="index.php?of_cat_sn=<{$folder.cat_sn}>" style="font-size:12px;text-align:left;">
            <{$folder.cat_title}></a>(<{$folder.file_num}>)
            </div>
          </li>
        <{/foreach}>
        </ul>
      <{else}>
        <tbody id="dir_sort">
        <{foreach from=$folder_list item=folder}>
          <tr id="tr_<{$folder.cat_sn}>">
            <td colspan=2>
              <{if $up_power}>
                <label>
              <{/if}>
              <img src="images/s_folder<{$folder.lock}>.png" hspace="2" align="absmiddle"><a href="index.php?of_cat_sn=<{$folder.cat_sn}>"><{$folder.cat_title}></a>
              <{if $up_power}>
                </label>
              <{/if}>
            </td>
            <td style="font-size:11px;text-align:center;"><{$folder.file_num}><{$smarty.const._MD_TADUP_FILE}></td>
            <td style="font-size:11px;text-align:center;"><{$folder.cat_count}></td>
            <{if $only_show_desc!="1"}>
              <td style="font-size:12px;"><{$folder.cat_desc}></td>
            <{/if}>
            <{if $up_power}>
              <td style="text-align:center;">
                <{if $folder.file_num==0}>
                  <a href="javascript:delete_catalog_func(<{$folder.cat_sn}>,<{$folder.the_cat_sn}>);" class="btn btn-mini btn-danger"><{$smarty.const._TAD_DEL}></a>
                <{/if}>
              </td>
            <{/if}>
          </tr>
        <{/foreach}>
        </tbody>
      <{/if}>
    <{/if}>

    <{if $files_list}>
      <{if $list_mode=="more"}>
        <tbody id="sort">
          <{foreach from=$files_list item=file}>
            <tr id="tr_<{$file.cfsn}>">
              <td nowrap>
                <{if $up_power}>
                  <label class="checkbox inline">
                  <input type="checkbox" name="select_files[<{$file.cfsn}>]" value="<{$file.cf_name}>" class="u<{$file.cat_sn}>">
                <{/if}>
                <{if $file.pic}>
                  <div style="width:24px;height:24px;background-image: url(<{$file.pic}>);float:left;background-size:cover;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;margin-right:2px;"></div>
                <{/if}>
                <a href="index.php?op=dlfile&cfsn=<{$file.cfsn}>&cat_sn=<{$file.cat_sn}>&name=<{$file.fname}>">
                <{if $only_show_desc=="1"}>
                  <{$file.cf_desc}>
                <{else}>
                  <{$file.cf_name}>
                <{/if}>
                </a>

                <{if $up_power}>
                </label>
                <{/if}>
              </td>
              <td style="font-size:11px;text-align:center;"><{$file.up_date}></td>
              <td style="font-size:11px;text-align:center;"><{$file.size}></td>
              <td style="font-size:11px;text-align:center;"><{$file.cf_count}></td>

              <{if $only_show_desc!="1"}>
                <td style="font-size:12px;">
                <{if $file.cf_desc!=$file.cf_name}>
                <{$file.cf_desc}>
                <{/if}></td>
              <{/if}>

              <{if $up_power}>
                <td style="text-align:center;">
                   <a href="javascript:delete_file_func(<{$file.cfsn}>,<{$cat_sn}>);" class="btn btn-mini btn-danger"><{$smarty.const._TAD_DEL}></a>
                  <a href="uploads.php?cfsn=<{$file.cfsn}>" class="btn btn-mini btn-warning"><{$smarty.const._TAD_EDIT}></a>
                </td>
              <{/if}>
            </tr>
          <{/foreach}>
        </tbody>
      <{else}>
        <ul id="sort" style="display:inline">
          <{foreach from=$files_list item=file}>
            <li id="tr_<{$file.cfsn}>" style="display:inline;margin:2px;width:<{$icon_width}>;height:130px;float:left;">
              <a href="index.php?op=dlfile&cfsn=<{$file.cfsn}>&cat_sn=<{$file.cat_sn}>" style="display:block;height:64px;overflow:hidden;margin:0px auto;text-align:center">
              <img src="<{$file.pic}>" title="<{$file.cf_desc}>" class="img-rounded" style="<{$file.thumb_style}>">
              </a>

              <div style="overflow: hidden;width:100%;height:50px;text-align:center;">
                <{if $up_power}>
                  <label class="checkbox inline">
                  <input type="checkbox" name="select_files[<{$file.cfsn}>]" value="<{$file.cf_name}>" class="u<{$file.cat_sn}>">
                <{/if}>

                <a href="index.php?op=dlfile&cfsn=<{$file.cfsn}>&cat_sn=<{$file.cat_sn}>" style="display:inline-block;width:auto;line-height:110%;font-size:12px;text-align:left;margin:0px auto;">

                <{if $only_show_desc=="1"}>
                  <{$file.cf_desc}>
                <{else}>
                  <{$file.cf_name}>
                <{/if}>
                </a>
                <{if $up_power}>
                  </label>
                <{/if}>
              </div>
            </li>
          <{/foreach}>
        </ul>
      <{/if}>
    <{/if}>

    <{if $list_mode=="more"}>
      </table>
    <{else}>
      </div>
    <{/if}>
  <{/if}>

  <{if $up_power}>
    <div class="well">
      <{if $files_list}>
        <div>
          <label class="radio inline">
            <input type="radio" name="all_selected"  value="all_del"><{$smarty.const._MD_TADUP_SELECTED_DEL}>
          </label>
        </div>

        <{if $move_option}>
          <div>
            <label class="radio inline span3">
            <input type="radio" name="all_selected"  value="all_move"><{$smarty.const._MD_TADUP_SELECTED_MOVETO}>
            </label>
            <select name='new_cat_sn'>
              <option value=0><{$smarty.const._MD_TADUP_ROOT}></option>
              <{$move_option}>
            </select>
          </div>
        <{/if}>
      <{/if}>

      <div class="row-fluid">
        <label class="span2">
          <{$smarty.const._MD_TADUP_SELECT_FOLDER}><{$smarty.const._TAD_FOR}>
        </label>
        <select name="add_to_cat" size=1 class="span3">
          <option value="0"><{$smarty.const._MD_TADUP_ROOT}></option>
          <{$menu_option}>
      	</select>
        <input type="text" name="creat_new_cat" class="span3" placeholder="<{$smarty.const._MD_TADUP_CREAT_NEW_CATE}>">
      </div>

      <div class="row-fluid">
        <label class="span2">
          <{$smarty.const._MD_TADUP_SELECT_FILES}><{$smarty.const._TAD_FOR}>
        </label>
        <{$upform}>
        <input type="text" name="cf_desc" class="span5"  value="<{$cf_desc}>" placeholder="<{$smarty.const._MD_TADUP_FILE_DESC}>">
        <input name="op" type="hidden" value="save_files">
        <input name="cat_sn" type="hidden" value="<{$cat_sn}>">
        <button type="button" class="btn"><{$smarty.const._TAD_RESET}></button>
        <button type="submit" class="btn btn-primary"><{$smarty.const._TAD_GO}></button>
      </div>
    </div>

    <span class="help-block text-right">
    php.ini: memory_limit (<{$memory_limit}>) > post_max_size (<{$post_max_size}>) >      upload_max_filesize (<{$upload_max_filesize}>) ;
    max_execution_time=<{$max_execution_time}>
    </span>
  <{/if}>
</form>
