This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/plugin/survey_client.php
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

254 lines
8.5 KiB
PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="user-scalable=yes,initial-scale=1,maximum-scale=3.0,minimum-scale=1" />
<meta http-equive="Cache-Control" content="max-age=3153600"/>
<title>问卷调查-E订通</title>
<style>
BODY {
margin:0px;padding:10px;background-color:#ffffff;
}
a,a:link,a:visited,a:active {
text-decoration:none;COLOR: #ffffff;FONT-SIZE:14px;
}
a:hover {
TEXT-DECORATION: none;COLOR: #cccccc;FONT-SIZE:14px;
}
input,select,option{
height:30px;
}
td,select,div,li,ul,textarea,form {
font-family:宋体;FONT-SIZE:14px;background-color:#f0f0f0;line-height:100%;
}
.selection{
vertical-align:middle; margin-top:0;
}
</style>
<script>
function answer_check_submit(num){
var answer_str='';
var pass=true;
for(var i=0;i<=num;i++){
var num_checked=0;
var tmp_0=document.getElementsByName('answer_'+i);
for(var j=0;j<tmp_0.length;j++){
var tmp_1=document.getElementById(i+"_"+j);
if(tmp_1.type=='text'){
tmp_1.value=tmp_1.value?tmp_1.value:'客户未回答此问题.'
var text_id=document.getElementById('text_'+i+'_'+j).value;
answer_str+=','+text_id+'|'+tmp_1.value;
num_checked++;
}else{
if(tmp_1.checked){
answer_str+=','+tmp_1.value;
num_checked++;
}
if(tmp_1.disabled==true){
num_checked++;
}
}
}
if(num_checked==0 && tmp_0.length>0){
pass=false;
alert('第 '+(i)+' 题未作答,请返回第 '+(i)+' 题答题.');
document.getElementById(i).focus();
break;
}
}
if(num>0 && pass){
answer_str=answer_str.substring(1);
document.getElementById('answer_str').value=answer_str;
document.form_answer.submit();
}
}
function answerAction(id){
var actionObj=document.getElementById(id);
var aid=actionObj.name.split('_');
str=actionObj.value
var url='../plugin/survey_gl.php?str='+str;
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.open('POST',url,true);
xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
var res=xmlhttp.responseText;
arr=res.split(',');
for (var i=0;i<arr.length;i++){
for(var j=0;j<8;j++){
inputSta=arr[i].split('|');
var obj=document.getElementById(inputSta[1]+"_"+j);
if(obj){
if(inputSta[0]=='1'){
obj.disabled=false;
}else{
obj.disabled=true;
obj.checked=false;
}
}else{
break;
}
}
}
}
}
xmlhttp.send(null);
}
</script>
</head>
<body>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" name="form_answer" method="get">
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
<?php
require "../admin/config.php";
require "../tmpl/config.php";
require "../admin/include/function.php";
require "../admin/include/db_mysql.php";
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$uid=$_COOKIE["edt_".date("Ymd")."_cookie"];
$db=_mysql_connect();
if($uid==""){
alert("无法采集到当前用户身份信息,请尝试重新登录!");
exit();
}
$msg_login=get_db_msg("select title from ".$table_pre."client where id='".$uid."'");
class question{
public $ques_id;
public $ques_num;
public $ques_type;
public $ques_desc;
public $ques_selection;
public $ques_selection_exist=array();
function question_output(){
if($this->ques_desc){
echo "<tr><td id=\"".$this->ques_num."\" valign=\"top\" style=\"background-color:#f0f0f0;padding:10px;line-height:150%;\"><b>".($this->ques_num+1)."</b> . ".$this->ques_desc."</td></tr>";
}else return;
return;
}
function selection_output(){
if($this->ques_type){
$type=$this->ques_type;
if($type=="t") {$this->selection_output_text();}
if($type=="y"||$type=="n") {$this->selection_output_radio_checkbox();}
}else return;
return;
}
private function selection_output_text(){
$i=0;
$disable=$this->ques_gl?"disabled=\"disabled\"":"";
echo "<tr><td><input type=\"text\" name=\"answer_".$this->ques_id."\" id=\"".$this->ques_id."_".$i."\" value=\"".$this->ques_selection_exist[0]."\" style=\"width:400px;\" $disable /><input type=\"hidden\" id=\"text_".$this->ques_id."_".$i."\" value=".$this->ques_id."><hr></td></tr>";
return;
}
private function selection_output_radio_checkbox(){
if($this->ques_selection==""){
echo "<tr><td>该问题无备选项,请至后台管理系统将该问题完善.</td></tr>";
return;
}
if($this->ques_type=="y"){
$input_type="radio";
}if($this->ques_type=="n"){
$input_type="checkbox";
}
$i=0;
$arr_selection=explode("|",$this->ques_selection);
foreach($arr_selection as $value){
$tmp=explode(":",$value);
$checked="";
if(in_array($tmp[0],$this->ques_selection_exist)){
$checked="checked";
}
$disable=$this->ques_gl?"disabled=\"disabled\"":"";
echo "<tr><td><label><input class=\"selection\" ".$checked." type=\"".$input_type."\" name=\"answer_".$this->ques_id."\" id=\"".$this->ques_id."_".$i++."\" onchange='javascript:answerAction(this.id);' value=\"".$this->ques_id."|".$tmp[0]."\" $disable /><b>".$tmp[0]."</b> : ".$tmp[1]."</label></td></tr>";
}
echo "<tr><td><hr></td></tr>";
return;
}
}
switch($_GET[_a]){
default:
$rurl=$_GET["rurl"];
echo "<tr><td height=\"40\" valign=\"middle\" style=\"background-color:#cccccc;font-size:20px;font-weight:bold;\" align=\"center\">问卷调查</td></tr>";
echo "<tr><td height=\"30\" valign=\"middle\" style=\"font-size:14px;font-weight:bold;line-height:25px;padding:20px;\" align=\"left\">尊敬的客户(".$msg_login["title"]."):<br>&nbsp;&nbsp;&nbsp;&nbsp;亲爱的经销商朋友,感谢您参与定制调查问卷。此问卷不记名,所填信息也会严格保密,您的宝贵意见是我们改进产品的方向,感谢您的参与!</td></tr>";
$ques_num=0;
$abc=new question();
$result=$db->query("select * from ".$table_pre."plugin_surveyques order by id");
while($msg=$db->fetch_array($result)){
$res=$db->query("select selected from ".$table_pre."plugin_surveyanswer where uid='".$uid."'and qid='".$msg["id"]."'");
$arr_selected_exist=array();
while($msg1=$db->fetch_array($res)){
$arr_selected_exist[]=$msg1["selected"];
}
$abc->ques_id=$msg["id"];
$abc->ques_num=$ques_num;
$abc->ques_type=$msg["single"];
$abc->ques_desc=$msg["question"];
$abc->ques_selection=$msg["selection"];
$abc->ques_gl=$msg["gl"];
$abc->ques_selection_exist=$arr_selected_exist;
$abc->question_output();
$abc->selection_output();
$ques_num++;
$maxid=$msg["id"];
}
echo "<input type=\"hidden\" name=\"_a\" value=\"save_answer\"/>";
echo "<input type=\"hidden\" name=\"ques_num\" value=\"".$maxid."\"/>";
echo "<input type=\"hidden\" id=\"answer_str\" name=\"answer_str\" value=\"\"/>";
echo "<tr><td align=\"center\" style=\"background-color:#f0f0f0;padding:10px;line-height:100%;\"><input type=\"button\" onclick=\"answer_check_submit(".$maxid.")\"
value=\"提交问卷\"></td></tr>";
break;
case "save_answer":
$answer_arr=explode(",",$_GET[answer_str]);
//print_r($answer_arr);
//exit;
//修改问卷时先删除原答案
$msg=get_db_msg("select count(*) as count from web_plugin_surveyanswer where uid='".$uid."'");
if($msg["count"]>0)
$db->query("delete from web_plugin_surveyanswer where uid='".$uid."'");
//---------------------
foreach($answer_arr as $value_tmp){
$answer_info=explode("|",$value_tmp);
$db->query("insert into web_plugin_surveyanswer (uid,qid,selected) values ('".$uid."','".$answer_info[0]."','".$answer_info[1]."')");
}
alert_and_back("问卷已保存.");
break;
case "gl_answer":
$glstr=$_GET[str];
$arrStr="";
$q="select * from web_plugin_surveyques where gl='$glstr'";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$arrStr.=$m["id"].",";
}
$arrStr=substr($arrStr,0,strlen($arrStr)-1);
echo $arrStr;
break;
}
?>
</table>
</form>
</body>
</html>