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;$j0){ $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;$iquery($q1); $j=0; while($m1=$db->fetch_array($r1)){ //尺码 $str_size=""; $arr1=explode(",",$msg["size"]); for($k=0;$k0){ //取得杯型 $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;$iquery($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;$j0){ $color_bx_sign="y"; }else{ $color_bx_sign="n"; } $str_size=""; $arr_size=explode(",",$arrBx[$k][1]); for($j=0;$j'' 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."
"; $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."
"; $db->query($q1); } } // if(count($color_bx)>0){ for($i=0;$i$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."
"; $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."
"; $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".$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 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"; $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'' 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