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

323 lines
11 KiB
PHP

<?php
//------------------------------------------------------订货规则,起订量
header("Content-type: text/html; charset=utf-8");
if(THIS_IN!="edt_admin")
exit("错误的访问!");
//$uid=check_cookie();
//$db=_mysql_connect();
//$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
//---------priv
//$priv=return_priv($_m,$msg_login_user["priv"]);
$json_data="{";
/*if($priv[0]=="n"){
//没有操作权限
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
}else{*/
$arr_column_this=array("dj"=>"店铺等级","kh"=>"款号","color"=>"颜色代码","num"=>"数量");
switch($_a){
case "check":
$q="select kh from ".$table_pre."gz where cate='qdl' group by kh";
$r=$db->query($q);
$i=0;
$content="<b>以下数据有误:</b><br>";
$tmp="";
while($m=$db->fetch_array($r)){
$check=get_db_msg("select id from ".$table_pre."kh where no='".$m["kh"]."'");
if(!$check["id"]){
$content.=$i.".<a href=\"javascript:return false;\" onclick=\"window.opener.location.href='".$_SERVER[PHP_SELF]."?_cid=".$_cid."&_m=".$_m."&s_cate=".$s_cate."&s_no=".$m["kh"]."'\">".$m["kh"]."</a><br>";
$tmp.="{\"kh\":\"".$m["kh"]."\",\"v\":\"".$m["kh"]."\"},";
$i++;
}
}
if($i>0){
$str.="{\"cate\":\"款号有误\",\"data\":[".deel_end($tmp)."]},";
}
//include template("blank");
$json_data.="\"error\":[".deel_end($str)."],";
break;
case "add" :
//--------------------------新增
$http_pre=$http_pre?$http_pre:$_SERVER['HTTP_REFERER'];
if($id){
$msg=get_db_msg("select * from ".$table_pre."gz where id='".$id."' limit 0,1");
$json_data.="\"kh\":\"".$msg["kh"]."\",";
$dj=$msg["dj"];
$json_data.="\"dj\":\"".$msg["dj"]."\",";
$json_data.="\"num\":\"".$msg["num"]."\",";
//
}else{
$json_data.="\"kh\":\"\",";
$json_data.="\"dj\":\"\",";
$json_data.="\"num\":\"\",";
$dj="";
}
$select_dz="";
//取得选项
$tmp="";
$r1=$db->query("select dj from ".$table_pre."client where dj<>'' group by dj order by dj");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["dj"]."\",\"title\":\"".$m1["dj"]."\"},";
}
$tmp=deel_end($tmp);
$var="s_dj";
$select_dz.="{\"no\":\"dj\",\"title\":\"店铺等级\",\"value\":\"".$dj."\",\"op\":[".$tmp."]},";
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
break;
case "save_add":
//检查重复
if($kh){
$arr_kh=explode(",",$kh);
$kh=$arr_kh[0];
$tmp=explode("-",$arr_kh[1]);
$color=$tmp[0];
$check=get_db_msg("select id from ".$table_pre."gz where kh='".$kh."' and cate='qdl' and dj='".$dj."' and color='".$color."' and id<>'".$id."'");
if($check["id"]>0)
$msg_error="该数据已存在,请检查!";
}else{
$msg_error="请输入款号!";
}
if($msg_error){
$json_data.="\"code\":0,\"msg\":\"".$msg_error."\",";
}else{
if($id){
$log_action="修改";
$msg=get_db_msg("select * from ".$table_pre."gz where id='".$id."'");
$query="update ".$table_pre."gz set dj='".$dj."',kh='".$kh."',num='".$num."',color='".$color."' where id='".$id."'";
}else{
$log_action="新增";
$query="insert into ".$table_pre."gz (cate,dj,kh,color,num) values ('qdl','".$dj."','".$kh."','".$color."','".$num."')";
}
$log_remark=$dj."|".$kh."|".$color."|".$num;
$db->query($query);
set_log($log_action.get_cate_title_no("dhgz","qdl"),$log_remark);
$json_data.="\"code\":1,";
}
break;
case "del" :
$num=count($id);
if($num==0)
alert_and_back("请至少选择一条记录!");
for($i=0;$i<$num;$i++){
$tmp=get_db_msg("select * from ".$table_pre."gz where id='".$id[$i]."' limit 0,1");
//
$q="delete from ".$table_pre."gz where id='".$id[$i]."'";
//echo $q."<br>";
$db->query($q);
$lid.=$tmp["dj"]."|".$tmp["kh"]."|".$tmp["num"].", ";
}
$lid=substr($lid,0,-2);
set_log("删除".get_cate_title_no("dhgz","qdl"),$lid);
//url_redirect();
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"];
//echo $file1["name"]."--";
$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_this);
$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_this 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_this,$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";
$import_select=($import_select=="清空导入")?"y":"n";
$error_msg="";
if($error_msg){
$json_data.="\"code\":0,\"msg\":\"".$error_msg."\",";
}else{
$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_this);
$error_msg="";
if($import_type=="y"){
//清空款号相关数据
$db->query("delete from ".$table_pre."gz where cate='qdl';");
}
//
$insert_column="";
for($i=0;$i<count($arr_column[1]);$i++){
$insert_column.=",".$arr_column[1][$i];
}
for($i=1;$i<count($arr_content);$i++){
$tmp_arr=explode("|^_^|",$arr_content[$i]);
//取得款号
$kh="";
for($k=0;$k<count($arr_column[0]);$k++){
$ind=$arr_column[0][$k];
$ititle=$arr_column[1][$k];
if($ititle=="kh"){
$kh=trim($tmp_arr[$ind]);
}
}
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
$insert_value="";
for($k=0;$k<count($arr_column[0]);$k++){
$ind=$arr_column[0][$k];
$ititle=$arr_column[1][$k];
/*if($ititle=="size"){
$v1="";
$tmp1=explode(",",trim($tmp_arr[$ind]));
for($k1=0;$k1<count($tmp1);$k1++){
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$m_kh["size_group"]."' and title='".$tmp1[$k1]."'");
$v1.=$tmp["no"].",";
}
if($v1)
$v1=substr($v1,0,-1);
$insert_value.=",'".mysql_escape_string($v1)."'";
}else{
if(($is_gg=="y" || $is_gg=="b") && $ititle=="size"){
$insert_value.=",'".mysql_escape_string(get_gg_id(trim($tmp_arr[$ind])))."'";
}else{
$insert_value.=",'".mysql_escape_string(trim($tmp_arr[$ind]))."'";
}
}*/
$insert_value.=",'".mysql_escape_string(trim($tmp_arr[$ind]))."'";
}
$q="insert into ".$table_pre."gz (id,cate".$insert_column.") values ('','qdl'".$insert_value.")";
//echo $q."<br>";
$db->query($q);
}
//
del_tmp_file($tmp_file_name);
$log_remark=$import_flag;
set_log("导入起订量款规则数据",$log_remark);
}
break;
//----------------------------------------------------------------------/导入EXCEL
default :
$page=$page>0?$page:1;
$limit=$limit>0?$limit:10;
$start=($page-1)*$limit;
$end=$limit;
$sql_con="cate='qdl' and ";
if($s_no || $s_dj){
if($s_no)
$sql_con.="kh like '%".$s_no."%' and ";
if($s_dj)
$sql_con.="dj='".$s_dj."' and ";
}
if($sql_con)
$sql_con="where ".substr($sql_con,0,-4);
$query="select count(*) 'total' from ".$table_pre."gz ".$sql_con;
//$json_data.="\"q1\":\"".$query."\",";
$res=$db->query($query);
$msg=$db->fetch_array($res);
$total=$msg["total"];
//page class
$op="";
$q1="select dj from ".$table_pre."client where dj<>'' group by dj order by dj";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$op.="<option value=\"".$m1["dj"]."\"";
if($s_dj==$m1["dj"])
$op.=" selected";
$op.=">".$m1["dj"]."</option>";
}
$query="select * from ".$table_pre."gz ".$sql_con." order by id limit ".$start.",".$end;
//echo $query."<br>";
//$json_data.="\"q2\":\"".$query."\",";
$res=$db->query($query);
$count=0;
$xh_ms=get_set("xh_ms");
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total.",\"data\":[";
$str_tmp="";
while($msg=$db->fetch_array($res)){
$list=$start+$count+1;
$msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$msg["kh"]."'");
$str_tmp.="{";
$str_tmp.="\"id\":\"".$msg["id"]."\",";
if($msg["dj"]){
$str_tmp.="\"dj\":\"".$msg["dj"]."\",";
}else{
$str_tmp.="\"dj\":\"所有店铺\",";
}
$str_tmp.="\"kh\":\"".$msg["kh"]."\",";
$str_tmp.="\"color\":\"".$msg["color"]."\",";
//$tmpkh=get_db_msg("select * from ".$table_pre."kh where no='".$msg["kh"]."'");
$ks=get_kh_xh($msg_kh)."#".$msg["kh"]." ".get_cate_title_no("color",$msg["color"])." ".get_cate_title_no("bc",$msg_kh["bc"])." ".get_cate_title_no("category",$msg_kh["category"]);
$str_tmp.="\"ks\":\"".$ks."\",";
$str_tmp.="\"bc\":\"".$msg["bc"]."\",";
$str_tmp.="\"num\":\"".$msg["num"]."\"";
$str_tmp.="},";
$count++;
}
$json_data.=substr($str_tmp,0,-1)."],";
break;
}
//}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>