connect($dbhost,$dbuser,$dbpw,$dbname,"p"); $iid=$_GET["iid"]; $dpid=$_GET["dpid"]; $obj=$_GET["obj"]; $_a=$_GET["_a"]; $m_kh=get_db_msg("select no,pm_dj,size,size_group from ".$table_pre."kh where id='".$iid."'"); $m_client=get_db_msg("select path,username from ".$table_pre."client where id='".$dpid."'"); switch($_a){ case "add": if($id){ $msg=get_db_msg("select * from ".$table_pre."size_pm where id='".$id."'"); $title=$msg["title"]; $gz=$msg["gz"]; $arr_gz=explode(":",$gz); $hj=$msg["num"]; }else{ $title=""; $arr_gz=array(); $hj=0; } //取得尺码 $str_size=""; $arr_size=explode(",",$m_kh["size"]); //计算尺码框宽度 $size_w=floor(200/count($arr_size)); $size_w=$size_w>30?30:$size_w; $arr_size_title=array(); $tr_size_title=$tr_size_input=""; for($j=0;$j".$m1["title"].""; $tr_size_input.=""; $str_size.=$m1["title"].":"; } 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=""; //$url=$_SERVER["PHP_SELF"]."?_a=save_add"; $content.="
"; $content.="".$tr_size_title.""; $content.="".$tr_size_input.""; $content.=""; $content.="
名称".$str_zxs."
".$hj."
"; break; case "save_add": $title=$_POST["title"]; $dpid=$_POST["dpid"]; $iid=$_POST["iid"]; $obj=$_POST["obj"]; $id=$_POST["id"]; $m_kh=get_db_msg("select no,pm_dj,size,size_group from ".$table_pre."kh where id='".$iid."'"); $m_client=get_db_msg("select path,username from ".$table_pre."client where id='".$dpid."'"); $arr_size=explode(",",$m_kh["size"]); for($j=0;$jquery($q1); while($m1=$db->fetch_array($r1)){ $arr_zxs[]=$m1["num"]; } if($arr_zxs){ if(!in_array($num,$arr_zxs)) alert_and_back("对不起,配码不符合装箱数,请检查!"); } // //检查是否存在 $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="pm.php?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(); } $qy_uid=get_qy_id($m_client["path"]); //echo $gz."-".$num."
"; 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("对不起,该配码已经使用,不允许修改!"); } $q1="update ".$table_pre."size_pm set title='".$title."',gz='".$gz."',num='".$num."' where id='".$id."'"; $db->query($q1); }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); } $rurl="pm.php?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(); 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("对不起,该配码已经使用,不允许删除!"); $q="delete from ".$table_pre."size_pm where id='".$id."'"; $db->query($q); $rurl="pm.php?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(); break; default: $content=""; $content.=""; //取得装箱数 $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); $sql_pm=""; while($m1=$db->fetch_array($r1)){ $sql_pm.="num='".$m1["num"]."' or "; } 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"; $r=$db->query($q); $content_pm="
选择配码
"; $i=0; $size_ws_kh=count(explode(",",$m_kh["size"])); 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)?"":" disabled"; $content_pm.=""; $i++; } } $content_pm.="
".$m["title"]."".$m["gz"]."=".$m["num"]."
"; if($i==0) $content_pm="暂无您的配码信息,请先新增。"; $content.="".$content_pm.""; // $content.=""; break; } ?> --