<%Response.Expires=0%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>盛维在线调查系统v9.0免费版-&gt问卷调查系统后台管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="盛维在线调查系统v9.0免费版" name=description>
<link rel="stylesheet" href="../../inc/manage.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!--#include file="../../config.asp"-->
<!--#include file="../../manage/checkuserflag.asp"-->
<%call CheckUserFlag("02")%>
<!--#include file="menu_edit.asp"-->
<%
Function OpenDB(DBfile)
    Set ObjTC_DB = Server.CreateObject("dc_data100_v1_0.C_A_Config")
    Set DbConn = Server.CreateObject("ADODB.Connection")
    DbConn.open ObjTC_DB.dbPath(DBfile)
End Function
dim dbconn
openDb DataPathFile

Set ObjDCW = Server.CreateObject("dc_data100_v1_0.C_A_Config")

s_catalogID=Request("catalogid")
'response.write "s_catalogID=" & s_catalogID & "<br>"

type_id=Request("type_id")
if type_id="" or not isnumeric(type_id) then
  type_id=0
else
  type_id=cint(type_id)
end if

keyword=replace(Request("keyword"),"'","")

%>
<!--#include file="include/const.asp"-->
<script language="javascript">
  function count_checked_items() {
  var number_checked=0;
  var box_count=document.frm_list.productid.length;
  if ( box_count==null ) {
  if ( document.frm_list.productid.checked==true ) {
  number_checked=1;}else {
  number_checked=0;}}
  else {
  for ( var i=0; i < (box_count); i++ ) {
  if ( document.frm_list.productid[i].checked==true ) {
  number_checked++;}}}return number_checked;
  }
  
  function add_to_edit() {
      if (count_checked_items()>0){                           
		  document.frm_list.action="survey_edit.asp";
		  document.frm_list.submit();       
      }
      else{
          alert('请您先选择要修改的问卷!');
          return false;       
      }}
	  
  function turn_to_edit() {
      if (count_checked_items()>0){ 
          if(confirm("选中问卷的所有投票将全部删除,您真的要把选中的问卷设置成可编辑状态吗?")){                       
			  document.frm_list.action="survey_edit_set.asp?s=1";
			  document.frm_list.submit(); 
		  }        
      }
      else{
          alert('请您先选择要设置成可编辑状态的问卷!');
          return false;       
      }}
 
 function publish_survey() {
      if (count_checked_items()>0){ 
          if(confirm("问卷发布后不可以轻易进行编辑,您真的要发布选中的问卷吗?")){                       
			  document.frm_list.action="survey_edit_set.asp?s=0";
			  document.frm_list.submit(); 
		  }        
      }
      else{
          alert('请您先选择要发布的问卷!');
          return false;       
      }}
	  
  function del_to() {
      if (count_checked_items()>0){           
          if(confirm("该问卷下的所有调查主题将全部删除,您真的要删除这些问卷吗?")){           
          document.frm_list.action="survey_del.asp";
          document.frm_list.submit();
          }
      }
      else{
          alert('请您先选择要删除的问卷!');
          return false;       
      }}
  
  function select_All(checked){
          
      for (var i=0;i<document.frm_list.elements.length;i++){
      var e = document.frm_list.elements[i];
      if (e.name != 'allbox')
          e.checked = checked;        
      }
      document.all.check_all.checked=checked;
  }       
  
  function select_ok(){
      if(document.all.check_all.checked){
          document.frm_list.button_select.value="取消";
          select_All(true)}
      else{
          document.frm_list.button_select.value="全选";
          select_All(false)
          }}
  
  function select_change(){
      if(document.frm_list.button_select.value=="全选"){            
          document.frm_list.button_select.value="取消";
          select_All(true);           
          }
      else{
          document.frm_list.button_select.value="全选";
          select_All(false);          
          }       
  }
  

function showDiv(s,s_date,o_date) //显示或关闭图层
{ //alert(s);
	if(s=="hidden"){
	document.all.new_catalog.style.visibility="hidden"; 
	}
	else{
	document.all.surveyID.value=s;
	document.all.startdate.value=s_date;
	document.all.overdate.value=o_date;	
	document.all.new_catalog.style.visibility="visible"; 
	}
	//history.back(-1);
    //选择后,让第一项被选中,这样,就有Change啦. 
    //document.all.sel.options[0].selected=true; 
}

function isdatejavasc(inputdate){
	if(IsDate(inputdate)==false){
		alert(inputdate+"日期格式输入错误！");
		return false; 
	}
}

function isdatejs(){
	ss_date=document.update_d.startdate.value;
	oo_date=document.update_d.overdate.value;
	if(IsDate(ss_date)==false){
		alert("开始日期：" + ss_date + " 格式输入错误！");
		return false; 
	}else if(IsDate(oo_date)==false){
		alert("结束日期：" + oo_date + " 格式输入错误！");
		return false; 
	}else{
	document.update_d.action="survey_set_date.asp";
    document.update_d.submit(); 
	}
}	

function IsDate(dateval){
	var arr = new Array();
	//alert("02/30/2008");
	if(dateval.indexOf("-") != -1){
		arr = dateval.toString().split("-");
	}else if(dateval.indexOf("/") != -1){
		arr = dateval.toString().split("/");
	}else{
		return false;		
	}
	
	//yyyy-mm-dd || yyyy/mm/dd
	if(arr[0].length==4){
		var date = new Date(arr[0],arr[1]-1,arr[2]);
		if(date.getFullYear()==arr[0] && date.getMonth()==arr[1]-1 && date.getDate()==arr[2]){
			return true;			
		}
	}
	//dd-mm-yyyy || dd/mm/yyyy
	if(arr[2].length==4){
		var date = new Date(arr[2],arr[1]-1,arr[0]);
		if(date.getFullYear()==arr[2] && date.getMonth()==arr[1]-1 && date.getDate()==arr[0]){
			return true;
		}
	}
	//mm-dd-yyyy || mm/dd/yyyy
	if(arr[2].length==4){
		var date = new Date(arr[2],arr[0]-1,arr[1]);
		if(date.getFullYear()==arr[2] && date.getMonth()==arr[0]-1 && date.getDate()==arr[1]){
			return true;			
		}
	}
	
	return false;
}
</script>
<table width="96%" border="0" cellspacing="1" cellpadding="0" align="center" height="37" class="p9">
  <form name="frm_search" action="survey_list.asp" method="post">
    <tr> 
      <td align="center" bgcolor="#ffffff" height=40>
        <%sql_str="where Catalog_company_id=" & Session("DC_Manage_CompanyID")
		if Session("DC_Manage_DepartmentID")<>0 then
			sql_str=sql_str & " and CatalogBig=" & Session("DC_Manage_DepartmentID")
		end if
		set myrs_root=server.CreateObject("adodb.recordset")
              myrs_root.Open "select catalogid,catalogname,CatalogBig from DC_Title_catalog "&sql_str&" order by CatalogBig asc",dbconn,1,1 

        if s_catalogID="" then s_catalogID=0
          %>
          <script language="javascript">
          function chang_product_type(){
              location.href="survey_list.asp?catalogid="+document.frm_search.catalogid.options[document.frm_search.catalogid.selectedIndex].value;
          }
        </script>
        问卷类别:
      <select name="catalogid" style="WIDTH: 150px; COLOR: navy; font-size:9pt" onChange="javascript:chang_product_type();">
          <option value="0" <%=object_selected(type_id,"0")%>>所有类别</option>
		  <%
                do until myrs_root.EOF
                   Response.Write "<option value='" & myrs_root("catalogid") & "' " & object_selected(s_catalogID,cstr(myrs_root("catalogid"))) & " style='color:navy;background:#f0f0f0'>" & myrs_root("catalogname")
					departmentID=myrs_root("CatalogBig")
					if departmentID<>"" then
						departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"A_Manage_Department","A_M_D_Name"," where A_M_D_ID=" & departmentID)
						if departM=0 then
							response.write "-"
						else
							totalput = UBound(D_data_Dep)
							rs_dep=split(D_data_Dep(0),",")
							response.write "(" & rs_dep(0) & ")"
						end if
					end if
				   response.write "</option>"                          
                   myrs_root.MoveNext
                loop
                %>
        </select>
        <select name="type_id" style="WIDTH: 150px; COLOR: navy; font-size:9pt">
          <option value="0" <%=object_selected(type_id,"0")%>>所有子类别</option>
          <%  set myrs_child=server.CreateObject("adodb.recordset")
                  sql="select id,typename from DC_Title_type where catalogID=" & s_catalogID & " order by id"
				  myrs_child.Open sql,dbconn,1,1
                      
                  do until myrs_child.EOF 
                      Response.Write "<option value='" & myrs_child("id") & "' " & object_selected(type_id,myrs_child("id")) & ">" & myrs_child("typename") & "</option>"
                      myrs_child.MoveNext 
                  loop
                  myrs_child.Close
                  set myrs_child=nothing
                 %>
        </select>
        关键字: 
        <input type="text" style="WIDTH: 150px; COLOR: navy;font-size:9pt" name="keyword" class=p9 value="<%=keyword%>">
        <input type="submit" value="搜索" name=button_223 class="p9" style="WIDTH: 60px; HEIGHT: 22px;">
      </td>
    </tr>
  </form>
<%strF="where p.D_T_S_company_id=" & Session("DC_Manage_CompanyID")
if Session("DC_Manage_DepartmentID")<>0 then
	strF=strF & " and p.A_M_D_ID=" & Session("DC_Manage_DepartmentID")
end if
if s_catalogID<>0 then
	strF=strF & " and p.catalogID=" & s_catalogID
end if
sqlstr="select p.*,t.id,t.typename from DC_Title_survey p,DC_Title_type t " & strF & " and p.type_id=t.id"
if type_id>0 then sqlstr=sqlstr & " and p.type_id=" & type_id

if keyword<>"" then
          sqlstr=sqlstr & " and ("
          sqlstr=sqlstr & "Survey_title like '%" & keyword & "%' or Survey_title_exp like '%" & keyword & "%'"
          sqlstr=sqlstr & ")" 
end if

sqlstr=sqlstr & " order by D_T_S_ID desc"

'Response.Write sqlstr
'Response.End 

'survey=ObjDCW.read_record(D_data,DataPathFile,"A_Manage_Department","A_M_D_ID,A_M_D_Name,A_M_D_Manager,A_M_D_Exp"," order by A_M_D_ID")'读出记录,结果保存在D_data数组中

set myrs=server.CreateObject("adodb.recordset")              
myrs.Open sqlstr,dbconn,1,1

%>    
    <tr bgcolor="#ffffff"> 
      <td align="center" class=p14 height=80> 
        <%if myrs.RecordCount=0 then%>
         对不起!没有找到<b><%=keyword%></b>相关问卷!<a href="javascript:history.back();"><span class=p14>返回</span></a>
        <%else
          myrs.PageSize=10'每页显示的记录数
          total_page=myrs.PageCount
          total_red=myrs.RecordCount 
          current_page=Request.Form("me_page")
                  
          if current_page="" then
              current_page=1
          elseif not isnumeric(current_page) then
              current_page=1
          else
              current_page=cint(current_page)
          end if

          if current_page>total_page then 
              current_page=total_page
          elseif current_page<1 then
              current_page=1
          end if
                  
          myrs.AbsolutePage=current_page
          
          '加入的返回代码！
          Response.Cookies("back_page")=current_page
          Response.Cookies("back_keyword")=keyword
          Response.Cookies("back_catalogid")=s_catalogid
          Response.Cookies("back_type_id")=type_id
          'Response.Cookies("back_ver")=current_ver
  
      %>
        <table border="0" cellpadding="0" cellspacing="0" class="p9" width="100%">
          <form name="frm_list" method="post">
          <%if keyword<>"" then%>
          <tr align="left"> 
            <td height="26" >&nbsp;以下是与关键字<font color=red><%=keyword%></font>有关的问卷</td>
          </tr>
          <%end if%>
          <tr align=center><td>
  <table border="1" cellpadding="2" cellspacing="0" class="p9" bordercolor="#cccccc" bordercolordark="#FFFFFF" bordercolorlight="#cccccc" width="100%">
          <tr> 
          <td width="4%" align="center" > 
            <input type="checkbox" name="check_all" value="1" onClick="select_ok();">          </td>
          <td width="38%"><b>问卷标题</b>(点击题目标题可以预览效果)</td>
          <td width="5%" align="center">内容编辑</td>
          <td width="5%" align="center">外观设置</td>
          <td width="5%" align="center">参数设置</td>
          <td width="5%" align="center">代码调用</td>
          <td width="5%" align="center">Email发送</td>
          <td width="11%" align="center"><b>类别</b></td>
          <td width="5%" align="center"><b>部门</b></td>
          <td width="17%" align="center" ><b>开始日期/结束日期</b></td>
          <td width="4%" align="center" ><b>状态</b></td>
        </tr>       
          <%For j = 1 to myrs.PageSize%>
          <tr height="26"> 
            <td width="4%" align="center" > 
              <input type="checkbox" name="productid" value="<%=myrs("D_T_S_ID")%>">            </td>
            <td><a href="../../survey.asp?id=<%=myrs("D_T_S_ID")%><%if myrs("D_T_Active")=true then response.write "&bo=1" end if%>" target="_blank"><%response.write myrs("Survey_title")' & "/" & myrs("frist_date") & "/" & myrs("update_date")%></a></td>
            <td align="center"><%if myrs("D_T_Active")=true then%>
            <a href="survey_add.asp?survey_id=<%=myrs("D_T_S_ID")%>" target="_self"><img src="../../images/edit.gif" width="15" height="13" border="0" vspace="2" hspace="2" align="absmiddle" alt="编辑问卷内容"></a>
            <%else%>
            <img src="../../images/edit1.gif" width="15" height="13" border="0" vspace="2" hspace="2" align="absmiddle" alt="已发布不能进行编辑">
            <%end if%></td>
            <td align="center">
            <a href="../../survey_page_set.asp?id=<%=myrs("D_T_S_ID")%>" target="_blank"><img src="../../images/edit.gif" width="15" height="13" border="0" vspace="2" hspace="2" align="absmiddle" alt="设置问卷外观"></a></td>
            <td align="center"><a href="survey_canshu_set.asp?survey_id=<%=myrs("D_T_S_ID")%>" target="_self"><img src="../../images/modifyoption.png" width="15" height="13" border="0" vspace="2" hspace="2" align="absmiddle" alt="设置问卷环境参数"></a>            </td>
            <td align="center">            
			<%if myrs("D_T_Active")=false then%>
            <a href="survey_dy.asp?survey_id=<%=myrs("D_T_S_ID")%>&survey_name=<%=myrs("Survey_title")%>" target="_self"><img src="../../images/ie.gif" width="17" height="17" border="0" vspace="2" hspace="2" align="absmiddle" alt="调用代码"></a>
            <%else%>
            <img src="../../images/ie1.gif" width="17" height="17" border="0" vspace="2" hspace="2" align="absmiddle" alt="未发布不能调用">
            <%end if%>            </td>
            <td align="center">
            <%if myrs("email_send")=true and myrs("D_T_Active")=false then%>
            <a href="survey_send.asp?S_id=<%=myrs("D_T_S_ID")%>" target="_self"><img src="../../images/send2.gif" width="38" height="17" border="0" vspace="2" hspace="2" align="absmiddle" alt="使用电子邮件发送问卷"></a>
            <%else%>
            <img src="../../images/send3.gif" width="38" height="17" border="0" vspace="2" hspace="2" align="absmiddle" alt="问卷尚未发布或没有开启Email发送的功能，不能发送">
            <%end if%>            </td>
            <td><%'response.write myrs("catalogid") & "/" & myrs("type_id")
	CatalogID_d=myrs("catalogid")
	if departmentID<>"" then
		departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"DC_Title_catalog","CatalogName"," where catalogid=" & CatalogID_d)
		if departM=0 then
			response.write "-"
		else
			totalput = UBound(D_data_Dep)
			rs_dep=split(D_data_Dep(0),",")
			response.write rs_dep(0)
		end if
	end if
	
	response.write "/"
	
	type_id_d=myrs("type_id")
	if departmentID<>"" then
		departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"DC_Title_type","TypeName"," where id=" & type_id_d)
		if departM=0 then
			response.write "-"
		else
			totalput = UBound(D_data_Dep)
			rs_dep=split(D_data_Dep(0),",")
			response.write rs_dep(0)
		end if
	end if
			%></td>
            <td align="center"><%
	departmentID=myrs("A_M_D_ID")
	if departmentID<>"" then
		departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"A_Manage_Department","A_M_D_Name"," where A_M_D_ID=" & departmentID)
		if departM=0 then
			response.write "-"
		else
			totalput = UBound(D_data_Dep)
			rs_dep=split(D_data_Dep(0),",")
			response.write rs_dep(0)
		end if
	end if
			%></td>
            <td width="17%" align="left">
            <%sdate=myrs("D_T_StartDate")
			sdate_b=Year(sdate) & "-" & Month(sdate) & "-" & Day(sdate)
			odate=myrs("D_T_OverDate")
			odate_b=Year(odate) & "-" & Month(odate) & "-" & Day(odate)%>
            <a class=text href='javascript:showDiv("<%=myrs("D_T_S_ID") & """,""" & sdate_b & """,""" & odate_b %>")' title="点击即可修改问卷投票日期">
            <%response.write sdate & "/" & odate%></a></td>
          <td width="4%" align="center"><b> 
              <%if sdate<=Date() and Date()<=odate then%>
              <img src="../../images/poll.gif" width="15" height="15" align="absmiddle" vspace="2" hspace="2" alt="当前调查项目">
			  <%else%>
              <img src="../../images/poll1.gif" width="15" height="15" align="absmiddle" vspace="2" hspace="2" alt="已关闭的项目">
          <%end if%>
              </b></td>
          </tr>
          <%myrs.MoveNext
          If myrs.EOF Then Exit For
        next
        %>
        </table>
        </td></tr>
          <tr align="center"> 
            <td height="50">
            <input type="hidden" name="catalogid" value=<%=catalogid%>>
             <!-- <input type="button" value="发送问卷" name=button_22 class="p9" style="WIDTH: 100px; HEIGHT: 24px;" size=134>
              
              <input type="button" value="修改标题及日期" name=button_22 class="p9" style="WIDTH: 108px; HEIGHT: 24px;" size=134 onClick="javascript:add_to_edit();">-->
　              
<input type="button" value="设置成可编辑" name=button_22 class="p9" style="WIDTH: 100px; HEIGHT: 24px;" size=134 onClick="javascript:turn_to_edit();">
<input type="button" value="发布问卷" name=button_22 class="p9" style="WIDTH: 100px; HEIGHT: 24px;" size=134 onClick="javascript:publish_survey();">
<input type="button" value="删除" name=button_21 class="p9" style="WIDTH: 80px; HEIGHT: 24px;" size=134 onClick="javascript:del_to();">
<input type="button" value="全选" name=button_select class="p9" style="WIDTH: 80px; HEIGHT: 24px;" size=134 onClick="javascript:select_change();">
            </td>
          </tr>
          </form>          
        </table>        
      </td>
  </tr>   
      <tr height="24" bgcolor="#f0f0f0"> 
            <td> 
              <div align="center"><strong>分页显示:</strong> <font color=red>第<%=current_page%>页/总<%=total_page%>页 
                | 总<%=total_red%>个</font> 
                <%call showpage%>
                　　转到第 
                <input type="text" name="goto_page1" value="<%=current_page%>" style="border: 1px solid rgb(200,200,200)" size=4 maxlength=4>
                页 
                <input style="height:20;WIDTH: 42px;" class="s02" hideFocus type="button" value="GoTo" name="cmd_goto" onClick="javascript:viewPage(document.all.goto_page1.value);">              
              <form action="survey_list.asp" method=post name="frm_page">
              <input type="hidden" name="me_page">
              <input type="hidden" name="catalogid" value=<%=s_catalogid%>>
              <input type="hidden" name="keyword" value=<%=keyword%>>
              <input type="hidden" name="type_id" value=<%=type_id%>>
              </form>
              </div>
            </td>
  </tr>
    <!--#include file="include/showpage.asp"-->
    <%end if%> 
</table>
<%myrs.Close
set myrs=nothing
dbconn.close
set dbconn=nothing%>
<br>
<div id="new_catalog" style="background:#ffffff;position:absolute;left:expression((body.clientWidth-450)/2);top:expression((body.clientHeight-250)/2);width:450;height:250;visibility: hidden;"><table border="1" cellpadding="2" cellspacing="0" class="p9" bordercolor="#cccccc" bordercolordark="#FFFFFF" bordercolorlight="#677CD9" width="450">
          <tr> 
          <td width="100%" align="center" height="250"><form id="update_d" name="update_d" method="post" action="">
           <span style="FONT-SIZE: 14px"><b><font color="#215DC6">请输入调查的开始和结束日期</font></b></span><br><br>
           <input id="surveyID" type="hidden" name="surveyID" value="" style="border: 1px solid rgb(200,200,200)" size=14 maxlength=14><br>
           开始日期：<input id="startdate" type="text" name="startdate" value="" style="WIDTH: 120px; COLOR: navy;font-size:9pt" size=18 maxlength=18 onChange="javascript:isdatejavasc(document.update_d.startdate.value);">(如：2008-8-31)<br>
           结束日期：<input id="overdate" type="text" name="overdate" value="" style="WIDTH: 120px; COLOR: navy;font-size:9pt" size=18 maxlength=18 onChange="javascript:isdatejavasc(document.update_d.overdate.value);">(如：2010-9-30)
         <br><br><input type="button" value="修　改" name=button_22 class="p9" style="WIDTH: 100px; HEIGHT: 24px;" size="134"  onClick="javascript:isdatejs();">
         <br><br>
         </form>
          <a class=text href='javascript:showDiv("hidden")' >关闭</a></td></tr></table></div>
</body>
</html>