$t){ $r.=$t.","; } $r=substr($r,0,-1); }else{ $r=$arr; } return $r; } header("Content-type: text/html; charset=utf-8"); if(THIS_IN!="edt_admin") exit("错误的访问!"); //-------------------------------execute action //require THIS_FILE_ROOT."/include/excel_class.php"; //require THIS_FILE_ROOT."/include/excel_fun.php"; $image_file_type="jpg|jpeg"; $uid=check_cookie(); $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"]); $json_data="{"; if($priv[0]=="n"){ //没有操作权限 $json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],"; }else{ $json_data.="\"uid\":".$uid.","; $arr_column_size_not["kh"]="款号"; $arr_column_size_not["color"]="颜色代码"; if(trim($bx_sizegroup_title)) $arr_column_size_not["bx"]="杯型"; if(trim($child_sizegroup_title)) $arr_column_size_not["bx"]="款型"; if($is_gg=="y" || $is_gg=="b") $arr_column_size_not["bx"]=d_translate("gg"); $arr_column_size_not["size"]="尺码"; // $arr_kh_size=arr_select("size","title","title"); switch($_a){ case "add" : //--------------------------新增 //$http_pre=$http_pre?$http_pre:$_SERVER['HTTP_REFERER']; if($id){ $msg=get_db_msg("select * from ".$table_pre."size_not where id='".$id."'"); $msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$msg["kh"]."'"); $is_ggk=is_ggk($msg_kh["id"]); $arr_color=explode(",",$msg_kh["color"]); $arr_size=explode(",",$msg_kh["size"]); //取得杯型 $arrBx=array(); $r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["kh"]."' order by bx"); $i1=0; $strbx=""; 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_kh["size"]; } $strcb=""; for($i=0;$iquery($q1); while($m1=$db->fetch_array($r1)){ $check=get_db_msg("select count(*) 'num' from ".$table_pre."size_not where kh='".$msg["kh"]."' and color='".$arr_color[$i]."' and bx='".$m1["gg"]."'"); $ck1=""; if($check["num"]>0){ $ck1=" checked"; } $tmpa=""; $arr_size=explode(",",$msg_kh["size"]); for($j=0;$j0){ $ck1=" checked"; } $sbx=""; if($show_bx=="y"){ $sbx=$arrBx[$k][0]; } $arr_size=explode(",",$arrBx[$k][1]); $tmpa=""; for($j=0;$j"; $kh=trim($kh); $msg_kh=get_db_msg("select id,color,size,size_group from ".$table_pre."kh where no='".$kh."'"); if($msg_kh["id"]>0){ if($child_sizegroup_title){ $tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$child_sizegroup_title."' limit 0,1"); $child_sizegroup_id=$tmp["id"]; }else{ $child_sizegroup_id=0; } $arr_color_kh=explode(",",$msg_kh["color"]); $arr_size_kh=explode(",",$msg_kh["size"]); }else{ $error_msg="款号错误!"; } if($error_msg){ $json_data.="\"code\":99,\"msg\":\"".$error_msg."\","; }else{ if($msg_kh["size_group"]==$child_sizegroup_id){ //童装 //删除多余数据 $q="select * from ".$table_pre."size_not where kh='".$kh."'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ if(!in_array($m["color"]."_".get_child_bx_ind($m["bx"]),$color_bx)){ $db->query("delete from ".$table_pre."size_not where id='".$m["id"]."'"); } } if(count($color_bx)>0){ foreach($color_bx as $k1 => $color_bx1){ $v1="size_".$color_bx1; $size1=arr_to_str1($$v1); $tmp=explode("_",$color_bx1); $check=get_db_msg("select * from ".$table_pre."size_not where kh='".$kh."' and color='".$tmp[0]."' and bx='".get_child_bx_title($tmp[1])."'"); if($check["id"]>0){ $q="update ".$table_pre."size_not set size='".$size1."' where id='".$check["id"]."'"; }else{ $q="insert into ".$table_pre."size_not (kh,color,bx,size) values ('".$kh."','".$tmp[0]."','".get_child_bx_title($tmp[1])."','".$size1."')"; } $db->query($q); } } }else{ //非童装 //删除多余数据 $q="select * from ".$table_pre."size_not where kh='".$kh."'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ if(!in_array($m["color"]."_".$m["bx"],$color_bx)){ $db->query("delete from ".$table_pre."size_not where id='".$m["id"]."'"); } } if(count($color_bx)>0){ foreach($color_bx as $k1 => $color_bx1){ $v1="size_".$color_bx1; $size1=arr_to_str1($$v1); $tmp=explode("_",$color_bx1); $check=get_db_msg("select * from ".$table_pre."size_not where kh='".$kh."' and color='".$tmp[0]."' and bx='".$tmp[1]."'"); if($check["id"]>0){ $q="update ".$table_pre."size_not set size='".$size1."' where id='".$check["id"]."'"; }else{ $q="insert into ".$table_pre."size_not (kh,color,bx,size) values ('".$kh."','".$tmp[0]."','".$tmp[1]."','".$size1."')"; } //echo $q."
"; $db->query($q); } } } 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++){ $tmp=get_db_msg("select kh from ".$table_pre."size_not where id='".$id[$i]."'"); //删除款号表 $db->query("delete from ".$table_pre."size_not where id='".$id[$i]."'"); $lid.=$tmp["kh"].","; } $json_data.="\"code\":1,"; $lid=substr($lid,0,-1); set_log("不予下单尺码",$lid); 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_size_not); $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_size_not as $k => $v){ $column.=$v.","; } if($column) $column=substr($column,0,-1); $msg1=array(); $msg1[0]=array("可导入正确字段",$column); // $column=""; for($i=0;$i".$arr_thead[$i].","; } if($column) $column=substr($column,0,-1); // $msg1[1]=array("检测到的有效字段",$column); // $total=count($arr_content)-1; $msg1[2]=array("记录条数",$total); $m1=""; for($i=0;$iquery("TRUNCATE TABLE ".$table_pre."size_not;"); } // $insert_column=""; for($i=0;$i"; $db->query($q); } // del_tmp_file($tmp_file_name); $log_remark=$import_flag; set_log("导入不予下单尺码数据",$log_remark); } break; //----------------------------------------------------------------------/导入EXCEL //----------------------------------------------------------------------导出数据 case "export": $column=""; foreach($arr_column_size_not as $k => $v){ $column.="{\"k\":\"".$k."\",\"t\":\"".$v."\"},"; } if($column) $column=substr($column,0,-1); $json_data.="\"col\":[".$column."],"; //$json_data.="\"color_select\":[{\"k\":\"2\",\"t\":\"纵向\"},{\"k\":\"1\",\"t\":\"横向逗号隔开\"}],"; break; case "export_do": //取得字段选择的值 foreach($arr_column_size_not as $k => $v){ $var="col_".$k; if($$var=="on"){ $ex_col[]=$k; } } $num=count($ex_col); if($num==0) alert_and_back("请至少选择一个要导出的字段"); $show_bx=$show_gg="n"; $data=array(); //设置表头 for($i=0;$i<$num;$i++){ $data["header"][0][]=get_main_value($arr_column_size_not,$ex_col[$i]); } //取得数据 $query="select * from ".$table_pre."size_not order by kh"; $r=$db->query($query); $row=0; while($m=$db->fetch_array($r)){ for($i=0;$i<$num;$i++){ $k=$ex_col[$i]; if($k=="size"){ $m_kh=get_db_msg("select size_group from ".$table_pre."kh where no='".$m["kh"]."'"); $arr_size1=explode(",",$m[$k]); $size_title1=""; for($j=0;$jquery($q); $i=0; $content=""; //检查款号 $tmp=""; while($m=$db->fetch_array($r)){ $tmp1=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'"); if(!$tmp1["id"]){ $tmp.="{\"kh\":\"".$m["kh"]."\",\"v\":\"".$m["kh"]."\"},"; $i++; } } if($i>0){ $str.="{\"cate\":\"款号有误\",\"data\":[".deel_end($tmp)."]},"; } //检查颜色 $error_color=""; $q="select * from ".$table_pre."size_not where color<>'' order by kh,color"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $tmp1=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'"); if($tmp1["id"]>0){ //检查颜色 $check_color=explode(",",$tmp1["color"]); $color=trim($m["color"]); if(!in_array($color,$check_color)){ $tmp.="{\"v\":\"".$m["id"]."-".$m["kh"]."-".$wrong_color."\",\"kh\":\"".$m["kh"]."\"},"; $i++; } } } if($i>0){ $str.="{\"cate\":\"颜色有误\",\"data\":[".deel_end($tmp)."]},"; } //检查尺码 $error_size=""; $q="select * from ".$table_pre."size_not where size<>'' and color<>'' order by kh,color"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $tmp1=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."'"); if($tmp1["id"]>0){ //检查尺码 $check_size=explode(",",$tmp1["size"]); $arr_size=explode(",",trim($m["size"])); for($j=0;$j0){ $str.="{\"cate\":\"尺码有误\",\"data\":[".deel_end($tmp)."]},"; } $json_data.="\"error\":[".deel_end($str)."],"; break; case "color_size" : // $msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'"); $is_ggk=is_ggk($msg_kh["id"]); $arr_color=explode(",",$msg_kh["color"]); $arr_size=explode(",",$msg_kh["size"]); //取得杯型 $arrBx=array(); $r1=$db->query("select * from ".$table_pre."size_bx where no='".$kh."' order by bx"); $i1=0; $strbx=""; 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_kh["size"]; } $strcb=""; for($i=0;$iquery($q1); while($m1=$db->fetch_array($r1)){ $check=get_db_msg("select count(*) 'num' from ".$table_pre."size_not where kh='".$kh."' and color='".$arr_color[$i]."' and bx='".$m1["gg"]."'"); $ck1=""; if($check["num"]>0){ $ck1=" checked"; } $tmpa=""; $arr_size=explode(",",$msg_kh["size"]); for($j=0;$j0){ $ck1=" checked"; } $sbx=""; if($show_bx=="y"){ $sbx=$arrBx[$k][0]; } $arr_size=explode(",",$arrBx[$k][1]); $tmpa=""; for($j=0;$j0?$page:1; $limit=$limit>0?$limit:10; $start=($page-1)*$limit; $end=$limit; $sql_con=""; if($s_no){ if($s_no) $sql_con.="kh like '%".$s_no."%' and "; } if($sql_con) $sql_con="where ".substr($sql_con,0,-4); $sql_order=str_replace("!"," desc",$order); $query="select count(distinct kh) 'total' from ".$table_pre."size_not ".$sql_con; $res=$db->query($query); $msg=$db->fetch_array($res); $total=$msg["total"]; $json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total.",\"data\":["; $query="select * from ".$table_pre."size_not ".$sql_con." group by kh order by kh limit ".$start.",".$end; //echo $query."
"; $res=$db->query($query); $count=0; $str_tmp=""; 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"]); //取得杯型 $arrBx=array(); $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++; } $show_bx=($i1>0)?"y":"n"; if(count($arrBx)==0){ $arrBx[0][0]=""; $arrBx[0][1]=$msg["size"]; } // $list=$start+$count+1; $str_tmp.="{"; $str_tmp.="\"id\":\"".$msg["id"]."\","; $str_tmp.="\"xh\":\"".$list."\","; $str_tmp.="\"kh\":\"".$msg["kh"]."\","; //颜色 $str=$str1=$str2=""; $q="select * from ".$table_pre."size_not where kh='".$msg["kh"]."' order by color"; $r=$db->query($q); $tmpa=""; while($m=$db->fetch_array($r)){ if(trim($m["color"])){ $str.="".$m["color"]."-".get_cate_title_no("color",$m["color"]).""; $str1.="{\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\","; $str2.=$m["color"]."-".get_cate_title_no("color",$m["color"])."|"; if($m["bx"]){ if($is_ggk=="y" || $is_ggk=="b"){ $str.="".get_gg_title($m["bx"]).""; $str1.="\"bx\":\"".get_gg_title($m["bx"])."\","; }else{ $str.="".$m["bx"].""; $str1.="\"bx\":\"".$m["bx"]."\","; } }else{ $str1.="\"bx\":\"\","; } //尺码 $str_size=""; if(trim($m["size"])){ $arr1=explode(",",$m["size"]); for($j=0;$j"; $str_tmp.="\"c_s\":[".$str1."]"; $str_tmp.="},"; $count++; } $json_data.=substr($str_tmp,0,-1)."],"; break; } } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>