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

598 lines
18 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."'");
//权限判断
$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_cl_zd)){
$num=count($sys_cl_zd);
$num_cl_zd=($num<5)?$num:5;
}
$arr_column_kh_cl["username"]="客户代码";
$arr_column_kh_cl["usertitle"]="客户名称";
//
$arr_column_kh_cl["zsh"]="展示号";
$arr_column_kh_cl["title"]="陈列号";
//
if($num_cl_zd>0){
for($i=1;$i<=$num_cl_zd;$i++){
$arr_column_kh_cl["zd".$i]=$sys_cl_zd[$i-1];
}
}
$arr_column_kh_cl["mb"]="模板";
$arr_column_kh_cl["wzh"]="位置号";
$arr_column_kh_cl["pic"]="图片名称";
$arr_column_kh_cl["kh"]="款号";
$arr_column_kh_cl["color"]="颜色代码";
$arr_column_kh_cl["pic_my"]="款色图片";
$arr_column_kh_cl["ord"]="次序号";
$arr_column_kh_cl["bxk"]="备选款";
$arr_column_kh_cl["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_cl where zsh='".$zsh."' limit 0,1");
$pic_mini=get_kh_cl_mini($msg["pic"]);
$pic_big=get_kh_cl_big($msg["pic"]);
$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_cl");
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["pic"]."\",";
$select_dz="";
if($num_cl_zd>0){
for($i=1;$i<=$num_cl_zd;$i++){
$arr_column_kh_cl["zd".$i]=$sys_cl_zd[$i-1];
$select_dz.="{\"zd\":\"zd".$i."\",\"zdtitle\":\"".$sys_cl_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_cl where zsh='".$zsh."' and ord='".$i."'");
if($tmp22["id"]>0){
$v2=$tmp22["kh"];
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."],";
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_cl where zsh='".$old_zsh."' and ord='".$i."'");
if($$v1){
$arr_tmp=explode("|",$$v1);
if($check["id"]>0){
$q="update ".$table_pre."kh_cl 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_cl (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_cl 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_cl where zsh='".$zsh."' limit 0,1");
$pic=get_kh_cl_big($msg["pic"]);
$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 "save_add_pic":
$up_image=$_FILES["up_file"];;
$msg=get_db_msg("select * from ".$table_pre."kh_cl where zsh='".$zsh."' limit 0,1");
if($up_image["name"]){
$path1="../attachments/cl/".$s_dir."big";
$path2="../attachments/cl/".$s_dir."mini";
$new_file_name=$msg["pic"].".jpg";
make_mini_picture($up_image["tmp_name"],$path1."/".$new_file_name,800);
//缩略图
make_mini_picture($path1."/".$new_file_name,$path2."/".$new_file_name,400);
}
$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_cl 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_cl 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 where no='".$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_cl";
$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_cl group by zsh";
$r=$db->query($q);
$i=0;
$tmp="";
while($m=$db->fetch_array($r)){
$pic=get_kh_cl_mini($m["pic"]);
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_cl where zsh='".$id[$i]."' limit 0,1");
//
del_file("../attachments/cl/".$s_dir."big/".$tmp["pic"].".jpg");
del_file("../attachments/cl/".$s_dir."mini/".$tmp["pic"].".jpg");
$q="delete from web_kh_cl 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_cl where ".$zd."='".$v1."' limit 0,1");
if($check["id"]>0 && $zsh>0){
$q="update ".$table_pre."kh_cl 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;
//----------------------------------------------------------------------导入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_cl);
$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_cl 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_cl,$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_cl;");
}
$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_cl);
$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);
$zsh_arr=array();
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"){
if(trim($tmp_arr[$ind]) && is_numeric($tmp_arr[$ind])){
$insert_value.="'".trim($tmp_arr[$ind])."',";
}else{
$insert_value.="'999',";
}
}else if($ititle=="zsh"){
$zsh_arr[]=trim($tmp_arr[$ind]);
$insert_value.="'".trim($tmp_arr[$ind])."',";
}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_cl (".$insert_column.") values (".$insert_value.")";
//echo $q."<br>";
$db->query($q);
}
$zsh_qc_arr=array_unique($zsh_arr);
//更新次序号
if(is_array($zsh_qc_arr)){
foreach($zsh_qc_arr as $kwy=>$val){
$q1="select * from ".$table_pre."kh_cl where zsh='".$val."' and ord='999' order by id";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$tmp_max=get_db_msg("select max(ord) 'maxord' from ".$table_pre."kh_cl where zsh='".$val."' and ord<>'999'");
$px=$tmp_max["maxord"]+1;
$q2="update ".$table_pre."kh_cl set ord='".$px."' where id='".$m1["id"]."'";
$db->query($q2);
}
}
}
del_tmp_file($tmp_file_name);
$log_remark=$import_flag;
set_log("导入 陈列数据",$log_remark);
break;
//----------------------------------------------------------------------导出数据
case "export":
$column="";
foreach($arr_column_kh_cl 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_cl 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_cl,$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_cl ".$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_cl_".date("Y-m-d-H-i");
output_excel($file_name,$data);
set_log("导出 陈列信息");
exit;
break;
//-------------主界面
default:
$json_data.="\"lang_zsh\":\"展示号\",";
$json_data.="\"lang_kh\":\"款号\",";
$ctt=1;
$select_dz="";
for($i=0;$i<count($sys_cl_zd);$i++){
$zd="zd".$ctt;
$strtmp="";
$res1=$db->query("select ".$zd." from ".$table_pre."kh_cl 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_cl_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_cl_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_cl ".$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_cl ".$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="";
$q1="select * from ".$table_pre."kh_cl where zsh='".$msg["zsh"]."' order by ord";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$m2=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."' limit 0,1");
$pic2=($m1["color"])?get_kh_color_picture($m1["kh"],$m1["color"]):get_kh_picture($m1["no"],$m2["main_pic"],$m2["color"]);
$str_ks.=$m1["kh"].",".get_cate_title_no("color",$m1["color"]).",".$m1["color"].",".$pic2."|";
}
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_cl_zd);$i++){
$zd="zd".$ctt2;
if($msg[$zd])
$strzd.=$msg[$zd]."|";
$ctt2++;
}
if($strzd)
$strzd=substr($strzd,0,-1);
$pic=get_kh_cl_mini($msg["pic"]);;
$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.="\"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.="\"qx\":\"".$str_user."\"";
$str_tmp.="},";
$count++;
}
$json_data.=substr($str_tmp,0,-1)."],";
break;
}
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>