<?php
if($action=='edit') {
$arr = $dsql->GetOne("Select * from `#@__stepselect` where id='$id' ");
$sbjs = " onsubmit=\"alert('該分類是系統內置枚舉，不允許修改！'); return false;\" ";
if($arr['issystem']==0) $sbjs = '';
?>
<!-- 編輯表單 -->
<div style='float:left;'><b>修改類別</b></div>
<div style='float:right;'>[<a href="#" onclick="javascript:CloseTWin();">關閉</a>]</div>
<br style='clear:both' />
<form action='stepselect_main.php' method='post'<?php echo $sbjs; ?>>
<INPUT TYPE="hidden" NAME="action" value="edit_save" />
<INPUT TYPE="hidden" NAME="id" value="<?php echo $arr['id']; ?>" />
<div>類 別 名：<INPUT TYPE="text" NAME="itemname" class="iptxt" style='width:180px' value="<?php echo $arr['itemname']; ?>" /></div>
<div>緩存組名：<INPUT TYPE="text" NAME="egroup" class="iptxt" style='width:180px' value="<?php echo $arr['egroup']; ?>" /></div>
<div>緩存組名必須為英文或數字組合!</div>
<div><INPUT TYPE="submit" value="確定修改" class="np coolbg"/></div>
</form>
<?php
} else if($action=='addnew') {
?>
<!-- 新增類別表單 -->
<div style='float:left;'><b>新增類別</b></div>
<div style='float:right;'>[<a href="#" onclick="javascript:CloseTWin();">關閉</a>]</div>
<br style='clear:both' />
<form action='stepselect_main.php' method='post'>
<INPUT TYPE="hidden" NAME="action" value="addnew_save" />
<div>類 別 名：<INPUT TYPE="text" NAME="itemname" class="iptxt" style='width:180px' /></div>
<div>緩存組名：<INPUT TYPE="text" NAME="egroup" class="iptxt" style='width:180px' /></div>
<div>緩存組名必須為英文或數字組合!</div>
<div><INPUT TYPE="submit" value="確定增加" class="np coolbg"/></div>
</form>
<?php
} else if($action=='addenum') {
$arr = $dsql->GetOne("Select * from `#@__stepselect` where id='$id' ");
$dsql->Execute('out',"Select evalue,ename from `#@__sys_enum` where egroup='{$arr['egroup']}' And (evalue mod 500)=0  order by disorder asc,evalue asc");
$options = '';
if($arr['issign']==0)
{
  while($row1 = $dsql->GetArray('out')) $options .= "<option value='{$row1['evalue']}'>{$row1['ename']}</option>\r\n";
}
?>
<!-- 新增枚舉表單 -->
<div style='float:left;'><b>添加枚舉</b></div>
<div style='float:right;'>[<a href="#" onclick="javascript:CloseTWin();">關閉</a>]</div>
<br style='clear:both' />
<form action='stepselect_main.php' method='post'>
<INPUT TYPE="hidden" NAME="action" value="addenum_save" />
<INPUT TYPE="hidden" NAME="issign" value="<?php echo $arr['issign']; ?>" />
<INPUT TYPE="hidden" NAME="egroup" value="<?php echo $arr['egroup']; ?>" />
<div>
隸屬枚舉：<select name='topvalue' style='width:180px'>
<option value='0'>增加一級枚舉</option>
<?php echo $options; ?>
</select>
</div>
<div>　枚舉名：<INPUT TYPE="text" NAME="ename" class="iptxt" style='width:180px' /></div>
<div>　排序值：<INPUT TYPE="text" NAME="disorder" class="iptxt" style='width:180px' /></div>
<div>如果不指定，默認以枚舉添加先後來排序。</div>
<div><INPUT TYPE="submit" value="確定增加" class="np coolbg"/></div>
</form>
<?php
} else if($action=='view') {
	$arr = $dsql->GetOne("Select * from `#@__stepselect` where id='$id' ");
	$dsql->Execute('out',"Select * From `#@__sys_enum` where egroup like '{$arr['egroup']}' order by disorder asc, evalue asc");
	$options = '';
  while($row1 = $dsql->GetArray('out')) 
  {
  		 if($row1['evalue']%500==0 || $arr['issign']==1)
  		 {
  				$options .= "<option value='{$row1['evalue']}'>{$row1['ename']}</option>\r\n";
  		 }
  		 else
  		 {
  				$options .= "<option value='{$row1['evalue']}'>  └─{$row1['ename']}</option>\r\n";
  		 }
  }
?>
<!-- 預覽聯動表單 -->
<div style='float:left;'><b>預覽聯動表單</b></div>
<div style='float:right;'>[<a href="#" onclick="javascript:CloseTWin();">關閉</a>]</div>
<br style='clear:both' />
<br style='clear:both' />
<div>
<b>類別關係：</b>
<select name='topvalue' style='width:160px'>
<option value='0'>--請選擇--</option>
<?php echo $options; ?>
</select>
<br />
<br />
這裡僅顯示數據關係，實際應用中，二級聯動生成的表單是支持級連的，並非全部列出。
</div>
<br style='clear:both' />
<?php
}
?>