7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
131 lines
4.1 KiB
PHP
131 lines
4.1 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("kh_tb",$msg_login_user["priv"]);
|
|
$order_session=get_set("order_session");
|
|
$s_dir=$order_session?$order_session."/":"";
|
|
//
|
|
$arr_column_rfid=array("kh"=>"款号","color"=>"颜色代码","color_title"=>"颜色名称","rfid"=>"RFID");
|
|
|
|
$global_num=$max_tb_num;
|
|
$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_rfid);
|
|
$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_rfid 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_rfid,$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_rfid);
|
|
$db->query("TRUNCATE TABLE ".$table_pre."kh_rfid;");
|
|
$insert_column="";
|
|
for($i=0;$i<count($arr_column[1]);$i++){
|
|
$ititle=$arr_column[1][$i];
|
|
if($arr_column[1][$i]!="color_title")
|
|
$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!="color_title"){
|
|
$insert_value.="'".mysql_escape_string(trim($tmp_arr[$ind]))."',";
|
|
}
|
|
}
|
|
$insert_value=substr($insert_value,0,-1);
|
|
$q="insert into web_kh_rfid (".$insert_column.") values (".$insert_value.")";
|
|
//echo $q."<br>";
|
|
$db->query($q);
|
|
}
|
|
del_tmp_file($tmp_file_name);
|
|
$log_remark=$import_flag;
|
|
set_log("导入 RFID数据",$log_remark);
|
|
break;
|
|
}
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|