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

459 lines
18 KiB
PHP
Raw Permalink 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
//--------------------------------------------------导入导出
if(THIS_IN!="edt_c")
exit("错误的访问!");
require THIS_FILE_ROOT."/include/excel_class.php";
require THIS_FILE_ROOT."/include/excel_fun.php";
$uid=check_cookie();
$db=_mysql_connect();
$msg_login_user=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
$_title_=$_title_?$_title_:"导入导出";
$_nav_="<a href=\"./\">首页</a> > <a href=\"".$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."\">".$_title_."</a>";
$zk_type=get_set("zk_type");
if($bx_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$bx_sizegroup_title."' limit 0,1");
$bx_sizegroup_id=$tmp["id"];
}else{
$bx_sizegroup_id=0;
}
$arr_dp=array();
if($msg_login_user["face"]=="3"){
$q="select id,username,title,path from ".$table_pre."client where path='".$msg_login_user["path"]."-".$msg_login_user["id"]."'";
$r=$db->query($q);
$i=0;
while($m=$db->fetch_array($r)){
$arr_dp[$i]=array($m["id"],$m["username"],$m["path"],$m["title"]);
$i++;
}
$con_u_all="(upath like '".$msg_login_user["path"]."-".$msg_login_user["id"]."-%' or upath='".$msg_login_user["path"]."-".$msg_login_user["id"]."') and ";
}else if($msg_login_user["face"]=="2"){
$arr_upath=explode(",",$msg_login_user["charge_path"]);
$i2=0;
for($i=0;$i<count($arr_upath);$i++){
$m=get_db_msg("select face,id,title,username,path from ".$table_pre."client where id='".get_parent_id($arr_upath[$i])."'");
if($m["face"]=="4"){
$arr_dp[$i2]=array($m["id"],$m["username"],$m["path"],$m["title"]);
$i2++;
}
}
$con_u_all=get_qj_u_con_all($msg_login_user["charge_path"]);
}else{
$arr_dp[0]=array($msg_login_user["id"],$msg_login_user["username"],$msg_login_user["path"],$msg_login_user["title"]);
$con_u_all="uid='".$msg_login_user["id"]."' and";
}
switch($_a){
//----------------------------------------------------------------------导入EXCEL
case "import":
$js_function="function check_form(){
var obj=document.form1;
if(obj.file1.value==\"\"){
alert(\"请选择EXCEL文档!\");
obj.file1.focus();
return false;
}
document.getElementById('b_dr').value='处理中...';
document.getElementById('b_dr').disabled=true;
return true;
}";
$form_property=" onsubmit='return check_form();' enctype='multipart/form-data'";
$form_hidden=array("_a"=>"import_check");
$content[]=array("请选择excel文档","<input type=file name=file1 style='width:250px'>");
$content[]=array("是否清空原数据","<input type='radio' id='is_qk_y' name='is_qk' value='y'><label for='is_qk_y'>是</label>
<input type='radio' name='is_qk' id='is_qk_n' value='n'><label for='is_qk_y'>否</label>");
$content[]=array("格式说明","1、只支持2003版本的excel文档,如果提示格式问题,请另存为“Excel 97-2003工作簿”;<br>2、文档格式如下:<a href=\"drmb.xls\"><span style=\"font-size:14px;font-weight:bold;color:#0000ff;\"><模板下载></span></a>");
$_submit_button_="<input type=submit id='b_dr' name='b_dr' value='导 入' class='button1'> ";
$_width_=120;
include template("manage_add");
break;
case "import_check":
if(!$is_qk){
alert_and_back("请选择导入模式:是否清空原数据!");
}
$con_u_all=str_replace("uid","id",substr($con_u_all,0,-4));
$con_u_all=str_replace("upath","path",$con_u_all);
//取得可导入字段
$arr_column_order=array("client"=>"客户代码","no"=>"款号","color"=>"颜色代码");
//$arr_column_order["bx"]="版型";
$file1=$_FILES["file1"];
if($file1["name"]){
if(!check_file_type("xls",get_file_ext($file1["name"])))
alert_and_back("文件格式错误,请参考格式说明!");
}
$tmp_file_name=save_tmp_file($file1);
$tmp_content=get_tmp_content($tmp_file_name);
$arr_content=explode("|-|-|",$tmp_content);
$arr_thead=get_table_thead($tmp_content);
//检测
$str_client=$str_no=$str_color=$str_bx="";
$ind_client=0;
$ind_no=1;
$ind_color=2;
$total_avail=0;
$total_qx=0;
for($i=1;$i<count($arr_content);$i++){
$tmp_arr=explode("|^_^|",$arr_content[$i]);
if(trim($tmp_arr[0])){
$avail="y";
//检测客户代码
$tmp=get_db_msg("select * from ".$table_pre."client where username='".trim($tmp_arr[0])."' and face='4' and available<>'n' and is_checked<>'y' and ".$con_u_all);
if(!$tmp["id"]){
$str_client.=trim($tmp_arr[0]).";";
$avail="n";
}
//检测款号
$tmp_kh=get_db_msg("select id,color,no,color_ka from ".$table_pre."kh where no='".$tmp_arr[1]."'");
if($tmp_kh["id"]>0){
$iid=$tmp_kh["id"];
//款号正确,检测颜色
$tmp1=get_db_msg("select id,no from ".$table_pre."keyword where cate='color' and no='".$tmp_arr[2]."'");
$color=$tmp1["no"];
$arr_check_color=explode(",",$tmp_kh["color"]);
if($tmp1["id"]>0 && in_array($tmp1["no"],$arr_check_color)){
//颜色正确
}else{
$str_color.=$tmp_arr[1]."-".$tmp_arr[2].";";
$avail="n";
}
}else{
$str_no.=$tmp_arr[1].";";
$avail="n";
}
/*
if($avail!="n"){
//检测版型
$arr_right_bx=array();
$q4="select gg from ".$table_pre."kh_gg where iid='".$iid."' and color='".$color."'";
$r4=$db->query($q4);
while($m4=$db->fetch_array($r4)){
$arr_right_bx[]=$m4["gg"];
}
if(trim($tmp_arr[3])){
if(in_array(get_gg_id(trim($tmp_arr[3])),$arr_right_bx)){
//正确
}else{
$avail="n";
$str_bx.=$tmp["no"].",".$color.",".trim($tmp_arr[3]).";";
}
}else{
if(count($arr_right_bx)>0){
$avail="n";
$str_bx.=$tmp["no"].",".$color.",".trim($tmp_arr[3]).";";
}
}
}
*/
//是否取消
$arr1=explode(",",$tmp_kh["color_ka"]);
$is_ka=(in_array($tmp_arr[2],$arr1))?"y":"n";
$size_start=3;
if($avail=="y"){
$tmp1=get_db_msg("select color_ka from ".$table_pre."kh where no='".$tmp_arr[1]."'");
for($j=$size_start;$j<count($tmp_arr);$j++){
if($is_ka=="y"){
$total_qx+=$tmp_arr[$j];
}
$total_avail+=$tmp_arr[$j];
}
}
}
}
$str_check="";
if($str_client)
$str_check.="客户代码有误,请检查:".substr($str_client,0,-1)."<br>";
if($str_no)
$str_check.="款号有误,请检查:".substr($str_no,0,-1)."<br>";
if($str_color)
$str_check.="颜色有误,请检查:".substr($str_color,0,-1)."<br>";
if($str_bx)
$str_check.="版型有误,请检查:".substr($str_bx,0,-1)."<br>";
if(!$str_check){
$str_check="无误";
$avail="y";
}else{
$avail="n";
}
$content[]=array("字段检测结果","<p style=\"line-height:150%;\">".$str_check."</p>");
$total=count($arr_content)-1;
if($total_qx>0)
$str_qx="<span style='color:#ff0000;font-weight:bold;'>取消".$total_qx."件</span>";
else
$str_qx="";
$content[]=array("本次订单量","有效".($total_avail-$total_qx)."".$str_qx);
$dis_dr=($avail=="y")?"":" disabled";
$_submit_button_="<input type=submit id='b_dr' name='b_dr' value='导 入' class='button1'".$dis_dr."> <input type=button value='返 回' class='button1' onclick='history.back();'>";
$js_function="function check_form(){
var obj=document.form1;
document.getElementById('b_dr').value='处理中...';
document.getElementById('b_dr').disabled=true;
return true;
}";
$form_property=" onsubmit='return check_form();'";
$form_hidden=array("_a"=>"import_do","is_qk"=>$is_qk,"tmp_file_name"=>$tmp_file_name);
$_width_=100;
include template("manage_add");
break;
case "import_do":
$tmp_content=get_tmp_content($tmp_file_name);
$arr_content=explode("|-|-|",$tmp_content);
$total_avail=0;
if($is_qk=="y"){
$arr_client=array();
for($i=1;$i<count($arr_content);$i++){
$tmp_arr=explode("|^_^|",$arr_content[$i]);
//检测客户代码
$tmp=get_db_msg("select * from ".$table_pre."client where username='".trim($tmp_arr[0])."' and face='4' and available<>'n'");
if($tmp["id"]>0){
if(!in_array($tmp["id"],$arr_client))
$arr_client[]=$tmp["id"];
}
}
for($i=0;$i<count($arr_client);$i++){
$q="delete from ".$table_pre."order where uid='".$arr_client[$i]."'";
//echo $q."<br>";
$db->query($q);
}
}
for($i=1;$i<count($arr_content);$i++){
$tmp_arr=explode("|^_^|",$arr_content[$i]);
//检测客户代码
$tmp=get_db_msg("select * from ".$table_pre."client where username='".trim($tmp_arr[0])."' and face='4' and available<>'n'");
$uid1=$tmp["id"];
//取得款号
$tmp=get_db_msg("select id,color,no,size from ".$table_pre."kh where no='".$tmp_arr[1]."'");
$iid=$tmp["id"];
//取得颜色
$tmp1=get_db_msg("select id,no from ".$table_pre."keyword where cate='color' and no='".$tmp_arr[2]."'");
$color=$tmp1["no"];
/*
//取得版型
$arr_right_bx=array();
$q4="select gg from ".$table_pre."kh_gg where iid='".$iid."' and color='".$color."'";
$r4=$db->query($q4);
while($m4=$db->fetch_array($r4)){
$arr_right_bx[]=$m4["gg"];
}
if(trim($tmp_arr[3])){
$bx=get_gg_id(trim($tmp_arr[3]));
}else{
if(count($arr_right_bx)>0){
$bx=get_gg_id("-");
}else{
$bx="";
}
}
*/
$avail="y";
$size_start=3;
if($avail=="y"){
for($s1=1;$s1<=$sys_size_num;$s1++){
$v1="num_".$s1;
$ind=$s1+$size_start-1;
$$v1=$tmp_arr[$ind];
$total_avail+=$tmp_arr[$ind];
}
//导入数据
if(get_size_sql("count_total")>0){
$msg_to=get_db_msg("select * from ".$table_pre."client where id='".$uid1."'");
$m=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'");
$c=get_db_msg("select * from ".$table_pre."order where iid='".$iid."' and color='".$color."' and bx='".$bx."' and uid='".$uid1."'");
$arr_size=explode(",",$m["size"]);
if($c["id"]>0){
$sql1="";
for($s1=0;$s1<count($arr_size);$s1++){
$v1="num_".$arr_size[$s1];
$$v1+=$c[$v1];
$sql1.="num_".$arr_size[$s1]."='".$$v1."',";
}
$q1="update ".$table_pre."order set ".$sql1."add_date='".time()."' where id='".$c["id"]."'";
cache_order($uid1,$iid,$color,$bx);
}else{
//判断是否是删除款
$ka="n";
if($m["ka"]=="y"){
$ka="y";
}else{
$tmp=explode(",",$m["color_ka"]);
if(in_array($color,$tmp))
$ka="y";
}
$sql_size1=$sql_size2="";
for($s1=0;$s1<count($arr_size);$s1++){
$v1="num_".$arr_size[$s1];
$sql_size1.="num_".$arr_size[$s1].",";
$sql_size2.="'".$$v1."',";
}
$q1="insert into ".$table_pre."order (uid,upath,iid,kh_dj,no,season,gender,sxz,brand,category,category1,bc,series,theme,designer,price,price_zk,jgd,color,bx,ka,size_group_id,".$sql_size1."_key,add_date) values ('".$uid1."','".$msg_to["path"]."-".$msg_to["id"]."','".$m["id"]."','".$m["kh_dj"]."','".$m["no"]."','".$m["season"]."','".$m["gender"]."','".$m["sxz"]."','".$m["brand"]."','".$m["category"]."','".$m["category1"]."','".$m["bc"]."','".$m["series"]."','".$m["theme"]."','".$m["designer"]."','".$m["price"]."','".$m["price_zk"]."','".$m["jgd"]."','".$color."','".$bx."','".$ka."','".$m["size_group"]."',".$sql_size2."'".$_key."','".time()."')";
}
//echo $q1."<br>";
$db->query($q1);
cache_order($uid1,$m["id"],$color,$bx);
}
set_order_total($uid1);
}
}
//
del_tmp_file($tmp_file_name);
$log_remark=$msg_to["username"].",".$total_avail."";
set_log("导入订单",$log_remark);
echo "<script>
alert(\"数据导入成功!\");
window.location.href=\"".$_SERVER[PHP_SELF]."?_m=".$_m."\";
</script>";
break;
//----------------------------------------------------------------------/导入EXCEL
case "export_do":
if($dpid){
$tmp=get_db_msg("select id,path,face from ".$table_pre."client where id='".$dpid."'");
if($tmp["face"]=="4")
$con_u=" uid='".$tmp["id"]."' and ";
else
$con_u="(upath='".$tmp["path"]."-".$tmp["id"]."' or upath like '".$tmp["path"]."-".$tmp["id"]."-%') and ";
}else{
$con_u=$con_u_all;
}
if($s_ka=="y"){
$sql_con=" where ".$con_u." ka='y'";
}else{
$sql_con=" where ".$con_u." ka<>'y'";
}
$tmp=get_db_msg("select count(distinct uid) 'num' from ".$table_pre."order".$sql_con);
$total_num=$tmp["num"];
if($total_num>0){
$list=$list?$list:0;
$file_name=$file_name?$file_name:"details_".date("y-m-d-h-i-s")."_".get_rand(4).".xls";
$m_uid=get_db_msg("select uid from ".$table_pre."order".$sql_con." group by uid order by uid limit ".$list.",1");
if($list==0){
$content=get_execl_html_body()."<table x:str border=0 cellpadding=0 cellspacing=0 style='border-collapse:collapse;table-layout:fixed;'>";
//取得合并尺码
$arr_size_merged=get_size_merged();
$num_size_total=count($arr_size_merged);
//取得尺码表头内容
$num_size_group=0;
$size_tr=array();
$r1=$db->query("select * from ".$table_pre."keyword where cate='size' order by ord");
while($m1=$db->fetch_array($r1)){
$size_tr[$num_size_group]="";
for($i=1;$i<=$num_size_total;$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'");
$t=$tmp["title"]?$tmp["title"]:"&nbsp;";
$size_tr[$num_size_group].="<td>".$t."</td>";
}
$num_size_group++;
}
//-------------------/处理尺码表头结束
$content.="<tr><td rowspan=\"".$num_size_group."\">省代</td><td rowspan=\"".$num_size_group."\">客户</td><td rowspan=\"".$num_size_group."\">店铺名称</td><td rowspan=\"".$num_size_group."\">店铺代码</td><td rowspan=\"".$num_size_group."\">圆牌号</td><td rowspan=\"".$num_size_group."\">款号</td>";
//取得定制选项
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'season' and no<>'zd1' and no<>'zd2' and no<>'zd3' and no<>'zd4' and no<>'gender' order by ord";
$r=$db->query($q);
$num_dz=0;
while($m=$db->fetch_array($r)){
$content.="<td rowspan=\"".$num_size_group."\">".get_cate_title_no("arr_select",$m["no"])."</td>";
$num_dz++;
}
$content.="<td rowspan=\"".$num_size_group."\">我的星级</td><td rowspan=\"".$num_size_group."\">我的评价</td><td rowspan=\"".$num_size_group."\">吊牌价</td><td rowspan=\"".$num_size_group."\">颜色</td><td rowspan=\"".$num_size_group."\">颜色代码</td>";
//$content.="<td rowspan=\"".$num_size_group."\">版型</td>";
$content.=$size_tr[0]."<td rowspan=\"".$num_size_group."\">小计</td><td rowspan=\"".$num_size_group."\">吊牌金额</td>";
$content.="</tr>";
for($i=1;$i<$num_size_group;$i++){
$content.="<tr>".$size_tr[$i]."</tr>";
}
}else{
$content="";
}
if($list<$total_num){
$content.=get_order_by_uid($m_uid["uid"],$s_ka);
file_put_contents("xls/".$file_name,$content,FILE_APPEND);
echo "<br>".$list."/".$total_num."家店铺导出完成!<Br>";
$list++;
$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_a=export_do&list=".$list."&file_name=".$file_name."&dpid=".$dpid."&s_ka=".$s_ka;
url_redirect($url);
}else{
if($m_uid["uid"]>0)
$content.=get_order_by_uid($m["uid"],$s_ka);
$content.="</table></body></html>";
file_put_contents("xls/".$file_name,$content,FILE_APPEND);
echo $total_num."家店铺导出完成,<a href=\"xls/".$file_name."\">下载</a> <a href=\"".$_SERVER["PHP_SELF"]."?_m=".$_m."\">返回</a>";
}
}else{
echo "没有数据,<a href=\"".$_SERVER["PHP_SELF"]."?_m=".$_m."\">返回</a>";
}
break;
default:
$add_date=date("Y-m-d H:i:s");
//判断是不是代理
if($msg_login_user["face"]!="4"){
if($dp_id){
$dp_info=get_db_msg("select * from web_client where id='".$dp_id."'");
$dp_name=$dp_info["title"];
}
//取得店铺框
$str="var clients = [\n";
for($i=0;$i<count($arr_dp);$i++){
$str.="{id:\"".$arr_dp[$i][0]."\",t:\"".$arr_dp[$i][3]."\",u:\"".$arr_dp[$i][1]."\",p:\"".$arr_dp[$i][2]."-".$arr_dp[$i][0]."\"},\n";
}
if($i>0)
$str=substr($str,0,-2);
$str.="];\n";
$js_function.=$str."\n$(function() {
$('#dp').autocomplete(clients, {
max: 100, //列表里的条目数
minChars: 0, //自动完成激活之前填入的最小字符
width: 300, //提示的宽度,溢出隐藏
scrollHeight: 300, //提示的高度,溢出显示滚动条
matchContains: true, //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
autoFill: false, //自动填充
formatItem: function(row, i, max) {
return row.t+'('+row.u+')';
},
formatMatch: function(row, i, max) {
return row.t+row.u;
},
formatResult: function(row) {
return row.id;
}
}).result(function(event, row, formatted) {
document.form1.dp.value=row.t;
document.form1.dp_id.value=row.id;
dp_id=row.id;
});
});\n";
$dp_select="<input type=text name=\"dp\" id=\"dp\" style=\"width:300px\" onfocus=\"this.select()\" value=\"".$dp_name."\"><input type=hidden name=\"dp_id\" id=\"dp_id\" value=\"".$dp_id."\">";
}else{
$dp_info=get_db_msg("select * from web_client where id='".$uid."'");
$dp_name=$dp_info["title"];
$dp_id=$uid;
}
if($msg_login_user["face"]==4){
$content[]=array("店铺代码",$dp_info["username"]);
$content[]=array("店铺名称",$dp_info["title"]."<input type=hidden name=\"dp_id\" id=\"dp_id\" value=\"".$dp_id."\">");
}else{
$content[]=array("店铺代码或名称",$dp_select);
}
$content[]=array("取消款","<select name='s_ka' id='s_ka'>".get_main_op(array("n"=>"不含取消款","y"=>"取消款"),"")."</select>");
//js_code
$js_code="
function order_export(){
var dpid=document.getElementById('dp_id').value;
var ka_obj=document.getElementById('s_ka');
var s_ka=ka_obj.options[ka_obj.selectedIndex].value
var url='?_m=".$_m."&_a=export_do&dpid='+dpid+'&s_ka='+s_ka;
window.location.href=url;
document.getElementById('b_dc').value='处理中...';
document.getElementById('b_dc').disabled=true;
return true;
}
function order_import(){
var url='?_m=".$_m."&_a=import';
window.location.href=url;
}";
//
$form_property=" onsubmit=\"return ok()\"";
$form_hidden=array("_a"=>"export_do","http_pre"=>$_SERVER['HTTP_REFERER']);
$_width_="100";
$js_start="n";
$_submit_button_="<input id=\"b_dc\" name=\"b_dc\" type=\"button\" value=\"订单导出\" onclick=\"order_export();\"> <input type=\"button\" value=\"订单导入\" onclick=\"order_import();\">";
include template("manage_add");
break;
}
?>