<!--{template 'head'}-->
<script type="text/javascript">
setSubject("系统设置");
</script>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='tableborder'>
  <tr>
    <td class="tablerow"><b>管理选项</b>
		<a href='system.php?sys=extend&action=manage' style="margin-left:10px;">模型管理</a>  | <a href='system.php?sys=extend&action=add'>添加模型</a>
	</td>
  </tr>
</table>
<!--{if $action=='manage'}-->
<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' class='tableborder' id="mytable">
  <tr height='22'>
	<td class="tablerowhighlight" width=40>ID</td>
	<td class="tablerowhighlight"  width=200>模型名称</td>
	<td class="tablerowhighlight"  width=120>类型</td>
	<td class="tablerowhighlight"  width=150>数据表</td>
	<td class="tablerowhighlight"  width=100>状态</td>
	<td class="tablerowhighlight" >操作</td>
	</tr>
	<!--{loop $data $val}--->
	<tr class="item">
		<td class="tablerowl">{$val['id']}</td>
		<td style="padding-left:10px;">{$val['name']}</td>
		<td align=center><!--{if $val['pid'] == 0}-->系统模型<!--{else}--><font color=green>扩展模型</font><!--{/if}--></td>
		<td style="padding-left:10px;">{$val['table_name']}</td>
		<td align=center><!--{if $val['is_lock'] == 0}-->正常<!--{else}-->已锁定<!--{/if}--></td>
		<td style="padding-left:10px;">
		<!--{if $val['pid'] > 0}-->
			<a href="system.php?sys=extend&action=modify&id={$val['id']}">修改模型</a>
		   <span>|</span>
			<a href="system.php?sys=extend&action=delete&id={$val['id']}"  onclick="return makeSure();">删除模型</a>
		   <span>|</span>
			<a href="system.php?sys=extend&action=extend_manage&id={$val['id']}">管理扩展</a>
		   <span>|</span>
			<a href="system.php?sys=extend&action=extend_add&id={$val['id']}">添加扩展</a>
		<!--{else}-->
			<a href="system.php?sys=extend&action=extend_manage&id={$val['id']}">管理扩展</a>
		   <span>|</span>
			<a href="system.php?sys=extend&action=extend_add&id={$val['id']}">添加扩展</a>
		<!--{/if}-->
		</td>
	</tr>
	<!--{/loop}-->
</table>
<!--{/if}-->

<!--{if $action=='add'}-->
<form action="system.php?sys=extend&action=add" method="post" name="myform">
	<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' class='tableborder border'>
	  <tr height='36'>
		<td class="tablerowl" width=40% style="text-align:right;padding-right:10px;">继承自</td>
		<td class="tablerow">
			<select name="pid" id="pid">
				<!--{loop $data $val}-->
				<option value="{$val['id']}">{$val['id']} - {$val['name']}</option>
				<!--{/loop}-->
			</select>
			<p style="padding:5px 0"><font color="blue">不继承该模型的扩展属性</font></p>
		</td>
	  </tr>
	  <tr height='36'>
		<td class="tablerowl"  style="text-align:right;padding-right:10px;">模型名称</td>
		<td class="tablerow">
				<input type="text" name="name" value="" class="f-text" size=30 />
		</td>
	  </tr>
	  <tr height='36'>
		<td class="tablerowl"  style="text-align:right;padding-right:10px;">前台程序目录</td>
		<td class="tablerow">
				<p><input type="text" name="appname" value="" class="f-text" size=30 maxlength="30" /></p>
				<p style="color:green">不填的话，系统使用默认的程序执行</p>
				<p style="color:green">前台程序在 app 目录下，如果要自定义该目录，则需要实现相应的功能</p>
		</td>
	  </tr>
	  <tr height='36' class="tablerowl">
			<td colspan=2 class="tablerowl">
				<input type="hidden" name="update" value="1" />
				<input type="submit" value="添加"  class="f-button"/>
			</td>
	  </tr>
	</table>
</form>
<!--{/if}-->

<!--{if $action=='modify'}-->
<form action="system.php?sys=extend&action=modify&id={$id}" method="post" name="myform">
	<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' class='tableborder border'>
	  <tr height='36'>
		<td class="tablerowl" width=40%   style="text-align:right;padding-right:10px;">模型名称</td>
		<td class="tablerow">
				<input type="text" name="name" value="{$item['name']}" class="f-text" size=30 />
		</td>
	  </tr>
	  <tr height='36'>
		<td class="tablerowl"  style="text-align:right;padding-right:10px;">前台程序目录</td>
		<td class="tablerow">
				<p><input type="text" name="appname" value="{$item['appname']}" class="f-text" size=30 maxlength="30" /></p>
				<p style="color:green">不填的话，系统使用默认的程序执行</p>
				<p style="color:green">前台程序在 app 目录下，如果要自定义该目录，则需要实现相应的功能</p>
		</td>
	  </tr>
	  <tr height='36' class="tablerowl">
			<td colspan=2 class="tablerowl">
				<input type="hidden" name="update" value="1" />
				<input type="submit" value="修改"  class="f-button"/>
			</td>
	  </tr>
	</table>
</form>
<!--{/if}-->

<!--{if $action=='extend_manage'}-->
<script type="text/javascript">
var delField = function(resp){
	alert(1);
}
</script>
<form action="system.php?sys=extend&action=ordering&id={$id}" method="post" name="myform">
<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' class='tableborder' id="mytable">
	<tr>
	  <th colspan=8><strong>{$param['name']} 模型扩展管理</strong></th>
	</tr>
  <tr height='22'>
	<td class="tablerowhighlight" width=40>ID</td>
	<td class="tablerowhighlight"  width=60>排序</td>
	<td class="tablerowhighlight"  width=200>名称</td>
	<td class="tablerowhighlight"  width=120>扩展名称</td>
	<td class="tablerowhighlight"  width=100>扩展类型</td>
	<td class="tablerowhighlight"  width=80>必填</td>
	<td class="tablerowhighlight"  width=200>扩展说明</td>
	<td class="tablerowhighlight">操作</td>
	</tr>
	<!--{if $data}-->
	<!--{loop $data $val}--->
	<tr class="item">
		<td class="tablerowl" style="padding-left:10px;">{$val['eid']}</td>
		<td style="text-align:center"><input type="text" size=4 style="text-align:center" name="ordering[{$val['eid']}]" value="{$val['ordering']}" /></td>
		<td style="padding-left:10px;">{$val['name']}</td>
		<td style="padding-left:10px;">{$val['ext']}</td>
		<td style="padding-left:10px;">{$val['type']}</td>
		<td style="padding-left:10px;"><!--{if $val['need']}-->必填<!--{else}-->可选<!--{/if}--></td>
		<td style="padding-left:10px;">{$val['description']}</td>
		<td style="padding-left:10px;">
			<a href="system.php?sys=extend&action=extend_delete&eid={$val['eid']}" onclick="return makeSure();">删除</a>
			<span>|</span>
			<a href="system.php?sys=extend&action=extend_add&eid={$val['eid']}">修改</a>
		</td>
	</tr>
	<!--{/loop}-->
	<!--{else}-->	
	<tr class="item">
		<td colspan='8' class="tablerow"><p style="padding:15px;text-align:center;color:green;font-weight:bold;font-size:14px;">该模型没有扩展，<a href="system.php?sys=extend&action=extend_add&id={$id}">点击添加</a><p></td>
	</tr>	
	<!--{/if}-->
	<tr>
		<td colspan='8' class="tablerowl" style="text-align:left;padding-left:50px;">
			<input type='submit' value="更新排序" class="f-button" />
		</td>
	</tr>
</table>
</form>
<!--{/if}-->


<!--{if $action=='extend_add'}-->
<script type="text/javascript">
var moduleExtend = {
	change:function(type){
		if(type == 'input' || type == 'textarea' || type == 'html' || type == 'date' || type == 'map'){
			$('ext_area').style.display = 'none';
			if(type == 'input') $('for-upload').style.display = '';
			else $('for-upload').style.display = 'none';
			return true;
		}
		$('ext_area').style.display = '';
		$('for-upload').style.display = 'none';
	}
};
function extendAdd(){
	$('submit-act').disabled = true;
	Form.send('extend_add', function(resp){
		var json = evaljson(resp);
		if(json.status == 200){
			window.location.href = json.data;
			return true;
		}else if(json.status == 404){
			alert(json.message);
		}
		$('submit-act').disabled = false;
	});
	return false;
}
</script>
<form id="extend_add" name="extend_add" action="system.php?sys=extend&action=extend_add&eid={$eid}" method="post" name="myform" onsubmit="return extendAdd();">
	<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='tableborder  border'>
	<tr>
	  <th colspan=2><strong>添加模型扩展</strong></th>
	</tr>
	  <tr height='36'>
		<td class="tablerowl" width=20% style="text-align:right;padding-right:10px;"><font color="red">名称</font></td>
		<td class="tablerow"><input type="text" name="param[name]" value="{$param[name]}" class="f-text" size=30 /> 便于记忆用的</td>
	  </tr>
	  <tr height='36'>
		<td class="tablerowl" style="text-align:right;padding-right:10px;"><font color="red">扩展名称</font></td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<!--{if $eid < 1}-->
				<input type="text" name="param[ext]" value="{$param[ext]}" class="f-text" size=30 maxlength=30 /> 
				<!--{else}-->
				<input type="hidden" name="param[ext]" value="{$param[ext]}" class="f-text" size=30 maxlength=30 /> 
				<font color=green>{$param[ext]}</font>
				<!--{/if}-->
			</p>
			 <p style="color:green;padding-top:5px;">用于数据库扩展，只能使用英文（在前台使用“ext_扩展名称”访问）</p>
			 <p style="color:green;padding:5px 0">注意，扩展名请不要于任何其他模型扩展名相同</p>
		</td>
	  </tr>
	  <tr height='36'>
		<td class="tablerowl" style="text-align:right;padding-right:10px;">扩展说明</td>
		<td class="tablerow"><input type="text" name="param[description]" value="{$param[description]}" class="f-text" size=50 /> 用户输入时的提示说明，可以不填</td>
	  </tr>
	  <tr height='36'>
		<td class="tablerowl" style="text-align:right;padding-right:10px;"><font color="red">扩展类型</font></td>
		<td class="tablerow">
			<select name="param[type]" id="ext_type" onchange="moduleExtend.change(this.value)">
				<option value="input"<!--{if $param['type'] == 'input'}--> selected<!--{/if}-->>文本输入</option>
				<option value="date"<!--{if $param['type'] == 'date'}--> selected<!--{/if}-->>日期控件</option>
				<option value="map"<!--{if $param['type'] == 'map'}--> selected<!--{/if}-->>地图坐标</option>
				<option value="textarea"<!--{if $param['type'] == 'textarea'}--> selected<!--{/if}-->>多行文本</option>
				<option value="radio"<!--{if $param['type'] == 'radio'}--> selected<!--{/if}-->>单选选择</option>
				<option value="checkbox"<!--{if $param['type'] == 'checkbox'}--> selected<!--{/if}-->>多选选择</option>
				<option value="select"<!--{if $param['type'] == 'select'}--> selected<!--{/if}-->>下拉选择</option>
				<option value="html"<!--{if $param['type'] == 'html'}--> selected<!--{/if}-->>html输入</option>
			</select>
			<input type="checkbox" name="param[need]" id="need" value='1' <!--{if $param['need']}--> checked<!--{/if}--> /><label for="need">必填/必选</label>
			<span id="for-upload"><input type="checkbox" name="param[upload]" id="upload" value='1' <!--{if $param['upload']}--> checked<!--{/if}--> /><label for="upload">可以上传文件</label></span>
		</td>
	  </tr>
	  <tr id="ext_area" style="display:none;">
		<td class="tablerowl" style="text-align:right;padding-right:10px;">扩展选项</td>
		<td class="tablerow">
			<textarea style="width:300px;height:150px;" name="param[data]">{$param[data]}</textarea> 一行一个选择条件，不能含有英文逗号
		</td>
	  </tr>
	  <tr>
		<td class="tablerowl" style="text-align:right;padding-right:10px;">数据验证</td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<input type="text" name="param[filter]" value="{$param[filter]}" class="f-text" size="50" maxlength="250" />
			</p>
			<p style="color:green;padding:5px 0">只有该字段是必必填/必选时，系统才会调用该验证规则去验证数据（javascript验证）</p>
		</td>
	  </tr>
	  <tr>
		<td class="tablerowl" style="text-align:right;padding-right:10px;">数据验证错误提示</td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<input type="text" name="param[filter_error]" value="{$param[filter_error]}" class="f-text" size="50" maxlength="250" />
			</p>
			<p style="color:green;padding:5px 0">当使用数据验证规则，数据不符合规则时给用户的提示</p>
		</td>
	  </tr>
	  <tr>
		<td class="tablerowl" style="text-align:right;padding-right:10px;">可输入字数</td>
		<td class="tablerow">
			<input type="text" name="param[word_num]" value="{$param[word_num]}" class="f-text" size="50" style="width:50px;" />
		</td>
	  </tr>
	  <tr>
		<td class="tablerowl" style="text-align:right;padding-right:10px;">默认值</td>
		<td class="tablerow">
			<input type="text" name="param[word]" value="{$param[word]}" class="f-text" size="50" />
		</td>
	  </tr>
	  <tr>
		<td class="tablerowl" style="text-align:right;padding-right:10px;">扩展排序</td>
		<td class="tablerow">
			<input type="text" name="param[ordering]" value="{$param[ordering]}" class="f-text" size="50" style="width:50px;" />
		</td>
	  </tr>
	  <tr height='36' class="tablerowl">
			<td colspan=2 class="tablerowl">
				<input type="hidden" name="update" value="1" />
				<input type="hidden" name="param[id]" value="{$param[id]}" />
				<input type="submit" value="添加" id="submit-act"  class="f-button"/>
			</td>
	  </tr>
	</table>
</form>
<script type="text/javascript">
moduleExtend.change($('ext_type').value);
</script>
<!--{/if}-->

<!--{template 'foot'}-->