{load(fhead)}
<body class="mainbg">
	<div id="mainhearder"><span>您的位置：<a href="{$vd['root']}index.php?m=mod_b2b&c=Dealer&a=home">经销商管理系统</a> >> 财务管理 >> 销售提成报表查询</span></div>
	<div id="hearder">
	<span>
		<!--if($vd['data']['param'] == 'aid'){-->
	对 <font color="#ff6c00">{$vd['data']['agent']['aname']}</font> 用户进行商品购买权限设置
  <!--}-->
	</span>
	</div>
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td class="tableleft" style="border:0px;background:#f0f0f0">
		<form id="cform" method="post" action="index.php?m=mod_agent&c=Right&a=Save">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
			<td style="padding:15px">
        <table border="0" bordercolor="#86B9D6">
        	<tr>
            <td style="width:40%" align="right"><div style="padding-right:110px;font-weight:bold">商 品</div></td>
            <td style="width:20%" align="center"></td>
            <td style="width:40%" align="left">
            	<div style="padding-left:50px;font-weight:bold">
            	<!--if($vd['br']['isok']==1){-->允许<!--}else{-->不允许<!--}-->购买的商品
            	</div>
            </td>
          </tr>
          <tr>
            <td style="width:40%" align="right">
            	<select id="products" name="products" size="20" style="width:250px;height:350px">
            		{#Option($vd['products'],0,'pname','pid')}
            	</select>
            </td>
            <td style="width:20%" align="center">
            	<input type="button" value=" 删除&lt;&lt; " class="button" onclick="delrights()"/><br/><br/>
            	<input type="button" value=" 添加&gt;&gt; " class="button" onclick="addrights()"/>
            </td>
            <td style="width:40%" align="left">
            	<select id="rights" name="rights" size="20" style="width:250px;height:350px">
            		{#Option($vd['rights'],0,'pname','pid')}
            	</select>
            </td>
          </tr>
        </table>
        <input type="hidden" value="{$vd['br']['pids']}" name="pids" id="pids"/>
        <div id="opcontent">
          <div class="optxt">
          	<input type="hidden" value="{$vd['data']['param']}" name="param"/>
          	<input type="hidden" value="{$vd['data']['idx']}" name="idx"/>
          	<input type="hidden" value="{$vd['br']['id']}" name="id"/>
          	<input type="hidden" value="{$vd['br']['isok']}" name="isok"/>
          	<input type="submit" value="保 存 &gt;&gt" class="button"/>
            <input type="reset" value="重 置" class="button"/>
          </div>
        </div>
      </td>
    </tr>
  </table>
  </form>
</td>
</tr>
</table>
<script type="text/javascript">
  function addrights() 
  {
  	obj = $("products").options[$("products").options.selectedIndex];
    val = obj.value;
    txt = obj.text;
    
    
    
    org = "," + val + ",";
	  if($("pids").value.indexOf(org) > -1)
	  {
	  	alert('此商品已经在右侧列表中！');
	  	return;
	  }
    else
	  {
	  	$("pids").value += val + ",";
	  }
	 
    $("rights").options[$("rights").length] = new Option(txt, val);
  }
  
  function delrights()
  {
  	obj = $("rights").options[$("rights").options.selectedIndex];
  	val = obj.value;
  	
  	org = "," + val + ",";
	  $("pids").value = $("pids").value.replace(org, ",");
	
  	DelOptionByVal(val);
  }
  
  function DelOptionByVal(val)
  {
  	obj = $("rights");
  	len = $("rights").length;
  	
  	for(i = 0; i < len; i++)
  	{
  		if(obj.options[i].value == val)
  		{
  			obj.remove(i);
  			break;
  		}
  	}
  }
</script>
</body>
</html>
