<script src="../js/prototype.js" type="text/javascript"></script>
<script src="../js/scriptaculous.js" type="text/javascript"></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+"&amp;token={/literal}{$token}{literal}",
				recenterAuto:false
});

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

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

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

{/literal}-->
</script>

<div id="bsmContentArea">
	<!--タイトル/-->
	<h2 id="pageTitle">フォームジェネレータ</h2>
	<!--/タイトル-->
	<!--ローカルナビゲーション/-->
	<div id="localNavi">
		<h3>フォーム一覧&nbsp;&gt;&nbsp;パーツ設定</h3>
	</div>
	<!--/ローカルナビゲーション-->
	<div id="bsmMainArea">
		<div class="inner">
			<h3 class="pageTitle">パーツ一覧</h3>
<!--
			<div class="bsmContentsComment">
				<p>説明</p>
			</div>
-->
			<!-- /パーツ一覧 -->
			<div id="bsmListArea">

				<!--list/-->
				<div class="bsmPartsList">

					<!--buttonArea/-->
					<div class="bsmContentsBtnArea">
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td style="padding: 0 5px 0 0; width: 100px;">
									<form name="partlist" method="post" action="../frmlist/index.php">
										<input class="bsmBtnListBack" type="submit" name="BTNList" value="一覧に戻る" >
									</form>
								</td>
								<td class="rt">
									{if count($tpllist) != 0}
									<form name="partprev" method="post" action="../partlist/prev.php">
										<input class="bsmBtnView" type="submit" name="BTNreview" value="プレビュー" >
										<input type="hidden" name="prt_frm_id" value="{$prt_frm_id}">
										<input type="hidden" name="frm_defaultflg" value="{$frm_defaultflg}">
									</form>
									{/if}
								</td>
							</tr>
						</table>
					{if $frm_defaultflg != "1"}
					<div style="padding: 20px 0 0 0; text-align: left;">
						<input type="button" class="bsmBtnPartsAdd" value="フォームパーツを追加" onclick="return showBox('', '../partadd/index.php?prt_frm_id={$prt_frm_id}', 840, 500)"/>
					</div>
					{/if}

					</div>
					<!--/buttonArea-->

					<!--FormPartsListArea/-->
					<div class="bsmFormPartsListArea">
					<ul id="items">
						{foreach from="$tpllist" item="tplrecord" name="tpl"}
						<li id="part_{$tplrecord.prt_part_id}"{if $tplrecord.prt_u_date == ""} class="nonReg"{/if}>
							<table border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td class="ct" style="width: 51px;"><img src="../common-img/{$tplrecord.prt_part_type}ico.gif"></td>
									<td>{$tplrecord.prt_part_label}{if $tplrecord.prt_u_date == ""}（未設定）{/if}</th>
									<td class="w4 lt">
									<!--  <input class="bsmBtnEdit" type="submit" name="BTNedit" value="編集" onclick="return showBox('', 'edit.php?prt_part_id={$tplrecord.prt_part_id}&prt_frm_id={$tplrecord.prt_frm_id}&prt_part_type={$tplrecord.prt_part_type}&prt_part_sub_type={$tplrecord.prt_part_sub_type}&prt_part_fileupload_limitflg={$tplrecord.prt_part_fileupload_limitflg}&frm_defaultflg={$frm_defaultflg}', 840, 500)"> -->
									<input class="bsmBtnEdit" type="submit" name="BTNedit" value="編集" onclick="return showBox('', 'edit.php?prt_part_id={$tplrecord.prt_part_id}&prt_frm_id={$tplrecord.prt_frm_id}&prt_part_type={$tplrecord.prt_part_type}&prt_part_sub_type={$tplrecord.prt_part_sub_type}&prt_part_fileupload_limitflg={$tplrecord.prt_part_fileupload_limitflg}&frm_defaultflg={$frm_defaultflg}&prt_u_date={$tplrecord.prt_u_date}', 840, 500)">
									</td>
									{if $frm_defaultflg != "1"}
									<td class="w4 lt">
										<form name="delete" method="post" action="index.php">
											<input  class="bsmBtnDeleteParts"  type="submit" name="BTNdelete" value="削除" onClick ="return confirm('本当に削除してよろしいですか？')">
											<input type="hidden" name="prt_part_id" value="{$tplrecord.prt_part_id}">
											<input type="hidden" name="prt_frm_id" value="{$tplrecord.prt_frm_id}">
											<input type="hidden" name="token" value="{$token}">
										</form>
									</td>
									{/if}
								</tr>
							</table>
							</li>
							{foreachelse}
							<li>
								<p>登録されたパーツはありません</p>
							</li>
							{/foreach}
						</ul>
						</div>

					</div>
					<!--/list-->
			</div>
			<!-- パーツ一覧/ -->
		</div>
	</div>
	<script type="text/javascript">
	//<![CDATA[{literal}
	var sort_flg = true;
	Sortable.create("items", {tag:"li", overlap:"vertical" ,dropOnEmpty:true, constraint:"vertical",onUpdate:function(){getParams()}});

	//順序変更時のセッションへの保存処理
	function getParams() {

	  if(sort_flg) {
	   //items<ul>リストのパラメータ作成
	   var ccode = Sortable.sequence('items') //新規追加コンテナのcodeは0以下の値とする

	   var ctype = "";
	   //リストのパラメータをPHPへ渡し、itemsのulを書き換える

	   new Ajax.Request('../aj/page-layout.php',
	   		{
		   		"method": "get",
		   		parameters:'mode=sort&pagec_code='+ccode
		   		//parameters:'mode=sort&pagec_code='+ccode,
	            //onSuccess: function(request) {
	            //    alert('送信完了しました\nサーバからのメッセージ: '+request.responseText);
	            //}
	   		});
	  }
	 }
	{/literal}//]]>
	</script>
	<div id="bsmMenuArea">
		<div class="inner">
			{include file=$MENU}
		</div>
	</div>
</div>
