7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
662 lines
21 KiB
PHP
662 lines
21 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($_m,$msg_login_user["priv"]);
|
|
|
|
$arr_column_kh_md["dj"]="店铺等级";
|
|
$arr_column_kh_md["kh"]="款号";
|
|
$arr_column_kh_md["price"]="买断价格";
|
|
$arr_column_kh_md["color"]="颜色代码";
|
|
//杯型参数
|
|
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;
|
|
}
|
|
if($bx_sizegroup_id>0)
|
|
$arr_column_kh_md["bx"]="杯型";
|
|
if($is_gg=="y")
|
|
$arr_column_kh_md["bx"]="规格";
|
|
$arr_column_kh_md["size"]="尺码";
|
|
|
|
$json_data="{";
|
|
if($priv[0]=="n"){
|
|
//没有操作权限
|
|
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
|
|
}else{
|
|
$json_data.="\"uid\":".$uid.",";
|
|
switch($_a){
|
|
case "check":
|
|
$str="";
|
|
$tmp="";
|
|
$q="select * from ".$table_pre."kh_md group by kh order by kh";
|
|
$r=$db->query($q);
|
|
$i=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$check=get_db_msg("select * 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_md where color<>'' group by kh,color order by kh,color";
|
|
$r=$db->query($q);
|
|
$i=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$check=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'");
|
|
if($check["id"]>0){
|
|
//检查颜色
|
|
$check_color=explode(",",$check["color"]);
|
|
$color=trim($m["color"]);
|
|
if(!in_array($color,$check_color)){
|
|
$tmp.="{\"kh\":\"".$m["kh"]."\",\"v\":\"".$m["kh"].",".$m["color"]."\"},";
|
|
$i++;
|
|
}
|
|
|
|
}
|
|
}
|
|
if($i>0){
|
|
$str.="{\"cate\":\"款色有误\",\"data\":[".deel_end($tmp)."]},";
|
|
}
|
|
|
|
//检查尺码
|
|
$tmp="";
|
|
$q="select * from ".$table_pre."kh_md where size<>'' and color<>'' order by kh,color";
|
|
$r=$db->query($q);
|
|
$i=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$check=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'");
|
|
if($check["id"]>0){
|
|
//检查尺码
|
|
$check_size=explode(",",$check["size"]);
|
|
$arr_size=explode(",",trim($m["size"]));
|
|
for($j=0;$j<count($arr_size);$j++){
|
|
if(!in_array($arr_size[$j],$check_size)){
|
|
$tmp1=get_db_msg("select * from ".$table_pre."size where iid='".$tmp["size_group"]."' and no='".$arr_size[$j]."'");
|
|
$tmp.="{\"kh\":\"".$m["kh"]."\",\"v\":\"".$m["kh"].",".$m["color"].",".$tmp1["title"]."\"},";
|
|
$i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i>0){
|
|
$str.="{\"cate\":\"尺码有误\",\"data\":[".deel_end($tmp)."]},";
|
|
}
|
|
|
|
|
|
if(!$str){
|
|
$str.="{\"cate\":\"无误\",\"data\":[]},";
|
|
}
|
|
$json_data.="\"error\":[".deel_end($str)."],";
|
|
break;
|
|
case "get_size":
|
|
if($id){
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
|
|
$is_ggk=is_ggk($msg["id"]);
|
|
$arr=explode(",",$msg["color"]);
|
|
//价格
|
|
$show_price="吊牌价:".$msg["price"]."元/结算价".$msg["price_zk"]."元";
|
|
//取得杯型
|
|
$arrBx=array();
|
|
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["no"]."' order by bx");
|
|
$i1=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arrBx[$i1][]=$m1["bx"];
|
|
$arrBx[$i1][]=$m1["size"];
|
|
$i1++;
|
|
}
|
|
$show_bx=($i1>0)?"y":"n";
|
|
if(count($arrBx)==0){
|
|
$arrBx[0][0]="";
|
|
$arrBx[0][1]=$msg["size"];
|
|
}
|
|
|
|
$str_data="";
|
|
for($i=0;$i<count($arr);$i++){
|
|
if($is_ggk=="y"){
|
|
//有规格
|
|
$q1="select * from ".$table_pre."kh_gg where iid='".$msg["id"]."' and color='".$arr[$i]."'";
|
|
$r1=$db->query($q1);
|
|
$j=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
//尺码
|
|
$str_size="";
|
|
$arr1=explode(",",$msg["size"]);
|
|
for($k=0;$k<count($arr1);$k++){
|
|
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr1[$k]."'");
|
|
$str_size.=$arr1[$k]."|".$tmp["title"].",";
|
|
}
|
|
if($str_size)
|
|
$str_size=substr($str_size,0,-1);
|
|
$str_data.="{\"is_gg\":\"y\",\"color_bx\":\"".$arr[$i]."_".$m1["gg"]."\",\"color_bx_title\":\"".$arr[$i]."-".get_cate_title_no("color",$arr[$i])."\",\"bx\":\"".get_gg_title($m1["gg"])."\",\"size\":\"".$str_size."\"},";
|
|
$j++;
|
|
}
|
|
}else{
|
|
//无规格
|
|
for($j=0;$j<count($arrBx);$j++){
|
|
|
|
//尺码
|
|
$str_size="";
|
|
$arr1=explode(",",$arrBx[$j][1]);
|
|
for($k=0;$k<count($arr1);$k++){
|
|
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr1[$k]."'");
|
|
$str_size.=$arr1[$k]."|".$tmp["title"].",";
|
|
}
|
|
if($str_size)
|
|
$str_size=substr($str_size,0,-1);
|
|
$str_data.="{\"is_gg\":\"n\",\"color_bx\":\"".$arr[$i]."_".$arrBx[$j][0]."\",\"color_bx_title\":\"".$arr[$i]."-".get_cate_title_no("color",$arr[$i])."\",\"bx\":\"".$arrBx[$j][0]."\",\"size\":\"".$str_size."\"},";
|
|
}
|
|
}
|
|
}
|
|
|
|
if($str_data)
|
|
$str_data=substr($str_data,0,-1);
|
|
|
|
$json_data.="\"price\":\"".$show_price."\",";
|
|
$json_data.="\"data\":[".$str_data."],";
|
|
$json_data.="\"code\":1,";
|
|
}else{
|
|
$json_data.="\"code\":0,";
|
|
}
|
|
break;
|
|
case "add":
|
|
if($id){
|
|
$msg=get_db_msg("select * from ".$table_pre."kh_md where id='".$id."'");
|
|
$msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$msg["kh"]."'");
|
|
$arrBx=array();
|
|
if($bx_sizegroup_id>0){
|
|
//取得杯型
|
|
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["kh"]."' order by bx");
|
|
$i1=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arrBx[$i1][]=$m1["bx"];
|
|
$arrBx[$i1][]=$m1["size"];
|
|
$i1++;
|
|
}
|
|
}
|
|
if(count($arrBx)==0){
|
|
$arrBx[0][0]="";
|
|
$arrBx[0][1]=$msg_kh["size"];
|
|
}
|
|
$div_price="吊牌价:".$msg_kh["price"]."元/结算价".$msg_kh["price_zk"]."元";
|
|
|
|
//颜色,杯型,尺码
|
|
$arr_color=explode(",",$msg_kh["color"]);
|
|
for($i=0;$i<count($arr_color);$i++){
|
|
if($is_gg=="y"){
|
|
//有规格
|
|
$q1="select * from ".$table_pre."kh_gg where iid='".$msg_kh["id"]."' and color='".$arr_color[$i]."'";
|
|
$r1=$db->query($q1);
|
|
$j=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$check=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md where dj='".$msg["dj"]."' and kh='".$kh."' and color='".$arr_color[$i]."' and bx='".$m1["gg"]."'");
|
|
if($check["num"]>0){
|
|
$color_bx_sign="y";
|
|
}else{
|
|
$color_bx_sign="n";
|
|
}
|
|
$str_size="";
|
|
$arr_size=explode(",",$msg_kh["size"]);
|
|
for($j=0;$j<count($arr_size);$j++){
|
|
$check=get_db_msg("select size from ".$table_pre."kh_md where dj='".$msg["dj"]."' and kh='".$kh."' and color='".$arr_color[$i]."' and bx='".$m1["gg"]."'");
|
|
$check=explode(",",$check["size"]);
|
|
if(in_array($arr_size[$j],$check)){
|
|
$size_sign="y";
|
|
}else{
|
|
$size_sign="n";
|
|
}
|
|
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$msg_kh["size_group"]."' and no='".$arr_size[$j]."'");
|
|
$str_size.=$arr_size[$j]."|".$tmp["title"]."|".$size_sign.",";
|
|
}
|
|
if($str_size)
|
|
$str_size=substr($str_size,0,-1);
|
|
$str_data.="{\"is_gg\":\"n\",\"color_bx\":\"".$arr_color[$i]."_".$m1["gg"]."\",\"color_bx_sign\":\"".$color_bx_sign."\",\"color_bx_title\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\",\"bx\":\"".get_gg_title($m1["gg"])."\",\"size\":\"".$str_size."\"},";
|
|
}
|
|
}else{
|
|
//无规格
|
|
for($k=0;$k<count($arrBx);$k++){
|
|
$check=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md where dj='".$msg["dj"]."' and kh='".$kh."' and color='".$arr_color[$i]."' and bx='".$arrBx[$k][0]."'");
|
|
if($check["num"]>0){
|
|
$color_bx_sign="y";
|
|
}else{
|
|
$color_bx_sign="n";
|
|
}
|
|
$str_size="";
|
|
$arr_size=explode(",",$arrBx[$k][1]);
|
|
for($j=0;$j<count($arr_size);$j++){
|
|
$check=get_db_msg("select size from ".$table_pre."kh_md where dj='".$msg["dj"]."' and kh='".$kh."' and color='".$arr_color[$i]."' and bx='".$arrBx[$k][0]."'");
|
|
$check=explode(",",$check["size"]);
|
|
if(in_array($arr_size[$j],$check)){
|
|
$size_sign="y";
|
|
}else{
|
|
$size_sign="n";
|
|
}
|
|
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$msg_kh["size_group"]."' and no='".$arr_size[$j]."'");
|
|
$str_size.=$arr_size[$j]."|".$tmp["title"]."|".$size_sign.",";
|
|
}
|
|
if($str_size)
|
|
$str_size=substr($str_size,0,-1);
|
|
$str_data.="{\"is_gg\":\"n\",\"color_bx\":\"".$arr_color[$i]."_".$arrBx[$k][0]."\",\"color_bx_sign\":\"".$color_bx_sign."\",\"color_bx_title\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\",\"bx\":\"".$arrBx[$k][0]."\",\"size\":\"".$str_size."\"},";
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
$price=$msg["price"];
|
|
$s_no=$kh;
|
|
$dj=$msg["dj"];
|
|
}else{
|
|
|
|
}
|
|
|
|
//取得店铺等级
|
|
$ct=0;
|
|
$tmp_dj="";
|
|
$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)){
|
|
$tmp_dj.="{\"no\":\"".$m1["dj"]."\",\"title\":\"".$m1["dj"]."\"},";
|
|
$ct++;
|
|
}
|
|
if($ct>0){
|
|
$json_data.="\"s_show_dj\":\"y\",";
|
|
}else{
|
|
$json_data.="\"s_show_dj\":\"n\",";
|
|
}
|
|
$tmp_dj=deel_end($tmp_dj);
|
|
$json_data.="\"select_dj\":{\"no\":\"dj\",\"title\":\"店铺等级\",\"value\":\"".$dj."\",\"op\":[".$tmp_dj."]},";
|
|
$json_data.="\"price\":\"".$price."\",";
|
|
$json_data.="\"s_no\":\"".$s_no."\",";
|
|
$json_data.="\"dpj\":\"".$div_price."\",";
|
|
if($str_data)
|
|
$str_data=substr($str_data,0,-1);
|
|
$json_data.="\"data\":[".$str_data."],";
|
|
break;
|
|
case "save_add":
|
|
$msg_old=get_db_msg("select * from ".$table_pre."kh_md where id='".$id."'");
|
|
$msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$s_no."'");
|
|
if(!$msg_kh["id"]){
|
|
$json_data.="\"code\":0,\"msg\":\"款号有误,请检查!\",";
|
|
}else{
|
|
$arr_color_kh=explode(",",$msg_kh["color"]);
|
|
$arr_size_kh=explode(",",$msg_kh["size"]);
|
|
$color_bx=is_array($color_bx)?$color_bx:array($color_bx);
|
|
//print_r($color_bx);
|
|
if($msg_old["dj"]!=$dj){
|
|
$q="delete from ".$table_pre."kh_md where dj='".$msg_old["dj"]."' and kh='".$s_no."'";
|
|
//echo $q."<br>";
|
|
$db->query($q);
|
|
}
|
|
|
|
//删除多余数据
|
|
$q="select * from ".$table_pre."kh_md where dj='".$dj."' and kh='".$s_no."'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if(!in_array($m["color"]."_".$m["bx"],$color_bx)){
|
|
$q1="delete from ".$table_pre."kh_md where id='".$m["id"]."'";
|
|
//echo $q1."<br>";
|
|
$db->query($q1);
|
|
}
|
|
}
|
|
|
|
//
|
|
if(count($color_bx)>0){
|
|
for($i=0;$i<count($color_bx);$i++){
|
|
$v1="size_".$color_bx[$i];
|
|
|
|
$r22="";
|
|
if(is_array($$v1)){
|
|
foreach($$v1 as $k22=>$v22){
|
|
$r22.=$v22.",";
|
|
}
|
|
}
|
|
$size1=substr($r22,0,-1);
|
|
|
|
$tmp=explode("_",$color_bx[$i]);
|
|
$check=get_db_msg("select * from ".$table_pre."kh_md where dj='".$dj."' and kh='".$s_no."' and color='".$tmp[0]."' and bx='".$tmp[1]."'");
|
|
if($check["id"]>0){
|
|
$q="update ".$table_pre."kh_md set price='".$price."',size='".$size1."' where id='".$check["id"]."'";
|
|
}else{
|
|
$q="insert into ".$table_pre."kh_md (dj,kh,price,color,bx,size) values ('".$dj."','".$s_no."','".$price."','".$tmp[0]."','".$tmp[1]."','".$size1."')";
|
|
}
|
|
//echo $q."<br>";
|
|
$db->query($q);
|
|
}
|
|
}else{
|
|
//
|
|
$check=get_db_msg("select * from ".$table_pre."kh_md where dj='".$dj."' and kh='".$s_no."'");
|
|
if($check["id"]>0){
|
|
$q="update ".$table_pre."kh_md set price='".$price."' where id='".$check["id"]."'";
|
|
}else{
|
|
$q="insert into ".$table_pre."kh_md (dj,kh,price) values ('".$dj."','".$s_no."','".$price."')";
|
|
}
|
|
//echo $q."<br>";
|
|
$db->query($q);
|
|
}
|
|
|
|
if($id)
|
|
$log_action="更新";
|
|
else
|
|
$log_action="新增";
|
|
set_log($log_action."买断款",$kh);
|
|
|
|
$json_data.="\"code\":1,";
|
|
}
|
|
|
|
break;
|
|
case "del" :
|
|
$id=(is_array($id))?$id:array($id);
|
|
$num=count($id);
|
|
for($i=0;$i<$num;$i++){
|
|
$arr1=explode("|",$id[$i]);
|
|
$q="delete from ".$table_pre."kh_md where dj='".$arr1[0]."' and kh='".$arr1[1]."'";
|
|
$db->query($q);
|
|
$lid.=$arr1[0]."|".$arr1[1].", ";
|
|
}
|
|
$lid=substr($lid,0,-2);
|
|
set_log("删除 买断款",$lid);
|
|
$json_data.="\"code\":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_md);
|
|
$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_md 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_md,$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_md;");
|
|
}
|
|
$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_md);
|
|
$insert_column="";
|
|
for($i=0;$i<count($arr_column[1]);$i++){
|
|
$ititle=$arr_column[1][$i];
|
|
$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]);
|
|
|
|
//取得款号
|
|
$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" && $ititle=="bx")
|
|
$insert_value.="'".mysql_escape_string(get_gg_id(trim($tmp_arr[$ind])))."',";
|
|
else
|
|
$insert_value.="'".mysql_escape_string(trim($tmp_arr[$ind]))."',";
|
|
}
|
|
}
|
|
|
|
$insert_value=substr($insert_value,0,-1);
|
|
$q="insert into ".$table_pre."kh_md (".$insert_column.") values (".$insert_value.")";
|
|
//echo $q."<br>";
|
|
$db->query($q);
|
|
}
|
|
|
|
del_tmp_file($tmp_file_name);
|
|
$log_remark=$import_flag;
|
|
set_log("导入 买断款数据",$log_remark);
|
|
break;
|
|
//----------------------------------------------------------------------导出数据
|
|
case "export":
|
|
$column="";
|
|
foreach($arr_column_kh_md 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_md 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_md,$ex_col[$i]);
|
|
}
|
|
|
|
$query="select * from ".$table_pre."kh_md order by kh";
|
|
$r=$db->query($query);
|
|
$row=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'");
|
|
$arr_color=explode(",",$m["color"]);
|
|
for($j=0;$j<count($arr_color);$j++){
|
|
for($i=0;$i<$num;$i++){
|
|
$k=$ex_col[$i];
|
|
if($k=="size"){
|
|
$v1="";
|
|
$tmp1=explode(",",$m[$k]);
|
|
for($k1=0;$k1<count($tmp1);$k1++){
|
|
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$m_kh["size_group"]."' and no='".$tmp1[$k1]."'");
|
|
$v1.=$tmp["title"].",";
|
|
}
|
|
if($v1)
|
|
$v1=substr($v1,0,-1);
|
|
$data["body"][$row][]=$v1;
|
|
}else if($k=="color"){
|
|
$data["body"][$row][]=$arr_color[$j];
|
|
}else{
|
|
if($is_gg=="y" && $k=="bx")
|
|
$data["body"][$row][]=get_gg_title($m[$k]);
|
|
else
|
|
$data["body"][$row][]=$m[$k];
|
|
}
|
|
}
|
|
$row++;
|
|
}
|
|
}
|
|
|
|
$file_name="kh_md_".date("Y-m-d-H-i");
|
|
output_excel($file_name,$data);
|
|
set_log("导出 买断款信息");
|
|
exit;
|
|
break;
|
|
default:
|
|
$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.="{\"no\":\"".$m1["dj"]."\",\"title\":\"".$m1["dj"]."\"},";
|
|
}
|
|
$op=deel_end($op);
|
|
$json_data.="\"select_dpdj\":{\"no\":\"s_dj\",\"title\":\"店铺等级\",\"value\":\"".$s_dj."\",\"op\":[".$op."]},";
|
|
|
|
//
|
|
$page=$page>0?$page:1;
|
|
$limit=$limit>0?$limit:10;
|
|
$start=($page-1)*$limit;
|
|
$end=$limit;
|
|
|
|
$sql_con="";
|
|
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);
|
|
|
|
//取得总条数
|
|
$tmp=get_db_msg("select count(distinct kh) 'num' from ".$table_pre."kh_md ".$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_md ".$sql_con." group by dj,kh order by dj,kh limit ".$start.",".$end;
|
|
$res=$db->query($sql);
|
|
while($msg=$db->fetch_array($res)){
|
|
$msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$msg["kh"]."'");
|
|
$is_ggk=is_ggk($msg_kh["id"]);
|
|
$p="";
|
|
if($msg_kh["price"]>0){
|
|
$p.=" ¥".$msg_kh["price"]."元 ";
|
|
}
|
|
if($msg_kh["price_zk"]>0){
|
|
$p.=" ¥".$msg_kh["price_zk"]."元 ";
|
|
}
|
|
$this_dpdj=trim($msg["dj"])?trim($msg["dj"]):"所有店铺";
|
|
|
|
//颜色
|
|
$str="";
|
|
$q="select * from ".$table_pre."kh_md where dj='".$msg["dj"]."' and kh='".$msg["kh"]."' order by color";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if(trim($m["color"])){
|
|
if($is_ggk=="y"){
|
|
$str_bx=get_gg_title($m["bx"]);
|
|
}else{
|
|
$str_bx=$m["bx"];
|
|
}
|
|
|
|
//尺码
|
|
$str_size="";
|
|
if(trim($m["size"])){
|
|
$arr1=explode(",",$m["size"]);
|
|
for($j=0;$j<count($arr1);$j++){
|
|
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$msg_kh["size_group"]."' and no='".$arr1[$j]."'");
|
|
$str_size.=$tmp["title"].",";
|
|
}
|
|
}
|
|
|
|
$str.="{\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",\"bx\":\"".$str_bx."\",\"size\":\"".substr($str_size,0,-1)."\"},";
|
|
}
|
|
}
|
|
|
|
$list=$count+$start;
|
|
$str_tmp.="{";
|
|
$str_tmp.="\"ct\":\"".$list."\",";
|
|
$str_tmp.="\"dpdj\":\"".$this_dpdj."\",";
|
|
$str_tmp.="\"dj\":\"".$msg["dj"]."\",";
|
|
$str_tmp.="\"id\":\"".$msg["id"]."\",";
|
|
$str_tmp.="\"kh\":\"".$msg["kh"]."\",";
|
|
$str_tmp.="\"jsj\":\"".$p."\",";
|
|
$str_tmp.="\"mdj\":\"".$msg["price"]."\",";
|
|
$str_tmp.="\"detail\":[".substr($str,0,-1)."]";
|
|
$str_tmp.="},";
|
|
$count++;
|
|
}
|
|
$json_data.=substr($str_tmp,0,-1)."],";
|
|
break;
|
|
}
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|