<!--#include virtual="/show/adminhead.asp"-->
<!--#include file="adminleft.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />




<title><%=webname%>-优惠券</title>
<%
call logquanxian("f4",1)
%>



<DIV>

<script language=javascript>
function CheckIfEnglish( String )<!--检验表单必须是字母或数字-->
{ 
    var Letters = "abcdefghijklmnopqrstuvwxyz0123456789-";
     var i;
     var c;
      if(String.charAt( 0 )=='-')
	return false;
      if( String.charAt( String.length - 1 ) == '-' )
          return false;
     for( i = 0; i < String.length; i ++ )
     {
          c = String.charAt( i );
	  if (Letters.indexOf( c ) < 0)
	     return false;
     }
     return true;
}
function CheckIfid( String )<!--检验表单必须是数字-->
{ 
    var Letters = "1234567890";
     var i;
     var c;
      if(String.charAt( 0 )=='-')
	return false;
      if( String.charAt( String.length - 1 ) == '-' )
          return false;
     for( i = 0; i < String.length; i ++ )
     {
          c = String.charAt( i );
	  if (Letters.indexOf( c ) < 0)
	     return false;
     }
     return true;
}
function Checkjinid( String )<!--检验表单必须是数字-->
{ 
    var Letters = "1234567890.";
     var i;
     var c;
      if(String.charAt( 0 )=='-')
	return false;
      if( String.charAt( String.length - 1 ) == '-' )
          return false;
     for( i = 0; i < String.length; i ++ )
     {
          c = String.charAt( i );
	  if (Letters.indexOf( c ) < 0)
	     return false;
     }
     return true;
}
function ischinese(s)<!--检验表单必须是中文-->
{
var ret=true;
for(var i=0;i<s.length;i++)
ret=ret && (s.charCodeAt(i)>=10000);
return ret;
}
</script>
<script language=javascript>
function check_add()
{
   
   if(form.geshu.value=="" || !CheckIfid(form.geshu.value))
   {alert("数量填写错误");return false}
    if(form.geshu.value > 200)
	{alert("单次生成数量不得超过200");return false;}
   
   if(form.jiage.value=="" || !CheckIfid(form.jiage.value))
   {alert("价格填写错误");return false}
     if(form.jiage.value < 1)
	{alert("价格填写错误 应大于0");return false;}
	
   if(form.shixiao.value=="" || !CheckIfid(form.shixiao.value))
   {alert("时效填写错误");return false}
	if(form.shixiao.value > 365)
	{alert("时效填写错误 不得大于365");return false;}
    
}
</script>
<%
Function RndNumber(Min,Max) 
Randomize 
RndNumber=Int((Max - Min + 1) * Rnd() + Min) 
End Function 

act=SafeRequest("act")

if act="add" then

'feileiid=SafeRequestform("feileiid")
'shangid=SafeRequestform("shangid")
geshu=SafeRequestform("geshu")
fangshi=SafeRequestform("fangshi")
jiage=SafeRequestform("jiage")
shixiao=SafeRequestform("shixiao")
suoyou=SafeRequestform("suoyou")
shiyongid=SafeRequestform("shiyongid")
'if suoyou="" then
'if feileiid="" and shangid="" then call PopErr("分类和商品必须选定一个")
'end if

if geshu="" then call PopErr("数量填写错误")
if jiage="" then call PopErr("价格填写错误")
if shixiao="" then call PopErr("时效填写错误")

sql="select * from ayyouhuiquan" 
rs.open sql,conn,1,3

for i=1 to cint(geshu)

suiji=RndNumber(100,999)&second(now())&RndNumber(10,99)&year(now())&RndNumber(100,999)&minute(now())&RndNumber(10,99)&day(now())&RndNumber(100,999)&hour(now())&RndNumber(100,999)&Month(now())&RndNumber(1000,9999)

	rs.addnew
	rs("ayyouhuiquan")=suiji
	if trim(shiyongid)<>"" then 
	rs("ayyouhuisuoyou")=clng(shiyongid)
	rs("ayyouhuihuozeng")=1
	else
	rs("ayyouhuisuoyou")=clng(request.Cookies("aynameid"))
	end if
	rs("ayyouhuifangshi")=cint(fangshi)
	rs("ayyouhuijiage")=cint(jiage)
	rs("ayyouhuidate")=now()
	rs("ayyouhuishixiao")=cint(shixiao)
	if suoyou<>"" then rs("ayyouhuiall")=cint(suoyou)
	rs("ayyouhuijibie")=1
	rs.update
next
	rs.close
	call logadd(request.Cookies("aynameid"),"管理-优惠券已添加成功",0,0)
	call PopErr2("优惠券已添加成功","adminmyyouhui.asp")
end if

%>
<DIV id=main1200> 
<%call webleft()%>
<DIV id=main_right>
<DIV id=main_right_content>
<STYLE>.apply_style {
	POSITION: absolute
}
.right_title A {
	LINE-HEIGHT: 27px; WIDTH: 126px; DISPLAY: inline-block; BACKGROUND: url(<%=ossurl%>images/bg22.gif) no-repeat; HEIGHT: 27px
}
.right_title A.current {
	BACKGROUND: url(<%=ossurl%>images/main_right_title_bg.gif) no-repeat; COLOR: #fff; FONT-WEIGHT: bold
}
.table_style_1 TD {
	HEIGHT: 38px
}
.table_style_home_info TD {
	PADDING-BOTTOM: 0px; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; HEIGHT: 30px; PADDING-TOP: 0px
}
</STYLE>

<DIV class=right_titleadmin>&nbsp;&nbsp;优惠券</DIV>
<DIV class=main>

<form action="?act=add" method="post" name="form" id="form" onSubmit="return check_add()">
  <table width="99%" border="0" cellspacing="5" cellpadding="0" class="table_style_a1">
    <tr>
      <td width="140" align="center">允许所有商品：</td>
      <td><input name="suoyou" type="checkbox" id="suoyou" value="1" checked>
        （所有商品分类以及所有商品均可以使用优惠券 包括新添加的分类和商品 勾选此项时 以下两项设置视为无效）</td>
    </tr>
    <tr>
      <td align="center">生成优惠券数量：</td>
      <td><input name="geshu" type="text" id="geshu" value="10" size="7" maxlength="3">
      个 （单次生成不得超过200个）</td>
    </tr>
    <tr>
      <td align="center">优惠券使用方式：</td>
      <td><input name="fangshi" type="radio" value="0" checked>
        抵金额 
          <input type="radio" name="fangshi" value="1">
          按总价%计算       
        （优惠券一次交易只能使用一张 批发商户可以选择按总价%使用)</td>
    </tr>
    <tr>
      <td align="center">优惠券价值：</td>
      <td><p>
        <input name="jiage" type="text" id="jiage" value="1" size="7" maxlength="3">
        元/% （此项为整数 当选择抵金额时 会优惠设置的金额 当选择按总价百分比时 则选择总价%优惠</p>
        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;例如填写20% 100元的商品需另外支付80元 填写数字&gt;=100视为优惠券无效）</p></td>
    </tr>
    <tr>
      <td align="center">优惠券时效：</td>
      <td><input name="shixiao" type="text" id="shixiao" value="30" size="7" maxlength="3">
      天 （时效以天做单位 不得超过365天 优惠券过期后 系统将自动删除）</td>
    </tr>
    <tr>
      <td align="center">使用者ID：</td>
      <td><input name="shiyongid" type="text" id="shiyongid" size="15">
        可以送给此会员</td>
    </tr>
    <tr>
      <td colspan="2" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value=" 生 成 优 惠  券 ">
	  <%if cint(request.Cookies("ayjibie"))=9 then %>
	  <span style="color: #FF0000">注意：您是系统管理员 您生成的优惠券将通用所有商品</span>
	  <%end if%>	  </td>
      </tr>
  </table>
</form>
</DIV>
 

</DIV></DIV>
<DIV class=clear></DIV></DIV>
</DIV>
<SCRIPT>
$(function(){
$('.left_title').each(function(){
   $(this).click(function(){
	   var index=$('.left_title').index(this);
	   if($(this).next().hasClass('hide_m')){
		   $(this).next().removeClass('hide_m');
           $(this).next().show();		 
		   $(this).find('img').attr('src','<%=ossurl%>images/expansion.gif');
		   $.cookie('m_index_'+index,'',{expires:0});
	   } else {
	       $(this).next().hide();
		   $(this).next().addClass('hide_m');
		   $(this).find('img').attr('src','<%=ossurl%>images/shrank.gif');		   
		   $.cookie('m_index_'+index,'none',{expires:365});
	   }
   })
})

$('.left_title').each(function(){
	var index=$('.left_title').index(this);
    $(this).next().css('display',$.cookie('m_index_'+index) ? $.cookie('m_index_'+index) : '');
	if($.cookie('m_index_'+index)){
	    $(this).next().addClass('hide_m');
	}
	$(this).find('img').attr('src',$.cookie('m_index_'+index) ? '<%=ossurl%>images/shrank.gif' : '<%=ossurl%>images/expansion.gif');
})
})

</SCRIPT>


<!--#include virtual="/show/footadmin.asp"-->

