30?30:$size_w; $arr_size_title=array(); $tr_size_title=$tr_size_input=""; $str_s=""; for($j=0;$j".$m1["title"].""; $tr_size_input.=""; $str_size.=$m1["title"].":"; $str_s.="{\"title\":\"".$m1["title"]."\",\"id\":\"gz_".$arr_size[$j]."\",\"value\":\"".$arr_gz[$j]."\"},"; } if($str_s){ $str_s=deel_end($str_s); } if($str_size) $str_size=substr($str_size,0,-1); //取得装箱数 $arr_zxs=array(); $q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$m_client["username"]."' or dj='') and kh='".$m_kh["no"]."' order by num"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_zxs[]=$m1["num"]; } if($arr_zxs){ $str_zxs=arr_to_str($arr_zxs); $zxs=$arr_zxs[0]; }else{ $str_zxs=""; $zxs=0; } $content=""; $content.="
"; $content.="".$tr_size_title.""; $content.="".$tr_size_input.""; $content.=""; $content.="
名称".$str_zxs."
".$hj."
"; $json_data.="\"id\":\"".$id."\","; $json_data.="\"obj\":\"".$obj."\","; $json_data.="\"gz\":\"".$gz."\","; $json_data.="\"title\":\"".$title."\","; $json_data.="\"zxs\":\"".$str_zxs."\","; $json_data.="\"size\":[".$str_s."],"; $json_data.="\"hj\":\"".$hj."\","; break; case "save_add": $title=trim($title); if(strstr($title,"|")){ //alert_and_back("非法字串“|”,请检查!"); $msg="非法字串“|”,请检查!"; } if(!$title){ if(!$msg){ $msg="配码名称不能为空"; } } // $num=0; //检查是否符合尺码数量 $gz=""; $arr_size=explode(",",$m_kh["size"]); for($i=0;$iquery($q1); while($m1=$db->fetch_array($r1)){ $arr_zxs[]=$m1["num"]; } if($arr_zxs){ if(!in_array($num,$arr_zxs)){ //alert_and_back("对不起,配码不符合装箱数,请检查!"); if(!$msg){ $msg="对不起,配码不符合装箱数,请检查!"; } } } // //检查是否存在 $check=get_db_msg("select id from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."' and gz='".$gz."' and id<>'".$id."'"); if($check["id"]>0){ $rurl="?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj; //取得配码行数 $tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'"); $pm_rows=deel_num($tmp1["num"]); //echo ""; //exit(); if(!$msg){ $msg="保存失败!(该配码已经存在)"; } } $qy_uid=get_qy_id($m_client["path"]); if($id>0){ //修改 $msg_old=get_db_msg("select * from ".$table_pre."size_pm where id='".$id."'"); if($msg_old["gz"]!=$gz){ //如果已经有订单用了,不允许修改 $check1=get_db_msg("select count(*) 'num' from ".$table_pre."order_pm where pmid='".$id."'"); if($check1["num"]>0){ //alert_and_back("对不起,该配码已经使用,不允许修改!"); if(!$msg){ $msg="对不起,该配码已经使用,不允许修改!"; } } } if($msg){ $json_data.="\"code\":0,\"msg\":\"".$msg."\","; }else{ $q1="update ".$table_pre."size_pm set title='".$title."',gz='".$gz."',num='".$num."' where id='".$id."'"; $db->query($q1); $json_data.="\"code\":101,"; } }else{ if($msg){ $json_data.="\"code\":0,\"msg\":\"".$msg."\","; }else{ //新增 $q1="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,title,gz,num) values ('".$qy_uid."','".$dpid."','".$m_kh["size_group"]."','".$m_kh["pm_dj"]."','".$title."','".$gz."','".$num."')"; $db->query($q1); $json_data.="\"code\":101,"; } } $rurl="?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj; //取得配码行数 $tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'"); $pm_rows=deel_num($tmp1["num"]); $json_data.="\"pm_rows\":\"".$pm_rows."\","; //echo ""; //exit(); break; case "del": $check1=get_db_msg("select count(*) 'num' from ".$table_pre."order_pm where pmid='".$id."'"); if($check1["num"]>0){ //alert_and_back("对不起,该配码已经使用,不允许删除!"); $msg="对不起,该配码已经使用,不允许删除!"; } $check2=get_db_msg("select uid from ".$table_pre."size_pm where id='".$id."'"); if($check2["uid"]!=$dpid){ //alert_and_back("对不起,该配码已经使用,不允许删除!"); $msg="对不起,只能修改自己的配码!"; } if($msg){ $json_data.="\"code\":0,\"msg\":\"".$msg."\","; }else{ $q="delete from ".$table_pre."size_pm where id='".$id."'"; $db->query($q); $json_data.="\"code\":101,"; } $rurl="?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj; //取得配码行数 $tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'"); $pm_rows=deel_num($tmp1["num"]); $json_data.="\"pm_rows\":\"".$pm_rows."\","; //echo ""; //exit(); break; default: $content=""; $content.=""; $kh=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'"); $json_data.="\"size\":\"".$kh["size"]."\","; $json_data.="\"obj\":\"".$obj."\","; //取得装箱数 $q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$m_client["username"]."' or dj='') and kh='".$m_kh["no"]."' order by num"; //echo $q1; $r1=$db->query($q1); $sql_pm=""; $str_zxs=""; while($m1=$db->fetch_array($r1)){ $sql_pm.="num='".$m1["num"]."' or "; //$str_zxs.="{\"zxs\":\"".$m1["num"]."\"},"; $str_zxs.=$m1["num"].","; } if($str_zxs){ $str_zxs=deel_end($str_zxs); } $json_data.="\"zxs\":\"".$str_zxs."\","; if($sql_pm) $sql_pm=" and (".substr($sql_pm,0,-4).")"; //读取配码信息 //配码等级一样,店铺id一样或者店铺id为空(适合所有店铺的配码) $q="select * from ".$table_pre."size_pm where (uid='".$dpid."' or uid='') and pm_dj='".$m_kh["pm_dj"]."' ".$sql_pm." order by id"; //echo $q; $r=$db->query($q); $content_pm="
选择配码
"; $i=0; $size_ws_kh=count(explode(",",$m_kh["size"])); $str_pm=""; while($m=$db->fetch_array($r)){ $size_ws=count(explode(":",$m["gz"])); //echo $size_ws."|".$size_ws_kh."-
"; if($size_ws==$size_ws_kh){ $is_edit=($m["uid"]==$dpid)?"y":"n"; $str_pm.="{\"is_edit\":\"".$is_edit."\",\"id\":\"".$m["id"]."\",\"title\":\"".$m["title"]."\",\"gz\":\"".$m["gz"]."\",\"num\":\"".$m["num"]."\"},"; $content_pm.=""; $i++; } } if($str_pm){ $str_pm=deel_end($str_pm); } $json_data.="\"pm\":[".$str_pm."],"; $content_pm.="
".$m["title"]."".$m["gz"]."=".$m["num"]."
"; if($i==0) $content_pm="暂无您的配码信息,请先新增。"; $content.="".$content_pm.""; // $content.=""; break; } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>