7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
142 lines
4.5 KiB
PHP
142 lines
4.5 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."'");
|
|
//权限判断
|
|
$priv=return_priv("client",$msg_login_user["priv"]);
|
|
//
|
|
$arr_column_qjqx=array("qjdm"=>"区经代码","khdm"=>"客户代码");
|
|
|
|
$json_data="{";
|
|
if($priv[0]=="n"){
|
|
//没有操作权限
|
|
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
|
|
}else{
|
|
$json_data.="\"uid\":".$uid.",";
|
|
switch($_a){
|
|
//----------------------------------------------------------------------导入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_qjqx);
|
|
$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_qjqx 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_qjqx,$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\":[],";
|
|
}
|
|
break;
|
|
case "import_do":
|
|
$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_qjqx);
|
|
$insert_column="";
|
|
for($i=0;$i<count($arr_column[1]);$i++){
|
|
$insert_column.=$arr_column[1][$i].",";
|
|
}
|
|
$insert_column=substr($insert_column,0,-1);
|
|
|
|
//导入基础数据
|
|
$arr_qj=array();
|
|
for($i=1;$i<count($arr_content);$i++){
|
|
$tmp_arr=explode("|^_^|",$arr_content[$i]);
|
|
$arr_qj[$tmp_arr[0]][]=$tmp_arr[1];
|
|
}
|
|
$log_remark="";
|
|
foreach($arr_qj as $qjdm => $arr_username){
|
|
$m_qj=get_db_msg("select id from ".$table_pre."client where username='".$qjdm."' and face='2'");
|
|
if($m_qj["id"]>0){
|
|
$arr_uid=array();
|
|
for($j=0;$j<count($arr_username);$j++){
|
|
$tmp=get_db_msg("select id,path,face from ".$table_pre."client where username='".$arr_username[$j]."'");
|
|
if($tmp["face"]=="4"){
|
|
$arr_uid[]=$tmp["id"];
|
|
}else{
|
|
$q="select id from ".$table_pre."client where (path='".$tmp["path"]."-".$tmp["id"]."' or path like '".$tmp["path"]."-".$tmp["id"]."-%') and face='4'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$arr_uid[]=$m["id"];
|
|
}
|
|
}
|
|
}
|
|
$str_uid=arr_to_str($arr_uid);
|
|
$arr1=get_qj_charge($arr_uid);
|
|
$q="update ".$table_pre."client set charge_path='".$arr1[0]."',charge_path_real='".$arr1[1]."',charge_uid='".$str_uid."' where id='".$m_qj["id"]."'";
|
|
//echo $q."<br>";
|
|
$db->query($q);
|
|
$log_remark.=$qjdm.",";
|
|
}
|
|
}
|
|
del_tmp_file($tmp_file_name);
|
|
$log_remark=$import_flag;
|
|
set_log("导入 区经权限",$log_remark);
|
|
break;
|
|
}
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|