<? defined('ROOT_PHPLEFT') or exit(require '../../../404.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk"/>
<title>管理中心 - Powered By phpleft.com</title>
 <link href="css/main.css" type="text/css" rel="stylesheet">
 <script type="text/javascript" src="<?=PL_URL?>js/common.js"></script>
</head>
<body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0">
<div class="tpis"><img src="images/icos.gif" align="absmiddle"/>当前位置：基础设置  > <?=modname($menuid,'name')?> > 字段管理</div>

<? include inTemplate(menu);?>

<? if ($show=="bj" or $show=="add"){?>

 <?
  if ($thisid<>""){
  ?>
<form action="?file=post_center&post=menukey&input=bj" method="post" style="margin:0px; padding:0px;" onsubmit="return check();">  
  <?
  }else {
  ?>
<form action="?file=post_center&post=menukey&input=add" method="post" style="margin:0px; padding:0px;" onsubmit="return check();">
<?
  }
  ?>
 <input name="alladd[module]" type="hidden" value="<?=modname($menuid)?>">
  <?
  if ($thisid<>""){
  ?>
 <input name="alladd[keylist]" type="hidden" value="<?=$alladd[keylist]?>">
<input name="id" type="hidden" value="<?=$thisid?>">
<?
  }
  ?>
    <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
        <tr>
            <th colspan="3">
                 <?
  if ($thisid<>""){
  ?>编辑字段<? }else{?>添加字段<? }?></th>
        </tr>
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>当前模型</strong></td>
        <td width="383" height="30"><?=modname($menuid,'name')?><input name="alladd[moduleid]" type="hidden" id="moduleid" value="<?=$menuid?>" size="23"></td>
            <td height="30"></td>
        </tr>
   <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段名称</strong></td>
<td width="383" height="30"><input name="alladd[name]" type="text" id="name" value="<?=$alladd[name]?>" size="23"></td>
            <td height="30"><span id="cname">建议使用中文</span></td>
        </tr>
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段</strong></td>
        <td width="383" height="30" class="usertablerow1"><input name="alladd[thiskeys]" type="text" id="thiskeys" value="<?=$alladd[thiskeys]?>" size="23" <? if($show =="bj") echo ' disabled'?>></td>
            <td height="30" class="usertablerow1"><span id="cthiskeys">小写字母(a-z),数字(0-9) 推荐使用字母,不能以数字开头</span></td>
        </tr>
      
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>提示信息</strong></td>
        <td width="383" height="30" class="usertablerow1"><input name="alladd[note]" type="text" id="note" value="<?=$alladd[note]?>" size="50" /></td>
            <td height="30" class="usertablerow1"></td>
        </tr>
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段类型</strong></td>
            <td width="383" height="30">
<select name="alladd[keystype]" onChange="keystype(this.value)"<? if($show =="bj") echo ' disabled'?>>
<option value="varchar">字符(Varchar)</option>
<option value="int">整数(Int)</option>
<option value="float">小数(Float)</option>
<option value="text">文本(Text)</option>
</select></td>
            <td height="30">&nbsp;</td>
        </tr></table>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0" id='length_td'>
         <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段长度</strong></td>
          <td width="383" height="30" class="usertablerow1"><input name="alladd[length]" type="text" id="length" size="20" value="<?=$alladd[length]?><? if ($thisid=="") echo '255';?>" <? if($show =="bj") echo ' disabled'?>/></td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        </table>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
         <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>默认值</strong></td>
          <td width="383" height="30" class="usertablerow1"><input name="alladd[default_value]" type="text" value='<?=$alladd[default_value]?>' size="40" /></td>
            <td height="30" class="usertablerow1">例如默认值为 0，则填写 0; 例如加入时期函数则 time(); 需要带‘;’&nbsp;</td>
        </tr>
              <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>表单类型</strong></td>
            <td width="383" height="30"><select name="alladd[type]" onChange="types(this.value)">
<option value="text"<? if($alladd[type]=="text" or $alladd[type]=="") echo 'selected'?>>单行文本(text)</option>
<option value="textarea"<? if($alladd[type]=="textarea") echo 'selected'?>>多行文本(textarea)</option>
<option value="select"<? if($alladd[type]=="select") echo 'selected'?>>下拉框(select)</option>
<option value="radio"<? if($alladd[type]=="radio") echo 'selected'?>>单选框(radio)</option>
<option value="checkbox"<? if($alladd[type]=="checkbox") echo 'selected'?>>多选框(checkbox)</option>
<option value="hidden"<? if($alladd[type]=="hidden") echo 'selected'?>>隐藏域(hidden)</option>
<option value="date"<? if($alladd[type]=="date") echo 'selected'?>>日期选择</option>
<option value="thumb"<? if($alladd[type]=="thumb") echo 'selected'?>>缩略图上传</option>
<option value="file"<? if($alladd[type]=="file") echo 'selected'?>>文件上传</option>
</select></td>
            <td height="30">&nbsp;</td>
        </tr></table>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0" id="tvalue_td" style="display:none">
              <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>选项值</strong></td>
            <td width="383" height="30" class="usertablerow1"><textarea name="alladd[typevalue]" id="typevalue" style="width:250px;height:80px;overflow:visible;">
<?=$alladd[typevalue]?>
</textarea><br/>
一行一个 选项值|选项名称 按回车为结尾标志符</td>
            <td height="30" class="usertablerow1"></td>
        </tr></table>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
          <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>附加内容</strong></td>
            <td width="383" height="30" class="usertablerow1"><input name="alladd[add_js]" type="text" size="60" id="add_js" value='<?=$alladd['add_js']?>'/> </td>
            <td height="30" class="usertablerow1">可以添加表单属性、JS事件或CSS样式 如果有单引号请加 \</td>
        </tr>
         <tr>
            <td height="30" class="text" style="padding-right:10px; text-align:right"><strong>输入限制</strong></td>
            <td height="30" class="usertablerow1"><input name="alladd[geton]" type="text" id="geton" value="<?=$alladd[geton]?>" size="40" />
<select onChange="$('geton').value=this.value">
<option value=""<? if($alladd[geton]=="") echo 'selected'?>>无限制</option>
<option value="不能为空"<? if($alladd[geton]=="不能为空") echo 'selected'?>>不能为空</option>
<!--
<option value="限数字">限数字</option>
<option value="限字母">限字母</option>
<option value="限数字和字母">限数字和字母</option>
<option value="限E-mail地址">限E-mail地址</option>
<option value="限日期格式">限日期格式</option>-->
</select>
</td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
         <tr>
            <td height="30" class="text" style="padding-right:10px; text-align:right"><strong>前台发布是否显示</strong></td>
            <td height="30" class="usertablerow1"><input name="alladd[qis_or]" type="radio" id="radio" value="1" class="no"<? if ($alladd[qis_or]==1 or $thisid==""){ ?> checked<? }?>>
            是&nbsp;  <input name="alladd[qis_or]" type="radio" id="radio" class="no" value="0"<? if ($alladd[qis_or]==0 and $thisid<>""){ ?> checked<? }?>>
            否&nbsp;  <input name="alladd[qis_or]" type="radio" id="radio" class="no" value="2"<? if ($alladd[qis_or]==2 and $thisid<>""){ ?> checked<? }?>>
            显示不可编辑 </td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        <tr>
            <td height="30" class="text" style="padding-right:10px; text-align:right"><strong>后台发布是否显示</strong></td>
            <td height="30" class="usertablerow1"><input name="alladd[is_or]" type="radio" id="radio" value="1" class="no"<? if ($alladd[is_or]==1){ ?> checked<? }?>>
            是&nbsp;  <input name="alladd[is_or]" type="radio" id="radio" class="no" value="0"<? if ($alladd[is_or]==0){ ?> checked<? }?>>
            否 </td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        
          <tr>
          <td height="30" class="text" style="padding-right:10px; text-align:right"></td>
            <td height="30"><input type="submit" name="button" id="button" value=" 确 认 " class="ok"></td>
            <td height="30">&nbsp;</td>
        </tr>
</table>
    </form>
    <? }if ($show=="key"){ ?>
    <form action="?file=post_center&post=menukey&input=paixu&menuid=<?=$menuid?>" method="post">
    <table class="usertableborder bb" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
      <tr>
        <th colspan="7"> 模块管理</th>
      </tr>
      <tr align="center" class="list1 b">
        <td width="96" height="30"> 排序 </td>
        <td width="90" height="30">字段名称</td>
        <td width="110" height="30">字段</td>
        <td width="101" height="30">字段类型</td>
        <td width="91" height="30">是否显示</td>
        <td width="110" height="30">字段管理</td>
        <td width="368" height="30">&nbsp;</td>
      </tr>
      <tr align="center">
        <td width="96" height="30" valign="top"><input name="" type="text" id="keylist" value="-1" size="3" style="text-align:center"></td>
        <td width="90" height="30" valign="top">排序</td>
        <td width="110" height="30">id</td>
        <td width="101" height="30">自动增加</td>
        <td width="91" height="30">否</td>
        <td width="110" height="30">系统</td>
        <td height="30"></td>
      </tr>
      <?php foreach($tablelist as $id=>$t) { ?>
      
      <tr align="center" class="list<?php if($id%2==0) echo '1'?>">
        <td width="96" height="30" valign="top"><input name="inid[]" type="hidden" id="id" value="<?=$t['id']?>" size="3" style="text-align:center"><input name="keylist[]" type="text" id="keylist" value="<?=$t['keylist']?>" size="3" style="text-align:center"></td>
        <td width="90" height="30" valign="top"><?=$t['name']?></td>
        <td width="110" height="30"><?=$t['thiskeys']?></td>
        <td width="101" height="30"><?=$t['keystype']?><? if ($t['keystype']<>'text'){?>(<?=$t['length']?>)<? }?></td>
        <td width="91" height="30"><? if($t['is_or']==0){?>
          否
          <? }else{?>
          是
          <? }?></td>
        <td width="110" height="30"><a href="phpleft.php?file=menukey&show=bj&menuid=<?=$menuid?>&modulename=<?=$table?>&thisid=<?=$t['id']?>"><img src="<?=PL_URL?>ico/edit.png" align="absmiddle" alt="编辑字段" border="0"></a> <a href="?file=post_center&post=menukey&input=del&keys=<?=$t['thiskeys']?>&menuid=<?=$menuid?>&deltab=<?=$t['id']?>" onClick="if(!confirm('删除该字段！')) return false;" ><img src="<?=PL_URL?>ico/del.png" align="absmiddle" alt="删除字段" border="0"></a></td>
        <td height="30">&nbsp;</td>
      </tr>
      <?php } ?>
      <tr>
        <td height="30" style="padding-right:10px; text-align:right"><input type="submit" value="更新排序" class="ok"></td>
        <td height="30"></td>
        <td height="30" colspan="5">&nbsp;</td>
      </tr>
    </table></form>
<? }?>
      <script type="text/javascript">
function types(id) {
	if(id == 'select' || id == 'radio' || id == 'checkbox') {
		$('tvalue_td').style.display = 'block';		
	}else{
		$('tvalue_td').style.display = 'none';		
	}
	if(id == 'text') {
		$('add_js').value = 'size=\"30\"';
	} else if(id == 'textarea') {
		$('add_js').value = 'rows=\"5\" cols=\"80\"';
	} else {
		$('add_js').value = '';
	}
}

function keystype(id) {
	if(id == 'varchar') {
		$('length_td').style.display = 'block';
		$('length').value = '255';
	} else if(id == 'int') {
		$('length_td').style.display = 'block';
		$('length').value = '10';
	} else if(id == 'float') {
		$('length_td').style.display = 'none';
		$('length').value = '';
	} else if(id == 'text') {
		$('length_td').style.display = 'none';
		$('length').value = '';
	}
}
function check() {
	if($('name').value == '') {
    msg('请输入字段名称','cname','right_r');
		return false;
	}
	if($('thiskeys').value == '') {
    msg('请输入字段名','cthiskeys','right_r');
		return false;
	}
	return true;
}
</script>  
</body>
</html>
