'jgd' and no<>'sx' order by ord"; $r=$db->query($q); while($m=$db->fetch_array($r)){ if($m["no"]!="zd1" && $m["no"]!="zd2" && $m["no"]!="zd3"){ $arr_select_no1[]=$m["no"]; $arr_select_title1[]=$m["title"]; if($m["no"]!="designer"){ $arr_select_no2[]=$m["no"]; $arr_select_title2[]=$m["title"]; } } $arr_select_no[]=$m["no"]; $arr_select_title[]=$m["title"]; } // //--------------- $arr_column_kh["pic"]="图片"; $arr_column_kh["xh"]=d_translate("xh"); $arr_column_kh["no"]="款号"; $arr_column_kh["color_code"]="颜色代码"; $arr_column_kh["color"]="颜色名称"; if(is_array($sys_color_zd)){ if(count($sys_color_zd)>0){ foreach($sys_color_zd as $k1 => $v1){ $arr_column_kh["kh_color_".$k1]=$v1; } } } if($is_gg=="y"){ $arr_column_kh["gg"]=d_translate("gg"); foreach($sys_gg_zd as $k1 => $v1){ $arr_column_kh["kh_gg_".$k1]=$v1; } }else if($is_gg=="b"){ //版型 $arr_column_kh["gg"]=d_translate("gg"); } $arr_column_kh["size_bx"]="款型"; $arr_column_kh["title"]="款式名"; if($is_multi_price=="y"){ foreach($sys_multi_price as $k1 => $v1){ $arr_column_kh[$k1]=$v1; } }else{ $arr_column_kh["price"]="吊牌价"; } //$arr_column_kh["bd"]="最高订量"; //$arr_column_kh["dhbs"]=d_translate("dhbs"); $arr_column_kh["remark"]="备注"; $arr_column_kh["is_sp"]=d_translate("spk"); $arr_column_kh["ka"]="删除标记"; $arr_column_kh["in_ph"]="参与排行"; $arr_column_kh["size_group"]="尺码组"; $arr_column_kh["size"]="尺码"; $arr_column_kh["dpk"]="搭配款"; $arr_column_kh["dp_pic"]="搭配图"; $arr_column_kh["pm_dj"]="配码等级"; $arr_column_kh["unit_title"]="单位"; // for($i=0;$iquery($q0); $str_color=""; while($m0=$db->fetch_array($r0)){ $str_color.="{\"no\":\"".$m0["no"]."\",\"title\":\"".$m0["title"]."\"},"; } $str_color=deel_end($str_color); $json_data.="\"color\":[".$str_color."],"; break; case "add" : //--------------------------新增 $add_date=date("Y-m-d H:i:s"); if($id){ $msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'"); $add_date=date("Y-m-d H:i:s",$msg["add_date"]); $ka=$msg["ka"]; $xh=$msg["xh"]; $no=$msg["no"]; $title=$msg["title"]; $main_pic=$msg["main_pic"]; $color=$msg["color"]; $pm_dj=$msg["pm_dj"]; $unit_title=$msg["unit_title"]; //颜色 if($color){ $arr_color=explode(",",$color); $num_color=count($arr_color); }else{ $num_color=0; $arr_color=array(); } $color_title=""; for($i=0;$i $v1){ $gg_zd.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\"},"; } $gg_zd=deel_end($gg_zd); //规格取值 $gg_zd_value=""; $q1="select * from ".$table_pre."kh_gg where iid='".$id."' order by color,ord"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $m_gg=get_db_msg("select title from ".$table_pre."kh_gg_title where id='".$m1["gg"]."'"); $tmp="{\"zd\":\"title\",\"value\":\"".$m_gg["title"]."\"},"; foreach($sys_gg_zd as $k1 => $v1){ $tmp.="{\"zd\":\"".$k1."\",\"value\":\"".$m1[$k1]."\"},"; } $gg_zd_value.="{\"color\":\"".$m1["color"]."\",\"zd\":[".deel_end($tmp)."]},"; } $gg_zd_value=deel_end($gg_zd_value); //到色属性 $color_zd=""; foreach($sys_color_zd as $k1 => $v1){ $color_zd.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\"},"; } $color_zd=deel_end($color_zd); //到色属性取值 $color_zd_value=""; for($i=0;$i $v1){ $tmp.="{\"zd\":\"".$k1."\",\"value\":\"".$m1[$k1]."\"},"; } $color_zd_value.="{\"color\":\"".$arr_color[$i]."\",\"zd\":[".deel_end($tmp)."]},"; } $color_zd_value=deel_end($color_zd_value); //尺码组 $size_group_id=$msg["size_group"]; $tmp=get_db_msg("select id,title from ".$table_pre."keyword where id='".$size_group_id."'"); $size_group_title=$tmp["title"]; //尺码 $arr_size=explode(",",$msg["size"]); //备注 $remark=htmlspecialchars($msg["remark"]); $dpk=$msg["dpk"]; $price=$msg["price"]; $in_ph=$msg["in_ph"]; $is_sp=$msg["is_sp"]; }else{ //ord $tmp=get_db_msg("select max(xh) 'num' from ".$table_pre."kh"); if($tmp[num]>0) $xh=$tmp[num]+1; else $xh=1; $no=$title=$main_pic=$color=$color_title=$pic=$remark=$dpk=$pm_dj=$unit_title=""; //尺码组 $tmp=get_db_msg("select id,title from ".$table_pre."keyword where cate='size' order by ord limit 0,1"); $size_group_id=$tmp["id"]; $size_group_title=$tmp["title"]; $ka="n"; $in_ph="y"; $is_sp="n"; $arr_color=$arr_size=array(); $price=""; } //取得所有尺码 $q0="select id,title from ".$table_pre."keyword where cate='size' order by ord"; $r0=$db->query($q0); $str_size_all=""; while($m0=$db->fetch_array($r0)){ $str_size_all.="{\"id\":\"".$m0["id"]."\",\"title\":\"".$m0["title"]."\",\"size_bx\":["; if($m0["id"]==$bx_sizegroup_id){ //---文胸 $tmp=""; for($k1=0;$k1query("select no,title from ".$table_pre."size where iid='".$m0["id"]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp1.=$m1["no"]."|".$m1["title"].","; } $tmp1=deel_end($tmp1); $tmp.=$tmp1."\"},"; } $tmp=deel_end($tmp); $str_size_all.=$tmp; }else if($m0["id"]==$child_sizegroup_id){ //---童装 $tmp=""; foreach($arr_child_bx as $bx1 => $arr_size_title1){ //取得所有尺码 $tmp.="{\"bx\":\"".$bx1."\",\"size\":\""; $tmp1=""; for($j=0;$jquery("select no,title from ".$table_pre."size where iid='".$m0["id"]."' order by no"); $tmp1=""; while($m1=$db->fetch_array($r1)){ $tmp1.=$m1["no"]."|".$m1["title"].","; } $tmp1=deel_end($tmp1); $tmp.=$tmp1."\"}"; $str_size_all.=$tmp; } $str_size_all.="]},"; } $str_size_all=deel_end($str_size_all); //取得已选尺码 $size=""; if($size_group_id==$bx_sizegroup_id){ //---文胸 $tmp=""; for($k1=0;$k1 $arr_size_title1){ //取得所有尺码 $m1=get_db_msg("select size,price from ".$table_pre."size_bx where no='".$no."' and bx='".$bx1."'"); $tmp.="{\"bx\":\"".$bx1."\",\"size\":\"".$m1["size"]."\",\"price\":\"".$m1["price"]."\"},"; } $tmp=deel_end($tmp); $size.=$tmp; }else{ //标准 $size="{\"bx\":\"\",\"size\":\"".$msg["size"]."\"}"; } //echo $size."--
"; //取得定制选项 $select_dz=""; for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$msg[$arr_select_no[$i]]."\",\"op\":[".$tmp."]},"; } } $select_dz=deel_end($select_dz); //取得自定义字段 $select_zdy=""; $q="select no,title from ".$table_pre."keyword where (no='zd1' or no='zd2' or no='zd3') and flag_ka='y' order by ord"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $select_zdy.="{\"no\":\"".$m["no"]."\",\"title\":\"".$m["title"]."\",\"value\":\"".$msg[$m["no"]]."\"},"; } $select_zdy=deel_end($select_zdy); //取得多吊牌价 $str_ddp=""; if($is_multi_price=="y"){ foreach($sys_multi_price as $k1 => $v1){ if($id){ $str_ddp.="{\"k\":\"".$k1."\",\"v\":\"".$v1."\",\"value\":\"".$msg[$k1]."\"},"; }else{ $str_ddp.="{\"k\":\"".$k1."\",\"v\":\"".$v1."\",\"value\":\"\"},"; } } $str_ddp=deel_end($str_ddp); $json_data.="\"is_multi_price\":\"".$is_multi_price."\","; $json_data.="\"arr_multi_price\":[".$str_ddp."],"; } //取得规格 $content_color=""; $json_data.="\"is_gg\":\"".$is_gg."\","; $json_data.="\"gg_zd\":[".$gg_zd."],"; $json_data.="\"gg_zd_value\":[".$gg_zd_value."],"; $json_data.="\"color_zd\":[".$color_zd."],"; $json_data.="\"color_zd_value\":[".$color_zd_value."],"; $json_data.="\"ka\":\"".$ka."\","; $json_data.="\"xh\":\"".$xh."\","; $json_data.="\"no\":\"".$no."\","; $json_data.="\"title\":\"".$title."\","; $json_data.="\"color\":\"".$color."\","; $json_data.="\"color_title\":\"".$color_title."\","; $json_data.="\"pm_dj\":\"".$pm_dj."\","; $json_data.="\"unit_title\":\"".$unit_title."\","; $json_data.="\"pic\":[".$pic."],"; $json_data.="\"main_pic\":\"".$main_pic."\","; $json_data.="\"size_all\":[".$str_size_all."],"; $json_data.="\"size_group_id\":\"".$size_group_id."\","; $json_data.="\"size_group_title\":\"".$size_group_title."\","; $json_data.="\"size\":[".$size."],"; $json_data.="\"price\":\"".$price."\","; $json_data.="\"select_dz\":[".$select_dz."],"; $json_data.="\"select_zdy\":[".$select_zdy."],"; $json_data.="\"remark\":\"".htmlspecialchars($remark)."\","; $json_data.="\"in_ph\":\"".$in_ph."\","; $json_data.="\"is_sp\":\"".$is_sp."\","; $json_data.="\"dpk\":\"".$dpk."\","; $json_data.="\"add_date\":\"".$add_date."\","; $json_data.="\"lang_xh\":\"".d_translate("xh")."\","; $json_data.="\"lang_gg\":\"".d_translate("gg")."\","; $json_data.="\"child_sizegroup_title\":\"".$child_sizegroup_title."\","; $json_data.="\"bx_sizegroup_title\":\"".$bx_sizegroup_title."\","; break; case "copy" : //--------------------------复制 if($id>0){ $msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'"); $add_date=time(); //xh $tmp=get_db_msg("select max(xh) 'num' from ".$table_pre."kh"); if($tmp[num]>0) $xh=$tmp[num]+1; else $xh=1; //复制一条 $no=$msg["no"]."_copy"; $sql_dz1=$sql_dz2=""; for($i=0;$iquery($query); $lid=$db->insert_id(); $no_old=$msg["no"]; //取得新复制的记录 $msg=get_db_msg("select * from ".$table_pre."kh where id='".$lid."'"); //复制杯型 $r1=$db->query("select * from ".$table_pre."size_bx where no='".$no_old."'"); while($m1=$db->fetch_array($r1)){ $db->query("insert into ".$table_pre."size_bx (no,bx,size) values ('".$msg["no"]."','".$m1["bx"]."','".$m1["size"]."')"); } //复制到款色表 $arr_color=explode(",",$msg["color"]); for($i=0;$iquery($q1); } // $json_data.="\"code\":1,\"id\":\"".$lid."\","; }else{ $json_data.="\"code\":0,\"msg\":\"选择的记录不存在\","; } break; case "save_add" : $add_date=day_to_time($add_date); $json_data.="\"unit_title\":\"".$unit_title."\","; //根据尺码组名称取得尺码组id $tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$size_group_title."'"); $size_group=$tmp["id"]; $a=$size_group_id; $b=$size_group; // $v_size=""; if($size_group==$bx_sizegroup_id){ //文胸 $size_bx1=array(); for($i=0;$iquery("select no,title from ".$table_pre."size where iid='".$size_group."' order by no"); $tmp_size=""; while($m1=$db->fetch_array($r1)){ $v2="size_".$size_group."_".$i."_".$m1["no"]; if($$v2=="on") $tmp_size.=$m1["no"].","; } $tmp_size=deel_end($tmp_size); //echo $size_group."-".$i."-".$tmp_size."
"; // if($tmp_size){ $c=get_db_msg("select id from ".$table_pre."size_bx where no='".$no."' and bx='".$bx1."'"); if($c["id"]>0){ $q1="update ".$table_pre."size_bx set size='".$tmp_size."' where id='".$c["id"]."'"; }else{ $q1="insert into ".$table_pre."size_bx (no,bx,size) values ('".$no."','".$bx1."','".$tmp_size."')"; } $db->query($q1); $size_bx1[]=$bx1; //echo $arr_bx[$i-1].":".$$v1."
"; } } //删除未勾选的杯型数据 $q1="select * from ".$table_pre."size_bx where no='".$no."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ // if(!in_array($m1["bx"],$size_bx1)){ $db->query("delete from ".$table_pre."size_bx where id='".$m1["id"]."'"); } } $v_size=""; }else if($size_group==$child_sizegroup_id){ //童装 $size_bx1=array(); $i=0; foreach($arr_child_bx as $bx1 => $arr_bx_size_title1){ $v3="price_".$size_group."_".$i; $tmp_size=""; for($j=0;$j"; // if($tmp_size){ $c=get_db_msg("select id from ".$table_pre."size_bx where no='".$no."' and bx='".$bx1."'"); if($c["id"]>0){ $q1="update ".$table_pre."size_bx set size='".$tmp_size."',price='".$$v3."' where id='".$c["id"]."'"; }else{ $q1="insert into ".$table_pre."size_bx (no,bx,size,price) values ('".$no."','".$bx1."','".$tmp_size."','".$$v3."')"; } //echo $q1."
"; $db->query($q1); $size_bx1[]=$bx1; } $i++; } //删除未勾选的杯型数据 $q1="select * from ".$table_pre."size_bx where no='".$no."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ // if(!in_array($m1["bx"],$size_bx1)){ $db->query("delete from ".$table_pre."size_bx where id='".$m1["id"]."'"); } } $v_size=""; }else{ $v_size=""; $q1="select no,title from ".$table_pre."size where iid='".$size_group."' order by no"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $var="size_".$size_group."_0_".$m1["no"]; if($$var=="on") $v_size.=$m1["no"].","; } $v_size=deel_end($v_size); } $jgd=get_jgd($price); $is_sp=($is_sp=="on")?"y":"n"; $in_ph=($in_ph=="on")?"y":"n"; //取得颜色 $color1=""; $arr1=explode(",",$color); for($i=0;$i=".$ord." and o.iid='".$lid."' and o.bx=g.gg and o.color=g.color and o._key='".$_key."'"); $wrong_gg=""; if($m1["num"]>0){ //已经有订单的规格不能删除 $msg_error="已经有订单的规格不能删除!"; } } //验证颜色,尺码 if($id>0){ $msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'"); if($size_group==$bx_sizegroup_id){ //文胸 }else if($size_group==$child_sizegroup_id){ //童装 }else{ //是否修改了尺码 //echo $v_size."-".$msg["size"]; if($v_size!=$msg["size"]){ //取得差异的尺码 $arr1=explode(",",$v_size); $arr2=explode(",",$msg["size"]); $arr_size_jia=$arr_size_jian=$arr_size_cy=array(); for($i=0;$i0){ if(!in_array($arr1[$i],$arr2)){ $arr_size_cy[]=$arr1[$i]; $arr_size_jia[]=$arr1[$i]; } } } for($i=0;$i0){ if(!in_array($arr2[$i],$arr1)){ $arr_size_cy[]=$arr2[$i]; $arr_size_jian[]=$arr2[$i]; } } } sort($arr_size_cy); //检测尺码有订单,不允许修改 $flag=0; for($i=0;$i0){ $check=get_db_msg("select num_".$arr_size_cy[$i]." 'num' from ".$table_pre."order where iid='".$id."' and _key='".$_key."'"); if($check["num"]>0){ //取得尺码名称 $tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size_cy[$i]."'"); $msg_error="尺码(".$tmp["title"].")存在订单,请先删除该订单再操作!"; $flag++; } } } //没有订单,修改size_pm表 if(!$flag){ $q="select id,gz,num from ".$table_pre."size_pm where khid='".$id."'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $arr_pm1=explode(":",$m["gz"]); $arr_old_size=explode(",",$msg["size"]); $arr_old_pm=array(); for($i=0;$i"; $db->query($q1); } } } } //是否修改了颜色 if($color!=$msg["color"]){ // $check_arr_color=explode(",",$color); $tmp=explode(",",$msg["color"]); for($i=0;$i0) $wrong_color.=$tmp[$i].","; } } } if($wrong_color){ $msg_error="颜色(".substr($wrong_color,0,-1).")已经有订单,不能删除!"; $alter_color=""; }else{ $alter_color="color='".$color."',"; } if($size_group_id!=$size_group){ $tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."order where iid='".$id."' and _key='".$_key."'"); if($tmp1["num"]>0){ $msg_error="该款已经有订单,不能修改尺码组!"; } } } //验证款号重复 $c=get_db_msg("select count(*) 'num' from ".$table_pre."kh where id<>'".$id."' and no='".$no."'"); if($c["num"]>0) $msg_error="该款号已经存在,请检查!"; // if($msg_error){ $json_data.="\"code\":0,\"msg\":\"".$msg_error."\","; }else{ //--------------------------------------------------保存 $wrong_color=""; $color=deel_color($color); if($id){ $msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'"); $log_action="修改"; //是否修改了款号 if($no!=$msg["no"]){ //修改图片名字 modify_file_name("../attachments/design/big/".$msg["no"].".jpg","../attachments/design/big/".$no.".jpg"); modify_file_name("../attachments/design/mini/".$msg["no"].".jpg","../attachments/design/mini/".$no.".jpg"); $arr_color=explode(",",$msg["color"]); for($i1=0;$i1query($tmp); //修改陈列数据 $tmp="update ".$table_pre."kh_cl set kh='".$no."' where kh='".$msg["no"]."'"; $db->query($tmp); //修改橱窗数据 $tmp="update ".$table_pre."kh_cc set kh='".$no."' where kh='".$msg["no"]."'"; $db->query($tmp); //修改杯型数据 $tmp="update ".$table_pre."size_bx set no='".$no."' where no='".$msg["no"]."'"; $db->query($tmp); //修改规则表 $tmp="update ".$table_pre."gz set kh='".$no."' where kh='".$msg["no"]."'"; $db->query($tmp); } //取得定制选项 $sql_dz=""; for($i=0;$iquery($query); //设置修改订单表 $sql_dz=""; for($i=0;$iquery("update ".$table_pre."order set is_sp='".$is_sp."',no='".$no."',".$sql_dz."jgd='".$jgd."' where iid='".$id."' and _key='".$_key."'"); if($is_multi_price=="y"){ if(($price1 && $msg["price1"]!=$price1) || ($price2 && $msg["price2"]!=$price2) || ($price3 && $msg["price3"]!=$price3) || ($price4 && $msg["price4"]!=$price4) || ($price5 && $msg["price5"]!=$price5)){ //缓存折扣表 $q1="select * from ".$table_pre."zk where iid='".$id."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $db->query("update ".$table_pre."zk set price=zk*".get_price_dp($m1["cid"],$id)." where iid='".$id."'"); } //缓存订单表 $q1="select * from ".$table_pre."order where iid='".$id."' and _key='".$_key."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]); } //缓存客户表 set_order_total_all(); } }else{ //修改价格缓存订单 if($msg["price"]!=$price){ //缓存折扣表 $db->query("update ".$table_pre."zk set price=zk*".deel_num($price)." where iid='".$id."'"); //缓存订单表 $q1="select * from ".$table_pre."order where iid='".$id."' and _key='".$_key."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]); } //缓存客户表 set_order_total_all(); } } $lid=$id; }else{ //取得定制选项 $sql_dz1=$sql_dz2=""; for($i=0;$iquery($query); $lid=$db->insert_id(); } if($is_gg!="n"){ //-------------------------------保存规格 for($i=0,$ord=0;$i<$gg_num;$i++){ $var_gg_color="gg_color_".$i; $var_gg_title="gg_title_".$i; $var_gg_price="gg_price_".$i; $var_gg_zd1="gg_zd1_".$i; $var_gg_zd2="gg_zd2_".$i; $var_gg_zd3="gg_zd3_".$i; $var_gg_zd4="gg_zd4_".$i; $var_gg_zd5="gg_zd5_".$i; if(trim($$var_gg_title) && $$var_gg_color){ insert_gg(trim($$var_gg_title)); $ck=get_db_msg("select * from ".$table_pre."kh_gg where iid='".$lid."' and ord=".$ord); $new_gg=get_gg_id(trim($$var_gg_title)); $new_price=$$var_gg_price; $new_color=$$var_gg_color; if($ck["id"]>0){ $q1="update ".$table_pre."kh_gg set color='".$new_color."',gg='".$new_gg."',price='".$new_price."',zd1='".$$var_gg_zd1."',zd2='".$$var_gg_zd2."',zd3='".$$var_gg_zd3."',zd4='".$$var_gg_zd4."',zd5='".$$var_gg_zd5."' where id='".$ck["id"]."'"; $db->query($q1); if($new_color!=$ck["color"] || $new_gg!=$ck["gg"]){ //-----------修改了颜色或者规格 $sql_up1=""; if($new_color!=$ck["color"]) $sql_up1.="color='".$new_color."',"; if($new_gg!=$ck["gg"]) $sql_up1.="bx='".$new_gg."',"; $sql_up1=substr($sql_up1,0,-1); //处理订单 $db->query("update ".$table_pre."order set ".$sql_up1." where iid='".$lid."' and color='".$ck["color"]."' and bx='".$ck["gg"]."' and _key='".$_key."'"); } if($new_price && $new_price!=$ck["price"]){ //-----------修改了价格 //缓存折扣表 $q1="select * from ".$table_pre."zk where iid='".$lid."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $db->query("update ".$table_pre."zk set price=zk*".(get_price_dp($m1["cid"],$m1["iid"]))." where iid='".$lid."'"); } //缓存订单表 $q1="select uid,iid,color,bx from ".$table_pre."order where iid='".$lid."' and color='".$new_color."' and bx='".$new_gg."' and _key='".$_key."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]); //echo $m1["iid"].",".$m1["color"].",".$m1["bx"]."
"; } //缓存客户表 set_order_total_all(); } }else{ $q1="insert ".$table_pre."kh_gg (iid,color,ord,gg,price,zd1,zd2,zd3,zd4,zd5) values ('".$lid."','".$new_color."','".$ord."','".$new_gg."','".$new_price."','".$$var_gg_zd1."','".$$var_gg_zd2."','".$$var_gg_zd3."','".$$var_gg_zd4."','".$$var_gg_zd5."')"; $db->query($q1); //更新已订数据 $db->query("update ".$table_pre."order set bx='".$new_gg."' where iid='".$lid."' and color='".$new_color."' and bx='' and _key='".$_key."'"); } $ord++; } } //删除多余规格 $m1=get_db_msg("select count(*) 'num' from ".$table_pre."kh_gg g,".$table_pre."order o where g.iid='".$lid."' and g.ord>=".$ord." and o.iid='".$lid."' and o.bx=g.gg and o.color=g.color and o._key='".$_key."'"); $wrong_gg=""; if($m1["num"]>0){ //已经有订单的规格不能删除 $wrong_gg="已经有订单的规格不能删除!"; }else{ $db->query("delete from ".$table_pre."kh_gg where iid='".$lid."' and ord>=".$ord); } } //-------------------------------保存款色表 $arr_color=explode(",",$color); for($i=0;$i0){ $q1="update ".$table_pre."kh_color set zd1='".$$var_color_zd1."',zd2='".$$var_color_zd2."',zd3='".$$var_color_zd3."',zd4='".$$var_color_zd4."',zd5='".$$var_color_zd5."' where id='".$ck["id"]."'"; $db->query($q1); }else{ $q1="insert ".$table_pre."kh_color (iid,color,zd1,zd2,zd3,zd4,zd5) values ('".$lid."','".$arr_color[$i]."','".$$var_color_zd1."','".$$var_color_zd2."','".$$var_color_zd3."','".$$var_color_zd4."','".$$var_color_zd5."')"; $db->query($q1); } //echo $q1."
"; } //删除多余颜色 $q1="select * from ".$table_pre."kh_color where iid='".$lid."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ if(!in_array($m1["color"],$arr_color,true)){ $db->query("delete from ".$table_pre."kh_color where id='".$m1["id"]."'"); } } //echo $query."
"; set_log($log_action."款号",$no."|".$lid); $json_data.="\"code\":1,"; } break; case "set_main_pic" : $query="update ".$table_pre."kh set main_pic='".$c."' where id='".$id."'"; $db->query($query); //echo $query."
"; set_log("设置主图",$c."|".$id); $json_data.="\"code\":1,"; break; case "add_pic": $msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'"); $pic=get_kh_color_picture_big($msg["no"],$c); $arr_pic_set=out_good_pic_set_arr($pic,300,300); $json_data.="\"pic\":\"".$pic."\",\"pic_w\":\"".$arr_pic_set[0]."\",\"pic_h\":\"".$arr_pic_set[1]."\","; $json_data.="\"no\":\"".$msg["no"]."\",\"color\":\"".$c."\",\"color_title\":\"".get_cate_title_no("color",$c)."\","; break; case "save_add_pic": $up_image=$_FILES["up_file"];; $msg=get_db_msg("select no,color from ".$table_pre."kh where id='".$id."'"); if($del_pic=="y"){ del_file("../attachments/design/big/".$msg["no"]."_".$c.".jpg"); del_file("../attachments/design/mini/".$msg["no"]."_".$c.".jpg"); $check=explode(",",$msg["color"]); if($check[0]==$c){ del_file("../attachments/design/mini/".$msg["no"].".jpg"); del_file("../attachments/design/big/".$msg["no"].".jpg"); } }else{ if($up_image["name"]){ //$path1=$image_root; $path1="../attachments/design/big"; $path2="../attachments/design/mini"; $new_file_name=$msg["no"]."_".$c.".jpg"; make_mini_picture($up_image["tmp_name"],$path1."/".$new_file_name,800); //缩略图 make_mini_picture($path1."/".$new_file_name,$path2."/".$new_file_name); } } $json_data.="\"code\":1,"; break; case "set_spk" : $id=(is_array($id))?$id:array($id); $num=count($id); for($i=0;$i<$num;$i++){ $tmp=get_db_msg("select is_sp,no from ".$table_pre."kh where id='".$id[$i]."'"); $is_sp=($tmp["is_sp"]=="y")?"n":"y"; // $db->query("update ".$table_pre."kh set is_sp='".$is_sp."' where id='".$id[$i]."'"); $db->query("update ".$table_pre."order set is_sp='".$is_sp."' where iid='".$id[$i]."' and _key='".$_key."'"); $lid.=$tmp["no"].", "; } $lid=substr($lid,0,-2); set_log("设置饰品款",$lid); $json_data.="\"code\":1,"; break; case "del" : $id=(is_array($id))?$id:array($id); $num=count($id); //验证 $msg_error=""; for($i=0;$i<$num;$i++){ $tmp=get_db_msg("select no from ".$table_pre."kh where id='".$id[$i]."'"); $check=get_db_msg("select count(*) 'num' from ".$table_pre."order where iid='".$id[$i]."' and _key='".$_key."'"); if($check["num"]>0){ $msg_error="对不起,".$tmp["no"]."已经有订单,请先删除订单数据"; } } if($msg_error){ $json_data.="\"code\":0,\"msg\":\"".$msg_error."\","; }else{ //删除 for($i=0;$i<$num;$i++){ $tmp=get_db_msg("select no from ".$table_pre."kh where id='".$id[$i]."'"); //删除款号表 $db->query("delete from ".$table_pre."kh where id='".$id[$i]."'"); //删除款色表 $db->query("delete from ".$table_pre."kh_color where iid='".$id[$i]."'"); $lid.=$tmp["no"].","; } $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_kh); $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 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;$i0){ //尺码正常 }else{ //尺码有问题 $error_size.=$kh.",".$color.",".$tmp1[$k1]."
"; } } } } } if($error_size){ $error_msg="尺码有有问题,请检查!
".$error_size; } //检查颜色代码重复 $repeat_str=""; $r1=$db->query("select no,title from ".$table_pre."keyword where cate='color' group by no having count(no)>1 order by no"); while($m1=$db->fetch_array($r1)){ $repeat_str.=$m1["no"]."-".$m1["title"].","; } if($repeat_str){ $repeat_str=substr($repeat_str,0,-1); $error_msg="颜色代码有重复,请检查(".$repeat_str.")!"; } //检查订单 if($import_type=="y" || $import_select=="y"){ $check_dd=get_db_msg("select count(*) 'num' from ".$table_pre."order"); if($check_dd["num"]>0) $error_msg="对不起,已经有订单,不允许清空导入操作!"; } if($error_msg){ $json_data.="\"code\":0,\"msg\":\"".$error_msg."\","; del_tmp_file($tmp_file_name); }else{ $json_data.="\"code\":1,\"reload_type\":\"1\","; //-------------------------------------------导入数据 //----导入选项 $check_keyword_zd=array(); for($i=0;$iquery("TRUNCATE TABLE ".$table_pre."kh;"); $db->query("TRUNCATE TABLE ".$table_pre."ph;"); $db->query("TRUNCATE TABLE ".$table_pre."size_bx"); $db->query("TRUNCATE TABLE ".$table_pre."kh_gg_title"); $db->query("TRUNCATE TABLE ".$table_pre."kh_gg"); $db->query("TRUNCATE TABLE ".$table_pre."kh_color"); } if($import_select=="y"){ //清空选项数据 $db->query("delete from ".$table_pre."keyword where cate<>'zd_color' and cate<>'arr_select' and cate<>'size' and cate<>'jgd' and cate<>'dhgz'"); } for($i=1;$i"; update_keyword_color($tmp_color_code[$j],$tmp_color_title[$j]); } for($k=0;$k0){ //存在款号 $arr_old_color=explode(",",$check["color"]); if(!in_array($color,$arr_old_color)){ if(trim($check["color"])) $color=$check["color"].",".$color; else $color=$color; $q="update ".$table_pre."kh set color='".$color."',size='".size_hb($check["size"],$size)."' where id='".$check["id"]."'"; }else{ $q="update ".$table_pre."kh set size='".size_hb($check["size"],$size)."' where id='".$check["id"]."'"; } }else{ //不存在款号 for($k=0;$k"; if($q) $db->query($q); } // del_tmp_file($tmp_file_name); //去掉重复色号,处理价格带 $q="select * from ".$table_pre."kh"; $r=$db->query($q); $i=1; while($m=$db->fetch_array($r)){ //处理价格带 $q1="update ".$table_pre."kh set jgd='".get_jgd($m["price"])."' where id='".$m["id"]."'"; $db->query($q1); //去掉重复色 $arr_color=explode(",",trim($m["color"])); $arr_color1=array_unique($arr_color); if($arr_color1!=$arr_color){ $q1="update ".$table_pre."kh set color='".arr_to_str($arr_color1)."' where id='".$m["id"]."'"; $db->query($q1); } $i++; } //自动编排圆牌号 $tmp=get_db_msg("select max(xh) 'max_xh' from ".$table_pre."kh"); $max_xh=$tmp["max_xh"]>0?$tmp["max_xh"]:0; $q="select id,xh from ".$table_pre."kh where xh=0 order by no"; $r=$db->query($q); $i=1; while($m=$db->fetch_array($r)){ $this_xh=$max_xh+$i; $db->query("update ".$table_pre."kh set xh='".$this_xh."' where id='".$m["id"]."'"); $i++; } //导入杯型 if($bx_sizegroup_id>0 || $child_sizegroup_id>0){ for($i=1;$i"; if($size_group_id==$bx_sizegroup_id){ $c=get_db_msg("select id,size from ".$table_pre."size_bx where no='".$kh."' and bx='".$bx."'"); if($c["id"]>0){ $q1="update ".$table_pre."size_bx set size='".size_hb($c["size"],$size)."' where id='".$c["id"]."'"; }else{ $q1="insert into ".$table_pre."size_bx (no,bx,size) values ('".$kh."','".$bx."','".$size."')"; } //echo $q1."
"; $db->query($q1); }else if($size_group_id==$child_sizegroup_id){ $c=get_db_msg("select id,size from ".$table_pre."size_bx where no='".$kh."' and bx='".$bx."'"); if($c["id"]>0){ $q1="update ".$table_pre."size_bx set size='".size_hb($c["size"],$size)."',price='".$price."' where id='".$c["id"]."'"; }else{ $q1="insert into ".$table_pre."size_bx (no,bx,size,price) values ('".$kh."','".$bx."','".$size."','".$price."')"; } //echo $q1."
"; $db->query($q1); } } } //导入规格 if($is_gg!="n"){ //导入规格名称 for($i=1;$i $v1){ $tmp="kh_gg_".$k1; $$tmp=""; } } for($k=0;$k0){ //记录重复,不处理 }else{ $sql_insert1=$sql_insert2=""; if($is_gg=="y"){ foreach($sys_gg_zd as $k1 => $v1){ $tmp="kh_gg_".$k1; $sql_insert1.=",".$k1; $sql_insert2.=",'".$$tmp."'"; } } $q1="insert into ".$table_pre."kh_gg (iid,color,ord,gg".$sql_insert1.") values ('".$m_kh["id"]."','".$color."','".$i."','".$m_gg["id"]."'".$sql_insert2.")"; } //echo $q1."
"; $db->query($q1); } } //更新ord $q="select iid from ".$table_pre."kh_gg group by iid order by iid,color"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $q1="select id from ".$table_pre."kh_gg where iid='".$m["iid"]."' order by color,ord"; $r1=$db->query($q1); $i1=0; while($m1=$db->fetch_array($r1)){ $q2="update ".$table_pre."kh_gg set ord='".$i1."' where id='".$m1["id"]."'"; $db->query($q2); $i1++; } } } //导入款号颜色表 for($i=1;$i $v1){ $tmp="kh_color_".$k1; $$tmp=""; } for($k=0;$k0){ //记录重复,不处理 }else{ $sql_insert1=$sql_insert2=""; foreach($sys_color_zd as $k1 => $v1){ $tmp="kh_color_".$k1; $sql_insert1.=",".$k1; $sql_insert2.=",'".$$tmp."'"; } $q1="insert into ".$table_pre."kh_color (iid,color".$sql_insert1.") values ('".$m_kh["id"]."','".$color."'".$sql_insert2.")"; $db->query($q1); } //echo $q1."
"; } } $log_remark=$import_flag; set_log("导入 款号数据",$log_remark); } break; //----------------------------------------------------------------------/导入EXCEL //----------------------------------------------------------------------导出数据 case "export": $column=""; foreach($arr_column_kh as $k => $v){ if($k=="size_bx"){ if($bx_sizegroup_id>0 || $child_sizegroup_id>0) $column.="{\"k\":\"".$k."\",\"t\":\"".$v."\"},"; }else{ $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_kh 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++){ if($ex_col[$i]=="pic"){ $data["col"][]="img"; }else{ $data["col"][]="str"; } } //设置表头 for($i=0;$i<$num;$i++){ if($ex_col[$i]=="pic"){ $data["header"][0][]="图片|img"; }else if($ex_col[$i]=="color_code"){ $data["header"][0][]="颜色代码|str"; }else if($ex_col[$i]=="size_bx"){ $show_bx="y"; $data["header"][0][]=get_main_value($arr_column_kh,$ex_col[$i]); }else if($ex_col[$i]=="gg"){ $show_gg="y"; $data["header"][0][]=get_main_value($arr_column_kh,$ex_col[$i]); }else{ $data["header"][0][]=get_main_value($arr_column_kh,$ex_col[$i]); } } //取得数据 $query="select * from ".$table_pre."kh order by no"; $r=$db->query($query); $row=0; while($m=$db->fetch_array($r)){ //取得杯型 $arr1=array(); if(($m["size_group"]==$bx_sizegroup_id || $m["size_group"]==$child_sizegroup_id) && $show_bx=="y"){ $r1=$db->query("select * from ".$table_pre."size_bx where no='".$m["no"]."' order by bx"); $i1=0; while($m1=$db->fetch_array($r1)){ $arr1[$i1][]=$m1["bx"]; $arr1[$i1][]=$m1["size"]; $i1++; } } if(count($arr1)==0){ $arr1[0][]=""; $arr1[0][]=$m["size"]; } if($color_select=="1"){ //---------------------------------------------------颜色横向逗号方式 //取得规格 $i1=0; $str_gg=""; if($is_gg!="n" && $show_gg=="y"){ $r1=$db->query("select * from ".$table_pre."kh_gg where iid='".$m["id"]."' order by ord"); while($m1=$db->fetch_array($r1)){ $str_gg.=get_cate_title_no("color",$m1["color"])."-".get_gg_title($m1["gg"]).","; $i1++; } } if($i1>0) $str_gg=substr($str_gg,0,-1); // for($j1=0;$j1query("select * from ".$table_pre."kh_gg where iid='".$m["id"]."' and color='".$arr_color[$j]."' order by ord"); while($m1=$db->fetch_array($r1)){ $arr_gg_data[$i1]["gg"]=get_gg_title($m1["gg"]); if($is_gg=="y"){ foreach($sys_gg_zd as $k1 => $v1){ $tmp="kh_gg_".$k1; //$arr_gg_data[$i1][$k1]=$m1[$k1]; $arr_gg_data[$i1][$tmp]=$m1[$k1]; } } $i1++; } }else{ if(is_array($sys_color_zd) && count($sys_color_zd)>0){ $arr_color_data=array(); $i2=0; $r1=$db->query("select * from ".$table_pre."kh_color where iid='".$m["id"]."' and color='".$arr_color[$j]."' order by color"); while($m1=$db->fetch_array($r1)){ foreach($sys_color_zd as $k1 => $v1){ $tmp="kh_color_".$k1; $arr_color_data[$i2][$tmp]=$m1[$k1]; //$arr_color_data[$i2][$k1]=$m1[$k1]; } $i2++; } } } if($i1==0) $arr_gg_data[0]=array(); for($j1=0;$j11"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $tmp.="{\"kh\":\"".$m["no"]."\",\"v\":\"".$m["no"]."\"},"; $i++; } if($i>0){ $str.="{\"cate\":\"款号重复\",\"data\":[".deel_end($tmp)."]},"; } //--------------------圆牌号重复 $q="select * from ".$table_pre."kh group by xh having count(xh)>1"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $tmp.="{\"v\":\"".$m["xh"]."\",\"xh\":\"".$m["xh"]."\"},"; $i++; } if($i>0){ $str.="{\"cate\":\"".d_translate("xh")."重复\",\"data\":[".deel_end($tmp)."]},"; } //--------------------检查颜色 $q="select * from ".$table_pre."kh"; $r=$db->query($q); $tmp1=$tmp2=$tmp3=""; $i1=$i2=$i3=0; while($m=$db->fetch_array($r)){ //缺颜色 if(trim($m["color"])==""){ $tmp1.="{\"v\":\"".$m["id"]."-".$m["no"]."\",\"kh\":\"".$m["no"]."\"},"; $i1++; } //颜色不正确 if(trim($m["color"])!=""){ $arr1=explode(",",trim($m["color"])); $wrong_color=""; for($j=0;$j0){ $str.="{\"cate\":\"缺颜色\",\"data\":[".deel_end($tmp1)."]},"; } if($i2>0){ $str.="{\"cate\":\"颜色不正确\",\"data\":[".deel_end($tmp2)."]},"; } if($i3>0){ $str.="{\"cate\":\"颜色重复\",\"data\":[".deel_end($tmp3)."]},"; } //--------------------检查折扣 /* $zk_type=get_set("zk_type"); if($zk_type!=""){ $q="select * from ".$table_pre."kh"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $m1=get_db_msg("select count(*) 'num' from ".$table_pre."zk where iid='".$m["id"]."'"); if($m1["num"]<=0){ $tmp.="{\"v\":\"".$m["no"]."\",\"kh\":\"".$m["no"]."\"},"; $i++; } } if($i>0){ $str.="{\"cate\":\"未设置折扣\",\"data\":[".deel_end($tmp)."]},"; } } */ //--------------------检查价格 $q="select * from ".$table_pre."kh"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ if($m["price"]<=0){ $tmp.="{\"v\":\"".$m["no"]."\",\"kh\":\"".$m["no"]."\"},"; $i++; } } if($i>0){ $str.="{\"cate\":\"缺价格\",\"data\":[".deel_end($tmp)."]},"; } //--------------------检查图片 $q="select * from ".$table_pre."kh"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $pic=get_kh_picture($m["no"],$m["main_pic"],$m["color"]); if($pic=="images/no_pic_80.gif"){ $tmp.="{\"v\":\"".$m["no"]."(".$m["color"].")\",\"kh\":\"".$m["no"]."\"},"; $i++; } } if($i>0){ $str.="{\"cate\":\"缺图片的款\",\"data\":[".deel_end($tmp)."]},"; } $q="select * from ".$table_pre."kh"; $r=$db->query($q); $i=0; $tmp=""; while($m=$db->fetch_array($r)){ $tmp1=explode(",",$m["color"]); for($k=0;$k0){ $str.="{\"cate\":\"缺图片的款色\",\"data\":[".deel_end($tmp)."]},"; } $json_data.="\"error\":[".deel_end($str)."],"; break; case "detail": //可选择字段 $arr_zd["xh"]=d_translate("xh"); $arr_zd["price"]="零售价"; $arr_zd["price_zk"]="结算价"; $arr_zd["title"]="款式名"; for($i=0;$iquery("select * from ".$table_pre."keyword where cate='size' order by ord"); while($m1=$db->fetch_array($r1)){ $size_tr[$num_size_group]=""; for($i=1;$i<=$num_size_total;$i++){ $tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'"); $t=$tmp["title"]?$tmp["title"]:" "; $size_tr[$num_size_group].="{\"zd\":\"num_".$i."\",\"title\":\"".$t."\",\"is_size\":\"y\"},"; } $arr_size_merged[]=$m1["no"]; $num_size_group++; } //-------------------/处理尺码表头结束 $s_zd=$s_zd?$s_zd:"price"; $sql_con=""; $search_content=""; //字段 $zd=""; $zd1=""; $i=0; $arrzd=array(); $arrzd=explode(",",$s_zd); $zd_ct=0; foreach($arr_zd as $k1 => $v1){ $zd1.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\","; if(in_array($k1,$arrzd)){ $zd.=" checked"; $zd1.="\"sign\":\"y\""; $zd_ct++; }else $zd1.="\"sign\":\"n\""; $zd1.="},"; } $json_data.="\"th_zd\":[".substr($zd1,0,-1)."],"; $search_content.="显示列:".$zd; $search_content.=" "; //-----------------------/search //-----------------------tab //-----------------------/tab $json_data.="\"thead_str_group\":\"".$num_size_group."\","; $th_zd=""; for($i=0;$i".get_main_value($arr_zd,$s_zd[$i]).""; } $thead_str=""; $thead_str.="{\"zd\":\"bj\",\"title\":\"删除标记\",\"is_size\":\"n\"},{\"zd\":\"no\",\"title\":\"款号\",\"is_size\":\"n\"},"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $thead_str.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\",\"is_size\":\"n\"},"; $colnum++; } } $thead_str.="{\"zd\":\"color_title\",\"title\":\"颜色名称\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"color\",\"title\":\"颜色代码\",\"is_size\":\"n\"},{\"zd\":\"color2\",\"title\":\"尺码\",\"is_size\":\"n\"},"; if($bx_sizegroup_id>0){ $thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\",\"is_size\":\"n\"},"; } if($is_gg=="y"){ $thead_str.="{\"zd\":\"gg\",\"title\":\"".d_translate("gg")."\",\"is_size\":\"n\"},"; //$thead_str.="{\"zd\":\"ggprice\",\"title\":\"".get_main_value($sys_gg_zd,"price")."\",\"is_size\":\"n\"},"; } $thead_str.=substr($size_tr[0],0,-1); $thead_str2="\"0\":[".$thead_str."],"; for($i=1;$i<$num_size_group;$i++){ $thead_str2.="\"".$i."\":[".substr($size_tr[$i],0,-1)."],"; } $json_data.="\"thead_str\":{".substr($thead_str2,0,-1)."},"; $q="select * from ".$table_pre."kh order by xh"; //echo $q."
"; $r=$db->query($q); $count=0; $l=0; $_tcontent=array(); while($m=$db->fetch_array($r)){ $list=$count+1; $bg=($l%2)?"#f0f0f0":"#ffffff"; // $tmp_zd=""; for($i=0;$i"; $tmp_zd.=($s_zd=="title" || $s_zd=="price" || $s_zd=="xh")?deel_td($m[$s_zd[$i]]):deel_td(get_cate_title_no($s_zd[$i],$m[$s_zd[$i]])); $tmp_zd.=""; } //取得杯型 $arrBx1=array(); if($m["size_group"]==$bx_sizegroup_id){ $r1=$db->query("select * from ".$table_pre."size_bx where no='".$m["no"]."' order by bx"); $i1=0; while($m1=$db->fetch_array($r1)){ $arrBx1[$i1][]=$m1["bx"]; $arrBx1[$i1][]=$m1["size"]; $i1++; } }else{ $arrBx1[0][0]=""; $arrBx1[0][1]=$m["size"]; } //取得颜色 $arr_color=explode(",",$m["color"]); $arr_color_ka=explode(",",$m["color_ka"]); $num1=count($arr_color); for($j=0;$jquery("select gg from ".$table_pre."kh_gg where iid='".$m["id"]."' and color='".$arr_color[$j]."' order by ord"); $i1=0; while($m1=$db->fetch_array($r1)){ $arrBx[$i1][0]=$m1["gg"]; $arrBx[$i1][1]=$m["size"]; $i1++; } if($i1==0) $arrBx[0][0]=""; $arrBx[0][1]=$m["size"]; }else{ $arrBx=$arrBx1; } for($j1=0;$j1 $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $tbody_str2.="\"".$k1."\":\"".deel_td($m[$k1])."\","; }else if($k1=="xh"){ $tbody_str2.="\"".$k1."\":\"".get_kh_xh($m)."\","; }else{ $tbody_str2.="\"".$k1."\":\"".deel_td(get_cate_title_no($k1,$m[$k1]))."\","; } } } $tbody_str.="{\"bj\":\"".$ka."\",\"no\":\"".$m["no"]."\","; $tbody_str.=$tbody_str2; $tbody_str.=$tbody_str3; $tbody_str.="\"color_title\":\"".deel_td(get_cate_title_no("color",$arr_color[$j]))."\","; $tbody_str.="\"color\":\"".deel_td($arr_color[$j])."\","; if($bx_sizegroup_id>0){ $tbody_str.="\"bx\":\"".deel_td($arrBx[$j1][0])."\","; } if($is_gg=="y"){ //取得规格价格 $tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m2["iid"]."' and gg='".$m2["bx"]."'"); $tbody_str.="\"gg\":\"".deel_td(get_gg_title($arrBx[$j1][0]))."\","; //$tbody_str.="\"ggprice\":\"".deel_td($tmp["price"])."\","; } $tbody_str.="\"color2\":\"".deel_td($size)."\""; $tbody_str.="},"; $count++; } } $l++; } $json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; break; case "chache_pic_detail": //缓存细节图 $db->query("set names latin1;"); $t1=$table_pre."pic_detail"; //建立表 $db->query("DROP TABLE IF EXISTS ".$t1.";"); $db->query("CREATE TABLE `".$t1."` (`id` int(10) unsigned NOT NULL auto_increment,`kh` varchar(255) NOT NULL default '',`pic` varchar(255) NOT NULL default '',PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); // $pathdir="../attachments/design/mini"; $str=""; $i=0; if(is_dir($pathdir)){ $d=dir($pathdir); while($a=$d->read()){ if(is_file($pathdir.'/'.$a) && ($a!='.') && ($a!='..')){ //echo $a."|".$msg["no"]."_d
"; //echo stripos($a,$msg["no"]."_d")."
"; if(stristr($a,"-d")){ $tmp=explode("-d",$a); $q="insert into ".$t1." (kh,pic) values ('".$tmp[0]."','".$a."')"; $db->query($q); //echo $q."--
"; $str.=$a.","; $i++; } } } $d->close(); // } if($i>0){ $msg="找到以下细节图片:
".deel_end($str); }else{ $msg="没有找到细节图片(款号-d格式)!"; } $json_data.="\"code\":1,\"msg\":\"".$msg."\","; // break; //-------------主界面 default : // $json_data.="\"lang_spk\":\"".d_translate("spk")."\","; $json_data.="\"lang_xh\":\"".d_translate("xh")."\","; $is_spk=get_set("is_spk"); $json_data.="\"is_spk\":\"".$is_spk."\","; $zk_type=get_set("zk_type"); $json_data.="\"zk_type\":\"".$zk_type."\","; //取得定制选项 $select_dz=""; for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no1[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no1[$i]; $select_dz.="{\"no\":\"".$arr_select_no1[$i]."\",\"title\":\"".$arr_select_title1[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); $json_data.="\"select_dz\":[".$select_dz."],"; // $page=$page>0?$page:1; $limit=$limit>0?$limit:10; $start=($page-1)*$limit; $end=$limit; $sql_con=""; if($s_ka) $sql_con.=" and ka='".$s_ka."'"; if($s_ka_color=="y") $sql_con.=" and color_ka<>''"; if($s_is_sp) $sql_con.=" and is_sp='".$s_is_sp."'"; if($s_in_ph) $sql_con.=" and in_ph='".$s_in_ph."'"; if($s_xh) $sql_con.=" and xh='".$s_xh."'"; if($s_no) $sql_con.=" and no like '%".$s_no."%'"; for($i=0;$i0 ".$sql_con); $total_num=$tmp["num"]; //是否有折扣 $zk_type=get_set("zk_type"); $is_zk="n"; if($zk_type){ $is_zk="y"; } $query="select * from ".$table_pre."kh where id>0 ".$sql_con." order by xh,no limit ".$start.",".$end; //echo $query."
"; $res=$db->query($query); $count=0; $json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":["; $str_tmp=""; while($msg=$db->fetch_array($res)){ $list=$count_first+$count+1; $str_tmp.="{"; $str_tmp.="\"id\":\"".$msg["id"]."\","; //圆牌号 $str_tmp.="\"xh\":\"".get_kh_xh($msg)."\","; //款号 $str_tmp.="\"kh\":\"".$msg["no"]."\","; //取得选项值 $str1=""; for($i=0;$i $v1){ $str_price.=$v1.":".$msg[$k1]."元|"; } if($str_price) $str_price=substr($str_price,0,-1); }else{ $str_price=$msg["price"]."元"; } $str_tmp.="\"price\":\"".$str_price."\","; //颜色 $color=""; $tmp1=explode(",",$msg["color"]); $tmp2=explode(",",$msg["color_ka"]); for($k=0;$k0){ $tmp="y"; } } $str_tmp.="\"zk\":\"".$tmp."\","; //删除款 $str_tmp.="\"ka\":\"".$msg["ka"]."\""; $str_tmp.="},"; // $count++; } $json_data.=substr($str_tmp,0,-1)."],"; break; } } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>