connect($dbhost,$dbuser,$dbpw,$dbname,"p"); $magic_quotes_gpc = get_magic_quotes_gpc(); $register_globals = @ini_get('register_globals'); if(!$register_globals || !$magic_quotes_gpc) { @extract(daddslashes($_POST)); @extract(daddslashes($_GET)); } $uid=$_COOKIE[THIS_COOKIE]; if($uid!="1"){ $msg=get_db_msg("select username from ".$table_pre."user where id='1'"); echo "对不起,无权查看,请先用(".$msg["username"].")账号登陆,返回!"; exit; } $xh_ms=get_set("xh_ms"); $sys_size_num=get_max_size_num(); switch($_a){ case "view_order": //-------------------------------------取得订单 $default_group_by=""; $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9"); if($tmp["num"]>0){ $arr_group_by["9"]="区域"; $default_group_by="9"; } $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3"); if($tmp["num"]>0){ $arr_group_by["3"]="代理"; $default_group_by="3"; } $default_group_by=$default_group_by?$default_group_by:"4"; $arr_group_by["4"]="店铺"; $arr_group_by["1"]="明细"; $s_group_by=$s_group_by?$s_group_by:$default_group_by; $m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'"); $s_kh=$m_kh["no"]; $pic=get_kh_picture_debug($m_kh["no"],$m_kh["main_pic"],$m_kh["color"]); $pic1=out_good_pic($pic,200,200,'border=0'); $content=""; $content.=""; $sql_con="iid='".$khid."' and _key='".$sys_this_order_flag."' and "; if($color) $sql_con.="color='".$color."' and "; $sql_con=substr($sql_con,0,-4); $size=explode(",",$m_kh["size"]); if($s_group_by=="1"){ //------------------------明细 $con_dp_o=""; if($dpid){ $m1=get_db_msg("select id,path,title,username from ".$table_pre."client where id='".$dpid."'"); $p1=$m1["path"]."-".$m1["id"]; $con_dp_o.=" and uid='".$m1["id"]."'"; $content.=""; } $content.="
".$pic1."
".get_kh_xh($m_kh,'')."#".$m_kh["no"]."
"; foreach($arr_group_by as $k1 => $v1){ $sty=($k1==$s_group_by)?"font-weight:bold;border:1px solid #f0f0f0;padding:6px;":"font-weight:normal;border:1px solid #cccccc;padding:4px;"; $content.="".$v1." "; } $content.="
".$m1["title"]."(".$m1["username"].")
"; //表头 $content.=""; $tmp1=explode(",",$m_kh["color"]); for($l=0;$l".$tmp3["title"].""; } $content.=""; $q="select * from ".$table_pre."order where ".$sql_con.$con_dp_o." order by uid,color,add_date"; $r=$db->query($q); $hj=$count=0; while($m=$db->fetch_array($r)){ $tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'"); $m_kh=get_db_msg("select no,color,color_ka from ".$table_pre."kh where id='".$m["iid"]."'"); $arr_color_ka=explode(",",$m_kh["color_ka"]); $flag_ka=(in_array($m["color"],$arr_color_ka))?"(已删除)":""; $content.=""; $content.=""; $content.=""; //尺码列表 $xj=0; for($l=0;$l".$m["num_".$size[$l]].""; } $content.=""; $count++; } if($count==0 && $dpid){ $arr_color=explode(",",$m_kh["color"]); $arr_color_ka=explode(",",$m_kh["color_ka"]); for($i1=0;$i1(已删除)":""; $content.=""; } } //合计 $hj_colspan=3; $content.=""; for($l=0;$l".$$v1.""; } $content.=""; }else{ //------------------------店铺、代理、区域 $con_dp=$con_dp_o=""; if($s_group_by=="4"){ if($s_sj){ $m1=get_db_msg("select id,path,title,username from ".$table_pre."client where id='".$s_sj."'"); $p1=$m1["path"]."-".$m1["id"]; $con_dp.=" and (path='".$p1."' or path like '".$p1."-%')"; $con_dp_o.=" and (upath='".$p1."' or upath like '".$p1."-%')"; $content.=""; } } //取得数组 $arr1=array(); $q="select * from ".$table_pre."client where face='".$s_group_by."'".$con_dp; $r=$db->query($q); while($m=$db->fetch_array($r)){ if($s_group_by=="4"){ $tmp_sql=" and uid='".$m["id"]."'"; }else{ $p=$m["path"]."-".$m["id"]; $tmp_sql=" and upath like '".$p."-%'"; } $tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_dp_o); //if($tmp["num"]>0) $arr1[$m["id"]]=$tmp["num"]; } arsort($arr1); $content.="
店铺款号颜色小计订单时间
".$tmp["title"]."(".$tmp["username"].")".$m_kh["no"]."".$m["color"]."-".get_cate_title_no("color",$m["color"]).$flag_ka."".$xj."".date("d日 H点i分",$m["add_date"])."
".$m1["title"]."(".$m1["username"].")".$m_kh["no"]."".$arr_color[$i1]."-".get_cate_title_no("color",$arr_color[$i1]).$flag_ka."
合计".$hj." 
".$m1["title"]."(".$m1["username"].")
"; //表头 $content.=""; for($l=0;$l".trim($tmp3["title"]).""; } $content.=""; // $hj=0; $list=1; foreach($arr1 as $id1 => $num1){ $hj+=$num1; $m=get_db_msg("select id,path,title,username from ".$table_pre."client where id='".$id1."'"); if($s_group_by=="4"){ $tmp_sql=" and uid='".$m["id"]."'"; $link_var=""; }else{ $p=$m["path"]."-".$m["id"]; $tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')"; $link_var=""; } $tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_dp_o); $content.=""; for($l=0;$l".$tmp["num_".$size[$l]].""; //尺码合计 $v1="hj_".$size[$l]; $$v1+=$tmp["num_".$size[$l]]; } $content.=""; $list++; } //合计 $hj_colspan=2; $content.=""; for($l=0;$l".$$v1.""; } $content.=""; } $content.="
序号客户小计
".$list."".$link_var.$m["title"]."(".$m["username"].")".$num1."
合计".$hj."
"; break; case "edit": //-------------------------------------修改订单 $m_kh=get_db_msg("select no,size,size_group,color,color_ka,pm_dj from ".$table_pre."kh where id='".$khid."'"); $m_client=get_db_msg("select username,title from ".$table_pre."client where id='".$dpid."'"); $arr_size=explode(",",$m_kh["size"]); $arr_color_ka=explode(",",$m_kh["color_ka"]); //-----------------尺码 $str_size_title=""; $arr_size_title=array(); for($i=0;$iquery($q1); $zxs=""; while($m1=$db->fetch_array($r1)){ $zxs.=$m1["num"].","; } if($zxs) $zxs=substr($zxs,0,-1); //-----------------取得配码的行数 $tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'"); $pm_rows=$tmp1["num"]; // $colspan1=3+count($arr_size); // $q="select * from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$dpid."' and iid='".$khid."' and color='".$color."'"; //echo $q."--
"; $r=$db->query($q); $num_arr="["; $total_xs=$total_num=$j1=0; while($m1=$db->fetch_array($r)){ $tmp=get_db_msg("select title,gz from ".$table_pre."size_pm where id='".$m1["pmid"]."'"); $num_arr.="[\"".$color."|".get_cate_title_no("color",$color)."\",".$j1.",\"".$tmp["title"]."|".$tmp["gz"]."\",".$m1["xs"].",\"".$is_ka."\",\"".$is_selected."\"],"; $total_xs+=$m1["xs"]; $total_num+=$m1["xs"]*count_pm_num($tmp["gz"]); $j1++; } if($j1==0){ $num_arr.="[\"".$color."|".get_cate_title_no("color",$color)."\",0,\"|\",0,\"".$is_ka."\",\"".$is_selected."\"],"; $j1=1; } $num_arr.="]"; break; case "save_edit": //-------------------------------------保存修改 if(substr($str_sub,strlen($str_sub)-1,1)==",") $str_sub=substr($str_sub,0,-1); $arr_str_sub=explode(",",$str_sub); $msg=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'"); //检测配码 $arr_str_sub1=array(); $arr_pm_id=array(); $qy_uid=get_qy_id($msg_login["path"]); for($i1=0;$i10){ $pmid1=$m_pm["id"]; }else{ $pm_title="临时".get_rand_num(4); $num=count_pm_num($arr_tmp[1]); $q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,khid,title,gz,num) values ('".$qy_uid."','".$dpid."','".$msg["size_group"]."','临时配码','".$msg["id"]."','".$pm_title."','".$arr_tmp[1]."','".$num."')"; //echo $q."
"; $db->query($q); $pmid1=$db->insert_id(); } $arr_pm_id[$i1]=$pmid1; } //保存订单 $arr_size=explode(",",$msg["size"]); $arr_color_ka=explode(",",$msg["color_ka"]); $tmp_total_num=0; $tmp_old=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key='".$sys_this_order_flag."' and uid='".$dpid."' and iid='".$khid."'"); //取得总量 for($i=0;$i'jgd' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_select_no[]=$m1["no"]; } $check1=get_db_msg("select * from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$color."' and gz='1' limit 0,1"); if(!in_array($color,$arr_color_ka) && !$check1["id"]){ $sql_size1=$sql_size2=$sql_size3=""; $c=0; for($k=0;$k0){ $q="update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where id='".$check["id"]."'"; $db->query($q); cache_order($dpid,$khid,$color,""); }else{ $q="delete from ".$table_pre."order where id='".$check["id"]."'"; $db->query($q); } }else{ if($c>0){ $sql1=$sql2=""; for($i1=0;$i1query($q); cache_order($dpid,$khid,$color,""); } } count_ph($dpid,$khid,$color); } //清空配码信息 $db->query("delete from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$dpid."' and iid='".$khid."' and color='".$color."'"); //保存配码信息 for($i1=0;$i1query($q); } //计算数量变化 $log_hd_old_num=$tmp_old["num"]; $log_hd_num=$tmp_total_num-$tmp_old["num"]; echo ""; break; default: // break; } ?> <?php if(trim($m_kh["no"])) echo $m_kh["no"]." - ";?>总部修改订单
店 铺:".$m_client["title"]."(".$m_client["username"].")
款 号:".$m_kh["no"]."
颜 色:".$color."-".get_cate_title_no("color",$color)."
装箱数:".$zxs."
"; echo ""; }else{ echo "
"; if($content){ echo ""; } echo "
总部修改订单
输入款号
".$content."
"; } ?>