{include file="header.tpl" page_name=$page_name sys_name=$sys_name}
<div align="center">
{$admin_nav}
	{if $task eq '' || $task eq 'list'}
    {if $type_data}
    <div style="width:98%; background-color:#FFF; padding:5px 0px; text-align:left;">
    	&nbsp;&nbsp;&nbsp;<input type="button" value="添加属性组"  onclick="window.location.href='admincp.php?action=types&task=add'" />
        <input type="button" value="添加属性"  onclick="window.location.href='admincp.php?action=types&task=add_attr'"/>
    </div>
   <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder tableborder_line">
<tr class="header">
    <td width="105">序号</td>
    <td width="185">参数组名称</td>
    <td width="509">属性值总数</td>
    <td width="159">操作</td>
     </tr>
   	<tbody>
    {foreach from=$type_data item=type}
    	<tr>
        	<td style=" text-align:left; width:50px;">{$type.type_id}</td>
            <td style="text-align:center;">{$type.type_name}</td>
            <td style="text-align:center">{$type.total}</td>
            <td style="text-align:center"><a href="admincp.php?action=types&task=list_attr&type_id={$type.type_id}">查看属性值</a> | <a href="javascript:void(0);" onclick="if(confirm('您确认要执行本操作吗?本操作将删除该参数组组下的所有属性值.'))this.href='admincp.php?action=types&task=delete_type&id={$type.type_id}'">删除</a> | <a href="admincp.php?action=types&task=edit&id={$type.type_id}">编辑</a></td>
        </tr>
        {/foreach}
    </tbody>
  	</table>
    {else}
    <div class="notice_msg">无可用数据.</div>
    {/if}
    {/if}
    
    <!--action list end -->
    {if $task eq 'add' || $task eq 'edit'}
    	<form method="post" action="admincp.php?action=types" autocomplete="off">
       <input type="hidden" value="{if $task eq 'add'}add_types{else}edit_types{/if}" name="task"/>
       {if $task eq 'edit'}
       		<input type="hidden" value="{$data.type_id}"  name="type_id"/>
       {/if}
	   <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
       	<tr>
        	<td class="one">名称</td>
            <td><input type="text" name="type_name" value="{$data.type_name}" /><span class="red">*</span></td>
        </tr>
        <tr>
        	<td class="one">描述信息</td>
            <td><textarea  style="width:321px; height:150px;" name="type_desc">{$data.type_desc}</textarea></td>
        </tr>
        	<tr>
            	<td colspan="3" align="center"><div style="padding:5px;"><input type="submit" value="保 存" /> &nbsp;<input type="button" value="属性组列表" onclick="window.location.href='admincp.php?action=types'" /></div></td>
            </tr>
		</table>
        </form>
   {/if}
   {if $task eq 'list_attr'}
   {literal}
   	<script type="text/javascript">
    	function load_attrs(obj){
			var v = $(obj).val();
			if(v!=0){
				window.location.href='admincp.php?action=types&task=list_attr&type_id='+v;
			}
		}
    </script>	
   {/literal}
<div class="left" style="text-align:left; width:98%;">
	   选择要查看的参数组:<select onchange="load_attrs(this);" style="width:150px;">
   		<option value="0">请选择...</option>
        {foreach from=$type_data item=type}
        	<option value="{$type.type_id}">{$type.type_name}</option>
        {/foreach}
   </select>
   	<input type="button" value="添加属性值" onclick="window.location.href='admincp.php?action=types&task=add_attr'"/>
    &nbsp;<input type="button" value="属性组列表" onclick="window.location.href='admincp.php?action=types'" />&nbsp;&nbsp;<input  type="button" value="删除所选" onclick="sub_form(this);" />
</div>
<br  class="clear"/>
{if $attr_data.total>0}
{literal}
<script  type="text/javascript">
	function sub_form(obj){
		$("#arttr_list_form").submit();	
	}
	$(document).ready(function(){
		checkAllFormData('attr_click_id','attr_tag');	
	})
</script>
{/literal}
<form method="post" action="admincp.php?action=types" id="arttr_list_form">
<input  type="hidden" value="delete_attr" name="task" />
   	   <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder tableborder_line">
<tr class="header">
    <td width="50"><input type="checkbox" value=""  id="attr_click_id" /></td>
    <td width="119">名称</td>
    <td width="126">录入方式</td>
    <td width="273">所属参数组</td>
    <td width="350">属性值</td>
    <td width="40">操作</td>
     </tr>
   	<tbody>
    {foreach from=$attr_data.data item=attr}
    	<tr>
        	<td style=" text-align:center; width:50px;"><!--{$attr.attr_id} --><input class="attr_tag" type="checkbox" value="{$attr.attr_id}"  name="attr_ids[]"/></td>
            <td style="text-align:center;">{$attr.attr_name}</td>
           	<td style="text-align:center">{if $attr.input_model eq '1'}直接输入{elseif $attr.input_model eq '2'}下拉选择{/if}</td>
            <td style="text-align:center">
            	{foreach from=$type_data item=t}
                	{if $t.type_id eq $attr.attr_type_id}{$t.type_name}{/if}
                {/foreach}
            </td>
            <td nowrap="nowrap">{$attr.attr_value}</td>
            <td style="text-align:center"><a href="admincp.php?action=types&task=edit_attr&id={$attr.attr_id}">编辑</a></td>
        </tr>
        {/foreach}
    </tbody>
  	</table>
    </form>
    <div style=" width:98%; background-color:#FFF; text-align:left;">{$attr_data.page}</div>
    {else}
    <div class="notice_msg">无可用数据,请添加.</div>
    {/if}
   {/if}
   {if $task eq 'add_attr' || $task eq 'edit_attr'}
   		<form method="post" action="admincp.php?action=types" autocomplete="off">
        <input type="hidden" value="{$task}"  name="task"/>
        <input type="hidden" value="{$data.attr_id}"  name="attr_id"/>
           <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
            <tr>
                <td width="150" style="width:150px;" class="one">属性名称</td>
                <td width="90%"><input type="text" name="attr_name" value="{$data.attr_name}" /><span class="red">*</span></td>
            </tr>
            <tr>
                <td class="one" style="width:150px;">所属参数组</td>
                <td>
                	<select name="attr_type_id" style="width:150px;">
                    	<option value="0">请选择...</option>
                        {foreach from =$type_data item=type}
                        	<option value="{$type.type_id}"  {if $data.attr_type_id eq $type.type_id}selected="selected" {/if}>{$type.type_name}</option>
                         {/foreach}
                    </select> 
                    <span class="red">*</span>
                </td>
            </tr>
            <tr>
            	<td class="one" style="width:150px;">录入方式:</td>
                <td>
                {literal}
                	<script type="text/javascript">
                    	$(document).ready(function(){
							$('.input_tag').css({"cursor":"pointer"});
							$('.input_tag').click(function(){
								var obj = $(this).find('input');
								$(obj).attr("checked",true);
								var v = $.trim((obj).val());
								if(v=='1'){
									$("#show_input_model").hide();
									$("#input_values").attr("disabled",true);	
								}else if(v=='2'){
									$("#show_input_model").show();
									$("#input_values").attr("disabled",false);	
								}
							})
						})
                    </script>
                {/literal}
                	<span class="input_tag">手工输入:<input  type="radio" value="1"  checked="checked" name="input_model"/> </span> &nbsp;<span class="input_tag">从列表中选择: <input type="radio" value="2" {if $data.input_model eq '2'} checked="checked"{/if} name="input_model" /> </span>
                    </td>
            </tr>
            <tr  id="show_input_model" style="display:{if $data.input_model eq '2'}{else}none{/if};">
            <td class="one" nowrap="nowrap" style=" width:150px;">请输入值:</td>
            	<td>
                	<textarea name="attr_value" {if $data.input_model neq '2'}disabled="disabled"{/if} id="input_values" style="width:350px; height:200px;">{$data.attr_value}</textarea> 一行一个
                </td>
            </tr>
            
                <tr>
                    <td colspan="3" align="center"><div style="padding:5px;"><input type="submit" value="保 存" /> &nbsp;&nbsp;   	<input type="button"  onclick="window.location.href='admincp.php?action=types&task=list_attr'" value="属性列表" />
</div></td>
                </tr>
            </table>
        </form>
   {/if}
</div>
{include file="footer.tpl"}