<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>{$config.page_title|escape}</title>
{if $config.meta_robots}<meta name="robots" content="{$config.meta_robots}">
{/if}
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="{$config.root_uri}/bootstrap/bootswatch/{$appearance.bootswatch_name}/bootstrap.min.css" media="screen">
<link rel="stylesheet" href="{$config.root_uri}/css/parts.css">
<link rel="stylesheet" href="{$config.root_uri}/css/flatmemo.css">
<link rel="stylesheet" href="{$config.root_uri}/font-awesome/css/font-awesome.min.css">

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="{$config.root_uri}/bootstrap/bootstrap.min.js" defer></script>
<script src="{$config.root_uri}/js/flatmemo.js" defer></script>
<script src="{$config.root_uri}/js/jquery_kill_referrer.js" defer></script>

{literal}
<script>
sent=0;
function kakunin() {
if (sent ==0){
if ( document.FM.category_name.value == '' ){  alert('カテゴリ名を入力して下さい'); return false;}
if (confirm('カテゴリ【'+document.FM.category_name.value+'】を作成します。よろしいですか？')) {sent=1;accessing(); return true;} else {return false;}
}
if (sent==1){return false;}
}

/* リネーム確認*/
renamesent=0;
function rename_kakunin(obj) {
if (renamesent ==0){
obj.new_category_name.style.backgroundColor='#ffd1d1';
if ( obj.new_category_name.value == '' ){  alert('変更するカテゴリ名を入力して下さい'); return false;}
if (confirm('カテゴリ【'+obj.new_category_name.value+'】に変更を加えます。よろしいですか？')) {renamesent=1;return true;}
else {
obj.new_category_name.style.backgroundColor='#ffffff';
return false;
}
}
if (renamesent==1){return false;}
}
/* 削除確認 */
var deletesent=0;
function delete_kakunin(category_name,category_id) {
if (deletesent==0){
if (confirm('カテゴリ【'+ category_name +'】を削除します。\nカテゴリ内のデータも全て削除されます\nよろしいですか？')){
deletesent=1;
accessing('accessing_'+category_id);
location.href = 'memo_admin.php?cmd=category_delete_submit&category_id=' + category_id;
}
else { return false;}
}
else if (deletesent==1){return false;}
}
</script>
{/literal}

</head>
<body>

{include file="inc/header.html"}


<div class="container">

<div class="page-header">
<h1>カテゴリの編集 <small>カテゴリの追加・変更・削除を行います</small></h1>
</div>

<div class="row mb30">
<div class="col-xs-12">
<div class="pull-left"><a href="{$config.memo_uri}"><i class="fa fa-arrow-left"></i> トップに戻る</a>　　</div>
<div class="pull-right"><a href="{$config.admin_uri}?cmd=category_edit_input" ><i class="fa fa-file-text"></i> カテゴリの編集</a>　　
<a href="{$_program_name}?cmd=category_turn_input"><i class="fa fa-list"></i> カテゴリの順番変更</a>　　
<a href="{$_program_uri}?cmd=tag_edit_input" ><i class="fa fa-file-text"></i> タグの編集</a>
</div>
</div> <!-- /.col-xs-12 -->
</div>
<hr />


<div class="row">

<div class="col-xs-12 mb25">
<h2><i class="fa fa-check"></i> カテゴリの追加</h2>
<form name="FM" action="{$_program_uri}" onsubmit="return kakunin()">
<input type="hidden" name="cmd" value="category_add_submit" />
<div class="row">
<div class="pull-left pt5 ml15 ">
<h4>新規カテゴリ名：</h4>
</div>
<div class="pull-left ml10">
<input type="text" name="category_name" class="form-control" />
</div>
<div class="pull-left ml10">
<button type="submit" class="btn btn-primary">カテゴリ追加</button>
</div>
</div>

<div class="row ml1">
<p id="accessing" class="fm_accessing" style="display:none;"><i class="fa fa-refresh fa-spin"></i> now accessing...</p>
</div>

</form>
</div> <!-- /.col-xs-12 -->

</div> <!-- /.row -->


<div class="row mt25 mb25">
<div class="col-xs-12 mb25">
<h2><i class="fa fa-check"></i> カテゴリの編集</h2>


{ foreach from=$category_loop key="k" item="v" name="loopname"}
<!--category↓ -->

<div class="col-md-6 mt40">

<form enctype="multipart/form-data" style="display:inline;" method="post" name="FM2" action="{$_program_uri}" onsubmit="return rename_kakunin(this)">
<input type="hidden" name="cmd" value="category_edit_submit" />
<input type="hidden" name="category_id" value="{$v.category_id}" />

<div class="col-sm-2">
<div class="fm_icon2">
<a href="{$config.memo_uri}/category/{$v.category_id}"><p style="background-image: url({$config.icon_uri}/{if $v.icon_file_name}{$v.icon_file_name}{else}noicon.jpg{/if})"></p></a>
</div>
</div><!-- /.col-sm-2-->

<div class="col-sm-10">

<div class="row">
<div class="col-sm-4">カテゴリ名</div>
<div class="col-sm-8"><input type="text" name="new_category_name" class="form-control" value="{$v.category_name|escape}" /></div>
</div>

<div class="row mt2">
<div class="col-sm-4">説明文</div>
<div class="col-sm-8">
<textarea name="desc_name" rows="4" class="form-control">{$v.desc_name|escape}</textarea>
<label><input type="checkbox" name="view_mode" value="off" {if $v.view_mode == 'off'}checked{/if} /> 押し入れ( トップから隠します )</label><br />
</div>
</div><!-- /.row -->

<div class="row mt2">
<div class="col-sm-4">アイコン</div>
<div class="col-sm-8"><input class="form-control" name="icon_attach" type="file" /></div>
</div><!-- /.row -->

</div><!-- /.col-sm-10-->

<div class="row mt15 ml10">
<div class="col-sm-12">
<input type="submit" class="btn btn-primary"  value="変更する" />
<input type="button" class="btn btn-danger" onclick="delete_kakunin('{$v.category_name|escape}','{$v.category_id}');" value="【{$v.category_name|escape}】を削除する" />
<p id="accessing_{$v.category_id}" class="fm_accessing" style="display:none;"><i class="fa fa-refresh fa-spin"></i> now accessing...</p>

</div>
</div><!-- /.row -->


</form>
</div>
<!--category↑ -->
{ /foreach }

</div> <!-- /.col-xs-12 -->

</div>

</div>

{include file="inc/footer.html"}

</body>
</html>
