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/admin/module/kh_ty.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

792 lines
26 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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."'");
//
$time_forever=time()+365*24*3600;
$ty_only_tb=$_COOKIE["edt_ty_only_tb"];
if(!$ty_only_tb)
setcookie("edt_ty_only_tb","on",$time_forever,"/");
//权限判断
$priv=return_priv($_m,$msg_login_user["priv"]);
$order_session=get_set("order_session");
$s_dir=$order_session?$order_session."/":"";
$global_num=$max_cl_num;
$num_cl_zd=0;
if(is_array($sys_ty_zd)){
$num=count($sys_ty_zd);
$num_cl_zd=($num<5)?$num:5;
}
$arr_column_kh_ty["username"]="客户代码";
$arr_column_kh_ty["usertitle"]="客户名称";
//
$arr_column_kh_ty["zsh"]="展示号";
$arr_column_kh_ty["title"]="推演号";
//
if($num_cl_zd>0){
for($i=1;$i<=$num_cl_zd;$i++){
$arr_column_kh_ty["zd".$i]=$sys_ty_zd[$i-1];
}
}
$arr_column_kh_ty["mb"]="模板";
$arr_column_kh_ty["wzh"]="位置号";
$arr_column_kh_ty["pic"]="图片名称";
$arr_column_kh_ty["dp"]="搭配";
$arr_column_kh_ty["kh"]="款号";
$arr_column_kh_ty["color"]="颜色代码";
$arr_column_kh_ty["pic_my"]="款色图片";
$arr_column_kh_ty["ord"]="次序号";
$arr_column_kh_ty["bxk"]="备选款";
$arr_column_kh_ty["remark"]="推演介绍";
$json_data="{";
if($priv[0]=="n"){
//没有操作权限
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
}else{
$json_data.="\"uid\":".$uid.",";
switch($_a){
case "add":
if($zsh){
$msg=get_db_msg("select * from ".$table_pre."kh_ty where zsh='".$zsh."' limit 0,1");
$pic_mini=get_kh_ty_mini($msg["title"]);
$pic_big=get_kh_ty_mini($msg["title"]);
$title=$msg["title"];
$pic=$msg["pic"];
$old_zsh=$zsh;
}else{
$pic_big=$pic_mini="images/no_pic_80.gif";
//kph
$tmp=get_db_msg("select max(zsh) 'num' from ".$table_pre."kh_ty");
if($tmp[num]>0)
$zsh=$tmp[num]+1;
else
$zsh=1;
$title="".$zsh."";
$pic="";
$old_zsh="";
}
$arr_pic_set=out_good_pic_set_arr($pic_mini,120,120);
$json_data.="\"zsh\":\"".$zsh."\",";
$json_data.="\"clh\":\"".$title."\",";
$json_data.="\"pic\":\"".$pic."\",";
$json_data.="\"picurl\":\"".$pic_mini."\",";
$json_data.="\"pic_w\":\"".$arr_pic_set[0]."\",";
$json_data.="\"pic_h\":\"".$arr_pic_set[1]."\",";
$json_data.="\"clremark\":\"".htmlspecialchars($msg["remark"])."\",";
$json_data.="\"old_zsh\":\"".$old_zsh."\",";
$json_data.="\"old_pic\":\"".$msg["title"]."\",";
$select_dz="";
if($num_cl_zd>0){
for($i=1;$i<=$num_cl_zd;$i++){
$arr_column_kh_ty["zd".$i]=$sys_ty_zd[$i-1];
$select_dz.="{\"zd\":\"zd".$i."\",\"zdtitle\":\"".$sys_ty_zd[$i-1]."\",\"zdval\":\"".$msg["zd".$i]."\"},";
}
}
if($select_dz)
$select_dz=substr($select_dz,0,-1);
$json_data.="\"select_dz\":[".$select_dz."],";
$select_ks="";
for($i=1;$i<=$global_num;$i++){
$v2="";
if($zsh>0){
$tmp22=get_db_msg("select * from ".$table_pre."kh_ty where zsh='".$zsh."' and ord='".$i."'");
if($tmp22["id"]>0 && $tmp22["dp"]){
$v2=$tmp22["dp"];
//if($tmp22["color"])
//$v2.="|".get_cate_title_no("color",$tmp22["color"])."|".$tmp22["color"];
}
}
$select_ks.="{\"k1\":\"".$i."\",\"k2\":\"ks_".$i."\",\"k3\":\"".$v2."\"},";
}
if($select_ks)
$select_ks=substr($select_ks,0,-1);
$json_data.="\"select_ks\":[".$select_ks."],";
$select_ks="";
for($i=($global_num+1);$i<=$global_num*2;$i++){
$v2="";
if($zsh>0){
$tmp22=get_db_msg("select * from ".$table_pre."kh_ty where zsh='".$zsh."' and ord='".$i."'");
if($tmp22["id"]>0 && $tmp22["kh"]){
$v2=$tmp22["kh"];
if($tmp22["color"])
$v2.="|".get_cate_title_no("color",$tmp22["color"])."|".$tmp22["color"];
}
}
$select_ks.="{\"k1\":\"".$i."\",\"k2\":\"ks1_".$i."\",\"k3\":\"".$v2."\"},";
}
if($select_ks)
$select_ks=substr($select_ks,0,-1);
$json_data.="\"select_ks1\":[".$select_ks."],";
break;
case "save_add":
//处理数据
for($i=1;$i<=$global_num;$i++){
$q="";
$v1="ks_".$i;
$check=get_db_msg("select id from ".$table_pre."kh_ty where zsh='".$old_zsh."' and ord='".$i."'");
if($$v1){
$arr_tmp=explode("|",$$v1);
if($check["id"]>0){
$q="update ".$table_pre."kh_ty set zsh='".$zsh."',title='".$clh."',zd1='".$zd1."',zd2='".$zd2."',zd3='".$zd3."',zd4='".$zd4."',zd5='".$zd5."',pic='".$pic."',remark='".$clremark."',dp='".$arr_tmp[0]."' where id='".$check["id"]."'";
}else{
$q="insert into ".$table_pre."kh_ty (zsh,title,zd1,zd2,zd3,zd4,zd5,pic,remark,ord,color) values ('".$zsh."','".$clh."','".$zd1."','".$zd2."','".$zd3."','".$zd4."','".$zd5."','".$pic."','".$clremark."','".$i."','".$arr_tmp[0]."')";
}
}else{
if($check["id"]>0)
$q="delete from ".$table_pre."kh_ty where id='".$check["id"]."'";
}
if($q){
$db->query($q);
}
}
for($i=($global_num+1);$i<=$global_num*2;$i++){
$q="";
$v1="ks1_".$i;
$check=get_db_msg("select id from ".$table_pre."kh_ty where zsh='".$old_zsh."' and ord='".$i."'");
if($$v1){
$arr_tmp=explode("|",$$v1);
if($check["id"]>0){
$q="update ".$table_pre."kh_ty set zsh='".$zsh."',title='".$clh."',zd1='".$zd1."',zd2='".$zd2."',zd3='".$zd3."',zd4='".$zd4."',zd5='".$zd5."',pic='".$pic."',remark='".$clremark."',kh='".$arr_tmp[0]."',color='".$arr_tmp[2]."' where id='".$check["id"]."'";
}else{
$q="insert into ".$table_pre."kh_ty (zsh,title,zd1,zd2,zd3,zd4,zd5,pic,remark,ord,kh,color) values ('".$zsh."','".$clh."','".$zd1."','".$zd2."','".$zd3."','".$zd4."','".$zd5."','".$pic."','".$clremark."','".$i."','".$arr_tmp[0]."','".$arr_tmp[2]."')";
}
}else{
if($check["id"]>0)
$q="delete from ".$table_pre."kh_ty where id='".$check["id"]."'";
}
if($q){
$db->query($q);
}
}
if($old_pic!=$pic){
//修改图片名字
if(is_file("../attachments/cl/".$s_dir."big/".$old_pic.".jpg")){
copy("../attachments/cl/".$s_dir."big/".$old_pic.".jpg","../attachments/cl/".$s_dir."big/".$pic.".jpg");
del_file("../attachments/cl/".$s_dir."big/".$old_pic.".jpg");
}
if(is_file("../attachments/cl/".$s_dir."mini/".$old_pic.".jpg")){
copy("../attachments/cl/".$s_dir."mini/".$old_pic.".jpg","../attachments/cl/".$s_dir."mini/".$pic.".jpg");
del_file("../attachments/cl/".$s_dir."mini/".$old_pic.".jpg");
}
}
$json_data.="\"code\":1,";
break;
case "add_pic":
$msg=get_db_msg("select * from ".$table_pre."kh_ty where zsh='".$zsh."' limit 0,1");
$pic=get_kh_ty_mini($msg["title"]);
$arr_pic_set=out_good_pic_set_arr($pic,300,300);
$json_data.="\"pic\":\"".$pic."\",\"pic_w\":\"".$arr_pic_set[0]."\",\"pic_h\":\"".$arr_pic_set[1]."\",";
$json_data.="\"this_title\":\"".$msg["title"]."\",";
break;
case "set_cookie":
setcookie("edt_ty_only_tb",$only_tb,$time_forever,"/");
$json_data.="\"code\":1,";
break;
case "set_is_show":
//----
$ty_only_tb=$_COOKIE["edt_ty_only_tb"];
if($_v=="y" && $ty_only_tb=="on"){
$log_action="设置";
$db->query("update ".$table_pre."kh_ty set is_show='y' where zsh='".$zsh."'");
$db->query("update ".$table_pre."kh_ty set is_show='n' where zsh<>'".$zsh."' and is_show='y'");
}else if($_v=="y" && $ty_only_tb=="off"){
$log_action="设置";
$db->query("update ".$table_pre."kh_ty set is_show='y' where zsh='".$zsh."'");
}else{
$db->query("update ".$table_pre."kh_ty set is_show='n' where zsh='".$zsh."'");
$log_action="取消";
}
set_log($log_action."同步推演",$zsh);
$json_data.="\"only_test\":\"".$ty_only_tb."\",";
$json_data.="\"code\":1,";
break;
case "testorder":
if($s_client){
$arr_select_no=array();
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_select_no[]=$m1["no"];
}
$client=get_db_msg("select * from ".$table_pre."client where username='".$s_client."' limit 0,1");
$upath=$client["path"]."-".$client["id"];
$sql="select * from ".$table_pre."kh_ty ";
$res=$db->query($sql);
$arr_kc=array();
while($msg=$db->fetch_array($res)){
if($msg["dp"]){
$q="select * from ".$table_pre."kh_dp where title='".$msg["dp"]."'";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$kc=$m["kh"]."-".$m["color"];
if(!in_array($kc,$arr_kc)){
$kh=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'");
if($kh["id"]){
$arr_size=explode(",",$kh["size"]);
$sql1=$sql2="";
for($i1=0;$i1<count($arr_select_no);$i1++){
$sql1.=$arr_select_no[$i1].",";
$sql2.="'".$kh[$arr_select_no[$i1]]."',";
}
$sql_size2=$sql_size3="";
for($k=0;$k<count($arr_size);$k++){
$sql_size2.=",'1'";
$sql_size3.=",num_".$arr_size[$k];
}
$check=get_db_msg("select id from ".$table_pre."order where uid='".$client["id"]."' and iid='".$kh["id"]."' and color='".$m["color"]."' and _key='".$sys_this_order_flag."'");
if(!$check["id"]){
$qa="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$client["id"]."','".$upath."','".$kh["id"]."','".$kh["no"]."',".$sql2."'".get_jgd($kh["price"])."','".$m["color"]."','','".$kh["is_sp"]."','".$kh["size_group"]."'".$sql_size2.",'".$sys_this_order_flag."','".get_sx($m["color"])."','".time()."')";
$db->query($qa);
cache_order($client["id"],$kh["id"],$m["color"],"");
$arr_kc[$kc]=$kc;
}
}
}
}
}else{
$kc=$msg["kh"]."-".$msg["color"];
if(!in_array($kc,$arr_kc)){
$kh=get_db_msg("select * from ".$table_pre."kh where no='".$msg["kh"]."'");
if($kh["id"]){
$arr_size=explode(",",$kh["size"]);
$sql1=$sql2="";
for($i1=0;$i1<count($arr_select_no);$i1++){
$sql1.=$arr_select_no[$i1].",";
$sql2.="'".$kh[$arr_select_no[$i1]]."',";
}
$sql_size2=$sql_size3="";
for($k=0;$k<count($arr_size);$k++){
$sql_size2.=",'1'";
$sql_size3.=",num_".$arr_size[$k];
}
$check=get_db_msg("select id from ".$table_pre."order where uid='".$client["id"]."' and iid='".$kh["id"]."' and color='".$msg["color"]."' and _key='".$sys_this_order_flag."'");
if(!$check["id"]){
$qa="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$client["id"]."','".$upath."','".$kh["id"]."','".$kh["no"]."',".$sql2."'".get_jgd($kh["price"])."','".$msg["color"]."','','".$kh["is_sp"]."','".$kh["size_group"]."'".$sql_size2.",'".$sys_this_order_flag."','".get_sx($msg["color"])."','".time()."')";
$db->query($qa);
cache_order($client["id"],$kh["id"],$msg["color"],"");
$arr_kc[$kc]=$kc;
}
}
}
}
}
$json_data.="\"code\":\"101\",";
}
break;
case "save_add_pic":
$up_image=$_FILES["up_file"];;
$msg=get_db_msg("select * from ".$table_pre."kh_ty where zsh='".$zsh."' limit 0,1");
if($up_image["name"]){
$path1="../attachments/ty/big";
$path2="../attachments/ty/mini";
$new_file_name=$msg["title"].".jpg";
make_mini_picture($up_image["tmp_name"],$path1."/".$new_file_name,800);
//缩略图
make_mini_picture($path1."/".$new_file_name,$path2."/".$new_file_name,200);
}
$json_data.="\"code\":1,";
break;
case "mod_upath_do":
$arr_zsh=explode(",",$zsh);
if($s_dp=="_all_"){
$upath="";
}else{
$m1=get_db_msg("select path,id from ".$table_pre."client where username='".$s_dp."'");
$upath=$m1["path"]."-".$m1["id"];
}
$num=count($arr_zsh);
for($i=0;$i<$num;$i++){
$q="update ".$table_pre."kh_ty set upath='".$upath."' where zsh='".$arr_zsh[$i]."'";
$db->query($q);
$lid.=$arr_zsh[$i].", ";
}
$lid=substr($lid,0,-2);
set_log("修改推演权限",$lid);
$json_data.="\"code\":1,";
break;
case "check":
//检查款号
$str="";
$tmp="";
$q="select kh from ".$table_pre."kh_ty group by kh";
$r=$db->query($q);
$i=0;
while($m=$db->fetch_array($r)){
$check=get_db_msg("select id from ".$table_pre."kh_dp where title='".$m["kh"]."'");
if(!$check["id"]){
$tmp.="{\"kh\":\"".$m["kh"]."\",\"v\":\"".$m["kh"]."\"},";
$i++;
}
}
if($i>0){
$str.="{\"cate\":\"搭配号有误\",\"data\":[".deel_end($tmp)."]},";
}
//检查颜色
$tmp="";
$q="select * from ".$table_pre."kh_ty";
$r=$db->query($q);
$i=0;
while($m=$db->fetch_array($r)){
$check2=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'");
$arr_color=explode(",",$check2["color"]);
if(!in_array($m["color"],$arr_color,true)){
$tmp.="{\"kh\":\"".$m["kh"]."\",\"v\":\"".$m["kh"].",".$m["color"]."\"},";
$i++;
}
}
if($i>0){
//$str.="{\"cate\":\"款色有误\",\"data\":[".deel_end($tmp)."]},";
}
//--------------------检查图片
$q="select * from ".$table_pre."kh_ty group by zsh";
$r=$db->query($q);
$i=0;
$tmp="";
while($m=$db->fetch_array($r)){
$pic=get_kh_ty_mini($m["title"]);
if($pic=="images/no_pic_80.gif"){
$tmp.="{\"zsh\":\"".$m["zsh"]."\",\"v\":\"".$m["zsh"]."(".$m["title"].")\"},";
$i++;
}
}
if($i>0){
$str.="{\"cate\":\"缺图片\",\"data\":[".deel_end($tmp)."]},";
}
//--------------------检查对比图片
$q="select * from ".$table_pre."kh_ty order by zsh";
$r=$db->query($q);
$i=0;
$tmp="";
while($m=$db->fetch_array($r)){
$q1="select * from ".$table_pre."kh_dp where title='".$m["kh"]."'";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$pic=get_kh_ty_mini($m["title"]);
if($pic=="images/no_pic_80.gif"){
$tmp.="{\"zsh\":\"".$m["zsh"]."\",\"v\":\"".$m["zsh"]."(".$m["title"].")\"},";
$i++;
}
}
}
if($i>0){
$str.="{\"cate\":\"缺对比图片\",\"data\":[".deel_end($tmp)."]},";
}
if(!$str){
$str.="{\"cate\":\"无误\",\"data\":[]},";
}
$json_data.="\"error\":[".deel_end($str)."],";
break;
//删除
case "del" :
$id=(is_array($id))?$id:array($id);
$num=count($id);
for($i=0;$i<$num;$i++){
$tmp=get_db_msg("select * from ".$table_pre."kh_ty where zsh='".$id[$i]."' limit 0,1");
//
del_file("../attachments/cl/".$s_dir."big/".$tmp["title"].".jpg");
del_file("../attachments/cl/".$s_dir."mini/".$tmp["title"].".jpg");
$q="delete from web_kh_ty where zsh='".$id[$i]."'";
$db->query($q);
$lid.=$id[$i].", ";
}
$lid=substr($lid,0,-2);
set_log("删除推演",$lid);
$json_data.="\"code\":1,";
break;
case "zsh_pl":
$arr=explode("\n",$text);
$msg="";
for($i=0;$i<count($arr);$i++){
$str1=str_replace("","|",$arr[$i]);
$str1=str_replace(",","|",$arr[$i]);
$arr1=explode("|",$str1);
$v1=trim($arr1[0]);
$zsh=trim($arr1[1]);
$check=get_db_msg("select * from ".$table_pre."kh_ty where ".$zd."='".$v1."' limit 0,1");
if($check["id"]>0 && $zsh>0){
$q="update ".$table_pre."kh_ty set zsh='".$zsh."' where ".$zd."='".$v1."'";
$db->query($q);
$msg.="{\"t1\":\"".$v1."|".$zsh."\",\"t2\":\"y\"},";
}else{
//有误
$msg.="{\"t1\":\"".$v1."|".$zsh."\",\"t2\":\"n\"},";
}
}
$json_data.="\"code\":1,\"data\":[".substr($msg,0,-1)."],";
break;
case "dp_select" :
//
$query="select DISTINCT zsh,title from ".$table_pre."kh_dp order by zsh";
//echo $query."<br>";
$res=$db->query($query);
$count=0;
$data=array();
$str_tmp="";
$i=0;
while($msg=$db->fetch_array($res)){
$str_tmp.="{\"zsh\":\"".$msg["zsh"]."\",\"t1\":\"".$msg["title"]."\"},";
$i++;
}
$json_data.="\"data\":[".deel_end($str_tmp)."],";
break;
//----------------------------------------------------------------------导入EXCEL
case "import":
//目录权限
$arr_path=array(
"cache"=>"admin/cache"
);
$json_data.="\"path_priv\":[";
$tmp="";
foreach($arr_path as $path_real => $path_title){
$tmp.="{\"title\":\"".$path_title."\",\"priv\":";
if(new_is_writeable($path_real)==1){
$tmp.="\"y\"";
}else{
$tmp.="\"n\"";
}
$tmp.="},";
}
$json_data.=substr($tmp,0,-1)."],";
break;
case "import_check":
$file1=$_FILES["up_file"];
$tmp_file_name=save_tmp_file($file1);
$tmp_content=get_tmp_content($tmp_file_name);
$arr_content=explode("\n",$tmp_content);
$arr_thead=get_table_thead($tmp_content);
$arr_column=check_table_thead($arr_thead,$arr_column_kh_ty);
$msg="";
if(count($arr_column[0])==0){
$msg.="未检测到可导入字段,请返回检查EXCEL文件!";
del_tmp_file($tmp_file_name);
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
}else{
//
$column="";
foreach($arr_column_kh_ty as $k => $v){
$column.=$v.",";
}
if($column)
$column=substr($column,0,-1);
$msg1=array();
$msg1[0]=array("可导入正确字段",$column);
//
$column="";
for($i=0;$i<count($arr_thead);$i++){
if(in_array(get_main_key($arr_column_kh_ty,$arr_thead[$i]),$arr_column[1])){
$style=" style='font-weight:bold;color:#0000ff'";
}else{
$style=" style='color:#cccccc'";
}
$column.="<span".$style.">".$arr_thead[$i]."</span>,";
}
if($column)
$column=substr($column,0,-1);
//
$msg1[1]=array("检测到的有效字段",$column);
//
$total=count($arr_content)-1;
$msg1[2]=array("记录条数",$total);
$m1="";
for($i=0;$i<count($msg1);$i++){
$m1.="{\"col1\":\"".$msg1[$i][0]."\",\"col2\":\"".$msg1[$i][1]."\"},";
}
if($m1)
$m1=substr($m1,0,-1);
$json_data.="\"code\":1,\"tmp_file_name\":\"".$tmp_file_name."\",\"msg\":[".$m1."],";
$json_data.="\"input\":[{\"type\":\"radio\",\"title\":\"导入方式\",\"name\":\"import_type\",\"op\":\"清空导入|新增导入\",\"value\":\"清空导入\"}],";
}
break;
case "import_do":
$import_type=($import_type=="清空导入")?"y":"n";
if($import_type=="y"){
$db->query("TRUNCATE TABLE web_kh_ty;");
}
$json_data.="\"code\":1,\"reload_type\":\"1\",";
//-------------------------------------------导入数据
$tmp_content=get_tmp_content($tmp_file_name);
$arr_content=explode("\n",$tmp_content);
$arr_thead=get_table_thead($tmp_content);
$arr_column=check_table_thead($arr_thead,$arr_column_kh_ty);
$insert_column="";
for($i=0;$i<count($arr_column[1]);$i++){
$ititle=$arr_column[1][$i];
if($ititle=="username" || $ititle=="usertitle"){
}else{
$insert_column.=$arr_column[1][$i].",";
}
}
$insert_column=substr($insert_column,0,-1);
for($i=1;$i<count($arr_content);$i++){
$tmp_arr=explode("|^_^|",$arr_content[$i]);
$insert_value="";
for($k=0;$k<count($arr_column[0]);$k++){
$ind=$arr_column[0][$k];
$ititle=$arr_column[1][$k];
if($ititle=="ord"){
$insert_value.="'0',";
}else if($ititle=="username" || $ititle=="usertitle"){
}else{
$insert_value.="'".mysql_escape_string(trim($tmp_arr[$ind]))."',";
}
}
$insert_value=substr($insert_value,0,-1);
$q="insert into web_kh_ty (".$insert_column.") values (".$insert_value.")";
//echo $q."<br>";
$db->query($q);
}
//更新次序号
$q="select * from ".$table_pre."kh_ty group by zsh order by zsh";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$q1="select * from ".$table_pre."kh_ty where zsh='".$m["zsh"]."' order by ord";
$r1=$db->query($q1);
$i=1;
while($m1=$db->fetch_array($r1)){
$q2="update ".$table_pre."kh_ty set ord='".$i."' where id='".$m1["id"]."'";
$db->query($q2);
//echo $q2."<br>";
$i++;
}
}
del_tmp_file($tmp_file_name);
$log_remark=$import_flag;
set_log("导入 推演数据",$log_remark);
break;
//----------------------------------------------------------------------导出数据
case "export":
$column="";
foreach($arr_column_kh_ty as $k => $v){
$column.="{\"k\":\"".$k."\",\"t\":\"".$v."\"},";
}
if($column)
$column=substr($column,0,-1);
$json_data.="\"col\":[".$column."],";
break;
case "export_do":
//取得字段选择的值
foreach($arr_column_kh_ty as $k => $v){
$var="col_".$k;
if($$var=="on"){
$ex_col[]=$k;
}
}
$num=count($ex_col);
if($num==0)
alert_and_back("请至少选择一个要导出的字段");
for($i=0;$i<$num;$i++){
$data["col"][]='str';
$data["header"][0][]=get_main_value($arr_column_kh_ty,$ex_col[$i]);
}
if($s_client){
if($s_client=="_all_"){
$sql_con.="(upath='') and ";
}else{
$tmp=get_db_msg("select * from ".$table_pre."client where username='".$s_client."'");
if($tmp["id"]>0){
$s_jxs=$tmp["path"]."-".$tmp["id"];
$sql_con.="(upath='".$s_jxs."' or upath like '".$s_jxs."-%') and ";
}
}
}
if($sql_con)
$sql_con="where ".substr($sql_con,0,-4);
$query="select * from ".$table_pre."kh_ty ".$sql_con." order by zsh,ord";
$r=$db->query($query);
$row=0;
while($m=$db->fetch_array($r)){
for($i=0;$i<$num;$i++){
$k=$ex_col[$i];
if($k=="username" || $k=="usertitle"){
$m1=get_db_msg("select username,title 'usertitle' from ".$table_pre."client where id='".get_parent_id($m["upath"])."'");
$data["body"][$row][]=$m1[$k];
}else{
$data["body"][$row][]=$m[$k];
}
}
$row++;
}
$file_name="kh_ty_".date("Y-m-d-H-i");
output_excel($file_name,$data);
set_log("导出 推演信息");
exit;
break;
//-------------主界面
default:
$json_data.="\"lang_zsh\":\"展示号\",";
$json_data.="\"lang_kh\":\"款号\",";
$ty_only_tb=$_COOKIE["edt_ty_only_tb"];
$json_data.="\"only\":\"".$ty_only_tb."\",";
$ctt=1;
$select_dz="";
for($i=0;$i<count($sys_ty_zd);$i++){
$zd="zd".$ctt;
$strtmp="";
$res1=$db->query("select ".$zd." from ".$table_pre."kh_ty group by ".$zd." order by ".$zd);
while($msg1=$db->fetch_array($res1)){
$strtmp.="{\"no\":\"".$msg1[$zd]."\",\"title\":\"".$msg1[$zd]."\"},";
}
$strtmp=deel_end($strtmp);
$var="s_".$zd;
$select_dz.="{\"no\":\"".$zd."\",\"title\":\"".$sys_ty_zd[$i]."\",\"value\":\"".$$var."\",\"op\":[".$strtmp."]},";
$ctt++;
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
$page=$page>0?$page:1;
$limit=$limit>0?$limit:10;
$start=($page-1)*$limit;
$end=$limit;
//条件
$sql_con="";
if($s_kh || $s_zsh){
if($s_zsh)
$sql_con.="zsh='".$s_zsh."' and ";
if($s_kh)
$sql_con.="kh like '%".$s_kh."%' and ";
}
if($s_client){
if($s_client=="_all_"){
$sql_con.="(upath='') and ";
}else{
$tmp=get_db_msg("select * from ".$table_pre."client where username='".$s_client."'");
if($tmp["id"]>0){
$s_jxs=$tmp["path"]."-".$tmp["id"];
$sql_con.="(upath='".$s_jxs."') and ";
}
}
}
$ctt=1;
for($i=0;$i<count($sys_ty_zd);$i++){
$zd="zd".$ctt;
$v="s_".$zd;
if($$v)
$sql_con.=" ".$zd."='".$$v."' and ";
$ctt++;
}
if($sql_con)
$sql_con="where ".substr($sql_con,0,-4);
//取得总条数
$tmp=get_db_msg("select count(distinct zsh) 'num' from ".$table_pre."kh_ty ".$sql_con);
$total_num=$tmp["num"];
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":[";
$count=1;
$str_tmp="";
$sql="select * from ".$table_pre."kh_ty ".$sql_con." group by zsh order by zsh limit ".$start.",".$end;
$res=$db->query($sql);
while($msg=$db->fetch_array($res)){
$list=$count+$start;
$str_ks="";
$str_dp="";
$q1="select * from ".$table_pre."kh_ty where zsh='".$msg["zsh"]."' order by ord";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
if($m1["dp"]){
$pic2=get_kh_dp_mini($m1["dp"]);
$str_dp.=$m1["dp"].",".$pic2."|";
}elseif($m1["kh"]){
//$m2=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."' limit 0,1");
$pic2=get_kh_color_picture($m1["kh"],$m1["color"]);
$str_ks.=$m1["kh"].",".get_cate_title_no("color",$m1["color"]).",".$m1["color"].",".$pic2."|";
}
}
if($str_dp)
$str_dp=substr($str_dp,0,-1);
if($str_ks)
$str_ks=substr($str_ks,0,-1);
if($msg["upath"]==""){
$str_user="全国";
}else{
$str_user=get_path_title($msg["upath"],"-",$table_pre."client","title");
}
$ctt2=1;
$strzd="";
for($i=0;$i<count($sys_ty_zd);$i++){
$zd="zd".$ctt2;
if($msg[$zd])
$strzd.=$msg[$zd]."|";
$ctt2++;
}
if($strzd)
$strzd=substr($strzd,0,-1);
$pic=get_kh_ty_mini($msg["title"]);;
$arr_pic_set=out_good_pic_set_arr($pic,120,120);
$str_tmp.="{";
$str_tmp.="\"ct\":\"".$list."\",";
$str_tmp.="\"zsh\":\"".$msg["zsh"]."\",";
$str_tmp.="\"clh\":\"".$msg["title"]."\",";
$str_tmp.="\"zd\":\"".$strzd."\",";
$str_tmp.="\"dp\":\"".$str_dp."\",";
$str_tmp.="\"kh\":\"".$str_ks."\",";
$str_tmp.="\"pic_src\":\"".$pic."\",";
$str_tmp.="\"pic_w\":\"".$arr_pic_set[0]."\",";
$str_tmp.="\"pic_h\":\"".$arr_pic_set[1]."\",";
$str_tmp.="\"cljs\":\"".htmlspecialchars($msg["remark"])."\",";
$str_tmp.="\"is_show\":\"".$msg["is_show"]."\",";
$str_tmp.="\"qx\":\"".$str_user."\"";
$str_tmp.="},";
$count++;
}
$json_data.=substr($str_tmp,0,-1)."],";
break;
}
}
function get_kh_ty_mini($clh){
global $order_session;
$s_dir=$order_session?$order_session."/":"";
$pic="../attachments/ty/mini/".$clh.".jpg";
if(!is_file($pic)){
$pic="images/no_pic_80.gif";
}
return $pic;
}
function get_kh_ty_big($clh){
global $order_session;
$s_dir=$order_session?$order_session."/":"";
$pic="../attachments/ty/big/".$clh.".jpg";
if(!is_file($pic)){
$pic="images/no_pic_big.gif";
}
return $pic;
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>