<script type="text/javascript" src="../js/prototype.js"></script>
<script type="text/javascript" src="../js/scriptaculous.js"></script>
<script type="text/javascript" src="../js/window/window.js"></script>

<link href="{$BINGOTOPURL}/js/window/themes/default.css" rel="stylesheet" type="text/css"/>
<link href="{$BINGOTOPURL}/js/window/themes/alert.css" rel="stylesheet" type="text/css"/>
<link href="{$BINGOTOPURL}/js/window/themes/alphacube.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript">
<!--{literal}
function reloadParentOnClose(){
	var url = window.top.document.URL;
	window.top.location.href=url;
}
var win;
function showBox(title, url, width, height) {

win = new Window(
			{className: "alphacube",
				title: title,
				width:width, height:height,
				url: url,
				recenterAuto:false
});

win.setCloseCallback(function(){
	reloadParentOnClose();
	return true;
					});

win.setZIndex(10001);
win.showCenter(true);
}

function closeBox() {
	Windows.close(win.getId());
	//location.reload();
}

{/literal}-->
</script>

<div id="bsmContentArea">
	<!--タイトル/-->
	<h2 id="pageTitle">フォームジェネレータ</h2>
	<!--/タイトル-->
	<!--ローカルナビゲーション/-->
	<div id="localNavi">
		<h3>フォーム一覧</h3>
	</div>
	<!--/ローカルナビゲーション-->
	<div id="bsmMainArea">
		<div class="inner">
			<h3 class="pageTitle">フォーム一覧</h3>
<!--
			<div class="bsmContentsComment">
				<p>説明</p>
			</div>
-->
			<!--list/-->
			<div class="bsmContentsList">
			<!--エラーコメント/-->
			{foreach from=$ERROR item="msg" name="err"}
				{if $smarty.foreach.err.first}
				<p class="errBox">{/if}
					{$msg}<br>
					{if $smarty.foreach.err.last}
				</p>
				{/if}
			{/foreach}
			<!--/エラーコメント-->
			<table class="bsmContentTable" width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<th class="ct w4">並び順</th>
					<th class="ct">フォーム名称</th>
					<th class="ct w6">公開・編集</th>
					<th class="ct w7">基本情報設定</th>
					<th class="ct w7">パーツ設定</th>
					<th class="ct w6">未対応件数</th>
					<th class="ct w7">受付一覧</th>
					<!--<th class="ct w7">選択項目集計</th>-->
					<th class="ct w4">複製</th>
				</tr>
				{foreach from="$tpllist" item="tplrecord" name="tpl"}
				<tr>
					<td class="ct">{$form.frm_order[$tplrecord.frm_id].html}</td>
					<td>{$tplrecord.frm_name|escape}</td>
					<td class="ct">
						<form name="frmact" method="post" action="index.php">
						{if $tplrecord.frm_actflg == 0}
							<input class="bsmBtnOpen" type="submit" name="bsmBtnAct" value="公開する">
						{else}
						 	<input class="bsmBtnReedition" type="submit" name="bsmBtnAct" value="再編集">
						{/if}
							<input type="hidden" name="frm_id" value="{$tplrecord.frm_id}">
							<input type="hidden" name="frm_actflg" value="{$tplrecord.frm_actflg}">
							<input type="hidden" name="token" value="{$token}">
						</form>
					</td>
					<td class="ct">
					{if $tplrecord.frm_actflg == 0}
						<form name="frmedit" method="post" action="../frmadd/index.php">
							<input class="bsmBtnBase" type="submit" name="BTNedit" value="基本情報設定">
							<input type="hidden" name="frm_id" value="{$tplrecord.frm_id}">
							<input type="hidden" name="frm_defaultflg" value="{$tplrecord.frm_defaultflg}">
							<input type="hidden" name="token" value="{$token}">
						</form>
					{/if}
					</td>
					<td class="ct">
					{if $tplrecord.frm_actflg == 0}
						<form name="partlist" method="post" action="../partlist/index.php">
							<input class="bsmBtnParts" type="submit" name="BTNpart" value="パーツ設定">
							<input type="hidden" name="frm_id" value="{$tplrecord.frm_id}">
							<input type="hidden" name="frm_defaultflg" value="{$tplrecord.frm_defaultflg}">
							<input type="hidden" name="frm_actflg" value="{$tplrecord.frm_actflg}">
							<input type="hidden" name="token" value="{$token}">
						</form>
					{/if}
					</td>
					<td class="ct">
						{$tplrecord.unCorrespondenceNumber}件
					</td>
					<td class="ct">
				    	<form name="inqhis" method="post" action="../inqlist/index.php">
							{if $tplrecord.active_inquiries > 0}<input class="bsmBtnContactList" type="submit" name="BTNinqhis" value="お問い合わせ一覧">{/if}
							<input type="hidden" name="frm_id" value="{$tplrecord.frm_id}">
							<input type="hidden" name="token" value="{$token}">
						</form>
					</td>
					<!--<td class="ct">
						{if $tplrecord.active_inquiries > 0}<input class="bsmBtnSelectVotes" type="button" name="BTNedit" value="選択項目集計" onclick="open_window({$tplrecord.frm_id}); return false;" >{/if}
					</td>-->
					<td class="ct">
				    	<!-- <form name="copy" method="post" action="_index.php"> -->
							<!-- <input class="bsmBtnCopy" type="submit" name="BTNcopy" value="複製" onClick="return confirm('複製処理を開始してもよろしいですか？')"> -->
							<input class="bsmBtnCopy" type="submit" name="BTNcopy" value="複製" onClick="return showBox('', '_index.php?frm_id={$tplrecord.frm_id}', 300, 150)">
						<input type="hidden" name="frm_id" value="{$tplrecord.frm_id}">
						<input type="hidden" name="token" value="{$token}">
						<!-- </form> -->
					</td>
				</tr>
				{if $smarty.foreach.tpl.last}
				<tr>
					<td class="lt" colspan="8" style="padding: 5px 0 0 0; border-bottom: none;">
					<form {$form.attributes} onSubmit="return setOrder();">
						<input type="submit" value="保存" name="bsmBtnOrder" class="bsmBtnSave" id="bsmBtnOrder">
					</form>
					</td>
				</tr>
				{/if}
				{foreachelse}
				<tr>
					<td colspan="8" class="ct">登録されているフォームはありません</td>
				</tr>
				{/foreach}
			</table>
			</div>
			<!--/list-->
		</div>
	</div>
	<div id="bsmMenuArea">
		<div class="inner">
			{include file=$MENU}
		</div>
	</div>
	<div class="clr"></div>
</div>

<script type="text/javascript">
//<![CDATA[{literal}
function setOrder(){
	var orders=$$(".orders"),
	param={bsmBtnOrder:1},
	len=orders.length;
	for(var i=1; i<len; i++){
		param[orders[i].name]=orders[i].value;
	}
    new Ajax.Request(location.href,{
		method: "post",
		parameters:param,
        onSuccess: function(request){
			location.href=location.href;
		}
   	});
	return false;
}

function open_window(frm_id){
	window.open('result.php?frm_id='+frm_id, 'result', 'height=600, width=700, menubar=no, toolbar=no, scrollbars=yes, resizable=no, location=no, status=no');
}
//]]>{/literal}
</script>
