<!--#include file="head.asp"-->
<style>body{background-color: #fff;}</style>

<%
act=SafeRequest("act")
page=SafeRequest("page")
link="myyouhui?ct="


if act="del" then
id=SafeRequest("id")
if id="" then call PopErr("获取参数错误")
sql="select * from ayyouhuiquan where ayyouhuiid="&clng(id)&" and ayyouhuisuoyou="&clng(request.Cookies("aynameid"))&"" 
rs.open sql,conn,1,3
if rs.bof and rs.eof then
call PopErr("未找到此项目")
else
if rs("ayyouhuihuozeng")=1 then
if rs("ayyouhuibuch")=0 then call PopErr("该优惠券还未得到系统补款，请补款后再尝试删除！")
end if
rs.delete
rs.close
call logadd(request.Cookies("aynameid"),"优惠券删除成功",0,0)
response.Redirect("myyouhui?page="&page&"")
end if
end if

isdel=SafeRequestform("isdel")
if isdel="alldel" then

list1=SafeRequestform("list1")
if list1="" then call PopErr("未找到此项目")
	delid=split(list1,",")
	
	For dianka=0 To Ubound(delid) 
	'response.Write delid(dianka)
	sql="select * from ayyouhuiquan where ayyouhuiid="&trim(delid(dianka))&" and ayyouhuisuoyou="&clng(request.Cookies("aynameid"))&"" 
	rs.open sql,conn,1,3
	if rs.bof and rs.eof then
	call PopErr("未找到此项目")
	else
	if rs("ayyouhuihuozeng")=1 then
	if rs("ayyouhuibuch")=0 then call PopErr2("有优惠券还未得到系统补款，请补款后再尝试删除！","myyouhui")
	end if
	rs.delete
	rs.close
	end if
	next
	call logadd(request.Cookies("aynameid"),"优惠券多选删除成功",0,0)
	response.Redirect("myyouhui?page="&page&"")

end if

%>


<SCRIPT LANGUAGE="JavaScript">
var checkflag1 = "false";
function check1(field) {
if (checkflag1 == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag1 = "true";
return "false"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag1 = "false";
return "true"; }
}

function unselectall1()
{
    if(document.myform.chkAll1.checked){
	document.myform.chkAll1.checked = document.myform.chkAll1.checked&0;
	checkflag1 = "false";
    } 	
}
</script>

<script language="JScript"> 
function copyToClipBoard(copyid,copycon){ 
if (navigator.userAgent.indexOf("MSIE") == -1)
{
  alert("您的浏览器非IE内核,请手动复制内容");
  return false;
}
var clipBoardContent=""; 
clipBoardContent += document.getElementById(copycon).value; 
window.clipboardData.setData("Text",clipBoardContent); 
copyid.innerHTML ="<font color=#FF3300> [已复制]</font>";
//alert(copyid); 
} 
</script>
<SCRIPT LANGUAGE="JavaScript">
function del(){

if(confirm("确定要删除通知吗？")){
	document.getElementById("isdel").value="alldel";
	document.getElementById(myform).submit();
        return true;
}else{
        return false;
}

}
</script>

<SCRIPT LANGUAGE="JavaScript">
function copy(){

var res=false;  
var youname = "";
for (var i=0;i<document.myform.list1.length;i++) 
{    
	var e = document.myform.list1[i];  
	if ( (e.name == 'list1')  &&  (e.type == 'checkbox')  &&  e.checked==true )      
	{      
	var youname =youname+document.getElementById("copyyouhui"+e.value).value+"\r\n";
	res=true;      
	}  

}  

if (res)  
{
	if (navigator.userAgent.indexOf("MSIE") == -1)
	{
  	alert("您的浏览器非IE内核,请手动复制内容");
  	return false;
	}
	window.clipboardData.setData("Text",youname); 
	alert("复制成功"); 
	//document.write(youname)
	

return false;
}

if (!res)  
{
alert("请至少选择一条信息！");  
return false;
}




}
</script>



<main>
<div  class="container">
<div class="ui-lrctnei">
<%call userleft()%>
<div class="r"> 
<div class="ui-content">
                        
					
                            
<div class="neiye">


            <!-------------------------------------- 开始 -------------------------------------->									
            <div class="neibiaoti"></div>
            <div class="neibiaoti2">管理优惠券</div>
           	<div class="gexian"></div>
                	<div class="neitable">
                    <form action="?page=<%=page%>" method="post" name="myform" id="myform"> 
					<table>
                        <tr class="hd">
                            <td width="40">&nbsp;</td>
                            <td>优惠券</td>
                            <td>价值</td>
                            <td>重复</td>
                            <td>平台赠送</td>
                            <td>适用范围</td>
                            <td>是否使用</td>
                            <td>添加时间</td>
                            <td>时效</td>
                            <td>删除</td>
                        </tr>
						<%
                        sql="select * from ayyouhuiquan where ayyouhuisuoyou="&request.Cookies("aynameid")&" order by ayyouhuiid desc" 
                        rs.open sql,conn,1,1
                        rs.pagesize=50
                        pagecount=rs.pagecount 
                        if request("page")="" then 
                        page=1
                        else
                        page=int(request("page")) 
                        end if
                        if page<=0 then page=1 
                        if request("page")="" then page=1
                        if not(rs.bof and rs.eof) then
                        rs.absolutepage=page
                        do while not rs.eof%>
                  		<tr onmouseover=this.bgColor='#FAFAFA' onmouseout=this.bgColor='#ffffff'>
                            <td><input name="list1" type="checkbox" id="list1" value="<%=rs("ayyouhuiid")%>" onClick="unselectall1()"></td>
                            <td>
							<%=rs("ayyouhuiquan")%>	
                            <input  name="copyyouhui<%=rs("ayyouhuiid")%>" type="hidden" id="copyyouhui<%=rs("ayyouhuiid")%>" value="<%=trim(rs("ayyouhuiquan"))%>"  maxlength="3">
                            <span id="c<%=rs("ayyouhuiid")%>"><a href="#" onClick=copyToClipBoard(<%response.Write"c"&rs("ayyouhuiid")%>,"copyyouhui<%=rs("ayyouhuiid")%>")> [复制]</a></span>
                            </td>
                            <td>
							<%if rs("ayyouhuifangshi")=0 then
                            response.Write rs("ayyouhuijiage")&"元"
                            elseif rs("ayyouhuifangshi")=1 then
                            response.Write rs("ayyouhuijiage")&"%"
                            end if
                            %>
                            </td>
                            <td>
							<%
                            if rs("ayyouhuiisty")=1 then
                            response.Write("<span style=color:#009933>是</span>")
                            else
                            response.Write("否")
                            end if
                            %>
                            </td>
                            <td>
							<% if rs("ayyouhuihuozeng")=1 then
                            response.Write("是")
                            elseif rs("ayyouhuihuozeng")=0 then
                            response.Write("-")
                            end if
                            %>
                            </td>
                            <td>
							<%if rs("ayyouhuiall")=1 then 
                            response.Write "<span title=适用于全部分类和商品>全部</span>"
                            else
                            isfen="no"
                                if trim(rs("ayyouhuiflid"))<>"0" then
                                response.Write "分类 "
                                isfen="yes"
                                fid=split(trim(rs("ayyouhuiflid")),",")
                                set rsf=server.CreateObject("adodb.recordset")
                                For dianka=0 To Ubound(fid) 
                                rsf.open "select aykanamesuoyou,aykafenleiid,aykafenleiname from aykafenlei where aykafenleiid="&fid(dianka)&" and aykanamesuoyou="&request.Cookies("aynameid")&"",conn,1,1
                                if not(rsf.bof and rsf.eof) then
                                response.Write "<span title="&trim(rsf("aykafenleiname"))&">"&fid(dianka)&"</span>&nbsp;"
                                else
                                response.Write "<span title=或已删除>"&fid(dianka)&"</span>&nbsp;"
                                end if
                                rsf.close
                                next
                                end if
                                if isfen="yes" then response.Write "<br>"
                                if trim(rs("ayyouhuishangid"))<>"0" then
                                response.Write "商品 "
                                fid=split(trim(rs("ayyouhuishangid")),",")
                                set rsf=server.CreateObject("adodb.recordset")
                                For dianka=0 To Ubound(fid) 
                                rsf.open "select aygoodsuoyouid,aygoodid,aygoodname from aygood where aygoodid="&fid(dianka)&" and aygoodsuoyouid="&request.Cookies("aynameid")&"",conn,1,1
                                if not(rsf.bof and rsf.eof) then
                                response.Write "<span title="&trim(rsf("aygoodname"))&">"&fid(dianka)&"</span>&nbsp;"
                                else
                                response.Write "<span title=或已删除>"&fid(dianka)&"</span>&nbsp;"
                                end if
                                rsf.close
                                next
                                end if
                            end if
                            %>
                            </td>
                            <td>
							<% if rs("ayyouhuiyesno")=0 then
                            response.Write("未使用")
                            elseif rs("ayyouhuiyesno")=1 then
                            response.Write("<span style=color:#FF0000>已使用</span>")
                            end if
                            %>
                            </td>
                            <td><%=rs("ayyouhuidate")%></td>
                            <td><%=rs("ayyouhuishixiao")%>天</td>
                            <td><a href="?act=del&id=<%=rs("ayyouhuiid")%>&page=<%=page%>"  onclick="javascript:return confirm('您确定要删除吗？');"><img src="<%=ossurl%>images/ico_del.gif" alt="删除分类" border="0"></a></td>
                        </tr>
						<%
                        n=n+1
                        rs.movenext 
                        if n>=rs.pagesize then exit do  
                        loop
                        end if
                        zongshu=rs.RecordCount
                        rs.close%>

                        <tr>
                            <td colspan="10" style="text-align:left">
                            &nbsp;&nbsp;&nbsp;<input name="chkAll1" type="checkbox" id="chkAll1" onClick="this.value=check1(this.form.list1)" value="checkbox">&nbsp;全选&nbsp;
                            <input type="submit" name="Submit" value="删除选定" onClick="return del();" class="logindlregedit"> 
                            <input type="button" name="Submit" value="复制选定" onClick="return copy();" class="logindlregedit"> 
                            <input type="hidden" name="isdel" id="isdel">
                            <input type="hidden" name="iscopy" id="iscopy">&nbsp;
                            <%call pageye()%>
                            </td>
                        </tr>

                    </table>
                    </form>
            		</div>
            <!-------------------------------------- 结束 -------------------------------------->
                   


                                                                 
                   
            <div class="gexian20"></div>
            <div class="mzsmbox2" style="padding-top:20px;">
            提示：优惠券价值不得高于订单价格50%并禁止0元交易，请参考商品实际情况添加优惠券
            </div>
          </div>
            
           




        <div class="clearfix"></div>



</div>








</div>
</div>
</div>
</div>
</main>


<footer>
<div class="container">
</div>
</footer>

</body>
</html>