7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
236 lines
7.7 KiB
PHP
236 lines
7.7 KiB
PHP
<?php
|
|
//-------------------------------款号管理
|
|
header("Content-type: text/html; charset=utf-8");
|
|
if(THIS_IN!="edt_admin")
|
|
exit("错误的访问!");
|
|
//-------------------------------execute action
|
|
$db=_mysql_connect();
|
|
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
|
|
$arr_questype=array("y"=>"单选题","n"=>"复选题","t"=>"输入框");
|
|
//权限判断
|
|
$priv=return_priv($_m,$msg_login_user["priv"]);
|
|
$json_data="{";
|
|
if($priv[0]=="n"){
|
|
//没有操作权限
|
|
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
|
|
}else{
|
|
$json_data.="\"uid\":".$uid.",";
|
|
|
|
$arr_column_survey=array("question"=>"问题描述","single"=>"选项类型","selection"=>"备选项描述/文本答案描述","list_whoselected"=>"客户","manager"=>"上级路径");
|
|
switch($_a){
|
|
case "add" :
|
|
//--------------------------新增
|
|
$add_date=date("Y-m-d H:i:s");
|
|
if($id){
|
|
$msg=get_db_msg("select * from ".$table_pre."plugin_surveyques where id='".$id."'");
|
|
$question=$msg["question"];
|
|
$single=$msg["single"];
|
|
$selection=$msg["selection"];
|
|
$gl=$msg["gl"];
|
|
|
|
}else{
|
|
$question="";
|
|
$single="";
|
|
$selection="";
|
|
$gl="";;
|
|
}
|
|
$tmp_xx="";
|
|
foreach($arr_questype as $key=>$value){
|
|
$tmp_xx.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
|
|
}
|
|
$tmp_xx=deel_end($tmp_xx);
|
|
$json_data.="\"xx\":{\"no\":\"single\",\"value\":\"".$single."\",\"op\":[".$tmp_xx."]},";
|
|
|
|
$json_data.="\"question\":\"".$question."\",";
|
|
$json_data.="\"single\":\"".$single."\",";
|
|
$json_data.="\"selection\":\"".$selection."\",";
|
|
$json_data.="\"gl\":\"".$gl."\",";
|
|
break;
|
|
case "save_add" :
|
|
//echo $single;
|
|
if($single!=="t"){
|
|
for($i=0,$num=count($selection_sub);$i<$num;$i++){
|
|
if($selection_sub[$i]!==""&&$selection_desc[$i]!=="")
|
|
$selection[]=$selection_sub[$i].":".$selection_desc[$i];
|
|
}
|
|
$selection=@implode("|",$selection);
|
|
}else{
|
|
$selection="";
|
|
}
|
|
|
|
$question=$question?$question:"未定义的问题";
|
|
|
|
if($id){
|
|
$q="update ".$table_pre."plugin_surveyques set question='".$question."',selection='".$selection."',single='".$single."' where id='".$id."'";
|
|
$db->query($q);
|
|
}else{
|
|
$q="insert ".$table_pre."plugin_surveyques (question,single,selection) values ('".$question."','".$single."','".$selection."')";
|
|
$db->query($q);
|
|
}
|
|
$json_data.="\"code\":1,";
|
|
break;
|
|
case "del" :
|
|
$id=(is_array($id))?$id:array($id);
|
|
$num=count($id);
|
|
for($i=0;$i<$num;$i++){
|
|
$tmp=get_db_msg("select no from ".$table_pre."kh where id='".$id[$i]."'");
|
|
//删除款号表
|
|
$db->query("delete from ".$table_pre."kh where id='".$id[$i]."'");
|
|
//删除款色表
|
|
$db->query("delete from ".$table_pre."kh_color where iid='".$id[$i]."'");
|
|
$lid.=$tmp["no"].",";
|
|
}
|
|
$json_data.="\"code\":1,";
|
|
break;
|
|
//----------------------------------------------------------------------导出数据
|
|
case "export":
|
|
$column="";
|
|
foreach($arr_column_survey as $k => $v){
|
|
$column.="{\"k\":\"".$k."\",\"t\":\"".$v."\"},";
|
|
}
|
|
if($column)
|
|
$column=substr($column,0,-1);
|
|
$json_data.="\"col\":[".$column."],";
|
|
$json_data.="\"color_select\":[{\"k\":\"2\",\"t\":\"纵向\"},{\"k\":\"1\",\"t\":\"横向逗号隔开\"}],";
|
|
break;
|
|
case "export_do":
|
|
//取得字段选择的值
|
|
foreach($arr_column_survey as $k => $v){
|
|
$var="col_".$k;
|
|
if($$var=="on"){
|
|
$ex_col[]=$k;
|
|
}
|
|
}
|
|
$num=count($ex_col);
|
|
if($num==0)
|
|
alert_and_back("请至少选择一个要导出的字段");
|
|
$show_bx=$show_gg="n";
|
|
$data=array();
|
|
//设置表头数据类型
|
|
for($i=0;$i<$num;$i++){
|
|
if($ex_col[$i]=="pic"){
|
|
$data["col"][]="img";
|
|
}else{
|
|
$data["col"][]="str";
|
|
}
|
|
}
|
|
//设置表头
|
|
for($i=0;$i<$num;$i++){
|
|
if($ex_col[$i]=="pic"){
|
|
$data["header"][0][]="图片|img";
|
|
}else if($ex_col[$i]=="color_code"){
|
|
$data["header"][0][]="颜色代码|str";
|
|
}else if($ex_col[$i]=="size_bx"){
|
|
$show_bx="y";
|
|
$data["header"][0][]=get_main_value($arr_column_survey,$ex_col[$i]);
|
|
}else if($ex_col[$i]=="gg"){
|
|
$show_gg="y";
|
|
$data["header"][0][]=get_main_value($arr_column_survey,$ex_col[$i]);
|
|
}else{
|
|
$data["header"][0][]=get_main_value($arr_column_survey,$ex_col[$i]);
|
|
}
|
|
}
|
|
//取得数据
|
|
$query="select * from ".$table_pre."plugin_surveyques order by id";
|
|
$r=$db->query($query);
|
|
$row=0;
|
|
while($msg_0=$db->fetch_array($r)){
|
|
|
|
$arr_tmp_0=explode("|",$msg_0["selection"]);
|
|
foreach($arr_tmp_0 as $value){
|
|
if($value!==""){
|
|
$arr_tmp_1=explode(":",$value);
|
|
$content_selection=$arr_tmp_1[0]." : ".$arr_tmp_1[1];
|
|
$query_1="select uid from ".$table_pre."plugin_surveyanswer where qid='".$msg_0["id"]."' and selected='".$arr_tmp_1[0]."'";
|
|
}else{
|
|
$content_selection="";
|
|
$query_1="select uid,selected from ".$table_pre."plugin_surveyanswer where qid='".$msg_0["id"]."'";
|
|
}
|
|
|
|
$res_1=$db->query($query_1);
|
|
while($msg_1=$db->fetch_array($res_1)){
|
|
$use_info=get_db_msg("select face,path,title from ".$table_pre."client where id='".$msg_1["uid"]."'");
|
|
if($use_info["face"]=="4"||$use_info["face"]=="3"){
|
|
$manager_id=array_pop(explode("-",$use_info["path"]));
|
|
$manager_info=get_db_msg("select title from ".$table_pre."client where id='".$manager_id."'");
|
|
}
|
|
for($i=0,$num_col=count($ex_col);$i<$num_col;$i++){
|
|
if($ex_col[$i]=="selection"){
|
|
$data["body"][$row][]=$content_selection!==""?$content_selection:$msg_1["selected"];
|
|
}elseif($ex_col[$i]=="list_whoselected"){
|
|
$data["body"][$row][]=$use_info["title"];
|
|
}elseif($ex_col[$i]=="manager"){
|
|
$data["body"][$row][]=$manager_info["title"];
|
|
}elseif($ex_col[$i]=="single"){
|
|
$data["body"][$row][]=get_main_value($arr_questype,$msg_0[$ex_col[$i]]);
|
|
}else{
|
|
$data["body"][$row][]=$msg_0[$ex_col[$i]];
|
|
}
|
|
}
|
|
$row++;
|
|
}
|
|
}
|
|
}
|
|
$file_name="wjdc_".date("Y-m-d-H-i");
|
|
//print_r($data);
|
|
//exit;
|
|
output_excel($file_name,$data);
|
|
set_log("导出 问卷调查信息");
|
|
exit;
|
|
break;
|
|
//----------------------------------------------------------------------/导出数据
|
|
//-------------主界面
|
|
default :
|
|
//
|
|
//
|
|
$page=$page>0?$page:1;
|
|
$limit=$limit>0?$limit:10;
|
|
$start=($page-1)*$limit;
|
|
$end=$limit;
|
|
$sql_con="";
|
|
if($s_keyword){
|
|
$sql_con="where ";
|
|
$sql_con.="question like '%".$s_keyword."%' and";
|
|
$sql_con=substr($sql_con,0,-4);
|
|
}
|
|
$json_data.="\"s_keyword\":\"".$s_keyword."\",";
|
|
//取得总条数
|
|
$tmp=get_db_msg("select count(*) 'total' from ".$table_pre."plugin_surveyques ".$sql_con);
|
|
$total_num=$tmp["total"];
|
|
//是否有折扣
|
|
$query="select * from ".$table_pre."plugin_surveyques ".$sql_con." order by id limit ".$start.",".$end;
|
|
//echo $query."<br>";
|
|
$res=$db->query($query);
|
|
$count=1;
|
|
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":[";
|
|
$str_tmp="";
|
|
while($msg=$db->fetch_array($res)){
|
|
$list=$count+$start;
|
|
$str_tmp.="{";
|
|
$str_tmp.="\"id\":\"".$msg["id"]."\",";
|
|
$str_tmp.="\"xh\":\"".$list."\",";
|
|
$str_tmp.="\"question\":\"".$msg["question"]."\",";
|
|
$str_tmp.="\"single\":\"".$msg["single"]."\",";
|
|
if($msg["single"]=="y"){
|
|
$str_tmp.="\"single_t\":\"单选题\",";
|
|
}
|
|
if($msg["single"]=="n"){
|
|
$str_tmp.="\"single_t\":\"复选题\",";
|
|
}
|
|
if($msg["single"]=="t"){
|
|
$str_tmp.="\"single_t\":\"输入框\",";
|
|
}
|
|
//$str_tmp.="\"selection\":\"".$msg["selection"]."\",";
|
|
$str_tmp.="\"gl\":\"".$msg["gl"]."\"";
|
|
|
|
$str_tmp.="},";
|
|
//
|
|
$count++;
|
|
}
|
|
$json_data.=substr($str_tmp,0,-1)."],";
|
|
break;
|
|
}
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|